/* EasyGymAI Admin. Tokens first; dark is the default look, light follows prefers-color-scheme or the manual toggle. */
:root {
  color-scheme: dark;
  --bg:#0e110f; --bg-2:#0a0c0b; --surface:#161a17; --surface-2:#1d221e; --surface-3:#272d28;
  --text:#eaf1eb; --muted:#93a196; --line:rgba(255,255,255,.09); --line-strong:rgba(255,255,255,.18);
  --accent:#b7f36b; --on-accent:#10200a; --accent-text:#b7f36b; --accent-soft:rgba(183,243,107,.13); --heat-rgb:183,243,107;
  --good:#6ee7a0; --good-soft:rgba(110,231,160,.14); --warn:#ffb454; --warn-soft:rgba(255,180,84,.15);
  --on-bad:#1a0704; --bad:#ff7a6b; --bad-soft:rgba(255,122,107,.15); --info:#75bfff; --info-soft:rgba(117,191,255,.14);
  --c1:#b7f36b; --c2:#75bfff; --c3:#ffb454; --c4:#c39bff; --c5:#5fe0c0;
  --cell-empty:rgba(255,255,255,.07); --track:rgba(255,255,255,.08); --hover:rgba(255,255,255,.04);
  --shadow:0 1px 2px rgba(0,0,0,.35); --focus:#b7f36b; --overlay:rgba(0,0,0,.6);
  --r:14px; --r-sm:10px;
  --font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:#f4f6f2; --bg-2:#ffffff; --surface:#ffffff; --surface-2:#f0f3ee; --surface-3:#e4e9e1;
  --text:#152018; --muted:#5c6b60; --line:rgba(20,40,25,.11); --line-strong:rgba(20,40,25,.22);
  --accent:#b7f36b; --on-accent:#10200a; --accent-text:#3a7410; --accent-soft:rgba(95,160,30,.13); --heat-rgb:95,170,30;
  --good:#17803f; --good-soft:rgba(23,128,63,.12); --warn:#a85f00; --warn-soft:rgba(217,130,0,.14);
  --on-bad:#ffffff; --bad:#c42f22; --bad-soft:rgba(212,56,42,.11); --info:#1d62b8; --info-soft:rgba(43,123,214,.11);
  --c1:#68ae1c; --c2:#2b7bd6; --c3:#d98200; --c4:#8a5cf0; --c5:#0e9c80;
  --cell-empty:rgba(20,40,25,.08); --track:rgba(20,40,25,.09); --hover:rgba(20,40,25,.04);
  --shadow:0 1px 2px rgba(20,40,25,.08); --focus:#2b7a0c; --overlay:rgba(10,20,12,.45);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg:#f4f6f2; --bg-2:#ffffff; --surface:#ffffff; --surface-2:#f0f3ee; --surface-3:#e4e9e1;
    --text:#152018; --muted:#5c6b60; --line:rgba(20,40,25,.11); --line-strong:rgba(20,40,25,.22);
    --accent:#b7f36b; --on-accent:#10200a; --accent-text:#3a7410; --accent-soft:rgba(95,160,30,.13); --heat-rgb:95,170,30;
    --good:#17803f; --good-soft:rgba(23,128,63,.12); --warn:#a85f00; --warn-soft:rgba(217,130,0,.14);
    --on-bad:#ffffff; --bad:#c42f22; --bad-soft:rgba(212,56,42,.11); --info:#1d62b8; --info-soft:rgba(43,123,214,.11);
    --c1:#68ae1c; --c2:#2b7bd6; --c3:#d98200; --c4:#8a5cf0; --c5:#0e9c80;
    --cell-empty:rgba(20,40,25,.08); --track:rgba(20,40,25,.09); --hover:rgba(20,40,25,.04);
    --shadow:0 1px 2px rgba(20,40,25,.08); --focus:#2b7a0c; --overlay:rgba(10,20,12,.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-msg { color: var(--muted); padding: 24px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 12px 14px; background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav svg, .tabbar svg, .btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-foot .who { padding: 4px 10px 8px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.side-foot button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; background: none; border-radius: var(--r-sm); color: var(--muted); font-weight: 500; text-align: left; }
.side-foot button:hover { background: var(--hover); color: var(--text); }
.side-foot svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.main { min-width: 0; padding: 26px 32px 56px; }
.content { max-width: 1260px; margin: 0 auto; }
.topbar, .tabbar, .scrim { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; line-height: 1.2; letter-spacing: -.015em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ago { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.crumb { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }
.help { color: var(--muted); font-size: 12.5px; max-width: 78ch; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { background: var(--bad); border-color: transparent; color: var(--on-bad); }
.btn.danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.outline-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.in, select.in, textarea.in { width: 100%; min-height: 36px; padding: 6px 11px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--text); }
textarea.in { resize: vertical; min-height: 72px; line-height: 1.45; }
.in::placeholder { color: var(--muted); opacity: .8; }
.in:focus-visible { outline-offset: 0; border-color: var(--focus); }
select.in { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { width: 140px; }
.filters .field.grow { flex: 1 1 200px; width: auto; max-width: 280px; }
.filters .field.narrow { width: 118px; }
.only-m { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button, .seg a { min-height: 32px; padding: 0 12px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.seg button + button, .seg a + a { border-left: 1px solid var(--line); }
.seg button:hover, .seg a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-current="true"], .seg [aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
.seg .count { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--track); color: var(--text); font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--track); padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent-text); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--accent-text); }
.switch:disabled { opacity: .5; }

/* ---------- cards & KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card > .card-h { font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card > h2 small, .card-h small { font-weight: 400; color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 14px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; color: inherit; }
a.kpi:hover { border-color: var(--line-strong); text-decoration: none; background: var(--surface-2); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.kpi .k-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .k-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi .spark { margin-top: 6px; width: 100%; display: block; }
.kpi.warn { border-color: var(--warn); background: var(--warn-soft); }
.kpi.warn .k-value { color: var(--warn); }
.kpi.bad .k-value { color: var(--bad); }
.kpi .flag { position: absolute; top: 12px; right: 12px; }
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); margin-bottom: 14px; }
.alert strong { color: var(--warn); }
.alert.bad { border-color: var(--bad); background: var(--bad-soft); }
.alert.bad strong { color: var(--bad); }
.alert .grow { flex: 1; min-width: 0; }
.alert-list { display: flex; flex-direction: column; gap: 8px; }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; line-height: 1.6; background: var(--track); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.strong { border-color: currentColor; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--track); border: 1.5px solid var(--muted); vertical-align: middle; }
.dot.on { background: var(--good); border-color: var(--good); }
.stars { display: inline-flex; gap: 1px; color: var(--warn); }
.stars svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.stars svg.on { fill: currentColor; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line-strong); color: var(--muted); }
.pill.on { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl thead th { position: sticky; top: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface); white-space: nowrap; padding-top: 11px; padding-bottom: 11px; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tr.click { cursor: pointer; }
.tbl tr.flagged { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
.tbl .sort { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; font-weight: inherit; }
.tbl .sort:hover { color: var(--text); }
.tbl .sort .arr { font-size: 10px; opacity: .35; }
.tbl th[aria-sort="ascending"] .arr, .tbl th[aria-sort="descending"] .arr { opacity: 1; color: var(--accent-text); }
.tbl th[aria-sort="ascending"], .tbl th[aria-sort="descending"] { color: var(--text); }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 8px; align-items: center; }
.totals { display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 12px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.totals div { display: flex; flex-direction: column; }
.totals span { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.totals b { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.totals .push { margin-left: auto; justify-content: center; }
.heat td.h { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 70px; }
.heat td.h.nil { color: var(--muted); font-weight: 400; }

/* ---------- states ---------- */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--hover), transparent); animation: shimmer 1.4s infinite; }
.skel.card-s { height: 92px; border-radius: var(--r); }
.skel.line { height: 14px; margin: 10px 0; }
.skel.block { height: 220px; border-radius: var(--r); }
.state { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 44px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r); color: var(--muted); }
.state strong { color: var(--text); font-size: 15px; }
.state.err { border-style: solid; border-color: var(--bad); background: var(--bad-soft); }
.state svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* ---------- charts ---------- */
.chart { position: relative; padding-top: 4px; }
.chart-svg, .spark { display: block; width: 100%; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-base { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-ymax { position: absolute; left: 0; top: -9px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface); padding-right: 6px; line-height: 1.2; }
.chart-x { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover); }
.chart .col:hover rect:not(.hit) { filter: brightness(1.12); }
.area-fill { opacity: .16; }
.area-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; fill: none; }
.over { opacity: .95; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { font-variant-numeric: tabular-nums; }
.stackbar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--track); gap: 2px; }
.stackbar .seg { min-width: 3px; }
.stackbar.tall { height: 22px; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.hb-row { display: grid; grid-template-columns: minmax(70px, 28%) minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.hb-label { min-width: 0; overflow-wrap: anywhere; }
.hb-label small { display: block; color: var(--muted); font-size: 11.5px; }
.hb-track { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.hb-fill { height: 100%; border-radius: 999px; }
.hb-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 3ch; }
.heatgrid { display: block; width: 100%; max-width: 360px; height: auto; }
.heatgrid .cell { fill: var(--cell-empty); }
.heatgrid .cell.on { fill: var(--c1); }
.donut { width: 130px; height: 130px; flex: none; transform: rotate(0); }
.donut-track { stroke: var(--track); }
.donut-num { fill: var(--text); font-size: 6.5px; font-weight: 700; font-family: var(--font); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.toggle-row { display: flex; align-items: center; gap: 8px; }

/* ---------- misc blocks ---------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 18px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; padding: 2px 10px; border-radius: 8px; background: var(--surface-3); font-family: var(--mono); font-size: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); }
details.meta summary { cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: min(320px, 56vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.meta[open] summary { white-space: normal; }
details.meta pre { margin: 6px 0 0; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-sm); font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; }
.fb { display: flex; flex-direction: column; gap: 10px; }
.fb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 12.5px; color: var(--muted); }
.fb-msg { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; }
.fb-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.fb-note { display: flex; gap: 8px; align-items: flex-start; }
.fb-note textarea { flex: 1; min-height: 40px; height: 40px; }
.ping-out { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(60% 50% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 28px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card .brand { padding: 0; }
.login-card h1 { font-size: 20px; letter-spacing: -.01em; }
.form-error { color: var(--bad); font-size: 13px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--bad-soft); }
.form-error:empty { display: none; }

/* ---------- dialog & toast ---------- */
dialog { padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); color: var(--text); width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 70px rgba(0,0,0,.45); }
dialog::backdrop { background: var(--overlay); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 22px 22px 18px; max-height: calc(100vh - 34px); overflow-y: auto; }
.dlg h2 { font-size: 17px; letter-spacing: -.01em; }
.dlg p { color: var(--muted); }
.dlg .foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.dlg .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); border-left: 4px solid var(--accent-text); border-radius: var(--r-sm); box-shadow: 0 8px 28px rgba(0,0,0,.35); font-size: 13.5px; animation: toast-in .18s ease-out; }
.toast.err { border-left-color: var(--bad); }
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast button { border: 0; background: none; color: var(--muted); padding: 0 2px; font-size: 18px; line-height: 1; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skel::after { display: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-21, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 8px 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; flex: 1; min-width: 0; }
  .topbar .t-title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; border-radius: var(--r-sm); color: var(--text); }
  .icon-btn:hover { background: var(--hover); }
  .icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; height: auto; width: min(300px, 86vw); z-index: 50; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; padding-top: max(18px, env(safe-area-inset-top)); }
  .nav-open .side { transform: none; visibility: visible; transition: transform .2s ease; }
  .nav a, .side-foot button { min-height: 46px; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding-bottom: env(safe-area-inset-bottom); background: var(--bg-2); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--accent-text); }
  .main { padding: 16px 14px calc(78px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 20px; }
  .btn, .in, select.in { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .seg button, .seg a { min-height: 40px; }
  .switch { height: 28px; width: 48px; }
  .switch::after { width: 22px; height: 22px; }
  .switch[aria-checked="true"]::after { transform: translateX(20px); }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi .k-value { font-size: 21px; }
  .grid.cols-2, .grid.cols-3.keep { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .filters .field, .filters .field.grow, .filters .field.narrow { width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); max-width: none; }
  .filters .field.grow { flex-basis: 100%; width: 100%; }
  .only-m { display: flex; }
  .tbl.rsp thead { display: none; }
  .tbl-wrap.rsp-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tbl.rsp, .tbl.rsp tbody, .tbl.rsp tr, .tbl.rsp td { display: block; }
  .tbl.rsp tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .tbl.rsp tr.flagged { background: var(--warn-soft); border-color: var(--warn); box-shadow: none; }
  .tbl.rsp td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 4px 0; border: 0; text-align: right; }
  .tbl.rsp td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .tbl.rsp td:not([data-label])::before { display: none; }
  .tbl.rsp td:not([data-label]) { justify-content: flex-start; text-align: left; }
  .tbl.rsp td.r { text-align: right; }
  .hb-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .hb-label { grid-column: 1; }
  .hb-val { grid-column: 2; grid-row: 1; }
  .hb-track { grid-column: 1 / -1; }
  .toasts { bottom: calc(70px + env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; }
  .dlg .two { grid-template-columns: 1fr; }
  .totals .push { margin-left: 0; }
  .fb-note { flex-direction: column; }
  .fb-note textarea { width: 100%; }
}
.main:focus { outline: none; }
.sr-only-label { position: absolute; left: -9999px; }
.cell-link { font-weight: 600; }
.mini-track { width: 120px; max-width: 100%; }
.nowrap-r { white-space: nowrap; text-align: right; }
.crumb svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge svg, .pill svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.alert > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.alert.bad > svg { stroke: var(--bad); }
.tabbar svg { width: 21px; height: 21px; }
