@font-face { font-family: "Hanken Grotesk"; src: url(/static/fonts/hanken-grotesk-latin-wght-normal.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url(/static/fonts/newsreader-latin-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --paper: #f5f6f3;
  --surface: #ffffff;
  --sunk: #f9faf8;
  --ink: #121a2b;
  --ink-2: #485166;
  --muted: #7b8394;
  --rule: #e3e6e1;
  --rule-2: #cdd2cb;
  --accent: #0e5a4a;
  --accent-ink: #0a4237;
  --accent-tint: #e5efeb;
  --amber: #8c5a10;
  --amber-tint: #f7eedd;
  --rust: #9e3624;
  --rust-tint: #f6e4df;
  --display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  --r: 8px;
  --r-sm: 5px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--sans); color: var(--ink); background: var(--paper); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; color: var(--ink); letter-spacing: -0.005em; }
h1 { font-size: 32px; line-height: 1.12; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 16.5px; line-height: 1.3; }
p { margin: 0 0 10px; max-width: 74ch; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--rule); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.wordmark { display: flex; align-items: center; gap: 10px; padding: 22px 22px 20px; text-decoration: none; color: var(--ink); }
.wordmark img { width: 28px; height: 28px; }
.wordmark span { font-family: var(--display); font-size: 23px; font-weight: 500; letter-spacing: -0.01em; }
.rail nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.rail .group { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); }
.rail nav a { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; margin: 1px 0; color: var(--ink-2); text-decoration: none; border-radius: var(--r-sm); }
.rail nav a:hover { background: var(--sunk); color: var(--ink); }
.rail nav a.active { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.badge { background: var(--amber); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 600; line-height: 18px; }
.me { border-top: 1px solid var(--rule); padding: 14px 22px; font-size: 13px; }
.me b { display: block; font-weight: 600; }
.me button { margin-top: 6px; }
main { padding: 30px 40px 72px; outline: none; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.crumb { font-size: 13px; margin-bottom: 8px; color: var(--muted); }
.crumb a { text-decoration: none; }

/* ---------- sections */
.band { margin-bottom: 36px; }
.band > h2 { margin-bottom: 12px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 20px 22px; margin-bottom: 18px; }
.panel > h3 { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a, .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-2); padding: 8px 12px; margin-bottom: -1px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; border-radius: 0; }
.tabs a:hover, .tabs button:hover { color: var(--ink); background: none; }
.tabs .on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- figures: one ledger row */
.figures { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 18px; }
.fig { flex: 1 1 150px; padding: 16px 20px; border-right: 1px solid var(--rule); min-width: 0; }
.fig:last-child { border-right: 0; }
.fig .v { font-family: var(--display); font-size: 30px; line-height: 1.05; font-weight: 450; }
.fig .l { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.fig .s { color: var(--muted); font-size: 12px; }
.fig.attn .v { color: var(--amber); }

/* ---------- tables */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; background: var(--sunk); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbf9; }
td.num, th.num { text-align: right; }
.panel table th { background: transparent; }
.bar { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.bar i { display: block; height: 8px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar span { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }

/* ---------- list code tag */
.code { display: inline-block; font-weight: 600; font-size: 12.5px; letter-spacing: .04em; color: var(--accent-ink); background: var(--accent-tint);
  border: 1px solid #cfe1da; border-radius: 4px; padding: 0 6px; line-height: 20px; text-decoration: none; white-space: nowrap; }
a.code:hover { background: #d6e8e1; }
.code.big { font-size: 15px; padding: 2px 9px; line-height: 24px; }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--rule-2); border-radius: var(--r-sm); padding: 7px 10px; width: 100%; }
textarea { min-height: 90px; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-tint); }
select[multiple] { min-height: 96px; padding: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); margin: 5px 0; }
.check input { margin: 0; accent-color: var(--accent); }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.row > .field { flex: 1 1 170px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.grid2 input, .filters input, .filters select { min-width: 0; }
button, .btn { font: inherit; font-weight: 600; font-size: 13.5px; border-radius: var(--r-sm); padding: 7px 14px; cursor: pointer; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; text-decoration: none; display: inline-block; line-height: 1.4; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-ink); color: #fff; }
button.secondary, .btn.secondary { background: #fff; color: var(--ink); border-color: var(--rule-2); }
button.secondary:hover, .btn.secondary:hover { border-color: var(--ink-2); background: #fff; color: var(--ink); }
button.quiet { background: transparent; border-color: transparent; color: var(--accent); padding: 4px 8px; font-weight: 600; }
button.quiet:hover { background: var(--accent-tint); color: var(--accent-ink); }
button.danger { background: #fff; color: var(--rust); border-color: #e2b9b0; }
button.danger:hover { background: var(--rust-tint); color: var(--rust); }
button:disabled { opacity: .45; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; padding: 2px 9px; border-radius: 12px; background: #fff; color: var(--ink-2); border: 1px solid var(--rule-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: #fff; }

/* ---------- records workspace */
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 6px 18px 18px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.filters fieldset { min-width: 0; border: 0; border-bottom: 1px solid var(--rule); margin: 0; padding: 14px 0; }
.filters fieldset:last-of-type { border-bottom: 0; }
.filters legend { font-family: var(--display); font-size: 16px; font-weight: 500; padding: 0; margin-bottom: 8px; }
.resultbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.count { font-family: var(--display); font-size: 28px; font-weight: 450; }
.count small { font-family: var(--sans); font-size: 14px; color: var(--ink-2); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* ---------- status pills */
.pill { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 20px; }
.pill.resp { background: var(--accent-tint); color: var(--accent-ink); }
.pill.sold { background: var(--accent); color: #fff; }
.pill.cancel { background: var(--rust-tint); color: var(--rust); }
.pill.dnr { background: #eceef2; color: var(--ink-2); }
.pill.none { background: transparent; color: var(--muted); border: 1px dashed var(--rule-2); }
.pill.custom { background: var(--amber-tint); color: var(--amber); }
.pill.warn { background: var(--amber-tint); color: var(--amber); }
.pill.off { background: #eceef2; color: var(--muted); }

/* ---------- lead history trail */
.trail { list-style: none; margin: 0; padding: 0 0 0 4px; }
.trail > li { position: relative; padding: 0 0 24px 30px; }
.trail > li::before { content: ""; position: absolute; left: 6px; top: 10px; bottom: -6px; width: 1px; background: var(--rule-2); }
.trail > li:last-child::before { display: none; }
.trail > li::after { content: ""; position: absolute; left: 0; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--accent); }
.trail > li.buy::after { background: var(--accent); }
.trail .when { font-size: 12.5px; color: var(--muted); }
.trail .what { font-family: var(--display); font-size: 18px; }
.trail .events { list-style: none; margin: 10px 0 0; padding: 0; border-left: 1px solid var(--rule); }
.trail .events li { padding: 4px 0 4px 14px; font-size: 13px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- mapping & upload */
.maptable td { vertical-align: middle; }
.maptable select { max-width: 320px; }
.maptable .sample { color: var(--muted); font-size: 12.5px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 1.5px dashed var(--rule-2); border-radius: var(--r); padding: 36px; text-align: center; background: var(--surface); }
.dropzone.over { border-color: var(--accent); background: var(--accent-tint); }
.dropzone .btn { margin: 6px 0; }
.steps { display: flex; gap: 22px; margin-bottom: 20px; counter-reset: s; font-size: 13px; }
.steps span { color: var(--muted); }
.steps span::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--rule-2); margin-right: 7px; font-size: 11.5px; }
.steps span.on { color: var(--ink); font-weight: 600; }
.steps span.on::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps span.done::before { background: var(--accent-tint); border-color: var(--accent-tint); color: var(--accent-ink); }

/* ---------- review */
.review-item { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--amber); border-radius: var(--r); padding: 16px 20px; margin-bottom: 14px; }
.review-item.unmatched { border-left-color: var(--rule-2); }
.review-item .reason { font-weight: 600; margin-bottom: 8px; }
.kv { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; margin-bottom: 10px; }
.kv b { color: var(--muted); font-weight: 500; }
.cand { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-sm); font-weight: 400; color: var(--ink); margin: 0 0 2px; border: 1px solid transparent; }
.cand:hover { background: var(--sunk); }
.cand.sugg { border-color: #cfe1da; background: #f4f9f7; }

/* ---------- permissions grid */
.permgrid td:first-child { min-width: 260px; }
.permgrid .grp td { background: var(--sunk); font-family: var(--display); font-size: 15px; color: var(--ink); }
.src { font-size: 11.5px; color: var(--muted); }
.src.custom { color: var(--amber); font-weight: 600; }

/* ---------- notices */
.notice { background: var(--amber-tint); border: 1px solid #ead7b1; color: #5d3d08; padding: 11px 15px; border-radius: var(--r); margin-bottom: 16px; }
.okbox { background: var(--surface); border: 1px solid #cfe1da; border-top: 3px solid var(--accent); padding: 18px 22px; border-radius: var(--r); margin-bottom: 16px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 8px 10px; word-break: break-all; user-select: all; }
.empty { padding: 40px 30px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--rule-2); border-radius: var(--r); }
.empty h3 { margin-bottom: 6px; }
.empty p { margin: 0 auto 14px; }
.loading { color: var(--muted); padding: 30px 0; }

/* ---------- sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-card { width: min(400px, 100%); }
.auth-card .wordmark { justify-content: center; padding: 0 0 22px; }
.auth-card .wordmark img { width: 34px; height: 34px; }
.auth-card .wordmark span { font-size: 30px; }
.auth-card .panel { padding: 26px 28px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card button[type=submit] { width: 100%; padding: 9px; margin-top: 6px; }
.auth-err { color: var(--rust); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: 90vw; font-size: 13.5px; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--rust); }
dialog { border: 1px solid var(--rule); border-radius: 10px; padding: 0; width: min(580px, 94vw); box-shadow: 0 24px 60px rgba(18, 26, 43, .22); color: var(--ink); }
dialog::backdrop { background: rgba(18, 26, 43, .32); }
#modalBody { padding: 24px 26px; }
#modalBody h2 { margin-bottom: 14px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail nav { overflow-x: auto; flex-wrap: nowrap; }
  .rail nav a { white-space: nowrap; }
  .fig { flex-basis: 140px; }
  .rail { position: static; height: auto; }
  .rail nav { display: flex; flex-wrap: wrap; padding: 0 10px 10px; }
  .rail .group { display: none; }
  .rail nav a { padding: 5px 9px; }
  .wordmark { padding: 14px 16px 8px; }
  .me { display: flex; gap: 10px; align-items: center; padding: 8px 16px; }
  .me button { margin: 0; }
  main { padding: 20px 16px 60px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; max-height: none; }
  .grid2 { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  h1 { font-size: 27px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- list family tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 10px; padding-left: 16px; border-left: 1px solid var(--rule-2); }
.tnode { padding: 7px 10px; margin: 2px 0; border-radius: var(--r-sm); }
.tnode.here { background: var(--accent-tint); }
.trail > li.code-ev::after { border-style: dashed; }
.seller-card { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; padding: 10px 12px; background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 13px; }
.live-cpl { font-family: var(--display); font-size: 26px; line-height: 1.1; }
