/* ===========================================================================
   GRI Voice QC Data Capture — light enterprise theme, adopted from the
   team's UI mockup (GRI_Voice_QC_Capture_Team_Mockup_1.html) as the visual
   and navigation reference. Same mobile-first discipline as before: base
   rules target 320-430px phones, a 431px breakpoint adds tablet
   refinements, a 1025px breakpoint builds the full desktop layout
   (including pinning the sidebar). No horizontal scrolling at any
   supported width.

   Class/id names already used by gri-app.js and qc-grid.js are preserved
   exactly (state-pill, notice*, stage-*, context-*, orb-*, icon-btn*,
   error-banner, caption-*, qc-*) — only their colors and, where noted,
   their container changed in this pass. Everything under "shell & nav"
   and "cards / empty states" below is new, for the sidebar/topbar layout
   and the five screens still pending real-data wiring.
=========================================================================== */

:root {
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --surface: #f8fafc;
  --panel: #ffffff;
  --panel-inverse: #0f172a; /* sidebar stays a fixed dark rail in both color schemes */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #1d4ed8;
  --accent-dark: #1e3a8a;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;

  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --ok-border: #bbf7d0;

  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;

  --neutral-soft: #f1f5f9;
  --neutral-border: #e2e8f0;

  --corrected: #6d28d9;
  --corrected-soft: #f5f3ff;
  --corrected-border: #ddd6fe;

  /* Voice-session states — each gets its own hue so Ready / Connecting /
     Listening / Processing / Speaking are never confusable at a glance. */
  --state-ready: #64748b;
  --state-connecting: #b45309;
  --state-listening: #1d4ed8;
  --state-thinking: #6d28d9;
  --state-answering: #0e7490;

  /* Feeds web/voice-orb.js's canvas animation (adapted from Marea's own
     --voice-teal*/*-strong tokens) — the orb's drawing code never
     hardcodes a color, it always reads these two. Mapped to GRI's own
     accent so the animation stays in GRI's palette automatically if the
     accent ever changes, the same way Marea's engine follows its own
     --voice-teal* tokens. */
  --voice-teal: var(--accent);
  --voice-teal-strong: var(--accent-dark);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --space-3xs: 4px;
  --space-2xs: 6px;
  --space-xs: 10px;
  --space-sm: 14px;
  --space-md: 18px;
  --space-lg: 24px;
  --space-xl: 32px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --focus-ring: 0 0 0 3px rgba(29, 78, 216, 0.35);

  /* 44x44 is the minimum recommended touch target (WCAG 2.5.5 / mobile HIG). */
  --touch-min: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink-900: #f1f5f9;
    --ink-700: #cbd5e1;
    --ink-500: #94a3b8;
    --ink-300: #475569;
    --ink-200: #334155;
    --ink-100: #1e293b;
    --surface: #0b1220;
    --panel: #111a2e;
    --border: #243249;
    --border-strong: #324257;

    --accent: #5eead4;
    --accent-dark: #2dd4bf;
    --accent-soft: #0d3b36;
    --accent-border: #155e56;

    --ok: #4ade80;
    --ok-soft: #0f2e1d;
    --ok-border: #1f5136;

    --warn: #fbbf24;
    --warn-soft: #2e2306;
    --warn-border: #4d3b0d;

    --danger: #f87171;
    --danger-soft: #2e1313;
    --danger-border: #5a1f1f;

    --info: #38bdf8;
    --info-soft: #0b2436;
    --info-border: #155e75;

    --neutral-soft: #1a2436;
    --neutral-border: #2a3b54;

    --corrected: #c4b5fd;
    --corrected-soft: #241c42;
    --corrected-border: #3c2f6b;

    --state-ready: #94a3b8;
    --state-connecting: #fbbf24;
    --state-listening: #5eead4;
    --state-thinking: #c4b5fd;
    --state-answering: #38bdf8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);

    --focus-ring: 0 0 0 3px rgba(94, 234, 212, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink-900);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* belt-and-braces: layout itself must never need this */
}
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--ink-900); }
p { margin: 0; }
button, input, select { font-family: inherit; }
code { font-size: 0.92em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ======================================================= shell &amp; nav === */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.nav-backdrop { display: none; }

.sidebar {
  background: var(--panel-inverse);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 230px;
  transform: translateX(-100%);
  transition: transform 0.18s ease;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.sidebar.open { transform: translateX(0); }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  color: #06111f; font-weight: 700; font-size: 0.78rem; letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 600; font-size: 0.88rem; color: #fff; }
.brand-tag { font-size: 0.72rem; color: #93a3b8; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: #cbd5e1; text-align: left;
  padding: 10px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.86rem; width: 100%; min-height: var(--touch-min); position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(29,78,216,0.32); color: #fff; }
.nav-item.active .nav-icon { color: #93c5fd; }
.nav-icon { width: 18px; height: 18px; flex: none; color: #8ba0bc; }
.nav-badge {
  margin-left: auto; background: var(--warn); color: #fff; font-size: 0.68rem;
  font-weight: 700; border-radius: 999px; padding: 1px 7px; line-height: 1.4;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-footer-label { font-size: 0.78rem; color: #e2e8f0; font-weight: 600; }
.sidebar-footer-sub { font-size: 0.72rem; color: #7c8aa0; }

.main-col { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }
.topbar-route-title { font-size: 1.1rem; }
.mobile-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px; color: var(--ink-700); cursor: pointer; min-width: var(--touch-min); min-height: var(--touch-min); flex: none;
}
.topbar-right { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }

/* ------------------------------------------------------- inline notices */
.notice-region {
  position: fixed; left: var(--space-sm); right: var(--space-sm); bottom: var(--space-sm);
  display: flex; flex-direction: column; gap: var(--space-2xs);
  z-index: 100; pointer-events: none;
}
.notice {
  pointer-events: auto;
  background: var(--panel-inverse); border: 1px solid rgba(255,255,255,0.14);
  color: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: var(--space-xs) var(--space-sm); font-size: 0.86rem; line-height: 1.45;
  display: flex; align-items: flex-start; gap: var(--space-2xs);
  animation: notice-in 0.18s ease-out;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.notice::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: #93c5fd; }
.notice-success::before { background: #4ade80; }
.notice-error { border-color: rgba(248, 113, 113, 0.4); }
.notice-error::before { background: #f87171; }
.notice.notice-leaving { opacity: 0; transition: opacity 0.2s ease; }
@keyframes notice-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 431px) {
  .notice-region { left: auto; right: var(--space-lg); bottom: var(--space-lg); width: 380px; }
  .notice { max-width: none; }
}

/* -------------------------------------------------------------- main --- */
.main-content { padding: var(--space-md) var(--space-sm) var(--space-xl); max-width: 1180px; width: 100%; margin: 0 auto; }

.screen-head { margin-bottom: var(--space-md); }
.screen-head h2 { font-size: 1.05rem; margin-bottom: 3px; }
.screen-head p { color: var(--ink-500); font-size: 0.86rem; }
/* Download QC Entries as Excel feature: a screen-head with a trailing
   action button (e.g. "Download Excel" on All Readings), reusing the same
   flex pattern the workbook panel's head row already established. */
.screen-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.screen-head-row h2, .screen-head-row p { margin-bottom: 0; }
.screen-head-row h2 { margin-bottom: 3px; }

.section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); margin-bottom: var(--space-xs); }

/* --------------------------------------------------------------- cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-md); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: var(--space-md); }

/* ------------------------------------------------------------ badges --- */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-neutral { background: var(--neutral-soft); color: var(--ink-500); border: 1px solid var(--neutral-border); }
.badge-corrected { background: var(--corrected-soft); color: var(--corrected); border: 1px solid var(--corrected-border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid var(--accent-border); }
/* Field Reference refinement pass: "no threshold defined" reuses the same
   --info blue QcGrid's own .rule-unresolved rows already use for "no
   confirmed verdict" — one consistent color language for that idea across
   the app, distinct from badge-neutral's gray (reserved for a field that
   was never the kind of field a threshold applies to at all). */
.badge-info { background: var(--info-soft); color: var(--info); border: 1px solid var(--info-border); }
/* Multi-stage pass: every stage is now a real, usable workflow, so these
   two tags (a binary "is this stage live" label) no longer apply to any
   screen — rule_status now varies per FIELD instead (see .badge-* above,
   used by Field Reference's per-field tags). Left defined only in case an
   older cached page still references them; nothing in web/*.js emits them
   any more. */
.tag-implemented { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); border-radius: var(--radius-sm); padding: 3px 9px; font-size: 0.74rem; font-weight: 700; }
.tag-prototype { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); border-radius: var(--radius-sm); padding: 3px 9px; font-size: 0.74rem; font-weight: 700; }

/* -------------------------------------------------------- empty states */
.empty-state { text-align: center; padding: 36px 16px; color: var(--ink-500); }
.empty-state-icon { width: 36px; height: 36px; margin: 0 auto 12px; color: var(--ink-300); }
.empty-state h3 { color: var(--ink-700); font-size: 0.95rem; margin-bottom: 4px; }
.empty-state p { font-size: 0.84rem; line-height: 1.5; max-width: 440px; margin: 0 auto; }
.empty-state code { background: var(--ink-100); border-radius: 4px; padding: 1px 5px; }

/* ---- Phase 3: Audit Trail loading / error states — same .empty-state
   shell as the empty state above, with a modifier for color (error reuses
   --danger, already themed for light/dark) and a small spinner (reuses
   the existing orb-spin keyframe rather than defining a new one). */
.empty-state.is-error .empty-state-icon,
.empty-state.is-error h3 { color: var(--danger); }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--neutral-border); border-top-color: var(--accent);
  border-radius: 50%; animation: orb-spin 0.8s linear infinite;
}
.audit-meta { color: var(--ink-500); font-size: 0.78rem; margin: var(--space-xs) 0; }
.qc-status-badge.corrected { background: var(--corrected-soft); color: var(--corrected); border: 1px solid var(--corrected-border); }

/* ---- Phase 4: Field Reference (Field Reference refinement pass: grid
   columns replace the old space-between flex row, so Field/Unit/Status/
   Threshold line up consistently down the whole card instead of each
   row wrapping its own way — reuses .card/.badge-* wholesale). A header
   row (.reference-field-head) labels the four columns once per stage
   rather than repeating "Unit"/"Status" text beside every field. */
.reference-stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-xs); }
.reference-stage-label { font-size: 0.98rem; margin-bottom: 2px; }
.reference-stage-ref { color: var(--ink-500); font-size: 0.8rem; }
.reference-field-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) 56px minmax(120px, 170px) minmax(140px, 1.2fr);
  column-gap: var(--space-sm); row-gap: 2px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.reference-field-row:last-child { border-bottom: none; }
.reference-field-head {
  padding-top: 0; padding-bottom: 6px; border-bottom: 1px solid var(--border-strong);
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.68rem; font-weight: 700; color: var(--ink-500);
}
.reference-col-name { color: var(--ink-700); font-size: 0.88rem; }
.reference-field-head .reference-col-name { color: var(--ink-500); font-size: 0.68rem; }
.reference-col-unit { color: var(--ink-500); font-size: 0.82rem; }
.reference-col-status { display: flex; align-items: center; }
.reference-col-threshold { color: var(--ink-900); font-weight: 600; font-size: 0.86rem; line-height: 1.4; }
.reference-pending-tag { color: var(--ink-500); font-weight: 500; font-size: 0.78rem; font-style: italic; }
.reference-blocked-reason { color: var(--ink-700); font-size: 0.86rem; line-height: 1.5; margin-top: var(--space-2xs); }
.reference-unconfirmed-note { color: var(--warn); font-size: 0.8rem; margin-top: var(--space-2xs); font-style: italic; }
/* Multi-stage pass: an Area's own .notes (a stage-wide caveat, e.g. a form
   discrepancy) and a Field's own .note (shown per field row below its
   standard text) — both verbatim text from backend/qc_schema.py, never
   paraphrased here. Spans every column so a long ambiguity note never
   fights the grid for width. */
.reference-stage-notes { color: var(--ink-500); font-size: 0.82rem; line-height: 1.5; margin: 0 0 var(--space-xs); font-style: italic; }
.reference-field-note { grid-column: 1 / -1; color: var(--ink-500); font-size: 0.78rem; line-height: 1.4; margin-top: 2px; }

/* Phone widths: four tight grid columns stop being legible for long field
   names (task requirement: "long field names and notes work on smaller
   screens") — stack name/unit/status/threshold instead of forcing a
   horizontal squeeze or scroll. */
@media (max-width: 560px) {
  .reference-field-row { grid-template-columns: 1fr; row-gap: 4px; }
  .reference-field-head { display: none; }
  .reference-col-unit::before { content: "Unit: "; color: var(--ink-500); }
  .reference-col-threshold::before { content: "Threshold: "; color: var(--ink-500); font-weight: 500; }
}

/* ---- Field Reference refinement pass, task 6: Standards Management —
   a governance log, not a Field Reference redesign, so it gets its own
   small set of rules rather than overloading .reference-* (that screen
   stays read-only; this one has real forms/buttons). Reuses
   .card/.qc-btn/.qc-value-input/.badge-* wholesale. */
.standards-admin-card { border-left: 3px solid var(--accent); }
.standards-admin-note { color: var(--ink-700); font-size: 0.86rem; line-height: 1.5; margin: 0 0 var(--space-sm); }
.standards-admin-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-700); margin-bottom: var(--space-2xs); }
.standards-admin-input {
  width: 100%; max-width: 360px; min-height: var(--touch-min);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-900);
  border-radius: var(--radius-sm); padding: var(--space-2xs) var(--space-xs); font-size: 0.95rem;
}
.standards-stage-card + .standards-stage-card { margin-top: var(--space-md); }
.standards-field-block { padding: var(--space-sm) 0; border-bottom: 1px solid var(--border); }
.standards-field-block:last-child { border-bottom: none; }
.standards-field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.standards-field-head .qc-btn { flex: none; min-height: 36px; padding: 0 var(--space-sm); }
.standards-propose-form {
  display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: flex-end;
  margin-top: var(--space-sm); padding: var(--space-sm); background: var(--neutral-soft);
  border: 1px solid var(--neutral-border); border-radius: var(--radius-md);
}
.standards-propose-form label {
  display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; font-weight: 600; color: var(--ink-700);
  flex: 1 1 110px; min-width: 90px;
}
.standards-propose-form input[type="text"],
.standards-propose-form input[type="number"],
.standards-propose-form select {
  min-height: var(--touch-min); background: var(--panel); border: 1px solid var(--border-strong);
  color: var(--ink-900); border-radius: var(--radius-sm); padding: var(--space-2xs) var(--space-xs); font-size: 0.9rem;
}
.standards-field-inclusive { flex-direction: row !important; align-items: center; gap: var(--space-2xs) !important; font-weight: 500 !important; }
.standards-propose-form button[type="submit"] { flex: 1 1 100%; }
.standards-proposal-list { margin-top: var(--space-xs); display: flex; flex-direction: column; gap: var(--space-xs); }
.standards-proposal-row {
  background: var(--neutral-soft); border: 1px solid var(--neutral-border); border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
}
.standards-proposal-actions { display: flex; gap: var(--space-2xs); margin-top: var(--space-2xs); }
.standards-proposal-actions .qc-btn { flex: none; min-height: 32px; padding: 0 var(--space-sm); font-size: 0.78rem; }
@media (max-width: 560px) {
  .standards-field-head { flex-direction: column; align-items: flex-start; }
  .standards-field-head .qc-btn { width: 100%; }
}

/* ---- Phase 4: Settings & Help — plain prose cards; this list style is
   the only new rule (card/section-title are reused as-is). */
.settings-help-list { padding-left: 1.1em; display: flex; flex-direction: column; gap: var(--space-2xs); font-size: 0.88rem; line-height: 1.55; color: var(--ink-700); }

/* ---- Phase 5: Excel Import — upload + field-mapping review only. Reuses
   .card/.qc-btn/.qc-value-input/.badge-*/.empty-state wholesale; the rules
   below are the only new layout/visuals this screen needed. */
.excel-upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.excel-upload-row input[type="file"] { flex: 1 1 220px; min-width: 0; font-size: 0.86rem; color: var(--ink-700); }
.excel-upload-hint { color: var(--ink-500); font-size: 0.8rem; margin-top: var(--space-xs); line-height: 1.5; }

.excel-sheet-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-bottom: var(--space-sm); }
.excel-sheet-tab {
  background: var(--neutral-soft); border: 1px solid var(--neutral-border); color: var(--ink-700);
  border-radius: 999px; padding: 5px 13px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  min-height: var(--touch-min);
}
.excel-sheet-tab:hover { border-color: var(--accent); color: var(--accent-dark); }
.excel-sheet-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.excel-header-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-sm);
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.excel-header-row:last-child { border-bottom: none; }
.excel-header-info { min-width: 0; flex: 1 1 260px; }
.excel-header-name { font-weight: 600; color: var(--ink-900); word-break: break-word; }
.excel-header-flags { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-2xs); }
.excel-header-message { color: var(--ink-500); font-size: 0.8rem; margin-top: var(--space-2xs); line-height: 1.5; }
.excel-header-controls { flex: 1 1 220px; max-width: 320px; }
.excel-field-select { width: 100%; }

.excel-mapping-summary { color: var(--ink-700); font-size: 0.86rem; margin-bottom: var(--space-sm); }

/* Long-/wide-format detection banner, "existing value" display per header,
   and the recognized-but-excluded metadata note — Excel upload workflow
   fix (long-format workbook support). */
.excel-format-note {
  background: var(--neutral-soft); border: 1px solid var(--neutral-border); border-radius: var(--radius-sm);
  color: var(--ink-700); font-size: 0.82rem; line-height: 1.5; padding: 8px 12px; margin-bottom: var(--space-sm);
}
/* PDF-upload feature pass. */
.excel-pdf-preview {
  width: 100%; height: 420px; border: 1px solid var(--neutral-border); border-radius: var(--radius-md);
  margin-bottom: var(--space-sm); background: var(--panel);
}
.excel-blank-template-note {
  background: var(--info-soft); border: 1px solid var(--info-border); border-radius: var(--radius-md);
  color: var(--info); font-size: 0.86rem; line-height: 1.55; padding: 10px 12px; margin-bottom: var(--space-sm);
}
.excel-header-existing-value { color: var(--ink-700); font-size: 0.8rem; margin-top: var(--space-2xs); line-height: 1.5; }
.excel-header-existing-value strong { color: var(--ink-900); font-weight: 600; }
.excel-header-occurrence { color: var(--ink-500); font-size: 0.78rem; }
.excel-metadata-note {
  color: var(--ink-500); font-size: 0.8rem; line-height: 1.5; margin-top: var(--space-sm);
  padding-top: var(--space-sm); border-top: 1px dashed var(--neutral-border);
}
.excel-approved-note {
  color: var(--ok); font-size: 0.86rem; font-weight: 600; margin-top: var(--space-sm);
  background: var(--ok-soft); border: 1px solid var(--ok-border); border-radius: var(--radius-md); padding: 10px 12px;
}
/* PDF-upload feature pass: explains why Export is hidden for a PDF-origin
   linked workbook (web/gri-app.js's linkWorkbook()). */
.workbook-export-note {
  background: var(--neutral-soft); border: 1px solid var(--neutral-border); border-radius: var(--radius-sm);
  color: var(--ink-700); font-size: 0.82rem; line-height: 1.5; padding: 8px 12px; margin-top: var(--space-xs);
}

/* ---- Phase 2: Pending Review / All Readings ---------------------------
   Rows reuse .qc-row/.qc-field-label/.qc-standard/.qc-value/
   .qc-status-badge/.qc-edit-slot/.qc-actions/.qc-btn and .context-chip
   wholesale (all defined below/above already, same classes qc-grid.js's
   Capture rows use) — only the chip-wrapping row below is new. */
.reading-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.reading-row-chips { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-2xs); }

/* --------------------------------------------------------- stage select */
.stage-select h2 { font-size: 1.1rem; margin-bottom: var(--space-3xs); }
.stage-select-hint { color: var(--ink-500); font-size: 0.88rem; }
.stage-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.stage-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-md); text-align: left; cursor: pointer; color: var(--ink-900); font-size: 1rem;
  min-height: var(--touch-min); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.1s ease, background 0.15s ease;
}
.stage-card:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.stage-card:active:not(:disabled) { transform: scale(0.99); }
.stage-card:disabled { opacity: 0.55; cursor: not-allowed; }
.stage-card-label { font-weight: 600; display: block; margin-bottom: var(--space-3xs); }
.stage-card-ref { color: var(--ink-500); font-size: 0.78rem; display: block; margin-bottom: var(--space-2xs); font-variant-numeric: tabular-nums; }
.stage-card-blocked { color: var(--warn); font-size: 0.8rem; line-height: 1.4; display: block; }

/* ---------------------------------------------------------- voice stage */
.active-stage-banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-xs);
  margin-bottom: var(--space-sm); font-size: 0.92rem; color: var(--ink-500);
}
#activeStageLabel { font-weight: 600; color: var(--ink-900); }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline;
  font-size: 0.85rem; padding: var(--space-2xs) 0; min-height: var(--touch-min); display: inline-flex; align-items: center;
}
.link-btn:hover { color: var(--accent-dark); }

/* :not([hidden]) — the element is shown/hidden via the native `hidden`
   attribute; without this guard, this unconditional `display` would beat
   the UA default [hidden]{display:none} (equal specificity, author origin
   wins) and the strip would stay visibly rendered (empty) even hidden. */
.context-strip:not([hidden]) {
  display: flex; flex-wrap: wrap; gap: var(--space-2xs);
  margin-bottom: var(--space-md);
}
.context-chip {
  background: var(--ink-100); border: 1px solid var(--border); color: var(--ink-700);
  font-size: 0.78rem; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill);
  white-space: nowrap;
}
.context-chip strong { color: var(--ink-900); font-weight: 600; }

.voice-stage-body { display: flex; flex-direction: column; gap: var(--space-lg); }

.voice-workspace { display: flex; flex-direction: column; gap: var(--space-md); }
.voice-stage-main { display: flex; flex-direction: column; gap: var(--space-lg); }

.orb-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md); display: flex; flex-direction: column; align-items: center;
  box-shadow: var(--shadow-sm);
}

/* ---- orb / waveform ---------------------------------------------------
   The orb's interior is now a real canvas animation (web/voice-orb.js,
   adapted from Marea's existing voice-assistant animation) instead of the
   previous static CSS rings/bars/dot — see that file's module docstring
   for the full reuse/adaptation notes. .orb-wrap itself keeps its
   existing per-state border-color/box-shadow ring (a GRI-only visual cue
   with no Marea equivalent, left as-is) and now also clips its canvas
   child to the circle and pins a fixed dark backdrop — the same "always
   dark, independent of the rest of the app's light/dark theme" treatment
   Marea's own voice stage uses, so the teal/gold glow always has the
   contrast it was designed against. ------------------------------------- */
.orb-wrap {
  position: relative; width: 104px; height: 104px; border-radius: 50%;
  background: #0b1220;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  border: 2px solid var(--border-strong); transition: border-color 0.2s ease, box-shadow 0.2s ease;
  flex: none;
}
#voiceCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}

.orb-wrap[data-state="idle"] { color: var(--state-ready); }
.orb-wrap[data-state="connecting"] {
  border-color: var(--state-connecting); color: var(--state-connecting);
  box-shadow: 0 0 0 8px var(--warn-soft);
}
.orb-wrap[data-state="listening"] {
  border-color: var(--state-listening); color: var(--state-listening);
  box-shadow: 0 0 0 8px var(--accent-soft);
}
.orb-wrap[data-state="thinking"] {
  border-color: var(--state-thinking); color: var(--state-thinking);
  box-shadow: 0 0 0 8px var(--corrected-soft);
}
.orb-wrap[data-state="answering"] {
  border-color: var(--state-answering); color: var(--state-answering);
  box-shadow: 0 0 0 8px var(--info-soft);
  animation: orb-pulse 1.1s ease-in-out infinite;
}
.orb-wrap[data-state="error"] {
  border-color: var(--danger); color: var(--danger);
  box-shadow: 0 0 0 8px var(--danger-soft);
}

@keyframes orb-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
/* orb-spin is also used by .spinner (Phase 3's loading state, see below) —
   kept even though the orb itself no longer uses it. */
@keyframes orb-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes dot-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }
@media (prefers-reduced-motion: reduce) {
  .orb-wrap[data-state="answering"],
  .state-pill .dot { animation: none !important; }
}

.orb-hint { text-align: center; color: var(--ink-500); font-size: 0.88rem; margin: var(--space-sm) 0 0; }

.voice-controls { display: flex; gap: var(--space-xs); margin-top: var(--space-md); width: 100%; justify-content: center; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-700);
  padding: var(--space-xs) var(--space-md); border-radius: var(--radius-md); cursor: pointer;
  font-size: 0.86rem; font-weight: 600; min-height: var(--touch-min); min-width: 44px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn-icon { width: 18px; height: 18px; flex: none; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn.muted { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.icon-btn.stop-btn { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.icon-btn.stop-btn:hover:not(:disabled) { border-color: var(--danger); background: #fee2e2; }

/* :not([hidden]) — see the note on .context-strip above. */
.error-banner:not([hidden]) {
  display: flex; align-items: flex-start; gap: var(--space-2xs);
  background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger);
  padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-md); margin-top: var(--space-md);
  width: 100%; font-size: 0.86rem; line-height: 1.45;
}

.caption-panel {
  background: var(--ink-100); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-md); min-height: 64px;
}
.caption-empty { color: var(--ink-500); font-size: 0.88rem; }
.caption-role { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); margin-bottom: var(--space-3xs); }
.caption-role.you { color: var(--accent-dark); }
.caption-text { font-size: 0.95rem; line-height: 1.5; color: var(--ink-900); }

/* ------------------------------------------------------------ QC grid -- */
/* ==================================================== workbook panel ==
   Excel-first Capture redesign (web/gri-app.js's "Workbook panel"
   section). Same card/button language as every other panel on this
   screen (.card/.qc-btn/.link-btn are NOT redefined here, just reused). */
.workbook-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-md); box-shadow: var(--shadow-sm);
}
.workbook-panel-head { margin-bottom: var(--space-sm); }
.workbook-panel-head h2 { font-size: 1rem; }
.workbook-panel-hint { color: var(--ink-500); font-size: 0.8rem; margin-top: var(--space-3xs); }

.workbook-empty p { color: var(--ink-500); font-size: 0.86rem; margin: 0 0 var(--space-xs); }
.workbook-empty-note { font-size: 0.78rem !important; margin-top: var(--space-xs) !important; }
.workbook-picker-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.workbook-picker-select {
  flex: 1 1 220px; min-height: var(--touch-min);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-900);
  border-radius: var(--radius-sm); padding: var(--space-2xs) var(--space-xs); font-size: 0.9rem;
}

/* Download QC Report feature (All Readings screen) — a stage picker + date
   picker beside the "Download QC Report" button. Reuses .workbook-picker-select
   for the stage <select>; only the date input and the row layout are new. */
.qc-report-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs);
  width: 100%; margin-top: var(--space-2xs);
}
.qc-report-controls .workbook-picker-select { flex: 0 1 220px; min-width: 160px; }
.qc-report-date-input {
  min-height: var(--touch-min);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-900);
  border-radius: var(--radius-sm); padding: var(--space-2xs) var(--space-xs); font-size: 0.9rem;
}
.workbook-picker-status {
  font-size: 0.8rem; margin-top: var(--space-xs); padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm); background: var(--panel-muted, var(--panel)); border: 1px solid var(--border-strong);
}
.workbook-picker-status.is-error {
  background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger);
}

.workbook-file-info { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.workbook-file-name { font-weight: 600; color: var(--ink-900); overflow-wrap: anywhere; }

.workbook-field-preview { display: flex; flex-direction: column; gap: var(--space-2xs); margin-bottom: var(--space-sm); }
.workbook-field-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-xs); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.82rem; background: var(--neutral-soft);
}
.workbook-field-row.has-conflict { border-color: var(--danger-border); background: var(--danger-soft); }
.workbook-field-name { font-weight: 600; color: var(--ink-900); min-width: 0; overflow-wrap: anywhere; }
.workbook-field-cell { color: var(--ink-500); font-size: 0.74rem; white-space: nowrap; }

/* "Import readings" — the missing step between a linked workbook and real
   pending QC readings (backend/qc_import.py). Sits between the field
   preview and the Export button in the same workbook panel. */
.workbook-import-panel { margin-bottom: var(--space-sm); }
.workbook-import-status { color: var(--ink-500); font-size: 0.8rem; margin-bottom: var(--space-2xs); }
.workbook-import-status.is-ready { color: var(--ink-700); }
.workbook-field-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.workbook-conflict-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs);
  background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger);
  border-radius: var(--radius-sm); padding: var(--space-xs); font-size: 0.82rem; margin: var(--space-2xs) 0;
}
.workbook-conflict-actions { display: flex; gap: var(--space-2xs); margin-left: auto; }

/* Compact per-row "mapped to the workbook" tag, appended inside each
   QcGrid row's .qc-row-info block — a new, additive element (never a
   replacement of info/value/status/edit-slot/actions, which qc-grid.js's
   data-role wiring and tests/test_frontend_contract.py both depend on). */
.qc-mapped-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
  font-size: 0.72rem; color: var(--info); background: var(--info-soft); border: 1px solid var(--info-border);
  border-radius: var(--radius-pill); padding: 1px 8px; white-space: nowrap;
}
.qc-mapped-tag.has-conflict { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

/* Compact per-row conflict-resolution banner — also nested inside
   .qc-row-info (never a new direct .qc-row grid child, so the
   grid-template-areas below are untouched). Shown whenever the workbook's
   ORIGINAL cell for this field already held a value and the operator
   hasn't resolved it yet via POST .../resolve-conflict. This is
   deliberately independent of the row's pending/committed state and
   never gates the Confirm button: resolving it only records an audit
   answer (backend/excel_import_store.py's resolve_conflict docstring),
   it is not a second enforcement path over the QC confirm pipeline. */
.qc-row-conflict {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs);
  background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger);
  border-radius: var(--radius-sm); padding: 2px var(--space-xs); font-size: 0.72rem; margin-top: var(--space-2xs);
}
.qc-row-conflict-actions { display: flex; gap: 4px; }
.qc-row-conflict-actions button { font-size: 0.72rem; padding: 1px 8px; min-height: 0; }

.qc-grid-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-md); box-shadow: var(--shadow-sm);
}
.qc-grid-head { margin-bottom: var(--space-sm); }
.qc-grid-head h2 { font-size: 1rem; }
.qc-grid-subhead { color: var(--ink-500); font-size: 0.8rem; margin-top: var(--space-3xs); }

.qc-grid { display: flex; flex-direction: column; gap: var(--space-xs); }

/* Mobile: each reading is a stacked card. Grid-template-areas let us
   reflow the exact same DOM elements (qc-grid.js only ever queries
   [data-role="..."], never a layout-specific selector) into a completely
   different visual arrangement per breakpoint. */
/* Compact preview (Excel-first Capture redesign): shorter padding and a
   smaller value/label scale than before, so the full field list for a
   stage reads as a scannable dense list rather than a stack of big
   cards — the task's "replace the large, repetitive list of QC reading
   cards" requirement. The DOM structure and every [data-role="..."]
   element qc-grid.js wires up are unchanged; only sizing is compacted. */
.qc-row {
  display: grid;
  grid-template-areas:
    "info   info"
    "value  status"
    "edit   edit"
    "actions actions";
  grid-template-columns: 1fr auto;
  gap: var(--space-3xs) var(--space-sm);
  align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-sm);
}
.qc-row.state-pending { border-color: var(--warn-border); background: linear-gradient(180deg, var(--warn-soft), var(--panel) 65%); }
.qc-row.state-committed { border-color: var(--ok-border); }
.qc-row.out-of-spec { border-color: var(--danger-border); }
.qc-row.out-of-spec .qc-value { color: var(--danger); font-weight: 700; }

.qc-row-info { grid-area: info; min-width: 0; }
.qc-field-label { font-weight: 600; color: var(--ink-900); font-size: 0.92rem; }
.qc-standard { color: var(--ink-500); font-size: 0.76rem; margin-top: 1px; }

.qc-value {
  grid-area: value; font-variant-numeric: tabular-nums; font-size: 0.98rem; font-weight: 600;
  overflow-wrap: anywhere; color: var(--ink-900);
}
.qc-status-badge {
  grid-area: status; justify-self: end;
  font-size: 0.74rem; font-weight: 700; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill);
  text-align: center; white-space: nowrap;
}
.qc-status-badge.empty { background: var(--neutral-soft); color: var(--ink-500); border: 1px solid var(--neutral-border); }
.qc-status-badge.pending { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.qc-status-badge.committed { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.qc-row.out-of-spec .qc-status-badge.pending,
.qc-row.out-of-spec .qc-status-badge.committed { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

/* Multi-stage pass: a THIRD, distinct row/badge state for in_spec === null
   — "no confirmed threshold yet" (backend/qc_schema.py's "unresolved" rule
   status). This must never look like either "in spec" (ok/green) or "out
   of spec" (danger/red) — those claim a verdict that wasn't given. Uses
   --info (blue), already defined for both color schemes, previously
   unused. Lower specificity than .out-of-spec is irrelevant here: a field
   is never both (false and null are mutually exclusive). */
.qc-row.rule-unresolved { border-color: var(--info-border); }
.qc-row.rule-unresolved .qc-value { color: var(--info); }
.qc-row.rule-unresolved .qc-status-badge.pending,
.qc-row.rule-unresolved .qc-status-badge.committed,
.qc-status-badge.rule-unresolved { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }

.qc-edit-slot:not(:empty) { grid-area: edit; display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-2xs); }
.qc-value-input {
  flex: 1 1 120px; min-width: 100px; min-height: var(--touch-min);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-900);
  border-radius: var(--radius-sm); padding: var(--space-2xs) var(--space-xs); font-size: 0.95rem;
}
/* CPD-8581: the corrective-action editor is a <textarea> sharing
   .qc-value-input's base look, widened and resizable for multi-line text
   instead of .qc-value-input's single-line sizing. */
.qc-note-input { flex-basis: 220px; resize: vertical; font-family: inherit; }

.qc-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-2xs); }
.qc-actions:empty { margin-top: 0; }

.qc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink-700);
  border-radius: var(--radius-sm); padding: 0 var(--space-sm); cursor: pointer;
  font-size: 0.82rem; font-weight: 600; min-height: var(--touch-min); flex: 1 1 auto;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.qc-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.qc-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.qc-btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.qc-btn-ghost { background: transparent; }

/* --------------------------------------------------------- state pill -- */
.state-pill {
  display: flex; align-items: center; gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-pill);
  background: var(--neutral-soft); border: 1px solid var(--neutral-border);
  font-size: 0.82rem; font-weight: 600; color: var(--ink-700);
  min-height: var(--touch-min);
}
.state-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--state-ready); flex: none; }
.state-pill.ready { color: var(--ink-700); }
.state-pill.connecting { color: var(--state-connecting); border-color: var(--warn-border); background: var(--warn-soft); }
.state-pill.connecting .dot { background: var(--state-connecting); animation: dot-pulse 1s ease-in-out infinite; }
.state-pill.listening { color: var(--state-listening); border-color: var(--accent-border); background: var(--accent-soft); }
.state-pill.listening .dot { background: var(--state-listening); animation: dot-pulse 1.1s ease-in-out infinite; }
.state-pill.thinking { color: var(--state-thinking); border-color: var(--corrected-border); background: var(--corrected-soft); }
.state-pill.thinking .dot { background: var(--state-thinking); animation: dot-pulse 0.75s ease-in-out infinite; }
.state-pill.answering { color: var(--state-answering); border-color: #bae6fd; background: var(--info-soft); }
.state-pill.answering .dot { background: var(--state-answering); animation: dot-pulse 0.9s ease-in-out infinite; }
.state-pill.error { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.state-pill.error .dot { background: var(--danger); }

/* ============================================================ tablet === */
@media (min-width: 431px) {
  .main-content { padding: var(--space-lg) var(--space-md) var(--space-xl); }

  .stage-list { grid-template-columns: repeat(2, 1fr); }

  .orb-card { padding: var(--space-xl) var(--space-lg); }
  .orb-wrap { width: 120px; height: 120px; }

  .qc-row {
    grid-template-areas:
      "info  value  status"
      "edit  edit   edit"
      "actions actions actions";
    grid-template-columns: 1fr auto auto;
  }
  .qc-value { justify-self: end; }
}

/* ===================================================== sidebar/topbar == */
@media (max-width: 1024px) {
  .nav-backdrop[hidden] { display: none; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 40;
  }
}

/* ============================================================ desktop == */
@media (min-width: 1025px) {
  .app-shell { grid-template-columns: 230px 1fr; }
  .sidebar { position: sticky; left: auto; top: 0; transform: none; box-shadow: none; height: 100vh; }
  .mobile-nav-toggle { display: none; }

  .topbar { padding: var(--space-sm) var(--space-xl); }
  .main-content { padding: var(--space-xl) var(--space-lg) var(--space-xl); }

  .stage-list { grid-template-columns: repeat(3, 1fr); }

  .voice-stage-body {
    display: grid;
    grid-template-columns: 360px 1fr;
    align-items: start;
    gap: var(--space-xl);
  }
  .voice-workspace { position: sticky; top: calc(64px + var(--space-lg)); }
  .voice-stage-main { display: flex; flex-direction: column; gap: var(--space-lg); min-width: 0; }

  .qc-grid-section { padding: var(--space-lg); }

  .qc-row {
    grid-template-areas:
      "info value status actions"
      "edit edit   edit    edit";
    grid-template-columns: 1.6fr 0.8fr 0.9fr 1.1fr;
    gap: var(--space-md);
  }
  .qc-edit-slot:not(:empty) { margin-top: var(--space-2xs); }
  .qc-actions { justify-content: flex-end; margin-top: 0; }
  .qc-actions .qc-btn,
  .qc-edit-slot .qc-btn { flex: 0 0 auto; }
}

@media print {
  .sidebar, .topbar, .notice-region, .nav-backdrop { display: none; }
}

/* ============================================================================
   Excel-into-Capture integration (new): workbook-manage button, the generic
   modal shell (no .modal/.dialog/.drawer existed anywhere before this), the
   Live Reading Preview card, and the compact Recent Readings list. All reuse
   the existing design tokens (--panel/--border/--radius-*/--shadow-*/
   --space-*/--ink-*/status colors) rather than introducing new ones, so this
   reads as the same visual system as every other card on the page.
   ============================================================================ */

.workbook-panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); }
.workbook-panel-head-row h2 { margin: 0; }
.workbook-panel-head-row .link-btn { padding: 0; min-height: 0; font-size: 0.8rem; }

/* ---- generic modal shell ------------------------------------------------ */
body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-md);
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: min(640px, 100%);
  max-height: calc(100vh - var(--space-xl));
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-close {
  background: none; border: none; color: var(--ink-500); cursor: pointer;
  font-size: 1.4rem; line-height: 1; padding: var(--space-2xs); min-width: var(--touch-min); min-height: var(--touch-min);
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--neutral-soft); color: var(--ink-900); }
.modal-body {
  padding: var(--space-md);
  overflow-y: auto;
}
.modal-body .card:first-child { margin-top: 0; }

.capture-excel-use-card {
  margin-top: var(--space-sm); padding: var(--space-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--radius-md);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm);
}
.capture-excel-use-card p { margin: 0; font-size: 0.86rem; color: var(--ink-900); }

/* ---- Live Reading Preview ------------------------------------------------ */
.live-reading-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-md); box-shadow: var(--shadow-sm);
  width: 100%;
}
.live-reading-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); margin-bottom: var(--space-xs); }
.live-reading-head h2 { margin: 0; font-size: 1rem; }

.live-reading-status-badge {
  font-size: 0.74rem; font-weight: 700; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill);
  white-space: nowrap; background: var(--neutral-soft); color: var(--ink-500); border: 1px solid var(--neutral-border);
}
.live-reading-status-badge.is-pending { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.live-reading-status-badge.is-confirmed { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.live-reading-status-badge.is-rejected { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

.live-reading-empty { color: var(--ink-500); font-size: 0.88rem; margin: 0; }

.live-reading-body { display: flex; flex-direction: column; gap: var(--space-2xs); }
.live-reading-field { font-weight: 600; color: var(--ink-900); font-size: 0.95rem; }
.live-reading-value-row { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.live-reading-value { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; color: var(--ink-900); }
.live-reading-spec-badge {
  font-size: 0.74rem; font-weight: 700; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill);
  white-space: nowrap;
}
.live-reading-spec-badge:empty { display: none; }
.live-reading-spec-badge.out-of-spec { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.live-reading-spec-badge.rule-unresolved { background: var(--info-soft); color: var(--info); border: 1px solid var(--info-border); }

.live-reading-excel {
  font-size: 0.82rem; color: var(--ink-700); margin: 0;
  background: var(--neutral-soft); border: 1px solid var(--neutral-border); border-radius: var(--radius-sm);
  padding: var(--space-2xs) var(--space-xs);
}
.live-reading-reject-reason { color: var(--danger); font-size: 0.84rem; margin: 0; }

.live-reading-actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-top: var(--space-2xs); }

/* ---- Recent Readings ------------------------------------------------------ */
.recent-readings-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-md); box-shadow: var(--shadow-sm);
}
.recent-readings-card h2 { margin: 0 0 var(--space-xs); font-size: 0.95rem; }
.recent-readings-empty { color: var(--ink-500); font-size: 0.84rem; margin: 0; }

.recent-readings-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2xs); }
.recent-reading-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-xs); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--neutral-soft); font-size: 0.82rem;
}
.recent-reading-item.is-rejected { border-color: var(--danger-border); background: var(--danger-soft); }
.recent-reading-field { font-weight: 600; color: var(--ink-900); min-width: 0; overflow-wrap: anywhere; flex: 1 1 auto; }
.recent-reading-value { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-700); }
.recent-reading-status {
  font-size: 0.72rem; font-weight: 700; white-space: nowrap; padding: 1px 8px; border-radius: var(--radius-pill);
  background: var(--neutral-soft); color: var(--ink-500); border: 1px solid var(--neutral-border);
}
.recent-reading-status-pending { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.recent-reading-status-confirmed { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.recent-reading-status-edited { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.recent-reading-status-rejected { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

/* Transient highlight (web/qc-grid.js's _flashRow) so the grid row a reading
   just landed on — via voice OR a manual edit — is visually distinct from
   the rest of the grid for a couple of seconds (task §3: "make the current
   reading visually distinct from previous readings"), independent of (and
   in addition to) the dedicated Live Reading Preview card above. */
@keyframes qc-row-flash {
  0% { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-border); }
  100% { background: transparent; box-shadow: none; }
}
.qc-row.just-updated { animation: qc-row-flash 2.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .qc-row.just-updated { animation: none; outline: 2px solid var(--accent-border); outline-offset: 2px; }
}

@media (max-width: 1024px) {
  .modal { max-height: calc(100vh - var(--space-lg)); }
}
