:root {
  color-scheme: dark;
  --ink: #eefbf5;
  --muted: #91aaa0;
  --dim: #587168;
  --bg: #06110e;
  --surface: #0b1b16;
  --surface-2: #10251e;
  --line: #1d3b31;
  --mint: #67f3bd;
  --mint-2: #19c98c;
  --vehicle: #37b7e8;
  --treatment: #b998ff;
  --control: #f3b95c;
  --danger: #ff7f85;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: radial-gradient(circle at 75% 0%, #123126 0%, var(--bg) 35rem); color: var(--ink); min-width: 320px; }
button, select { font: inherit; }
button { color: inherit; }
a { color: var(--mint); }
.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 20; padding: .75rem 1rem; background: var(--mint); color: #032016; border-radius: 8px; }
.skip-link:focus { top: 1rem; }

.topbar { min-height: 68px; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: rgba(6, 17, 14, .78); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .65rem; font-size: 1.05rem; font-weight: 760; letter-spacing: -.03em; }
.brand > span:last-child span { color: var(--mint); }
.brand-mark { width: 29px; height: 29px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 4px; border: 1px solid #3e7562; border-radius: 8px; transform: rotate(7deg); }
.brand-mark i { background: var(--mint); border-radius: 50%; opacity: .9; }
.status-cluster { display: flex; align-items: center; gap: 1rem; }
.eyebrow, .kicker { font-size: .68rem; letter-spacing: .14em; font-weight: 750; color: var(--muted); margin: 0 0 .35rem; }
.status-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .42rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: #10221c; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.status-pill.ready { color: var(--mint); border-color: #2c6e56; }
.status-pill.partial { color: var(--control); }

main { width: min(1500px, calc(100% - clamp(1.2rem, 5vw, 6rem))); margin: 0 auto; }
.hero { padding: clamp(2.3rem, 7vw, 5.2rem) 0 2.3rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2.35rem, 5vw, 5.5rem); line-height: .92; letter-spacing: -.065em; margin: .6rem 0 1rem; max-width: 860px; }
h2 { font-size: 1.1rem; letter-spacing: -.025em; margin: 0; }
.hero-copy { color: var(--muted); max-width: 690px; font-size: clamp(.98rem, 1.5vw, 1.15rem); line-height: 1.65; margin: 0; }
.hero-actions, .manual-actions, .export-actions { display: flex; gap: .65rem; flex-wrap: wrap; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: .65rem 1rem; cursor: pointer; font-weight: 720; font-size: .82rem; transition: transform .16s, background .16s, border-color .16s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, select:focus-visible, .well:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(103, 243, 189, .45); outline-offset: 2px; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { color: #032016; background: var(--mint); box-shadow: 0 8px 28px rgba(25, 201, 140, .16); }
.button.primary:hover:not(:disabled) { background: #92ffd5; }
.button.secondary { background: #15362a; border-color: #285645; color: #cffff0; }
.button.ghost { background: transparent; border-color: #315348; color: var(--muted); }
.button.compact { min-height: 34px; padding: .4rem .7rem; font-size: .74rem; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .65fr); gap: 1rem; align-items: start; }
.primary-column, .side-column { display: grid; gap: 1rem; }
.side-column { position: sticky; top: 84px; }
.panel { background: linear-gradient(145deg, rgba(16, 37, 30, .96), rgba(9, 26, 21, .96)); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2vw, 1.35rem); box-shadow: 0 20px 50px rgba(0, 0, 0, .16); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.version-chip { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .7rem; }
.version-chip b { color: var(--mint); background: #15392b; border: 1px solid #286249; padding: .32rem .48rem; border-radius: 7px; }
.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .72rem; color: var(--muted); margin-bottom: 1rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.swatch.vehicle { background: var(--vehicle); }
.swatch.treatment { background: var(--treatment); }
.swatch.control { background: var(--control); }
.lock-symbol { color: var(--mint); font-style: normal; font-size: .58rem; }

.plate-scroll { overflow-x: auto; padding: .2rem .1rem .65rem; }
.plate-grid { min-width: 695px; display: grid; grid-template-columns: 25px repeat(12, minmax(44px, 1fr)); gap: 6px; align-items: center; }
.axis-label { text-align: center; color: var(--dim); font-size: .68rem; font-weight: 800; }
.well { aspect-ratio: 1; min-width: 0; border: 1px solid #25443a; background: #0a1814; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; cursor: pointer; overflow: hidden; transition: transform .15s, border-color .15s; }
.well:hover { transform: scale(1.06); z-index: 2; border-color: var(--mint); }
.well small { font-size: .52rem; color: #07120f; font-weight: 850; line-height: 1; }
.well strong { font-size: .62rem; color: #07120f; line-height: 1; }
.well.empty::after { content: ""; width: 42%; height: 42%; border: 1px solid #1f3931; border-radius: 50%; }
.well.vehicle { background: radial-gradient(circle at 36% 30%, #7edcff, var(--vehicle)); border-color: #5ed4ff; box-shadow: inset 0 0 0 4px rgba(3, 24, 31, .12); }
.well.treatment { background: radial-gradient(circle at 36% 30%, #d5c3ff, var(--treatment)); border-color: #c7acff; box-shadow: inset 0 0 0 4px rgba(24, 9, 42, .12); }
.well.control { background: radial-gradient(circle at 36% 30%, #ffe1a1, var(--control)); border-radius: 11px; border-color: #ffd17a; }
.well.locked::before { content: "◆"; position: absolute; top: 2px; right: 3px; color: #062116; font-size: .45rem; }
.well.edge-risk { box-shadow: 0 0 0 2px rgba(255, 127, 133, .42); }
.plate-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.plate-footer p { margin: 0; }
.text-button { background: transparent; border: 0; color: var(--mint); cursor: pointer; padding: .35rem; }

.candidate-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: .65rem; margin-bottom: .8rem; }
.candidate-card { border: 1px solid var(--line); border-radius: 13px; background: #0a1c16; padding: .85rem; }
.candidate-card.stale { opacity: .62; border-style: dashed; }
.candidate-card h3 { margin: 0; font-size: .9rem; }
.candidate-card header { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.candidate-card .strategy { color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
.candidate-card dl { display: grid; grid-template-columns: 1fr auto; gap: .28rem .5rem; margin: 0 0 .7rem; font-size: .7rem; }
.candidate-card dt { color: var(--muted); }
.candidate-card dd { margin: 0; font-variant-numeric: tabular-nums; }
.manual-actions { margin-top: .75rem; }
.comparison { margin-top: .75rem; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.comparison strong { color: var(--mint); }

.edit-panel { display: grid; grid-template-columns: 1fr 1.5fr; gap: 1.2rem; align-items: end; }
.edit-panel p:not(.kicker) { color: var(--muted); font-size: .78rem; line-height: 1.5; margin: .5rem 0 0; }
.move-form { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; align-items: end; }
label { display: grid; gap: .35rem; color: var(--muted); font-size: .7rem; }
select { width: 100%; min-height: 41px; color: var(--ink); background: #0a1814; border: 1px solid #315348; border-radius: 9px; padding: 0 .65rem; }
.check { grid-column: 1 / -1; display: flex; align-items: center; gap: .45rem; }
.check input { accent-color: var(--mint); }

.score-ring { width: 61px; height: 61px; flex: 0 0 auto; display: flex; align-items: baseline; justify-content: center; border-radius: 50%; border: 4px solid var(--mint-2); padding-top: 14px; background: #09231a; box-shadow: 0 0 24px rgba(25, 201, 140, .14); }
.score-ring strong { font-size: 1.15rem; }
.score-ring span { color: var(--muted); font-size: .55rem; }
.disclaimer { color: var(--dim); font-size: .67rem; line-height: 1.45; margin: -.35rem 0 1rem; }
.metric-list { display: grid; gap: .58rem; }
.metric { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; }
.metric span { font-size: .72rem; color: var(--muted); }
.metric strong { font-size: .75rem; }
.metric-track { grid-column: 1 / -1; height: 3px; background: #1d3a30; border-radius: 99px; overflow: hidden; }
.metric-track i { display: block; height: 100%; background: var(--mint); }
.validation-box { margin-top: 1rem; border-radius: 10px; padding: .75rem; background: #0b211a; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.validation-box.good { border: 1px solid #2b6b52; color: #b8f7dc; }
.validation-box.warn { border: 1px solid #745b2f; color: #f2d49c; }

.export-panel > p { color: var(--muted); font-size: .76rem; line-height: 1.55; }
.mini-state, .count-chip { padding: .3rem .5rem; border-radius: 7px; background: #152c24; color: var(--muted); font-size: .64rem; white-space: nowrap; }
.mini-state.approved { color: var(--mint); background: #123b2c; }
.csv-preview { max-height: 150px; overflow: auto; white-space: pre; margin: .9rem 0 0; background: #06120e; border: 1px solid #1b372e; color: #92cdb7; border-radius: 10px; padding: .75rem; font-size: .62rem; line-height: 1.5; }
.receipt { margin-top: .65rem; font-size: .72rem; color: var(--mint); }
.receipt a { display: inline-block; margin-top: .35rem; }

.ledger { list-style: none; padding: 0; margin: 0; max-height: 230px; overflow: auto; display: grid; gap: .62rem; }
.ledger li { position: relative; padding-left: 1.25rem; color: var(--muted); font-size: .68rem; line-height: 1.45; }
.ledger li::before { content: ""; position: absolute; top: .3rem; left: .1rem; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.ledger li.agent::before { background: var(--treatment); box-shadow: 0 0 8px var(--treatment); }
.ledger li.human::before { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.ledger b { color: var(--ink); text-transform: capitalize; }
.ledger time { color: var(--dim); font-family: ui-monospace, monospace; margin-right: .35rem; }
.notice { position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 150%); background: #d3ffec; color: #062017; border-radius: 10px; padding: .75rem 1rem; font-size: .78rem; font-weight: 700; transition: transform .2s; z-index: 20; box-shadow: 0 15px 45px rgba(0,0,0,.35); }
.notice.show { transform: translate(-50%, 0); }
.notice.error { background: #ffd2d4; color: #4b0f12; }
footer { width: min(1500px, calc(100% - clamp(1.2rem, 5vw, 6rem))); margin: 2rem auto 0; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--line); color: var(--dim); display: flex; justify-content: space-between; gap: 1rem; font-size: .7rem; }
footer p { margin: 0; }

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .side-column { position: static; grid-template-columns: 1fr 1fr; }
  .ledger-panel { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .topbar .eyebrow { display: none; }
  .hero { align-items: flex-start; flex-direction: column; }
  .workspace-grid, .side-column { display: grid; grid-template-columns: 1fr; }
  .ledger-panel { grid-column: auto; }
  .edit-panel { grid-template-columns: 1fr; }
  .move-form { grid-template-columns: 1fr; }
  .check { grid-column: auto; }
  footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
