/* stats dashboard. Paper and copper, like i-n8.com. */
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url(fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url(fonts/space-grotesk-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }

:root {
  --paper: #f8f5ef; --card: #fffdf9; --paper-2: #f1ece6; --ink: #15110d; --ink-2: #37322e; --pencil: #6d6863; --rule: #e3ded7; --grid: #ebe6df;
  --copper: #c56c21; --copper-ink: #a54c00; --wash: rgba(197, 108, 33, .13); --wash-strong: rgba(197, 108, 33, .22);
  --prev: #2f6fb8; --good: #17803d; --bad: #b42318;
  --display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif; --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r: 14px; --gutter: clamp(16px, 3vw, 32px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #110e0b; --card: #18140f; --paper-2: #1f1a15; --ink: #ece6dd; --ink-2: #cbc3b8; --pencil: #9a9187; --rule: #2c251f; --grid: #241e19;
    --copper: #d17a35; --copper-ink: #e59a5c; --wash: rgba(209, 122, 53, .16); --wash-strong: rgba(209, 122, 53, .28);
    --prev: #5a90d8; --good: #4cc36b; --bad: #f97066; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #110e0b; --card: #18140f; --paper-2: #1f1a15; --ink: #ece6dd; --ink-2: #cbc3b8; --pencil: #9a9187; --rule: #2c251f; --grid: #241e19;
  --copper: #d17a35; --copper-ink: #e59a5c; --wash: rgba(209, 122, 53, .16); --wash-strong: rgba(209, 122, 53, .28);
  --prev: #5a90d8; --good: #4cc36b; --bad: #f97066; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--pencil); }
[hidden] { display: none !important; }
.brand { font: 700 20px var(--display); letter-spacing: -.04em; text-decoration: none; margin: 0; white-space: nowrap; }
.brand .i { color: var(--copper); }
.brand b { font-weight: 500; color: var(--pencil); letter-spacing: -.02em; margin-left: 2px; }

/* ---------- sign in ---------- */
.signin { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.signin-box { width: min(380px, 100%); }
.signin-box .brand { font-size: 28px; margin-bottom: 36px; }
.signin form { display: grid; gap: 10px; }
.signin label { font-size: 13px; color: var(--pencil); }
.signin input { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.signin button { margin-top: 6px; padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 500; }
.signin .err { color: var(--bad); margin: 4px 0 0; font-size: 14px; }
.signin h1 { font: 700 30px/1.1 var(--display); letter-spacing: -.03em; margin: 0 0 8px; }
.checks { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--rule); }
.checks h2 { font: 500 13px var(--body); color: var(--pencil); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .08em; }
.checks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.checks li span { display: inline-block; width: 18px; font-weight: 700; }
.checks li.ok span { color: var(--good); } .checks li.no span { color: var(--bad); }
.checks small { display: block; margin-left: 22px; color: var(--pencil); }

/* ---------- top ---------- */
#app { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter) 60px; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 0 12px; flex-wrap: wrap; }
.site-pick select { appearance: none; border: 1px solid var(--rule); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236d6863' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; padding: 7px 32px 7px 12px; border-radius: 999px; font-weight: 500; }
.site-pick.single select { pointer-events: none; background-image: none; padding-right: 12px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); padding: 6px 10px; border-radius: 999px; }
.live:hover { background: var(--paper-2); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--pencil); }
.live.on i { background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.tools { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; }
.tools a { color: var(--pencil); text-decoration: none; } .tools a:hover { color: var(--ink); }
#theme span { display: block; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--ink); background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); }

/* ---------- controls ---------- */
.controls { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 10px 0 14px; background: var(--paper); }
.range { display: flex; background: var(--paper-2); border-radius: 999px; padding: 3px; }
.range button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.range button:hover { color: var(--ink); }
.range button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 500; }
#range-sm { display: none; }
.custom { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.custom input { border: 1px solid var(--rule); background: var(--card); border-radius: 8px; padding: 5px 8px; }
.custom button { padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 13px; }
.compare { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.compare input { accent-color: var(--copper); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 13px; max-width: 360px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip em { font-style: normal; opacity: .7; }
.chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; line-height: 1; }
.chip button:hover { background: rgba(255,255,255,.18); }

/* ---------- cards ---------- */
main { transition: opacity .2s; }
main.loading { opacity: .55; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px 20px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font: 500 15px var(--display); letter-spacing: -.01em; margin: 0; margin-right: auto; }
.tabs { display: flex; gap: 2px; font-size: 13px; }
.tabs button { padding: 3px 9px; border-radius: 999px; color: var(--pencil); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--paper-2); color: var(--ink); font-weight: 500; }
.link { font-size: 13px; color: var(--pencil); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- totals ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { text-align: left; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 16px 12px; display: grid; gap: 2px; position: relative; transition: border-color .2s; }
.kpi:hover { border-color: color-mix(in srgb, var(--copper) 45%, var(--rule)); }
.kpi[aria-pressed="true"] { border-color: var(--copper); box-shadow: inset 0 -3px 0 var(--copper); }
.kpi .l { font-size: 13px; color: var(--pencil); }
.kpi .v { font: 500 clamp(24px, 2.6vw, 32px)/1.15 var(--display); letter-spacing: -.03em; color: var(--ink); }
.kpi .d { font-size: 12px; color: var(--pencil); min-height: 18px; white-space: nowrap; }
.kpi .d.good { color: var(--good); } .kpi .d.bad { color: var(--bad); }

/* ---------- main chart ---------- */
.chart-card { margin-bottom: 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; border-radius: 2px; background: var(--copper); }
.legend i.prev { background: var(--prev); }
.chart { position: relative; height: 268px; outline-offset: 4px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--pencil); font: 400 11px var(--mono); font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--wash); }
.chart .line { fill: none; stroke: var(--copper); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.prev { stroke: var(--prev); }
.chart .cross { stroke: var(--pencil); stroke-width: 1; shape-rendering: crispEdges; }
.chart .dot { fill: var(--copper); stroke: var(--card); stroke-width: 2; }
.chart .dot.prev { fill: var(--prev); }
.chart .empty { fill: var(--pencil); font: 400 14px var(--body); }
.chart-table { max-height: 300px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 500; color: var(--pencil); position: sticky; top: 0; background: var(--card); }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 9px 12px; font-size: 12px; line-height: 1.45; box-shadow: 0 8px 24px -8px rgba(0,0,0,.4); min-width: 150px; }
.tip .t { opacity: .7; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .row i { width: 12px; height: 2px; border-radius: 2px; background: var(--copper); flex: none; }
.tip .row i.prev { background: var(--prev); }
.tip .row b { font: 500 14px var(--display); }
.tip .row span { opacity: .75; }

/* ---------- breakdown lists ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.cols { display: flex; justify-content: space-between; font-size: 12px; color: var(--pencil); padding: 0 2px 6px; }
.cols span:last-child { display: flex; gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.row { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 30px; padding: 0 2px 0 10px; text-align: left; border-radius: 6px; }
.row .bar { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 0 4px 4px 0; background: var(--wash); transform-origin: left; transition: background-color .15s; }
.row:hover .bar, .row:focus-visible .bar { background: var(--wash-strong); }
.row .name { position: relative; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row .name small { color: var(--pencil); margin-left: 6px; }
.row .num { position: relative; display: flex; gap: 16px; font-size: 13px; font-variant-numeric: tabular-nums; }
.row .num b { font-weight: 500; min-width: 36px; text-align: right; }
.row .num span { color: var(--pencil); min-width: 44px; text-align: right; }
.row.static { cursor: default; }
.list-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.empty-note { color: var(--pencil); font-size: 14px; padding: 18px 2px; }
.flow .name { display: flex; align-items: center; gap: 6px; }
.flow .arrow { color: var(--copper); }
.back { font-size: 13px; color: var(--pencil); margin-bottom: 8px; }
.back:hover { color: var(--ink); }
.props h3 { font: 500 12px var(--body); color: var(--pencil); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 6px; }
.props h3:first-child { margin-top: 0; }

/* ---------- right now ---------- */
.live-card { margin-bottom: 18px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 360px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--rule); font-size: 13px; align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed .ago { color: var(--pencil); font-variant-numeric: tabular-nums; }
.feed .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what b { font-weight: 500; }
.feed .what small { color: var(--pencil); margin-left: 6px; }
.feed .who { color: var(--pencil); white-space: nowrap; }
.foot { color: var(--pencil); font-size: 13px; line-height: 1.6; max-width: 70ch; }
.foot code { font: 12px var(--mono); background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- dialog ---------- */
dialog { width: min(720px, calc(100vw - 24px)); max-height: min(80svh, 760px); border: 1px solid var(--rule); border-radius: 18px; padding: 0; background: var(--card); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(20, 15, 10, .4); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.dlg-head h2 { font: 500 17px var(--display); margin: 0; margin-right: auto; }
.dlg-head input { border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 6px 12px; width: 180px; }
.dlg-head .x { font-size: 22px; width: 32px; height: 32px; border-radius: 50%; }
.dlg-head .x:hover { background: var(--paper-2); }
.dlg-body { padding: 8px 18px 18px; overflow: auto; max-height: calc(min(80svh, 760px) - 70px); }
.dlg-body td:first-child { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body tr.click { cursor: pointer; } .dlg-body tr.click:hover td { background: var(--wash); }

/* ---------- phones ---------- */
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .range { display: none; } #range-sm { display: block; border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: 7px 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 220px; }
  .tools { gap: 14px; }
  .card { padding: 16px 14px 14px; }
  .feed li { grid-template-columns: 52px minmax(0, 1fr); } .feed .who { grid-column: 2; margin-top: -6px; }
  .dlg-head input { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .controls, .tools, .live, #table-toggle { display: none !important; } .card { break-inside: avoid; } }
