/* Mobile first. Light and dark follow the phone's setting. No web fonts, no CDNs. */
:root {
  --page: #f9f9f7;
  --card: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --line: #e4e3dc;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --good: #0a7a0a;
  --warn: #b25e00;
  --bad-bg: #b42323;
  --bad-ink: #ffffff;
  --flag-bg: #fff4e0;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --card: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --line: #383835;
    --accent: #3987e5;
    --accent-soft: #184f95;
    --good: #3cc23c;
    --warn: #f0a53a;
    --bad-bg: #a32020;
    --flag-bg: #3a2a10;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main, header.top, footer { max-width: 980px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.25rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h2.section { margin: 26px 0 10px; font-size: 1.15rem; }
h2.mt { margin-top: 18px; }
h3 { font-size: .9rem; margin: 6px 0 8px; color: var(--ink-2); font-weight: 600; }
p { margin: 8px 0; }
code { font-size: .9em; background: var(--line); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--ink-2); }
.small, small { font-size: .82rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Alert */
.alert {
  background: var(--bad-bg); color: var(--bad-ink);
  padding: 12px 16px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; z-index: 5;
}

/* Header */
header.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 16px; padding-bottom: 6px; }
header.top p { margin: 4px 0 0; font-size: .9rem; }
.badge { display: inline-block; margin-top: 6px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--flag-bg); color: var(--warn); }
button.link { background: none; border: 1px solid var(--line); color: var(--ink-2); padding: 6px 12px; border-radius: 8px; font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.grid2, .grid3 { display: grid; gap: 12px; margin: 12px 0; }
.grid2 > .card, .grid3 > .card { margin: 0; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid2.tight { gap: 18px; }
@media (max-width: 420px) { .grid2.tight { grid-template-columns: 1fr; } }
@media (min-width: 700px) { .grid3 { grid-template-columns: repeat(3, 1fr); } .grid2 { grid-template-columns: repeat(3, 1fr); } .grid2.tight { grid-template-columns: 1fr 1fr; } }

.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero .right { text-align: right; }
.big { font-size: 2.4rem; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.big .of { font-size: 1.3rem; color: var(--ink-2); font-weight: 600; }
.progress { height: 12px; background: var(--line); border-radius: 99px; margin: 14px 0 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }

.stat .label { font-size: .8rem; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat .value.small-value { font-size: 1.15rem; }
.stat .unit { font-size: .9rem; font-weight: 500; color: var(--ink-2); }
.stat.flag { background: var(--flag-bg); border-color: var(--warn); }
.stat.flag strong { color: var(--warn); }
.status { font-size: .85rem; font-weight: 600; margin: 8px 0 0; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }

/* Ticket types */
table.types { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.types th { text-align: left; font-size: .78rem; color: var(--ink-2); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--line); }
table.types th.num { text-align: right; }
table.types td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.types td + td, table.types th + th { padding-left: 10px; }

/* Horizontal bars */
.hbar { display: grid; grid-template-columns: 5.5em 1fr 2.5em; align-items: center; gap: 8px; font-size: .88rem; margin: 5px 0; }
.hbar .hl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hv { text-align: right; font-variant-numeric: tabular-nums; }
.hbar .track { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.hbar .track > span { display: block; height: 100%; background: var(--accent-soft); border-radius: 99px; }
.hbar.best .track > span { background: var(--accent); }
.hbar.best .hl { font-weight: 700; }
.sources .hbar { grid-template-columns: 8.5em 1fr 2.5em; }
.hbar.untagged .hl { color: var(--ink-2); font-style: italic; }

/* Charts */
.chart { max-width: 720px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .base { stroke: var(--ink-2); stroke-width: 1; }
.chart .today { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--ink-2); font-size: 13px; }
.chart .bar { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .proj { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; }
.chart .cap { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 6 4; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: var(--ink); fill-opacity: .06; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); margin-top: 10px; }
.legend .key { display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid var(--accent); }
.legend .key.proj { border-top: 2px dotted var(--accent); }
.legend .key.cap { border-top: 1px dashed var(--ink-2); }
.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: var(--card); font-size: .82rem; padding: 5px 9px; border-radius: 6px; white-space: nowrap; }

/* Buyers: cards on a phone, a table-like grid on wider screens */
input[type=search], input[type=password] {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iPhone zooming in */
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--page); color: var(--ink);
}
.buyers { margin-top: 10px; }
.buyer { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.buyer.head { display: none; }
.buyer .bn { font-weight: 600; grid-column: 1; }
.buyer .bp { grid-column: 2; grid-row: 1; font-weight: 600; }
.buyer .bw { grid-column: 1; font-size: .82rem; }
.buyer .bt { grid-column: 2; font-size: .85rem; }
.buyer.dead .bn, .buyer.dead .bp { text-decoration: line-through; color: var(--ink-2); }
.buyer .tag { font-style: normal; font-size: .72rem; font-weight: 600; color: var(--warn); text-decoration: none; display: inline-block; }
.buyer .src { font-style: normal; font-size: .72rem; font-weight: 500; color: var(--ink-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; }
@media (min-width: 700px) {
  .buyer, .buyer.head { display: grid; grid-template-columns: 1fr 6em 7em 11em; align-items: center; }
  .buyer.head { font-size: .78rem; color: var(--ink-2); font-weight: 600; padding: 4px 0; }
  .buyer .bn, .buyer .bt, .buyer .bp, .buyer .bw { grid-column: auto; grid-row: auto; font-size: .92rem; }
  .buyer .bt small { display: none; }
}

footer { padding-top: 8px; padding-bottom: 40px; }

/* Login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 1.5rem; }
.login label { display: block; font-weight: 600; margin: 18px 0 6px; }
.login button { width: 100%; margin-top: 14px; padding: 12px; font: inherit; font-weight: 600; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.form-error { color: var(--bad-bg); font-weight: 600; }
@media (prefers-color-scheme: dark) { .form-error { color: #ff8a8a; } }
