/* ============================================================
   ETC Compliance Verifier — design tokens (spec §2)
   ============================================================ */
:root {
  /* Verdict / semantic — LOAD-BEARING (match Excel export) */
  --pass-bg: #92D050;        --pass-text: #15300A;  --pass-tint: #F2F9EC;  --pass-border: #5E9E2E;
  --fail-bg: #FF0000;        --fail-text: #FFFFFF;  --fail-tint: #FDECEC;  --fail-border: #C20000;
  --nr-bg:   #FFBF00;        --nr-text:   #3A2C00;  --nr-tint:   #FFF8E6;  --nr-border:   #C79100;
  --rf-bg:   #FF8A00;        --rf-text:   #FFFFFF;  --rf-tint:   #FFF1E2;  --rf-border:   #CC6E00;
  --skip-bg: #9AA0A6;        --skip-text: #FFFFFF;  --skip-tint: #F4F5F6;  --skip-border: #70757A;
  --over-bg: #6F42C1;        --over-text: #FFFFFF;  --over-tint: #F3EEFB;  --over-border: #54309B;
  --ack-bg:  #2D7A2D;        --ack-text:  #FFFFFF;  --ack-border:  #1E5A1E;

  /* Job-status (process states) */
  --st-queued-bg: #D0D7DE;   --st-queued-text: #1A1A1A;
  --st-extract-bg: #54AEFF;  --st-extract-text: #FFFFFF;
  --st-await-bg: #FFBF00;    --st-await-text: #3A2C00;
  --st-compare-bg: #54AEFF;  --st-compare-text: #FFFFFF;
  --st-complete-bg: #92D050; --st-complete-text: #15300A;
  --st-error-bg: #FF0000;    --st-error-text: #FFFFFF;

  /* Neutrals / chrome */
  --ink-900: #1A1A1A;
  --ink-600: #4A4F55;
  --ink-400: #6A6A72;
  --header-bg: #14181E;
  --canvas: #F7F7F8;
  --surface: #FFFFFF;
  --surface-2: #FBFBFC;
  --border: #E2E2E6;
  --border-strong: #C9CCD1;
  --accent: #DE002E;
  --accent-hover: #B11226;
  --accent-soft: #DE002E18;
  --locked: #9AA0A6;
  --danger-text: #B35900;
  --success-text: #2D7A2D;

  /* Spacing scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* Radius */
  --r-card: 8px; --r-ctl: 6px; --r-pill: 999px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Matrix row density (overridden by .density-comfortable) */
  --row-pad-y: 8px;
  --cell-pad-x: 12px;
  --matrix-fs: 13.5px;
}

.density-comfortable {
  --row-pad-y: 14px;
  --matrix-fs: 14.5px;
}

/* RETRIEVAL_FAILURE color toggle (Tweak): amber variant matches Excel */
.rf-amber {
  --rf-bg: #FFBF00; --rf-text: #3A2C00; --rf-tint: #FFF8E6; --rf-border: #C79100;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- App shell ---- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  background: var(--header-bg);
  color: #fff;
  height: 58px;
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s5);
  position: sticky; top: 0; z-index: 40;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid #0d1014;
}
button.brand { background: none; border: 0; cursor: pointer; padding: 0; font-family: inherit; }
.app-header .brand {
  display: flex; align-items: center; gap: var(--s3);
  font-size: 14px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; color: #fff;
}
.app-header .brand .sub { color: #79858f; font-weight: 400; font-size: 12px; }
.sh-logo { height: 34px; display: block; border-radius: 2px; }
.sh-mark { display: inline-flex; gap: 3px; align-items: center; }
.sh-mark i { display: block; width: 9px; height: 14px; background: var(--accent); clip-path: polygon(0 0, 55% 0, 100% 50%, 55% 100%, 0 100%, 45% 50%); }
.sh-mark i + i { opacity: .55; }
.sh-name { text-transform: uppercase; letter-spacing: .14em; font-weight: 400; font-size: 13.5px; color: #e8ebee; }
.sh-name b { font-weight: 700; color: #fff; }
.hdr-doc { display: inline-flex; align-items: center; gap: 10px; padding-left: var(--s4); border-left: 1px solid #2a323b; min-width: 0; }
.hdr-back { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: #9fb0c2; font-size: 12px; cursor: pointer; font-family: inherit; padding: 4px 0; }
.hdr-back:hover { color: #fff; }
.hdr-doc-id { font-size: 12.5px; font-weight: 700; color: #fff; white-space: nowrap; }
.hdr-doc-proj { font-size: 11.5px; color: #79858f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hdr-user { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #c5d2de; background: #1f262e; border: 1px solid #2a323b; border-radius: var(--r-pill); padding: 5px 11px; }
.hdr-logout { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: #79858f; font-size: 12px; cursor: pointer; font-family: inherit; padding: 4px; }
.hdr-logout:hover { color: #fff; }
.hdr-lang { display: inline-flex; border: 1px solid #2a323b; border-radius: var(--r-pill); overflow: hidden; margin-right: 6px; }
.hdr-lang button { background: transparent; color: #9fb0c2; border: 0; padding: 5px 11px; font-size: 11px; font-weight: 700; letter-spacing: .04em; cursor: pointer; font-family: inherit; }
.hdr-lang button.on { background: var(--accent); color: #fff; }
.hdr-lang button:not(.on):hover { color: #fff; }
@media (max-width: 1460px) {
  .app-header .brand .sub { display: none; }
  .hdr-doc-proj { display: none; }
}
@media (max-width: 1180px) {
  .stepper .step .step-label { display: none; }
  .stepper .step { padding: 5px 6px; }
  .app-header:has(.hdr-doc) .sh-logo { height: 24px; }
}

/* SH display type */
.sh-display { text-transform: uppercase; letter-spacing: .07em; font-weight: 700; line-height: 1.12; }

/* Stepper in header */
.stepper { display: flex; align-items: center; gap: 2px; margin-left: var(--s3); }
.stepper .step {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: #8497a9; padding: 5px 10px; border-radius: var(--r-pill);
  background: transparent; border: 0; cursor: not-allowed; font-family: inherit;
  white-space: nowrap;
}
.stepper .step .dot {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; background: #2b3e54; color: #8497a9;
  border: 1px solid #3a5067;
}
.stepper .step.reachable { cursor: pointer; color: #c5d2de; }
.stepper .step.reachable:hover { background: #25374a; }
.stepper .step.active { color: #fff; }
.stepper .step.active .dot { background: var(--accent); color: #fff; border-color: var(--accent); }
.stepper .step.done .dot { background: #2D7A2D; color: #fff; border-color: #2D7A2D; }
.stepper .sep { width: 14px; height: 1px; background: #3a5067; }

/* Main column */
.app-main { flex: 1; display: flex; justify-content: center; padding: var(--s6) var(--s5) var(--s7); }
.col { width: 100%; max-width: 880px; }
.col.wide { max-width: 1140px; }

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-400);
  font-size: 12.5px;
  padding: var(--s4) var(--s5);
  text-align: center;
}
.app-footer strong { color: var(--ink-600); font-weight: 600; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s5);
}
.card + .card { margin-top: var(--s4); }
.card-title { font-size: 24px; line-height: 30px; font-weight: 600; margin: 0 0 var(--s2); letter-spacing: -.01em; }
.card-sub { font-size: 15px; line-height: 22px; color: var(--ink-600); margin: 0 0 var(--s5); max-width: 62ch; }
.h3 { font-size: 18px; line-height: 26px; font-weight: 600; margin: 0; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-400); }

/* ---- Buttons ---- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  min-height: 40px; padding: 0 var(--s4);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-ctl); border: 1px solid transparent; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--fail-border); color: #fff; }
.btn-danger:hover { background: var(--fail-bg); }
.btn-secondary { background: var(--surface); color: var(--ink-900); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-400); }
.btn-ghost { background: transparent; color: var(--ink-600); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink-900); }
.btn[disabled], .btn.locked {
  background: var(--surface-2); color: var(--locked); border-color: var(--border);
  cursor: not-allowed; box-shadow: none;
}
.btn.locked { background: #eef0f2; }
.btn-sm { min-height: 32px; font-size: 12.5px; padding: 0 12px; }
.btn-lg { min-height: 46px; font-size: 15px; padding: 0 22px; }

/* ---- Pills / badges ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 4px 10px 4px 8px; border-radius: var(--r-pill); line-height: 1;
  border: 1px solid transparent;
}
.pill svg { width: 14px; height: 14px; }
.pill-sm { font-size: 11px; padding: 3px 8px 3px 6px; }

/* citation chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-600);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px;
  background: var(--surface); white-space: nowrap;
}
.chip svg { width: 11px; height: 11px; color: var(--ink-400); }

/* ---- Inputs ---- */
.input, .select, .textarea {
  font-family: var(--font-mono); font-size: 13.5px; color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl); padding: 9px 11px; width: 100%;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 64px; font-family: var(--font-sans); }
.field-error { border-color: var(--fail-border) !important; background: var(--fail-tint); }

/* ---- misc ---- */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.hr { height: 1px; background: var(--border); border: 0; margin: var(--s5) 0; }
.kbd { font-family: var(--font-mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--ink-600); }

.struck { text-decoration: line-through; color: var(--ink-400); }
