:root {
  --bg: #F3F4F6;
  --panel: #FFFFFF;
  --ink: #15171C;
  --muted: #5B616D;
  --line: #DCDFE5;
  --soft: #ECEEF2;
  --gold: #E5AE00;
  --gold-soft: #FFF3C7;
  --gold-ink: #15171C;
  --ok: #1E8A4C;
  --ok-soft: #E2F4EA;
  --warn: #B26B00;
  --warn-soft: #FDF0DB;
  --bad: #C2362F;
  --bad-soft: #FBE4E2;
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1115; --panel: #171A20; --ink: #ECEEF2; --muted: #9AA1AE; --line: #2A2F38; --soft: #20242C;
    --gold: #FFC61A; --gold-soft: #3A3014; --gold-ink: #15171C;
    --ok: #4CC17E; --ok-soft: #173325; --warn: #F0A63A; --warn-soft: #3A2A12; --bad: #F06A62; --bad-soft: #3D1C1A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1115; --panel: #171A20; --ink: #ECEEF2; --muted: #9AA1AE; --line: #2A2F38; --soft: #20242C;
  --gold: #FFC61A; --gold-soft: #3A3014; --gold-ink: #15171C;
  --ok: #4CC17E; --ok-soft: #173325; --warn: #F0A63A; --warn-soft: #3A2A12; --bad: #F06A62; --bad-soft: #3D1C1A;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--panel); }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-block: 12px 0; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; }
.brand h1 { font-family: var(--f-display); font-weight: 700; font-size: 20px; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.brand .sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.tabs a { display: block; padding: 8px 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); }
.tabs a:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
main { padding-block: 20px 48px; }
.notice { margin-bottom: 16px; padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 860px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.panel h2 { font-family: var(--f-display); font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.kpi .val { font-family: var(--f-display); font-weight: 700; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .of { color: var(--muted); font-size: 13px; }
.meter { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.meter.ok > span { background: var(--ok); } .meter.warn > span { background: var(--warn); } .meter.bad > span { background: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.gold { background: var(--gold-soft); color: var(--ink); }
.num { font-family: var(--f-data); font-variant-numeric: tabular-nums; font-size: 13px; }
.muted { color: var(--muted); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.barcell { min-width: 120px; }
.bar2 { position: relative; height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.bar2 .plan { position: absolute; inset: 0 auto 0 0; background: var(--gold-soft); }
.bar2 .spent { position: absolute; inset: 2px auto 2px 0; background: var(--gold); border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
input.budget { width: 96px; text-align: right; font-family: var(--f-data); font-size: 13px; }
button { cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; font-weight: 600; font-size: 14px; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 4px 8px; }
button.ghost:hover { color: var(--ink); background: var(--soft); }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.phase-now { display: flex; flex-direction: column; gap: 8px; }
.phase-now .name { font-family: var(--f-display); font-weight: 700; font-size: 22px; }
.tasklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tasklist li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--soft); }
.tasklist li:last-child { border-bottom: 0; }
.tasklist li.done .t { text-decoration: line-through; color: var(--muted); }
.tasklist input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.due { font-family: var(--f-data); font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.late { color: var(--bad); font-weight: 500; }
/* Timeline */
.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 760px; position: relative; }
.g-head, .g-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: center; }
.g-head { height: 28px; font-size: 12px; color: var(--muted); }
.g-track { position: relative; height: 100%; }
.g-row { height: 52px; border-top: 1px solid var(--soft); }
.g-label { font-weight: 600; font-size: 14px; padding-right: 10px; line-height: 1.2; }
.g-label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; font-family: var(--f-data); }
.g-bar { position: absolute; top: 14px; height: 24px; border-radius: 5px; background: var(--gold-soft); border: 1px solid var(--gold); display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; }
.g-bar.peak { background: var(--gold); color: var(--gold-ink); }
.g-bar.zero { background: transparent; border-style: dashed; }
.g-month { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding-left: 4px; line-height: 28px; white-space: nowrap; }
.g-grid { position: absolute; top: 28px; bottom: 0; left: 210px; right: 0; pointer-events: none; }
.g-grid .wk { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--soft); }
.g-grid .today { position: absolute; top: -6px; bottom: 0; border-left: 2px solid var(--bad); }
.g-grid .today span { position: absolute; top: -18px; left: 4px; font-size: 11px; color: var(--bad); font-weight: 600; }
.g-ms { position: absolute; top: 8px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; white-space: nowrap; }
.g-ms i { width: 12px; height: 12px; background: var(--ink); transform: rotate(45deg); display: block; }
.g-ms.gold i { background: var(--gold); outline: 1px solid var(--ink); }
.phase-tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.phase-tasks .panel h3 { font-family: var(--f-display); font-size: 16px; margin: 0; }
.phase-tasks .panel header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.addrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.addrow input[type="text"] { flex: 1 1 200px; }
/* Tests */
.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.fgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.fgrid label.wide { grid-column: 1 / -1; }
.fgrid input, .fgrid select { width: 100%; }
.factions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.formmsg { font-size: 13px; }
.formmsg.err { color: var(--bad); } .formmsg.okm { color: var(--ok); }
.tests { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.test header { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 4px; }
.test header h3 { font-family: var(--f-display); font-size: 18px; margin: 0; }
.test .chan { font-size: 13px; color: var(--muted); }
.test .note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 12px 0; }
.metric { background: var(--bg); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.metric .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.metric .v { font-family: var(--f-display); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.metric.hl { background: var(--gold-soft); }
.verdict { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--soft); font-size: 14px; margin-bottom: 12px; }
.verdict.ok { background: var(--ok-soft); } .verdict.warn { background: var(--warn-soft); } .verdict.bad { background: var(--bad-soft); }
.verdict b { white-space: nowrap; }
.tactions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.tactions input { width: 90px; }
.empty { color: var(--muted); font-size: 14px; padding-block: 12px; }
.spark { display: block; width: 100%; height: 48px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
@media (prefers-reduced-motion: no-preference) { .meter > span, .bar2 .spent { transition: width .3s ease; } }
@media (max-width: 520px) { .kpi .val { font-size: 24px; } .tabs { margin-left: 0; width: 100%; } }
/* ---- self-hosted additions ---- */
:root { --series-ios: #2a78d6; --series-android: #eb6834; color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-ios: #3987e5; --series-android: #d95926; } }
:root[data-theme="dark"] { --series-ios: #3987e5; --series-android: #d95926; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
.who { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; font-size: 13px; color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-family: var(--f-display); font-size: 22px; margin: 0; }
.login input { width: 100%; padding: 10px 12px; font-size: 16px; }
.login button { padding: 10px 12px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: var(--panel); color: var(--muted); padding: 6px 12px; }
.segmented button[aria-pressed="true"] { background: var(--gold-soft); color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .axis text { font-family: var(--f-data); font-size: 11px; fill: var(--muted); }
.chart .grid line { stroke: var(--soft); }
.chart .base { stroke: var(--line); }
.chart .xh { stroke: var(--muted); stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; z-index: 2; }
.tip b { font-family: var(--f-data); font-weight: 500; }
.tip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.syncs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sync { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.sync .err { color: var(--bad); word-break: break-word; }
