:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1a2332;
  --ink-soft: #5a6b82;
  --line: #e3e8ef;
  --accent: #0b6e99;
  --accent-soft: #e3f1f8;
  --good: #1a7f4e;
  --good-soft: #e4f5ec;
  --warn: #9a6700;
  --warn-soft: #fff3d6;
  --bad: #b3382c;
  --bad-soft: #fdeae7;
  --ref: #6941c6;
  --ref-soft: #f0ebfb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .09);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: .5px;
  border-radius: 8px; padding: 8px 10px; font-size: 15px;
}
h1 { font-size: 17px; margin: 0; }
.sub { margin: 0; color: var(--ink-soft); font-size: 12px; }
.actor-chip {
  background: var(--accent-soft); color: var(--accent); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; cursor: pointer; font-size: 13px;
}
nav#tabs {
  display: flex; gap: 4px; padding: 8px 20px 0; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
  /* not overflow:auto — it would clip the dropdown menus */
}
nav#tabs button {
  border: none; background: none; padding: 10px 14px 12px; font-size: 14px;
  color: var(--ink-soft); cursor: pointer; border-bottom: 2.5px solid transparent;
  font-weight: 600; white-space: nowrap;
}
nav#tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
nav#tabs button:hover { color: var(--ink); }
nav#tabs .spacer { flex: 1; }

/* grouped nav: eleven flat tabs was a list, not a menu */
.navgroup { position: relative; }
.navtop .caret { font-size: 10px; opacity: .7; margin-left: 2px; }
.navgroup.open .navtop { color: var(--ink); }
.navmenu {
  position: absolute; top: 100%; left: 4px; z-index: 40; min-width: 250px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .14); padding: 6px; margin-top: -1px;
}
.navmenu button {
  display: block; width: 100%; text-align: left; border-radius: 7px;
  padding: 8px 10px !important; border-bottom: none !important;
}
.navmenu button em {
  display: block; font-style: normal; font-weight: 400; font-size: 11.5px;
  color: var(--ink-soft); margin-top: 1px;
}
.navmenu button:hover { background: var(--accent-soft); }
.navmenu button.active { background: var(--accent-soft); color: var(--accent); }
.pill {
  background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px;
  padding: 1px 7px; margin-left: 4px; font-weight: 700;
}
.pill:empty { display: none; }
main { padding: 20px 24px 80px; max-width: 1280px; margin: 0 auto; }

/* ---- generic bits ---- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1 1 220px; }
h2 { font-size: 15px; margin: 4px 0 10px; }
h3 { font-size: 13.5px; margin: 0 0 8px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }
/* Anchors carry .btn too — every download on the Data tab is one. Scoping
   these to `button` left them rendering as bare blue links. */
.btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 13px; font-size: 13.5px; cursor: pointer; font-weight: 600; color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.subtle { border: none; background: none; color: var(--ink-soft); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
input[type=text], input[type=search], select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 14px;
  background: #fff; color: var(--ink); outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; color: var(--ink-soft); font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.tag {
  display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 11.5px;
  font-weight: 700; letter-spacing: .2px;
}
.tag.ref { background: var(--ref-soft); color: var(--ref); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.neutral { background: var(--accent-soft); color: var(--accent); }
.count-badge { font-weight: 700; color: var(--accent); }

/* ---- dashboard ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 750; letter-spacing: -.5px; }
.stat .lbl { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; margin-top: 8px; }
.bar > i { display: block; height: 100%; }
/* charts */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; min-width: 480px; height: auto; display: block; }
.chart [data-tip] { cursor: crosshair; }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none; font-size: 12px; line-height: 1.5;
  background: var(--ink); color: #fff; padding: 7px 10px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .22); max-width: 260px;
}
.chart-tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.chart-title {
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  letter-spacing: .02em; margin-bottom: 2px;
}
.chart-table { margin-top: 6px; }
.chart-table > summary {
  cursor: pointer; font-size: 12px; color: var(--ink-soft); padding: 4px 0;
  list-style: none; width: fit-content;
}
.chart-table > summary::before { content: "▸ "; }
.chart-table[open] > summary::before { content: "▾ "; }
.chart-table > summary:hover { color: var(--accent); }
.chart-table table { margin-top: 4px; font-size: 12px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---- review ---- */
.review-head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: none; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--ink-soft); font-size: 13.5px; }
.seg button.active { background: var(--accent); color: #fff; }
.review-card { display: flex; gap: 20px; }
.review-card .left { flex: 1 1 300px; min-width: 260px; }
.review-card .right { flex: 1.4 1 420px; }
.value-title { font-size: 19px; font-weight: 750; letter-spacing: -.3px; overflow-wrap: anywhere; }
.value-meta { color: var(--ink-soft); font-size: 12.5px; margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }
.samples { margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.samples div { padding: 2px 0; overflow-wrap: anywhere; }
.sugg-list {
  max-height: 336px;           /* ~5.5 suggestions visible, rest scroll */
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}
.sugg {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 9px 12px; margin-bottom: 7px; cursor: pointer; font-size: 14px;
}
.sugg:hover { border-color: var(--accent); background: var(--accent-soft); }
/* a standard created a moment ago, folded into a card already on screen —
   it has to be findable without re-reading the whole list */
.sugg.fresh { border-color: var(--good); background: var(--good-soft); }
.tag.new { background: var(--good-soft); color: var(--good); }
.sugg .key {
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  font-size: 11px; padding: 1px 6px; color: var(--ink-soft); font-weight: 700;
}
/* match confidence reads the same wherever it appears — suggestion list,
   group picker, anywhere else a score lands next to a name */
.score { font-weight: 750; font-size: 13px; }
.score.hi { color: var(--good); }
.score.mid { color: var(--warn); }
.score.lo { color: var(--ink-soft); }
.reasons { color: var(--ink-soft); font-size: 11.5px; }
.sugg .score { margin-left: auto; }
.sugg-combo {
  color: var(--ink-soft); font-size: 11px; margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.key-box {
  display: flex; gap: 10px; align-items: center; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere;
}

/* numbered dialog steps — a form with two inputs needs to say which is which */
.dlg-step {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  margin-top: 12px; background: var(--bg);
}
.dlg-step > h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 14px; }
.fld { display: block; }
.fld > span {
  display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px;
}
.fld > input { width: 100%; }
.fld > input.off { background: var(--line); color: var(--ink-soft); }
.picked-standard {
  background: var(--ref-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
.group-head {
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-soft); padding: 7px 10px; border-bottom: 1px solid var(--line);
}

/* group & collapse: pick many raw spellings, choose one standard */
.group-panel { border-top: 1px solid var(--line); margin-top: 12px; }
.group-list {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  margin: 10px 0 0; max-height: 260px; overflow-y: auto;
}
.group-list .combo-row { align-items: flex-start; }
.group-list .combo-row.on { background: var(--accent-soft); }
.group-list .score { font-size: 12.5px; min-width: 34px; text-align: right; }

/* the running basket: what you have ticked so far, kept above the search
   results so it stays put no matter how many times you search */
.group-head.picked-head {
  background: var(--accent-soft); color: var(--ink); text-transform: none;
  letter-spacing: 0; font-size: 12.5px; display: flex; align-items: center; gap: 8px;
}
.group-head.picked-head b { font-weight: 700; }
.group-head.picked-head { cursor: pointer; user-select: none; }
.group-head.picked-head:hover { filter: brightness(0.97); }
.group-head.picked-head .caret { font-size: 10px; opacity: .7; }
/* the names carry the summary and take the slack, so "clear" sits hard right */
.picked-names {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 400; color: var(--ink-soft);
}
#gpList { max-height: 340px; }
.btn.tiny { padding: 1px 7px; font-size: 12px; line-height: 1.5; }

/* two very different answers to "same model, different make" — the safe,
   record-scoped one leads; the brand merge is available but never the default */
.om-acts { display: flex; flex-direction: column; gap: 5px; align-items: stretch; }
.om-acts .btn { white-space: nowrap; }

/* the merge can also fill in a blank category — offered, never silent */
.fill-offer {
  display: flex; gap: 8px; align-items: flex-start; cursor: pointer;
  background: var(--good-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; margin: 10px 0 0; font-size: 14px;
}
.fill-offer .reasons { margin-top: 2px; }

/* shown for information, not for picking — no checkbox, no hover affordance */
.combo-row.muted-row { background: var(--bg); cursor: default; }

/* compact table inside a card — the import list, and anything like it */
table.mini { font-size: 13px; }
table.mini th, table.mini td { padding: 6px 8px; }
table.mini td .tag { margin-left: 6px; }

/* queue ordering picker — compact, so it sits in the head without crowding */
select.sortsel { padding: 5px 8px; font-size: 13px; }

/* bulk select on approvals + review */
.review-card .ap-check { display: flex; align-items: flex-start; padding-top: 4px; cursor: pointer; }
.apSel, .apBox, .rvSel { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); }
.bulk-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; box-shadow: var(--shadow); margin-bottom: 10px;
}
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rc-pick.done { color: var(--good); font-weight: 650; }
.gbtn {
  text-decoration: none; font-size: 13px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); line-height: 1;
  flex-shrink: 0;
}
.gbtn:hover { border-color: var(--accent); background: var(--accent-soft); }
.value-title .gbtn { vertical-align: 3px; margin-left: 6px; }

/* wrong-field combo dialog */
.combo-ctx {
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  margin-bottom: 14px; max-height: 160px; overflow-y: auto;
}
.combo-row {
  display: flex; gap: 6px; align-items: center; padding: 6px 10px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; cursor: pointer;
}
.combo-row:last-child { border-bottom: none; }
.combo-row:hover { background: var(--accent-soft); }
.combo-row input[type=checkbox] { margin-right: 4px; accent-color: var(--accent); }
.rc-step {
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: var(--panel);
}
.rc-step.done { border-left-color: var(--good); }
.rc-step h3, .rc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
/* combo correction: leaving a field alone is a valid choice, so the step
   starts neutral rather than amber-as-incomplete */
#ceRows .rc-step { border-left-color: var(--line); }
#ceRows .rc-step.done { border-left-color: var(--good); }
.step-n {
  background: var(--ink); color: #fff; border-radius: 50%; width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
}
.rc-step.done .step-n { background: var(--good); }
.req { color: var(--bad); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.rc-step.done .req { color: var(--good); }
.pick-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.action-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.kbd-hint { color: var(--ink-soft); font-size: 11.5px; margin-top: 10px; }
kbd {
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: inherit;
}

/* ---- toast / modal ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; gap: 14px; align-items: center;
  z-index: 60; font-size: 13.5px;
}
.toast button { background: none; border: none; color: #7fd4ff; font-weight: 700; cursor: pointer; font-size: 13.5px; }
.hidden { display: none !important; }
.modal {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px;
}
.modal .box {
  background: var(--panel); border-radius: 12px; padding: 20px 22px; width: 620px;
  max-width: 100%; max-height: 80vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.modal h2 { margin-top: 0; }
.typeahead { position: relative; }
.typeahead .results {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  z-index: 10; max-height: 260px; overflow: auto;
}
.typeahead .results div { padding: 8px 12px; cursor: pointer; }
.typeahead .results div:hover { background: var(--accent-soft); }

/* ---- categories tree ---- */
.cat-group { margin-bottom: 10px; }
.cat-group summary {
  cursor: pointer; font-weight: 700; font-size: 14.5px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
}
.cat-group[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cat-group .kids { border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px; background: var(--panel); }
.cat-kid { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13.5px; }
.cat-kid:first-child { border-top: none; }
.spacer { flex: 1; }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px;
  text-align: center; color: var(--ink-soft); background: var(--panel); cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
pre.code {
  background: #0f172a; color: #d7e3f4; border-radius: 8px; padding: 14px 16px;
  overflow: auto; font-size: 12.5px; line-height: 1.5;
}
.load-more { text-align: center; margin: 16px 0; }
.empty { text-align: center; color: var(--ink-soft); padding: 48px 0; font-size: 14.5px; }
.spin {
  border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  width: 26px; height: 26px; animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- registering a standard ---- */
/* Every field in this dialog is one the person filling it in has to read a
   label for, so they get room to breathe rather than the tight rhythm used
   where a form is a single box next to a button. */
.fld { margin-bottom: 12px; }
.fld > span em {
  font-style: normal; font-weight: 500; text-transform: none;
  letter-spacing: 0; color: var(--ink-soft); opacity: .75;
}
.fld .typeahead input { width: 100%; }
.picked-lbl { font-size: 13px; margin-top: 4px; }
textarea.paste {
  width: 100%; min-height: 150px; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); resize: vertical;
}
.note {
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: 9px 11px; margin: 10px 0; font-size: 14px;
}
.note.good { background: var(--good-soft); }
.note.warn { background: var(--warn-soft); }
.pickbox {
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
}
.pickbox > .small { padding: 6px 10px; }

/* a button that reads as a link — keyboard-reachable, unlike a bare <a> with
   no href, and it is an action rather than a destination */
.linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; text-align: center;
}
.linkish:hover { text-decoration: underline; }
