:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-soft: #eff4ff; --red: #b91c1c; --red-soft: #fef2f2;
  --amber: #b45309; --amber-soft: #fffbeb; --green: #15803d; --green-soft: #f0fdf4;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #0f172a; color: #fff; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .logo { color: #60a5fa; }
.brand .sub { font-weight: 400; color: #94a3b8; font-size: 13px; margin-left: 6px; }
.meta { flex: 1; color: #cbd5e1; font-size: 12.5px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: #9ca3af; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; color: #e2e8f0; border-color: #334155; }
.btn.ghost:hover { border-color: #64748b; }
.btn:disabled { opacity: .5; cursor: default; }

.banner { padding: 8px 20px; background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid #fde68a; font-size: 13px; }
.banner.error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }

.searchrow { display: flex; gap: 10px; padding: 14px 20px 8px; }
.search { position: relative; flex: 1; }
.search input { width: 100%; padding: 10px 40px 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 15px; }
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-size: 12px; background: var(--bg); }
.select { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 0 10px; }

.triage { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 20px 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip:hover { border-color: #9ca3af; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.chip.on .n { color: #dbeafe; }
.chip.red:not(.on) .n { color: var(--red); }
.chip.green:not(.on) .n { color: var(--green); }
.chip .label-sub { font-size: 12px; color: var(--muted); }
.chip.on .label-sub { color: #dbeafe; }

.layout { display: grid; grid-template-columns: 270px 1fr; gap: 16px; padding: 0 20px 24px; align-items: start; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.fgroup { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.fgroup:last-child { border-bottom: 0; }
.fgroup h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; justify-content: space-between; }
.fgroup h4 .why { text-transform: none; letter-spacing: 0; font-weight: 400; cursor: help; }
.opt { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; user-select: none; }
.opt input { margin: 0; accent-color: var(--accent); }
.opt .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .code { color: var(--muted); font-size: 12px; margin-right: 4px; }
.opt .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.opt.zero { opacity: .45; }
.fsc-search { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; margin-bottom: 6px; }
.fsc-list { max-height: 260px; overflow: auto; }
.cages { width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; resize: vertical; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; line-height: 1.4; }
.clear { display: block; width: calc(100% - 28px); margin: 10px 14px; }

.results { min-width: 0; }
.summary { display: flex; align-items: center; gap: 12px; margin: 2px 0 8px; color: var(--muted); }
.summary b { color: var(--ink); }
.summary .active { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.tag:hover { text-decoration: line-through; }

.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafafa; position: sticky; top: 0; }
td { padding: 9px 10px; border-bottom: 1px solid #f1f2f4; vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }
tbody tr.sel { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nom { font-weight: 600; }
.small { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; border-radius: 4px; padding: 1px 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.sa { background: #f3e8ff; color: #7e22ce; }
.badge.ext { background: var(--green-soft); color: var(--green); }
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.mine { background: var(--green-soft); color: var(--green); }
.due-red { color: var(--red); font-weight: 600; }
.due-amber { color: var(--amber); font-weight: 600; }
.due-past { color: var(--muted); text-decoration: line-through; }
.ext-link { color: var(--muted); padding: 2px 6px; border-radius: 4px; }
.ext-link:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 0; color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); box-shadow: -8px 0 30px rgba(0,0,0,.12); overflow: auto; padding: 20px 22px; }
.drawer h2 { margin: 4px 0 2px; font-size: 19px; }
.drawer .close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.drawer .actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; }
.drawer .grid { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin-bottom: 18px; }
.drawer .grid dt { color: var(--muted); }
.drawer .grid dd { margin: 0; }
.drawer h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.drawer table td, .drawer table th { padding: 6px 8px; }
.callout { background: var(--amber-soft); color: var(--amber); border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 13px; }
.callout.green { background: var(--green-soft); color: var(--green); }

.triage { flex-direction: column; align-items: stretch; gap: 10px; }
.funnel { display: flex; align-items: stretch; gap: 6px; }
.funnel .arrow { align-self: center; color: #9ca3af; font-size: 20px; }
.step { flex: 1; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; }
.step:hover { border-color: #9ca3af; }
.step .t { font-weight: 600; }
.step .s { grid-row: 2; color: var(--muted); font-size: 12px; }
.step .n { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.step.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.on .s { color: #dbeafe; }
.step.locked { border-style: dashed; }
.step.locked .s { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.welcome { display: flex; align-items: center; gap: 16px; background: var(--accent-soft); border: 1px solid #c7d7fe; border-radius: 10px; padding: 10px 14px; color: #1e3a8a; }
.welcome .btn { white-space: nowrap; }
.gtag { font-weight: 400; font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 4px; margin-left: 2px; }
.badge.cat { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.profile { background: #fbfcfe; }
.pfsec { margin-top: 10px; }
.pfl { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pfbtns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0; }
.gates { list-style: none; padding: 0; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 8px; }
.gates li { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.gates li:last-child { border-bottom: 0; }
.gi { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.gi.ok { background: var(--green-soft); color: var(--green); }
.gi.no { background: var(--red-soft); color: var(--red); }
.gi.unk { background: #f3f4f6; color: var(--muted); }

.gi.amber { background: var(--amber-soft); color: var(--amber); }
.heat { font-size: 11px; text-transform: none; letter-spacing: 0; border-radius: 4px; padding: 1px 6px; margin-left: 6px; font-weight: 600; }
.heat-crowded { background: var(--red-soft); color: var(--red); }
.heat-incumbent, .heat-contested { background: var(--amber-soft); color: var(--amber); }
.heat-thin { background: var(--green-soft); color: var(--green); }
.heat-unknown { background: #f3f4f6; color: var(--muted); }
.ev { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0; background: #fbfcfe; }
.ev label { display: inline-block; margin: 4px 12px 6px 0; }
.evin { width: 90px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.evin.short { width: 52px; }
details summary { cursor: pointer; margin: 8px 0; }

@media (max-width: 900px) {
  .funnel { flex-direction: column; }
  .funnel .arrow { display: none; }
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .hide-sm { display: none; }
}
