:root {
    --bg: #fafafa;
    --card: #fff;
    --border: #e5e5e5;
    --muted: #6b7280;
    --text: #111827;
    --accent: #2563eb;
    --pos: #16a34a;
    --neu: #9ca3af;
    --neg: #dc2626;
    --error: #b91c1c;
    --error-bg: #fef2f2;
}

body.dashboard {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    max-width: none;
}

.dashboard-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5em 1.25em 4em;
}

.dashboard-wrap h1 {
    margin-top: 0;
    font-size: 1.5em;
}

.header-band {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1em 1.25em;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1em;
    align-items: center;
    margin-bottom: 1.25em;
}
.header-band .filename { font-weight: 600; word-break: break-all; }
.header-band .meta { color: var(--muted); font-size: .9em; }
.header-band .meta span + span { margin-left: 1em; }
.header-band .lang-flag { font-size: 1.4em; margin-right: .35em; }

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: .5em;
    padding: .35em .6em;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1px solid var(--border);
    font-size: .9em;
}
.ai-badge.ai { background: #fef3c7; border-color: #fde68a; }
.ai-badge.human { background: #dcfce7; border-color: #bbf7d0; }
.ai-badge .bar {
    width: 80px; height: 6px;
    background: #e5e7eb; border-radius: 999px; overflow: hidden;
}
.ai-badge .bar > span {
    display: block; height: 100%; background: var(--accent);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1em;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1em;
    min-height: 180px;
}
.card.full { grid-column: 1 / -1; }
.card h2 {
    margin: 0 0 .75em;
    font-size: 1.05em;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.card.error { background: var(--error-bg); }
.card .error-chip {
    color: var(--error);
    font-size: .8em;
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 1px 6px;
}

.numgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .5em .75em;
}
.numgrid .stat {
    background: #f9fafb;
    border-radius: 6px;
    padding: .5em .6em;
}
.numgrid .stat .k { color: var(--muted); font-size: .8em; }
.numgrid .stat .v { font-weight: 600; font-size: 1.1em; }

.ngram-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75em;
}
@media (max-width: 700px) { .ngram-cols { grid-template-columns: 1fr; } }

.entities-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.entities-table th, .entities-table td {
    text-align: left; padding: .35em .5em; border-bottom: 1px solid var(--border);
}
.entities-table th { color: var(--muted); font-weight: 500; }

.placeholder { color: var(--muted); font-style: italic; }

.sentiment-bar {
    display: flex; height: 24px; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--border);
}
.sentiment-bar > span {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .75em; min-width: 0;
}
.sentiment-bar .pos { background: var(--pos); }
.sentiment-bar .neu { background: var(--neu); color: #fff; }
.sentiment-bar .neg { background: var(--neg); }

.compound { margin-top: .5em; color: var(--muted); font-size: .9em; }

.processing-wrap {
    max-width: 540px;
    margin: 4em auto;
    padding: 0 1em;
}
.progress-track {
    background: #e5e7eb; border-radius: 999px; overflow: hidden;
    height: 14px; margin: 1em 0 .5em;
}
.progress-fill {
    height: 100%; background: var(--accent);
    transition: width .3s ease;
}
.progress-meta { color: var(--muted); font-size: .9em; }

.neighbors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .75em;
}
.neighbor-card {
    display: block;
    padding: .6em .75em;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    background: #fff;
}
.neighbor-card:hover { border-color: var(--accent); }
.neighbor-filename { font-weight: 600; margin-bottom: .25em; word-break: break-all; }
.neighbor-snippet {
    color: var(--muted);
    font-size: .85em;
    margin-bottom: .4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.neighbor-similarity { color: var(--muted); font-size: .8em; }

.heatmap-grid {
    display: grid;
    gap: 2px;
    font-size: .8em;
    align-items: stretch;
    overflow-x: auto;
}
.heatmap-corner { background: transparent; }
.heatmap-col-label,
.heatmap-row-label {
    color: var(--muted);
    padding: .25em .4em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: center;
}
.heatmap-col-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-align: left;
    max-height: 8em;
    justify-self: center;
}
.heatmap-row-label {
    text-align: right;
    max-width: 12em;
}
.heatmap-cell {
    aspect-ratio: 1 / 1;
    min-width: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-variant-numeric: tabular-nums;
    font-size: .85em;
}
.heatmap-cell-dark { color: #fff; }

/* Sub-project #5: upload tabs + record button */
.upload-tabs .tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
  border-bottom: 1px solid #ccc;
}
.upload-tabs .tab {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  cursor: pointer;
}
.upload-tabs .tab.active {
  border-color: #ccc;
  background: #f6f6f6;
}
.upload-tabs .tab-body {
  padding: 1rem 0;
}

#record-app .warn { color: #c33; font-weight: 600; }
#record-app audio { display: block; margin: 0.5rem 0; }
#record-app button { margin-right: 0.5rem; }

.audio-dashboard audio { width: 100%; margin: 0.75rem 0; }
.transcript-card pre {
  white-space: pre-wrap;
  background: #f9f9f9;
  padding: 0.75rem;
  border-radius: 4px;
}

.progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress-indeterminate {
  background: linear-gradient(90deg, #eee 0%, #6cf 50%, #eee 100%);
  background-size: 200% 100%;
  animation: indeterminate 1.5s linear infinite;
}
.progress-determinate { background: #6cf; }
@keyframes indeterminate {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
