/* ClearDraft — operations tool for a shipping desk.
   Cool paper, not cream. Archivo for interface, IBM Plex Mono for every
   shipping code and field value: monospace is functional here, it makes
   "3" vs "4" and "21,577" vs "22,077" visible character by character. */

:root {
  --paper:      #EEF1F5;
  --surface:    #FFFFFF;
  --surface-2:  #F6F8FB;
  --ink:        #0D1520;
  --ink-2:      #4A5563;
  --ink-3:      #5E6A7A;
  --rule:       #DCE2EA;
  --rule-2:     #C3CCD8;
  --marine:     #14395E;

  /* Status only. Never used to tell one category from another. */
  --match:      #0F7357;
  --match-bg:   #E7F3EF;
  --mismatch:   #BE2D25;
  --mismatch-bg:#FBEAE8;
  --review:     #6C4BB6;
  --review-bg:  #EFEAF8;
  --marked:     #14395E;
  --marked-bg:  #E9EEF5;
  /* Same weight, different unit — resolved (not a defect), but distinct from
     an ordinary match so a clerk can still see why the numbers on the page
     don't look identical. Calm teal: not the mismatch red, not the marked
     navy, not the review purple. */
  --converted:    #0E7C86;
  --converted-bg: #E6F3F4;

  --display: 'Archivo', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r: 6px;
  --shadow: 0 1px 2px rgba(13,21,32,.06), 0 4px 14px rgba(13,21,32,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
a { color: inherit; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--marine); outline-offset: 2px; border-radius: 3px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.mark {
  width: 10px; height: 18px; align-self: center; border-radius: 1px;
  background: linear-gradient(to bottom, var(--marine) 0 46%, transparent 46% 54%, var(--mismatch) 54% 100%);
}
.brand-name { font-weight: 800; letter-spacing: -0.03em; font-size: 17px; }
.brand-sub {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .08em;
}
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 7px 13px; border-radius: var(--r); text-decoration: none;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--ink); color: #fff; }

/* ── Account control (topbar) ──────────────────────────────────
   Hidden until GET /api/auth/me answers; stays hidden for the whole
   session if accounts are unavailable, so the site behaves exactly as it
   does today. Signed out: one "Sign in" button. Signed in: the account's
   email, truncated on narrow screens, opening a small menu with "Sign out" —
   one obvious control, never two things fighting for the same click. */
.account {
  display: flex; align-items: center; gap: 8px;
  padding-left: 18px; border-left: 1px solid var(--rule);
  position: relative;
}
.account[hidden] { display: none; }
.account-btn {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: var(--r);
  padding: 8px 14px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.account-btn:hover { background: var(--surface); border-color: var(--ink-3); }
.account-user-wrap { display: flex; align-items: center; gap: 8px; }
.account-user-wrap[hidden] { display: none; }
.account-email-btn { max-width: 140px; display: inline-flex; align-items: center; }
.account-email-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: var(--shadow); min-width: 140px; padding: 6px;
}
.account-menu[hidden] { display: none; }
.account-menu-item {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 13.5px;
  color: var(--ink); background: none; border: 0; border-radius: 4px; padding: 10px;
  min-height: 44px; cursor: pointer;
}
.account-menu-item:hover { background: var(--surface-2); }

/* Topbar shortcut straight to "Marked as same", with a live pair count. */
.learned-shortcut { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.learned-shortcut-icon { font-family: var(--mono); font-weight: 700; color: var(--marine); }
.learned-shortcut[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.learned-shortcut[aria-current="page"] .learned-shortcut-icon { color: #fff; }
.learned-shortcut-count {
  font-size: 11.5px; font-weight: 700; min-width: 20px; padding: 1px 6px;
  border-radius: 999px; background: var(--marine); color: #fff;
  text-align: center; line-height: 18px;
}
.learned-shortcut-count[hidden] { display: none; }
.learned-shortcut-label-short { display: none; }

@media (max-width: 860px) {
  .account { padding-left: 10px; }
  .account-email-btn { max-width: 96px; }
  .learned-shortcut-label-full { display: none; }
  .learned-shortcut-label-short { display: inline; }
}
@media (max-width: 420px) {
  .account-btn { font-size: 12.5px; padding: 7px 10px; }
  .account-email-btn { max-width: 72px; }
  .learned-shortcut { padding-left: 8px; padding-right: 8px; gap: 4px; }
}

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 96px; }
.view-head { margin-bottom: 24px; }
.view-head h1 { font-size: 30px; }
.lede { margin: 6px 0 0; color: var(--ink-2); max-width: 66ch; }
.lede b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── Home / main menu ──────────────────────────────────────────
   Hick's law: one obvious primary action, two lighter-weight secondary
   cards below it, one quiet proof line at the very bottom. Nothing else
   competes for the first click. */
.home-hero { max-width: 62ch; margin: 12px 0 40px; }
.home-hero h1 { font-size: 34px; line-height: 1.15; }
.home-hero .lede { margin: 12px 0 24px; max-width: 56ch; }
.btn-large { font-size: 16px; padding: 15px 30px; min-height: 44px; }
.hero-caption { margin: 10px 0 0; font-size: 13px; color: var(--ink-3); max-width: 46ch; }

.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 32px; }
.home-card {
  display: block; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 18px 20px; text-decoration: none;
  color: inherit; min-height: 44px; transition: border-color .12s, background-color .12s;
}
.home-card:hover { border-color: var(--rule-2); background: var(--surface-2); }
.home-card-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.home-card-line { font-size: 13px; color: var(--ink-2); }

.home-proof {
  display: inline-block; font-family: var(--mono); font-size: 12px;
  color: var(--ink-2); text-decoration: none; border-bottom: 1px dotted var(--rule-2);
  padding-bottom: 1px;
}
.home-proof:hover { color: var(--ink-2); border-color: var(--ink-3); }

@media (max-width: 860px) {
  .home-hero h1 { font-size: 26px; }
  .home-cards { grid-template-columns: 1fr; }
}

.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;
}

.search-field { margin-bottom: 16px; }
.search-input {
  width: 100%; max-width: 420px; min-height: 40px; font-family: inherit;
  font-size: 13.5px; color: var(--ink); padding: 9px 12px;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--surface);
}
.search-input:focus-visible { outline: 2px solid var(--marine); outline-offset: 1px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 20px;
}
.tab {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 12px 14px; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); font-family: inherit; color: var(--ink-2);
  transition: border-color .12s;
}
.tab:hover { border-color: var(--rule-2); }
.tab-n { font-size: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.tab-l { font-size: 12.5px; }
.tab[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tab[data-tab="mismatch"][aria-selected="true"] { border-color: var(--mismatch); box-shadow: inset 0 0 0 1px var(--mismatch); }
.tab[data-tab="mismatch"][aria-selected="true"] .tab-n { color: var(--mismatch); }
.tab[data-tab="needs_review"][aria-selected="true"] { border-color: var(--review); box-shadow: inset 0 0 0 1px var(--review); }
.tab[data-tab="needs_review"][aria-selected="true"] .tab-n { color: var(--review); }

.case-list { display: flex; flex-direction: column; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.case {
  display: grid; grid-template-columns: 120px 1fr auto;
  gap: 16px; align-items: center;
  padding: 13px 16px; background: var(--surface);
  text-decoration: none; cursor: pointer;
}
.case:hover { background: var(--surface-2); }
.case-ref { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--marine); }
.case-subject { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-fields { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 3px 7px; border-radius: 3px; white-space: nowrap;
}
.chip-mismatch { background: var(--mismatch-bg); color: var(--mismatch); }
.chip-review   { background: var(--review-bg);   color: var(--review); }
.chip-match    { background: var(--match-bg);    color: var(--match); }
.chip-quiet    { background: var(--surface-2);   color: var(--ink-3); }
.chip-confirmed { background: var(--match-bg);    color: var(--match); }
.chip-flagged   { background: var(--mismatch-bg); color: var(--mismatch); }

.empty { padding: 48px 16px; text-align: center; color: var(--ink-3); background: var(--surface); }

.back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 6px; font-size: 13.5px; color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--ink); text-decoration: underline; }
.back::before { content: "\2190"; margin-right: 6px; }

.case-head { margin-bottom: 8px; }
.case-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 0 0 14px; }
.print-btn { display: inline-flex; align-items: center; min-height: 44px; margin: 0; }
.case-csv-btn { display: inline-flex; align-items: center; min-height: 44px; margin: 0; }
.print-only { display: none; }
.case-head .ref { font-family: var(--mono); font-size: 13px; color: var(--marine); font-weight: 500; }
.case-head h1 { font-size: 21px; margin: 4px 0 8px; }
.case-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.case-meta span { font-family: var(--mono); font-size: 12px; }

.verdict {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--r); margin-bottom: 22px;
  border: 1px solid;
}
.verdict-mismatch { background: var(--mismatch-bg); border-color: #F0C3BF; }
.verdict-review   { background: var(--review-bg);   border-color: #D6CBEE; }
.verdict-match    { background: var(--match-bg);    border-color: #BEDDD3; }
.verdict-icon { font-family: var(--mono); font-weight: 600; font-size: 15px; line-height: 1.4; }
.verdict-mismatch .verdict-icon { color: var(--mismatch); }
.verdict-review   .verdict-icon { color: var(--review); }
.verdict-match    .verdict-icon { color: var(--match); }
.verdict-text { font-size: 14px; }
.verdict-text strong { display: block; margin-bottom: 2px; }

/* ── THE SEAM ──────────────────────────────────────────────────
   The signature element. Two documents that should be identical,
   set either side of a hairline. Matching rows keep the seam
   unbroken; a discrepancy breaks it and pushes the two halves
   apart, so you can scan the gutter instead of reading 7 rows. */
.seam-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; margin-bottom: 24px; }
.seam-head, .seam-row {
  display: grid;
  grid-template-columns: 148px 1fr 34px 1fr;
  align-items: stretch;
}
.seam-head {
  background: var(--surface-2); border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
}
.seam-head > * { padding: 9px 14px; }
.seam-head .h-si, .seam-head .h-bl { color: var(--ink-2); font-weight: 600; }

.seam-row { border-bottom: 1px solid var(--rule); position: relative; }
.seam-row:last-child { border-bottom: 0; }
.seam-row > * { padding: 11px 14px; }

.f-label { min-width: 0; font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.f-label-actions { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; min-width: 0; margin-top: 8px; }
.f-label-actions .chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.variance-hint { margin-top: 5px; color: var(--ink-2); font-size: 11px; font-weight: 500; line-height: 1.3; }
.f-val {
  font-family: var(--mono); font-size: 13px; line-height: 1.45;
  word-break: break-word; display: flex; align-items: center;
  transition: transform .18s cubic-bezier(.2,.7,.3,1);
}
.f-val.empty-val { color: var(--ink-3); font-style: italic; }

.seam { position: relative; padding: 0 !important; }
.seam::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; background: var(--rule-2); transform: translateX(-50%);
}

.seam-row[data-state="match"] .seam::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px;
  border-radius: 50%; background: var(--match);
}

.seam-row[data-state="mismatch"] { background: var(--mismatch-bg); }
.seam-row[data-state="mismatch"] .seam::before {
  background: linear-gradient(to bottom,
    var(--mismatch) 0 28%, transparent 28% 72%, var(--mismatch) 72% 100%);
  width: 2px;
}
.seam-row[data-state="mismatch"] .seam::after {
  content: "\2260"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--mismatch); background: var(--mismatch-bg); padding: 0 3px;
}
.seam-row[data-state="mismatch"] .f-si { transform: translateX(-4px); }
.seam-row[data-state="mismatch"] .f-bl { transform: translateX(4px); }
.seam-row[data-state="mismatch"] .f-val { color: var(--mismatch); font-weight: 500; }
.seam-row[data-state="mismatch"] .f-label { color: var(--mismatch); font-weight: 600; }

.seam-row[data-state="unknown"] { background: var(--review-bg); }
.seam-row[data-state="unknown"] .seam::before { background: repeating-linear-gradient(to bottom, var(--review) 0 3px, transparent 3px 7px); }
.seam-row[data-state="unknown"] .f-label { color: var(--review); font-weight: 600; }

/* Same weight, written in different units ("22 MT" vs "22,000 KG") — resolved,
   not a defect, but worth a glance: calm, and deliberately not the mismatch
   red. Grouped/ordered with ordinary matches (see seamTable in app.js); only
   this row styling and the "units differ" chip set it apart. */
.seam-row[data-state="converted"] { background: var(--converted-bg); }
.seam-row[data-state="converted"] .seam::before { background: var(--converted); }
.seam-row[data-state="converted"] .seam::after {
  content: "\2248"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--converted); background: var(--converted-bg); padding: 0 3px;
}
.seam-row[data-state="converted"] .f-label { color: var(--converted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { .f-val { transition: none; } }

.proof-btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.2;
  padding: 6px 12px; border-radius: 999px; min-height: 32px;
  display: inline-flex; align-items: center;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.proof-btn:hover { background: var(--marine); border-color: var(--marine); }
.proof-btn[aria-expanded="true"] { background: var(--marine); border-color: var(--marine); }
.proof-btn:disabled { opacity: .45; cursor: not-allowed; }
.proof {
  padding: 0 14px 12px 148px;
  background: var(--surface-2); border-top: 1px dashed var(--rule);
}
.proof-line {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 4px; margin-top: 10px;
  white-space: pre-wrap; word-break: break-word;
}
.proof-line b { color: var(--ink); font-weight: 600; }
.proof-src { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 4px; }

.reply-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.reply-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}
.reply-head h3 { font-size: 14px; }
.reply-note { font-size: 12px; color: var(--ink-3); }
.reply-body {
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  padding: 16px; white-space: pre-wrap; color: var(--ink);
  max-height: 340px; overflow: auto;
}
.reply-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--rule); flex-wrap: wrap; }

.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: var(--r); cursor: pointer;
  border: 1px solid transparent; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1c2836; }
.btn-hint { font-size: 12.5px; color: var(--ink-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 16px;
}
.stat-n { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.stat-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 6px; }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.panel h3 { font-size: 15px; margin-bottom: 3px; }
.panel .sub { font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px; }
.panel-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.bar-row { display: grid; grid-template-columns: 152px 1fr 44px; gap: 12px; align-items: center; margin-bottom: 7px; }
.bar-label { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.bar-val { font-family: var(--mono); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }

.note {
  font-size: 13px; color: var(--ink-2); background: var(--surface-2);
  border-left: 2px solid var(--rule-2); padding: 12px 16px;
  border-radius: 0 var(--r) var(--r) 0; margin-top: 8px;
}
.note b { color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
  background: var(--ink); color: #fff; padding: 11px 20px;
  border-radius: var(--r); font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  box-shadow: var(--shadow); z-index: 50;
  display: flex; align-items: center; gap: 4px; max-width: calc(100vw - 32px);
}
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-has-action[data-show="true"] { pointer-events: auto; }

.toast-action {
  margin-left: 10px; padding: 4px 11px; font-size: 12.5px; font-weight: 600;
  color: #fff; background: transparent; border: 1px solid rgba(255, 255, 255, .45);
  border-radius: calc(var(--r) - 2px); cursor: pointer; white-space: nowrap;
}
.toast-action:hover { background: rgba(255, 255, 255, .15); }

@media (max-width: 860px) {
  main { padding: 22px 16px 72px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .brand-sub { display: none; }
  .tabs { grid-template-columns: 1fr 1fr; }
  .case { grid-template-columns: 1fr; gap: 6px; }
  .case-fields { justify-content: flex-start; }
  .seam-head { display: none; }
  .seam-row { grid-template-columns: 1fr; }
  .seam { display: none; }
  .seam-row > * { padding: 8px 14px; }
  .seam-row[data-state="mismatch"] .f-si,
  .seam-row[data-state="mismatch"] .f-bl { transform: none; }
  .f-si::before { content: "SI "; font-size: 10px; color: var(--ink-3); margin-right: 6px; }
  .f-bl::before { content: "BL "; font-size: 10px; color: var(--ink-3); margin-right: 6px; }
  .proof { padding-left: 14px; }
  .panel-2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 38px; }
}

/* ── mail + re-check additions ─────────────────────────────── */
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--rule-2); }
.btn-quiet:hover { background: var(--surface-2); }
.reply-past { border-top: 1px solid var(--rule); }
.reply-past summary { padding: 10px 16px; font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.reply-past .reply-body { color: var(--ink-2); padding-top: 0; }

.recheck { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 24px; overflow: hidden; }
.recheck-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.recheck-head h3 { font-size: 14px; }
.recheck-group { padding: 10px 16px 12px; border-bottom: 1px solid var(--rule); }
.recheck-group:last-child { border-bottom: 0; }
.recheck-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; font-weight: 600; }
.recheck-row { display: grid; grid-template-columns: 148px 1fr auto; gap: 12px; align-items: baseline; padding: 3px 0; }
.recheck-field { font-size: 13px; }
.recheck-val { font-family: var(--mono); font-size: 12.5px; }
.recheck-si { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.tone-mismatch { background: var(--mismatch-bg); }
.tone-mismatch .recheck-label, .tone-mismatch .recheck-field { color: var(--mismatch); }
.tone-review .recheck-label { color: var(--review); }
.tone-match .recheck-label { color: var(--match); }
.tone-quiet .recheck-label, .tone-quiet .recheck-val { color: var(--ink-3); }
@media (max-width: 860px) { .recheck-row { grid-template-columns: 1fr; gap: 2px; } }

/* ── Check a pair ──────────────────────────────────────────── */
.check-form { max-width: 720px; }

.drop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }

.drop-zone {
  position: relative; background: var(--surface); border: 1px dashed var(--rule-2);
  border-radius: var(--r); transition: border-color .12s, background-color .12s;
}
.drop-zone[data-drag="true"] { border-color: var(--marine); background: var(--surface-2); }
.drop-zone[data-filled="true"] { border-style: solid; border-color: var(--rule-2); }
.drop-label {
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 16px; cursor: pointer; text-align: center; align-items: center;
}
.drop-title { font-weight: 600; font-size: 14px; }
.drop-hint { font-size: 12px; color: var(--ink-3); }
.drop-filename {
  font-family: var(--mono); font-size: 12.5px; color: var(--marine);
  min-height: 1em; word-break: break-all;
}
.drop-zone:focus-within { outline: 2px solid var(--marine); outline-offset: 2px; border-radius: var(--r); }

/* Visually hidden but still focusable/clickable via its <label for>, so
   keyboard tab + Enter/Space and a plain click both work natively. */
.drop-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.email-details { margin-bottom: 18px; }
.email-details summary {
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  padding: 8px 0;
}
.email-details summary:hover { color: var(--ink); }
.email-fields { display: flex; flex-direction: column; gap: 12px; padding: 10px 0 4px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field-input {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--rule-2); border-radius: var(--r);
  background: var(--surface); resize: vertical; min-height: 44px;
}
.field-input:focus-visible { outline: 2px solid var(--marine); outline-offset: 1px; }

.check-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.link-btn {
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  background: none; border: 0; padding: 2px 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--ink); }

.sample-choice { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.sample-choice[hidden] { display: none; }

.check-result { margin-top: 28px; }
.check-meta {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  margin-bottom: 10px;
}

.check-error {
  background: var(--surface); border: 1px solid var(--rule-2); border-left: 3px solid var(--mismatch);
  border-radius: var(--r); padding: 14px 16px;
}
.check-error strong { display: block; margin-bottom: 4px; color: var(--ink); }
.check-error p { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-2); }
.check-error code {
  display: inline-block; font-family: var(--mono); font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 4px;
  padding: 4px 8px;
}

@media (prefers-reduced-motion: reduce) { .drop-zone { transition: none; } }

@media (max-width: 860px) {
  .drop-grid { grid-template-columns: 1fr; }
}

/* ── #/account: create-account / sign-in form ──────────────────── */
.account-reassure { font-size: 12.5px; color: var(--ink-2); margin: 8px 0 0; max-width: 50ch; }
.account-form { max-width: 420px; display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap .field-input { flex: 1 1 auto; padding-right: 62px; }
.password-toggle {
  position: absolute; right: 10px; min-height: 44px; min-width: 44px; padding: 2px 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.account-error {
  font-size: 13px; color: var(--mismatch); background: var(--mismatch-bg);
  border: 1px solid #F0C3BF; border-radius: var(--r); padding: 10px 12px;
}
.account-error[hidden] { display: none; }
.account-switch { margin: 2px 0 0; }
.account-switch .link-btn { padding: 0; min-height: 44px; display: inline-flex; align-items: center; }
.account-form .check-actions .btn { min-height: 44px; }

/* ── Add mail: "Drop .eml files" / "Paste an email" tabs ───────── */
.addmail { margin-bottom: 18px; }
.addmail[hidden] { display: none; }
.addmail-tabs {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r);
}
.switch-btn[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.addmail-section[hidden] { display: none; }
.paste-form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.paste-files-input { padding: 8px 11px; }

/* ── Your mail / Sample / Uploaded source switch ─────────────── */
.source-switch {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--r); margin-bottom: 20px; max-width: 100%;
}
.switch-btn {
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--ink-2); background: none; border: 0; cursor: pointer;
  padding: 9px 14px; min-height: 40px; border-radius: 5px;
  /* The uploaded dataset's own name is attacker-chosen (a zip filename) and
     unbounded in length — clip it rather than let one long name force the
     whole switch, or the page, to scroll sideways. */
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.switch-btn:hover { color: var(--ink); }
.switch-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

@media (max-width: 520px) {
  /* Wrap rather than force three buttons into equal thirds — a long
     "Uploaded: <name> (N)" label would otherwise squeeze the others
     unreadably narrow or push the row past the viewport. */
  .source-switch { display: flex; width: 100%; }
  .switch-btn { flex: 1 1 auto; min-width: 30%; padding: 9px 8px; font-size: 12.5px; }
}

/* ── Your mail: empty state ────────────────────────────────── */
.drop-zone-large { padding: 8px; }
.drop-zone-large .drop-label { padding: 48px 20px; }
.drop-zone-large .drop-title { font-size: 18px; }
.drop-zone-large .drop-hint { text-decoration: underline; text-underline-offset: 2px; }
.mine-howto { font-size: 12px; color: var(--ink-3); margin: 12px 0 0; max-width: 46ch; }
.mine-privacy { font-size: 12.5px; color: var(--ink-2); margin: 0 0 18px; max-width: 50ch; }
.mine-privacy[hidden] { display: none; }
.mine-privacy .link-btn { margin-left: 2px; }
.mine-empty-actions {
  display: flex; justify-content: flex-start; gap: 20px; margin: 0 0 22px; flex-wrap: wrap;
}
.mine-empty-actions[hidden] { display: none; }
.mine-empty-actions .link-btn { display: inline-flex; align-items: center; min-height: 44px; }

/* ── Your mail: populated state toolbar ────────────────────── */
.board-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.board-toolbar .search-field { margin-bottom: 0; flex: 1; min-width: 220px; }
.mine-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mine-actions[hidden] { display: none; }
.mine-actions .btn { min-height: 44px; }
.mine-actions .link-btn { display: inline-flex; align-items: center; min-height: 44px; }

/* ── Export menu ────────────────────────────────────────────── */
.export-wrap { position: relative; }
.export-wrap .btn { min-height: 44px; }
.export-menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: var(--shadow); min-width: 230px; padding: 6px;
}
.export-menu[hidden] { display: none; }
/* The button sits at the right of the toolbar on wide screens: open the
   menu leftwards there so it never runs off the page. Phones keep left:0. */
@media (min-width: 641px) { .export-menu { left: auto; right: 0; } }
.export-menu-item {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 13.5px;
  color: var(--ink); background: none; border: 0; border-radius: 4px; padding: 10px;
  min-height: 44px; cursor: pointer;
}
.export-menu-item:hover { background: var(--surface-2); }

#view-board.drag-over #board-normal,
#view-board.drag-over #addmail-panel { outline: 2px dashed var(--marine); outline-offset: 6px; border-radius: var(--r); }

/* ── Upload flow ────────────────────────────────────────────── */
.upload-panel { margin-bottom: 16px; }
.upload-progress {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px;
}
.upload-errors {
  background: var(--surface); border: 1px solid var(--rule-2); border-left: 3px solid var(--mismatch);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px;
}
.upload-errors-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.upload-error-row { font-size: 12.5px; color: var(--ink-2); padding: 3px 0; }
.upload-error-row b { color: var(--ink); font-weight: 600; }

.document-chooser {
  background: var(--surface); border: 1px solid var(--rule-2); border-left: 3px solid var(--review);
  border-radius: var(--r); padding: 18px; box-shadow: var(--shadow);
}
.document-chooser-badge {
  display: inline-block; margin-bottom: 8px; padding: 4px 8px; border-radius: 999px;
  background: var(--review-bg); color: var(--review); font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.document-chooser h3 { margin: 0 0 6px; font-size: 18px; }
.document-chooser-help { margin: 0 0 16px; color: var(--ink-2); font-size: 13.5px; }
.document-choice-group { border: 0; padding: 0; margin: 0 0 14px; }
.document-choice-group legend { margin-bottom: 7px; font-weight: 600; font-size: 13px; color: var(--ink); }
.document-choice {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 9px 10px;
  border: 1px solid var(--rule); border-radius: var(--r); cursor: pointer;
}
.document-choice + .document-choice { margin-top: 6px; }
.document-choice:hover { background: var(--surface-2); }
.document-choice input { margin-top: 3px; accent-color: var(--marine); }
.document-choice-copy { display: grid; gap: 2px; min-width: 0; }
.document-choice-copy strong { overflow-wrap: anywhere; font-size: 13.5px; }
.document-choice-copy small { color: var(--ink-3); font-family: var(--mono); font-size: 10.5px; }
.document-chooser-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.dataset-upload-summary {
  font-size: 13.5px; font-weight: 500; color: var(--match);
  background: var(--match-bg); border: 1px solid var(--match);
  border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px;
}

/* ── Uploaded case tag + original email (case review) ──────── */
.uploaded-tag { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.uploaded-received { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.skipped-note { font-size: 12.5px; color: var(--ink-3); margin: 4px 0 10px; }

.orig-email {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  margin: 10px 0 22px; overflow: hidden;
}
.orig-email summary {
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  padding: 12px 16px; min-height: 44px; display: flex; align-items: center;
  background: var(--surface-2); list-style: none;
}
.orig-email summary::-webkit-details-marker { display: none; }
.orig-email summary::after {
  content: "\25B8"; margin-left: auto; color: var(--ink-3); font-size: 12px;
  transition: transform .15s;
}
.orig-email[open] summary::after { transform: rotate(90deg); }
.orig-email summary:hover { color: var(--ink); }
.orig-email[open] summary { border-bottom: 1px solid var(--rule); }
.orig-body { padding: 14px 16px; }
.orig-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.orig-meta-line b { color: var(--ink); font-weight: 600; margin-right: 3px; }
.orig-text {
  font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
}
.orig-attachments { font-size: 12.5px; color: var(--ink-3); margin-top: 12px; }

@media (max-width: 860px) {
  .board-toolbar { align-items: stretch; }
  .mine-actions { justify-content: space-between; }
}

/* ── held-out comparison ───────────────────────────────────── */
.cmp { border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.cmp-row { display: grid; grid-template-columns: 1fr 130px 130px; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--rule); align-items: baseline; }
.cmp-row:last-child { border-bottom: 0; }
.cmp-head { background: var(--surface-2); font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cmp-l { font-size: 13px; color: var(--ink-2); }
.cmp-v { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.cmp-good { color: var(--match); font-weight: 600; }
.cmp-facts { font-size: 12.5px; color: var(--ink-2); margin-top: 12px; }
@media (max-width: 860px) { .cmp-row { grid-template-columns: 1fr 80px 80px; } }

/* ── phone top bar ─────────────────────────────────────────────
   Below 640px the topbar becomes two rows instead of squeezing (and
   eventually hiding) nav links into one: row one is the brand and the
   account control, row two is all four nav links sharing the width evenly.
   Nothing is ever hidden — every page stays one tap away on every phone. */
@media (max-width: 860px) {
  .nav { gap: 2px; }
  .nav-link { padding: 7px 9px; font-size: 13.5px; white-space: nowrap; }
}
@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px 0;
    gap: 0;
  }
  .brand { order: 1; }
  .account { order: 2; margin-left: auto; padding-left: 12px; }
  .nav {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    margin: 10px 0 0;
    gap: 0;
    border-top: 1px solid var(--rule);
  }
  .nav-link {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
    min-height: 44px;
    padding: 8px 4px;
    border-radius: 0;
    white-space: normal;
    line-height: 1.2;
  }
}
@media (max-width: 420px) {
  .brand-name { font-size: 16px; }
  .mark { display: none; }
}
@media (max-width: 380px) {
  .nav-link { font-size: 12px; padding: 8px 2px; }
  .account-email-btn { max-width: 56px; }
}

/* ── print ──────────────────────────────────────────────────────
   Only the view on screen prints: the case review or the Check-a-pair
   result. Chrome, controls and every button disappear; the seam table,
   verdict and reply text stay, with the print-only header filled in by
   the "Print / save as PDF" button right before window.print(). */
@media print {
  @page { margin: 14mm; }

  html, body { background: #fff; }
  body { color: #000; }

  .topbar, .skip, .nav, .back, .tabs, .search-field, #toast, .account,
  #check-form, button, .btn, .link-btn, .proof-btn, .done-bar,
  .export-wrap, .case-actions, .review-flag-form,
  #view-home, #view-board, #view-account { display: none !important; }

  .reply-textarea {
    border: 0 !important; resize: none !important; overflow: visible !important;
    background: transparent !important; color: #000 !important; padding: 16px !important;
  }

  .print-only { display: block; margin-bottom: 18px; }
  .print-only .print-title { font-weight: 800; font-size: 15px; }
  .print-only .print-ref { font-family: var(--mono); font-size: 12px; margin-top: 3px; }
  .print-only .print-time { font-family: var(--mono); font-size: 11px; color: #333; margin-top: 2px; }

  main { max-width: none; margin: 0; padding: 0; }

  .verdict, .seam-row, .reply-card, .recheck, .verdict-text {
    break-inside: avoid;
    box-shadow: none !important;
  }

  .verdict, .chip {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .seam-wrap, .reply-card, .recheck, .panel, .stat, .cmp, .case-list {
    box-shadow: none !important;
    border-color: #999 !important;
  }
}

/* ── Editable reply + Open in Gmail ────────────────────────── */
.reply-head { flex-direction: column; align-items: flex-start; gap: 6px; }
.reply-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reply-reset-btn { padding: 0; min-height: auto; }
.reply-textarea {
  display: block; width: 100%; box-sizing: border-box;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  padding: 16px; color: var(--ink); background: var(--surface);
  border: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  resize: none; overflow-y: hidden; min-height: 80px;
}
.reply-textarea:focus-visible { outline: 2px solid var(--marine); outline-offset: -2px; }

/* ── Done — next case ───────────────────────────────────────── */
/* Pinned to the bottom of the viewport on the case page, so it is reachable
   without scrolling past a long reply box (the whole reason it can be a
   long way down the page). Sticky, not fixed — once the page finishes
   scrolling it settles back into the normal flow, so it never floats over
   content that comes after it. safe-area-inset-bottom keeps the buttons
   clear of a phone's home-bar. */
.done-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 20px; margin-top: 24px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 -4px 14px rgba(13, 21, 32, .06);
}
.done-bar-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.done-bar-actions .link-btn { display: inline-flex; align-items: center; min-height: 44px; }
.done-bar-pos { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.done-bar-hint { display: none; font-size: 12px; color: var(--ink-3); }
@media (min-width: 861px) { .done-bar-hint { display: inline; } }

/* The case page's own bottom padding, so the sticky bar above never
   permanently covers the last real content once the page is scrolled all
   the way down. */
#view-review { padding-bottom: 24px; }

/* A toast fixed at its usual 28px offset would sit underneath (or behind)
   the sticky review bar on the case page — lift it clear whenever that bar
   is on screen. The bar is taller on narrow phones (buttons stack in a
   column, see the 520px rule below), so it needs more clearance there. */
body:has(.done-bar) .toast {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 520px) {
  body:has(.done-bar) .toast {
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  }
}

.chip-done { background: var(--surface-2); color: var(--ink-3); }
.case.case-done { opacity: .6; }

/* Phones: the bar is sticky, so every pixel of it hides the field table.
   Primary button on its own full-width row, the other actions as small
   links on one row under it, and no "Case k of N" line. */
@media (max-width: 520px) {
  .done-bar {
    flex-direction: column; align-items: stretch; gap: 4px;
    margin-top: 16px; padding: 8px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .done-bar-actions { justify-content: space-between; gap: 4px 12px; }
  .done-bar-actions .btn-primary { flex: 1 1 100%; justify-content: center; }
  .done-bar-actions .link-btn { min-height: 44px; min-width: 44px; padding: 0 8px; justify-content: center; font-size: 13px; }
  .done-bar-pos { display: none; }
}

/* ── Review status + "Something's wrong" flag form ─────────────── */
.review-status { font-size: 13.5px; color: var(--ink); }
.review-status-note { color: var(--ink-2); }
.review-flag-form {
  flex: 1 1 100%; display: flex; flex-direction: column; gap: 10px;
  margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.review-flag-form[hidden] { display: none; }
.review-flag-textarea { width: 100%; box-sizing: border-box; min-height: 72px; }
.review-flag-form .btn { align-self: flex-start; }

/* ── "ClearDraft did / Your part" panel ─────────────────────────── */
.your-part-panel {
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 12px 16px; margin: 0 0 22px; font-size: 13px; color: var(--ink-2);
  display: flex; flex-direction: column; gap: 4px;
}
.your-part-did { color: var(--ink-2); }
.your-part-yours { color: var(--ink); font-weight: 500; }

/* ── "To the order of" note ──────────────────────────────────────── */
.order-note { margin: -14px 0 24px; }

/* ── Accuracy: your reviews panel ────────────────────────────────── */
.reviews-agreement { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.reviews-flagged-list { margin: 12px 0 0; padding-left: 18px; }
.reviews-flagged-list li { font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
.reviews-flagged-list a { color: var(--marine); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* ── Triage banner (inbox board) ──────────────────────────────────
   The first thing a clerk sees on the board: where to start, and how
   close the queue is to done. Two states — work left, or every
   discrepancy/needs-a-human case handled — never told apart by colour
   alone, since both carry their own text. */
.triage {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px; margin: 0 0 16px;
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r);
}
.triage[hidden] { display: none; }
.triage-headline { font-size: 14.5px; color: var(--ink); }
.triage-headline strong { font-variant-numeric: tabular-nums; }
.triage-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.triage-start-btn { flex: none; }
.triage-progress-wrap { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; min-width: 180px; }
.triage-progress { flex: 1 1 auto; min-width: 100px; height: 8px; accent-color: var(--marine); }
.triage-progress-label {
  font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.triage-clear {
  background: var(--match-bg); border-color: #BEDDD3;
}
.triage-clear .triage-headline { color: var(--match); font-weight: 600; }
.triage-done-note { font-size: 13px; color: var(--ink-2); }

@media (max-width: 520px) {
  .triage-row { flex-direction: column; align-items: stretch; }
  /* flex: none - in a column, the desktop 200px flex-basis becomes a 200px
     HEIGHT and leaves a tall empty gap around the bar. */
  .triage-progress-wrap { min-width: 0; flex: none; }
}

/* "k left" under a tab's count — only present once that tab has at least
   one reviewed row, so the tab bar never repeats a number back at itself. */
.tab-left {
  display: block; font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

/* ── Learned equivalences ──────────────────────────────────────── */
/* "Mark as same" button on a mismatch row: same solid-pill style as
   .proof-btn, so a seven-row table doesn't grow a second visual style. */
.mark-same-btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.2;
  padding: 6px 12px; border-radius: 999px; min-height: 32px;
  display: inline-flex; align-items: center;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.mark-same-btn:hover { background: var(--marine); border-color: var(--marine); }
.mark-same-btn[aria-expanded="true"] { background: var(--marine); border-color: var(--marine); }
.mark-same-btn:disabled { opacity: .45; cursor: not-allowed; }

.mark-same-confirm {
  padding: 12px 14px; background: var(--surface-2); border-top: 1px dashed var(--rule);
}
.mark-same-prompt { font-size: 13px; color: var(--ink); margin-bottom: 10px; }
.mark-same-prompt b { font-family: var(--mono); }
.mark-same-scope { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; max-width: 60ch; }
.mark-same-reason-label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.mark-same-reason { width: 100%; box-sizing: border-box; resize: vertical; margin-bottom: 4px; }
.mark-same-reason-counter { font-size: 11px; color: var(--ink-3); margin-bottom: 10px; }
.mark-same-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mark-same-actions .btn { min-height: 38px; padding: 7px 16px; }
.mark-same-error { margin-bottom: 10px; }
.mark-same-saved-note { margin-top: 0; }

.learned-chip-wrap { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; }
.learned-chip { display: inline-block; }
.learned-undo-btn {
  font-size: 11px; padding: 0; min-height: 0; color: var(--ink-3);
  text-decoration: underline; text-underline-offset: 2px;
}
.learned-undo-btn:hover { color: var(--ink); }

/* ── seamTable: the "Marked as same" group ───────────────────────
   Own tone (marine), not mismatch/match/review — a marked row is neither
   a live defect nor a genuine match, it is a clerk's judgement call. */
.seam-group-label {
  padding: 8px 14px; font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--marked); background: var(--marked-bg);
  border-bottom: 1px solid var(--rule); border-top: 1px solid var(--rule);
}
.seam-row[data-state="covered"] { background: var(--marked-bg); }
.seam-row[data-state="covered"] .seam::before { background: var(--marked); }
.seam-row[data-state="covered"] .seam::after { content: "="; color: var(--marked); }
.seam-row[data-state="covered"] .f-label { color: var(--marked); font-weight: 600; }
.marked-same-panel { padding: 0 14px 12px; background: var(--marked-bg); border-bottom: 1px solid var(--rule); }
.marked-same-label { font-size: 12.5px; color: var(--ink-2); }
.marked-same-line a { color: var(--marked); }
.marked-same-reason { margin-top: 3px; font-style: italic; color: var(--ink-2); }
.marked-same-reason a { font-style: normal; }
.marked-same-actions { margin-top: 6px; display: flex; gap: 14px; }

.verdict-live-sub { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 400; }
.recheck-marked-chip, .chip-marked-same { margin-left: 8px; }
.reply-redrafted-chip { background: var(--marked-bg); color: var(--marked); }

/* ── #/learned — the management page ─────────────────────────────── */
.learned-usage { font-size: 13px; color: var(--ink-3); margin: 4px 0 16px; }
.learned-toolbar { margin-bottom: 10px; }
.learned-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.learned-chip-btn { border: 1px solid var(--rule-2); cursor: pointer; font-family: inherit; }
.learned-chip-btn[aria-pressed="true"] { background: var(--marked-bg); color: var(--marked); border-color: var(--marked); }
.learned-list { display: flex; flex-direction: column; gap: 0; }
.learned-row {
  padding: 14px 4px; border-bottom: 1px solid var(--rule); font-size: 13px;
}
.learned-row:last-child { border-bottom: 0; }
.learned-row-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.learned-field-chip { text-transform: capitalize; }
.learned-wordings { font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }
.learned-pair-arrow { color: var(--ink-3); margin: 0 6px; }
.learned-matches-as { margin-top: 4px; font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); overflow-wrap: anywhere; }
.learned-reason { margin-top: 6px; font-style: italic; color: var(--ink-2); }
.learned-meta { margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }
.learned-meta a { color: var(--ink-2); }
.learned-actions { margin-top: 8px; display: flex; gap: 16px; }
.learned-removed-line { color: var(--ink-3); font-size: 13px; }
/* display is set only via :not([hidden]) - an unconditional `display: flex`
   here would beat the UA [hidden] rule (author styles always win, whatever
   the specificity) and leave every row's edit form visibly open, the same
   trap the mark-as-same panel's own actions/buttons were built to avoid. */
.learned-edit-form[hidden] { display: none; }
.learned-edit-form:not([hidden]) { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: var(--r); }
.learned-edit-actions { display: flex; gap: 12px; align-items: center; }

@media (max-width: 620px) {
  .learned-row-head { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ── Fix a value ──────────────────────────────────────────────────
   "Fix value" button: same solid-pill style as .mark-same-btn/.proof-btn,
   so a seven-row table doesn't grow a fourth button style. Offered on any
   mismatched or unreadable field — unlike "Mark as same" it is never
   limited to the five learnable text fields, so its hover/open colour is
   the calm teal already used for "resolved, but worth a glance" rows
   (--converted), not the marine used for a learned pair. */
.fix-value-btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.2;
  padding: 6px 12px; border-radius: 999px; min-height: 32px;
  display: inline-flex; align-items: center;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.fix-value-btn:hover { background: var(--converted); border-color: var(--converted); }
.fix-value-btn[aria-expanded="true"] { background: var(--converted); border-color: var(--converted); }
.fix-value-btn:disabled { opacity: .45; cursor: not-allowed; }

.fix-value-panel {
  padding: 12px 14px; background: var(--surface-2); border-top: 1px dashed var(--rule);
}

/* The two explicitly-chosen modes — "misread" vs "amend" — as a small
   toggle group, plain words, never inferred from what gets typed below. */
.fix-value-mode-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.fix-value-mode-btn {
  font-family: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 8px 12px; border-radius: var(--r); cursor: pointer; text-align: left;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--rule-2);
  min-height: 44px;
}
.fix-value-mode-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.fix-value-mode-btn:hover:not([aria-pressed="true"]) { border-color: var(--ink-3); color: var(--ink); }

.fix-value-hint { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; max-width: 60ch; }
.fix-value-panel .field-label { margin-top: 8px; }
.fix-value-panel .field-label:first-of-type { margin-top: 0; }
.fix-value-input { width: 100%; box-sizing: border-box; margin-bottom: 2px; }
.fix-value-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.fix-value-actions .btn { min-height: 38px; padding: 7px 16px; }
.fix-value-error { margin-top: 10px; }

/* iOS Safari zooms the whole page on focusing any input under 16px — this
   keeps the corrected-value textareas at the platform's own no-zoom
   threshold on a phone, without changing their look on desktop. */
@media (max-width: 620px) {
  .fix-value-input { font-size: 16px; }
}

/* Own tone (teal), distinct from "Marked as same" (marine) and an ordinary
   match (green) — a fixed row is a clerk's correction, not the pipeline's
   own clean read. */
.seam-group-fixed {
  color: var(--converted); background: var(--converted-bg);
}
.seam-row[data-state="fixed"] { background: var(--converted-bg); }
.seam-row[data-state="fixed"] .seam::before { background: var(--converted); }
.seam-row[data-state="fixed"] .seam::after { content: "\2713"; color: var(--converted); }
.seam-row[data-state="fixed"] .f-label { color: var(--converted); font-weight: 600; }

.fix-value-audit {
  padding: 0 14px 12px; background: var(--converted-bg); border-bottom: 1px solid var(--rule);
  font-size: 12.5px; color: var(--ink-2);
}
.fix-value-audit .link-btn { margin-top: 6px; display: inline-flex; align-items: center; min-height: 44px; }

/* ── "Try to fool it" — Check a pair, mode 2 ─────────────────────────
   Mobile-first: one column by default (label, then SI input, then BL
   input, then chip + reason, all stacked; tap targets ≥44px; inputs at
   16px on phones so iOS Safari never zooms on focus). A two-column SI/BL
   layout only kicks in from 620px, same breakpoint the rest of this file
   already uses for "does this need a phone or a desktop layout". */
.check-mode-switch { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.check-mode-btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; min-height: 44px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--rule-2);
}
.check-mode-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.check-mode-btn:hover:not([aria-pressed="true"]) { border-color: var(--ink-3); color: var(--ink); }

.check-type-panel { max-width: 720px; }
.fool-lede { margin-top: 0; margin-bottom: 16px; font-size: 13.5px; color: var(--ink-2); }

.fool-tricks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fool-trick-btn {
  font-family: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 8px 12px; min-height: 44px; border-radius: var(--r); cursor: pointer;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--rule-2);
}
.fool-trick-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.fool-reset-btn { background: var(--surface); }

.fool-verdict {
  padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--rule);
  background: var(--surface-2); font-size: 14px; font-weight: 600; margin-bottom: 18px;
}
.fool-verdict[data-kind="mismatch"] { background: var(--mismatch-bg); border-color: #F0C3BF; color: var(--mismatch); }
.fool-verdict[data-kind="review"]   { background: var(--review-bg);   border-color: #D6CBEE; color: var(--review); }
.fool-verdict[data-kind="match"]    { background: var(--match-bg);    border-color: #BEDDD3; color: var(--match); }

.fool-rows { display: flex; flex-direction: column; gap: 12px; }
.fool-row {
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface);
  padding: 12px 14px;
}
.fool-row[data-state="mismatch"] { background: var(--mismatch-bg); border-color: #F0C3BF; }
.fool-row[data-state="unknown"]  { background: var(--review-bg);   border-color: #D6CBEE; }
.fool-row-label { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.fool-row-inputs { display: flex; flex-direction: column; gap: 8px; }
.fool-input-wrap { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.fool-input-tag { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.fool-input { width: 100%; box-sizing: border-box; min-height: 44px; }
.fool-row-result { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.fool-reason { font-size: 12.5px; color: var(--ink-2); }

@media (min-width: 620px) {
  .fool-row-inputs { flex-direction: row; gap: 12px; }
}

/* iOS Safari zooms the whole page on focusing any input under 16px. */
@media (max-width: 620px) {
  .fool-input { font-size: 16px; }
}

/* ── "Why this verdict?" — case page, collapsible plain-language trace ──
   Closed by default (a bare <details>, no JS needed to toggle); the
   numbered steps read only what is already in the case detail. */
.why-panel {
  margin: 14px 0 24px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); padding: 2px 14px;
}
.why-panel summary {
  cursor: pointer; padding: 10px 0; min-height: 44px; display: flex; align-items: center;
  font-weight: 600; font-size: 13.5px; list-style: none; color: var(--ink);
}
.why-panel summary::-webkit-details-marker { display: none; }
.why-panel summary::before {
  content: "▸"; display: inline-block; margin-right: 8px; color: var(--ink-3);
  transition: transform .1s;
}
.why-panel[open] summary::before { transform: rotate(90deg); }
.why-steps { margin: 0 0 14px; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.why-steps li { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.why-steps b { color: var(--ink); }
