/* Vote Admin — a light, quiet dashboard. The app's typefaces: Fraunces for
   headings, Inter for everything else (npm run admin:prepare copies them into
   vendor/fonts). The data is the only loud thing. Chart colors are the validated reference palette
   (dataviz): one series hue, recessive grid, status colors always with a word. */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(vendor/fonts/fraunces-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(vendor/fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 300 700; font-display: swap;
  src: url(vendor/fonts/fraunces-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 300 700; font-display: swap;
  src: url(vendor/fonts/fraunces-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(vendor/fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(vendor/fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --line: #e1e0d9;
  --line-2: #c3c2b7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --series-1: #2a78d6;
  --series-1-soft: rgba(42, 120, 214, 0.10);
  --accent: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #a52626;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, serif;
  /* The app's type scale (www/styles/tokens.css): screen title 24 Semibold,
     section title 20 Semibold, card title 16–18 Medium, body 16, secondary 14,
     caption 12 (Regular), button 16 Medium. */
  --fs-title: 24px;
  --fs-section: 20px;
  --fs-card: 18px;
  --fs-body: 16px;
  --fs-secondary: 14px;
  --fs-caption: 12px;
  --fs-button: 16px;
  --fw-title: 600;
  --fw-section: 600;
  --fw-card: 500;
  --fw-body: 400;
  --fw-button: 500;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: var(--fw-body) var(--fs-body)/1.5 var(--font); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: var(--fs-secondary); }
h1 { font-size: var(--fs-title); line-height: 1.25; margin: 0; font-weight: var(--fw-title); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
h2 { font-size: var(--fs-section); margin: 0 0 12px; font-weight: var(--fw-section); }
h3 { font-size: var(--fs-body); margin: 18px 0 8px; font-weight: var(--fw-card); color: var(--ink-2); }
h1, h2, h3, .brand { font-family: var(--font-display); }
.muted { color: var(--ink-2); }
.small, small { font-size: var(--fs-caption); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.boot { padding: 40px; color: var(--ink-2); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: var(--fw-card); font-size: var(--fs-card); color: var(--ink); margin: 0 8px 22px; }
.brand span { color: var(--ink-3); font-weight: var(--fw-body); }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: var(--fs-section); margin: 0 0 18px; }
.mark { width: 26px; height: 18px; position: relative; display: inline-block; }
.mark::before, .mark::after { content: ''; position: absolute; top: 1px; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--ink); }
.mark::before { left: 0; }
.mark::after { left: 9px; background: rgba(233, 104, 154, 0.25); }
.side nav { display: grid; gap: 2px; }
.side nav a { color: var(--ink-2); padding: 8px 10px; border-radius: 8px; font-weight: var(--fw-body); }
.side nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.side nav a[aria-current] { background: var(--surface-2); color: var(--ink); font-weight: var(--fw-card); }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
#page { padding: 24px 28px 64px; max-width: 1280px; outline: none; }
.page-head { margin-bottom: 18px; display: grid; gap: 4px; }
.crumbs { margin: 0 0 4px; font-size: var(--fs-caption); }

/* ---------- controls ---------- */
.btn { font: inherit; font-size: var(--fs-button); font-weight: var(--fw-button); display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2a28; }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { background: #b83232; }
.btn-danger-ghost { color: var(--critical-text); border-color: rgba(208, 59, 59, 0.45); }
.btn-xs { height: 28px; padding: 0 10px; border-radius: 8px; }
.btn-block { width: 100%; }
.field { display: grid; gap: 5px; font-size: var(--fs-secondary); }
.field > span { color: var(--ink-2); font-weight: var(--fw-card); }
.field em { font-style: normal; color: var(--ink-3); font-weight: var(--fw-body); }
.field small { color: var(--ink-3); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px; min-height: 34px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.filters .field { min-width: 150px; }
.field-grow { flex: 1 1 280px; }
.seg { font: inherit; font-size: var(--fs-button); font-weight: var(--fw-button); height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; }
.seg:hover { background: var(--surface-2); text-decoration: none; }
.seg.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- chips: a dot and a word, never color alone ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-caption); font-weight: var(--fw-body); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip-good i { background: var(--good); }
.chip-warning i { background: var(--warning); }
.chip-critical i { background: var(--critical); }
.chip-critical { color: var(--critical-text); }
.chip-accent i { background: var(--accent); }
.chip-muted { color: var(--ink-3); }
.chip-muted i { background: var(--line-2); }

/* ---------- cards, tiles, figures ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.cols .card { margin: 0; }
.cols + .card, .card + .cols { margin-top: 16px; }
.cols { margin-bottom: 16px; }
.hero-row { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; gap: 16px; margin-bottom: 16px; }
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; align-content: center; gap: 4px; }
.hero-value { font-size: 52px; line-height: 1.05; font-weight: var(--fw-title); letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tiles-wide { margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; align-content: start; position: relative; min-height: 96px; }
.tile-label { font-size: var(--fs-secondary); color: var(--ink-2); font-weight: var(--fw-body); }
.tile-value { font-size: var(--fs-title); font-weight: var(--fw-title); line-height: 1.2; }
.tile-sub { font-size: var(--fs-caption); color: var(--ink-3); }
.tile .spark { justify-self: end; margin-top: 4px; }
.spark-line { fill: none; stroke: var(--line-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot { fill: var(--series-1); }
.dash { transition: opacity 160ms; }
.dash.is-refreshing { opacity: 0.55; }
.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.chart { margin: 0; }
.chart .card-head b { display: block; }
.chart .card-head small { color: var(--ink-3); }
.chart-plot { position: relative; outline: none; }
.chart-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--ink-3); font-size: var(--fs-caption); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1-soft); stroke: none; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--ink); font-size: var(--fs-caption); font-weight: var(--fw-card); }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart-tip { position: absolute; top: -6px; left: 0; min-width: 100px; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: var(--fs-caption); pointer-events: none; display: grid; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }
.chart-tip b { font-size: var(--fs-secondary); }
.chart-tip span { color: #c3c2b7; }
.chart-empty { color: var(--ink-3); padding: 40px 0; text-align: center; }
.chart-table { width: 100%; border-collapse: collapse; font-size: var(--fs-secondary); }
.chart-table th, .chart-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; }
.bar-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 44%) 1fr auto; align-items: center; gap: 10px; border-radius: 6px; padding: 2px 4px; }
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-2); }
.bar-label { color: var(--ink-2); font-size: var(--fs-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; display: block; }
.bar-fill { display: block; height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar-value { font-size: var(--fs-secondary); font-weight: var(--fw-card); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }

/* ---------- tables and lists ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap { border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: var(--fs-caption); text-transform: none; color: var(--ink-3); font-weight: var(--fw-card); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-compact td { padding: 7px 10px; font-size: var(--fs-secondary); }
.table tr.is-muted td { color: var(--ink-3); }
.person { display: grid; color: var(--ink); }
.person small { color: var(--ink-3); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: 6px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 12px 0; color: var(--ink-2); }
.pager span { margin-right: auto; }
.facts { margin: 0; display: grid; }
.facts > div { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.list { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.stack { display: grid; gap: 12px; }
.empty { padding: 36px; text-align: center; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.alert { background: #fff6f2; border: 1px solid #f6c9b8; color: #7a2e12; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
.prompt { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--line-2); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.prompt small { display: block; color: var(--ink-3); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.photo-slot { width: 96px; height: 128px; border-radius: 10px; background: var(--surface-2); overflow: hidden; display: block; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.report-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-head .muted { margin-left: auto; }
.report-people { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting small { display: block; color: var(--ink-3); }
.setting-value { display: flex; align-items: center; gap: 10px; }
.details td { background: var(--surface-2); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* ---------- dialogs & toasts ---------- */
.modal-layer { position: fixed; inset: 0; background: rgba(11, 11, 11, 0.35); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.modal-form { padding: 22px; display: grid; gap: 14px; }
.modal-form h2 { margin: 0; }
.modal-body { margin: 0; color: var(--ink-2); }
.modal-error { margin: 0; color: var(--critical-text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; transition: opacity 180ms, transform 180ms; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: min(560px, calc(100% - 32px)); pointer-events: none; }
.toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.toast.is-critical { background: var(--critical); }
.toast.is-good { background: #1f5e1f; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.auth-card h1 { font-size: var(--fs-title); }
.auth-foot { color: var(--ink-3); font-size: var(--fs-caption); text-align: center; }
.form-error { color: var(--critical-text); margin: 0; }
.qr { display: block; margin: 4px auto; background: #fff; border-radius: 8px; }
.secret { word-break: break-all; }
.banner { margin: 0; padding: 10px 24px; background: #fff6e5; border-bottom: 1px solid #f1d9a6; color: #6b4a06; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 12px 0 0; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .top { padding: 10px 16px; position: static; }
  #page { padding: 18px 16px 48px; }
  .hero-row { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .diff { grid-template-columns: 1fr; }
}

/* ---------- reported chat photos ---------- */
.report-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
.modal-viewer { width: min(640px, 100%); }
.modal-sheet { width: min(720px, 100%); }
.sheet-body { max-height: 65vh; overflow: auto; display: grid; gap: 14px; }
.evidence-messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.evidence-messages li { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
.evidence-messages li[data-from="reported"] { border-left: 3px solid var(--critical, #b3261e); }
.evidence-messages li[data-from="reporter"] { border-left: 3px solid var(--line); }
.viewer-img { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: var(--surface-2); border-radius: 10px; -webkit-user-select: none; user-select: none; }

/* Operations and photo review */
.problems { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.problems li { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--warning); }
.problems li.is-bad { border-left-color: var(--critical); }
.problems li.is-info { border-left-color: var(--line-2); }
.chip-bad { border-color: var(--critical); }
.nowrap { white-space: nowrap; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.review-photo { aspect-ratio: 3 / 4; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.review-photo img { width: 100%; height: 100%; object-fit: cover; }
.row-actions { display: flex; gap: 8px; }
