/* PYRES console. Design tokens, layout and components; no framework.
   Theme: light by default, dark when the system asks for it, unless
   <html data-theme="light|dark"> (set by theme.js from localStorage) overrides it. */

:root {
  color-scheme: light;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-pill: 999px;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs: .9375rem; --fs-lg: 1.0625rem; --fs-xl: 1.375rem; --fs-2xl: 1.875rem;
  --sidebar-w: 252px;

  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f7f8fa; --surface-3: #eceef2;
  --border: #e2e5ea; --border-strong: #c9cfd8;
  --text: #141821; --text-2: #3d4556; --muted: #5f687a;
  --accent: #2554d4; --accent-hover: #1c44b0; --accent-fg: #ffffff; --accent-soft: #e9effd; --accent-line: #b8caf6;
  --ok: #12764a; --ok-soft: #e1f3e9;
  --warn: #965800; --warn-soft: #fcefd6;
  --bad: #c0281c; --bad-soft: #fde8e6;
  --info: #6a3ccc; --info-soft: #efe9fd;
  --neutral: #5f687a; --neutral-soft: #eef0f3;
  --grid: #eceef2;
  --ring: rgba(37, 84, 212, .4);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 16px -4px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px -8px rgba(16, 24, 40, .22);
  --term-bg: #0d1117; --term-fg: #d6dde8; --term-dim: #8d97aa; --term-ok: #6fd39b; --term-bad: #ff8a80; --term-cmd: #93b6ff;
  --tile-filter: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1016; --surface: #141a22; --surface-2: #19202a; --surface-3: #222a36;
    --border: #262e3a; --border-strong: #3a4454;
    --text: #e7eaf0; --text-2: #bcc4d2; --muted: #919bad;
    --accent: #7aa2ff; --accent-hover: #9ab8ff; --accent-fg: #0b1222; --accent-soft: #1a2747; --accent-line: #34508f;
    --ok: #4fc68d; --ok-soft: #10301f;
    --warn: #f2ad42; --warn-soft: #36270e;
    --bad: #ff7d73; --bad-soft: #3c1917;
    --info: #b59cfc; --info-soft: #271f45;
    --neutral: #9aa3b4; --neutral-soft: #222a36;
    --grid: #222a36;
    --ring: rgba(122, 162, 255, .45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -6px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 44px -8px rgba(0, 0, 0, .6);
    --term-bg: #080b10;
    --tile-filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1016; --surface: #141a22; --surface-2: #19202a; --surface-3: #222a36;
  --border: #262e3a; --border-strong: #3a4454;
  --text: #e7eaf0; --text-2: #bcc4d2; --muted: #919bad;
  --accent: #7aa2ff; --accent-hover: #9ab8ff; --accent-fg: #0b1222; --accent-soft: #1a2747; --accent-line: #34508f;
  --ok: #4fc68d; --ok-soft: #10301f;
  --warn: #f2ad42; --warn-soft: #36270e;
  --bad: #ff7d73; --bad-soft: #3c1917;
  --info: #b59cfc; --info-soft: #271f45;
  --neutral: #9aa3b4; --neutral-soft: #222a36;
  --grid: #222a36;
  --ring: rgba(122, 162, 255, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -6px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 44px -8px rgba(0, 0, 0, .6);
  --term-bg: #080b10;
  --tile-filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7);
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs)/1.5 var(--font); background: var(--bg); color: var(--text);
       -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: var(--fs-xl); font-weight: 650; margin: 0; }
h2 { font-size: var(--fs-lg); font-weight: 620; margin: 0 0 var(--s-3); }
h3 { font-size: var(--fs); font-weight: 620; margin: var(--s-4) 0 var(--s-2); }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s-3);
      overflow: auto; margin: 0; font-size: var(--fs-sm); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
pre.tall { max-height: 460px; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
      border-radius: 5px; font-size: .72rem; line-height: 1.5; color: var(--muted); text-align: center; background: var(--surface); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.err { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-all; max-width: 420px; }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s-3); top: -60px; z-index: 100; padding: var(--s-2) var(--s-3); background: var(--accent);
        color: var(--accent-fg); border-radius: var(--r-sm); }
.skip:focus { top: var(--s-3); }

/* icons from /static/icons.svg */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------ layout */
body.app { padding-left: var(--sidebar-w); min-height: 100vh;
  /* the sidebar column continues below the fixed sidebar (overscroll, full-page captures) */
  background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px),
    var(--border) var(--sidebar-w), var(--bg) var(--sidebar-w)) var(--bg); }
.main { min-width: 0; padding: var(--s-5) var(--s-6) var(--s-7); max-width: 1480px; width: 100%; }
body.bare .main { max-width: none; padding: 0; }
/* vertical rhythm between the blocks of a page (grids and stacks use gap) */
.main > * + *, .tab-panel > * + * { margin-top: var(--s-4); }

.sidebar { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); display: flex; flex-direction: column; gap: var(--s-4);
           padding: var(--s-4) var(--s-3); background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-2); color: var(--text); }
.side-brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none;
        background: linear-gradient(140deg, #3a6cf0, #2242b8); color: #fff; box-shadow: 0 2px 6px rgba(37, 84, 212, .35); }
.logo .i { stroke-width: 1.6; width: 20px; height: 20px; }
.brand-name { font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.brand-sub { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; letter-spacing: 0; }

.side-search { position: relative; margin: 0 var(--s-1); }
.side-search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.side-search input { padding-left: 34px; padding-right: 30px; background: var(--surface-2); height: 36px; }
.side-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.side-search input:focus + kbd { display: none; }

.side-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group { margin: var(--s-4) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
             text-transform: uppercase; letter-spacing: .06em; }
.nav-link { display: flex; align-items: center; gap: var(--s-3); padding: 7px var(--s-3); border-radius: var(--r-sm);
            color: var(--text-2); font-weight: 520; font-size: .9rem; width: 100%; border: 0; background: none; text-align: left;
            font-family: inherit; cursor: pointer; margin: 0; }
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.nav-link.on .i { stroke-width: 2; }
.nav-link .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--bad);
                   color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.nav-link.soon { cursor: default; color: var(--muted); }
.nav-link.soon:hover { background: none; color: var(--muted); }
.soon-tag { margin-left: auto; font-size: .66rem; font-weight: 600; padding: 1px 6px; border-radius: var(--r-pill);
            border: 1px dashed var(--border-strong); color: var(--muted); text-transform: lowercase; }
.side-foot { margin-top: auto; display: grid; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.side-foot form { margin: 0; }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: var(--r-sm);
                background: var(--surface-3); }
.theme-switch button { margin: 0; display: flex; align-items: center; justify-content: center; gap: 4px; height: 28px;
                       padding: 0 6px; border: 0; border-radius: 5px; background: none; color: var(--muted); font-size: var(--fs-xs);
                       font-weight: 560; cursor: pointer; }
.theme-switch button:hover { color: var(--text); background: none; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-switch .i { width: 14px; height: 14px; }

.topbar { display: none; }
.scrim { display: none; }

/* page header and breadcrumbs */
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; list-style: none; margin: 0 0 var(--s-3); padding: 0;
             font-size: var(--fs-sm); color: var(--muted); }
.crumbs li { display: flex; align-items: center; gap: 2px; min-width: 0; }
.crumbs li + li::before { content: ""; width: 6px; height: 6px; margin: 0 8px 0 4px; opacity: .6;
  border-right: 1.5px solid currentColor; border-top: 1.5px solid currentColor; transform: rotate(45deg); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text-2); font-weight: 560; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-5);
             margin-bottom: var(--s-5); }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.page-sub { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--fs-sm); max-width: 75ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5);
        box-shadow: var(--shadow-sm); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-h { padding: var(--s-4) var(--s-5) 0; }
.card.flush > .card-foot { padding: var(--s-3) var(--s-5); margin-top: 0; }
.card.flush > .card-sub { padding: 0 var(--s-5); margin: 0 0 var(--s-3); }
.card.flush > .empty { padding-top: var(--s-5); }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.card-h h2 { margin: 0; display: flex; align-items: center; gap: var(--s-2); }
.card-h h2 .i { color: var(--muted); }
.card-h .links { display: flex; gap: var(--s-3); font-size: var(--fs-sm); }
.card-sub { color: var(--muted); font-size: var(--fs-sm); margin: calc(var(--s-2) * -1) 0 var(--s-3); }
.card-foot { border-top: 1px solid var(--border); margin-top: var(--s-3); padding-top: var(--s-3); font-size: var(--fs-sm); color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: var(--s-4); align-items: start; }
.grid.stretch { align-items: stretch; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.stack { display: grid; gap: var(--s-4); align-content: start; min-width: 0; }
.span-all { grid-column: 1 / -1; }

/* collapsible sections (crash report) */
details.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
details.section > summary { list-style: none; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-5);
                            cursor: pointer; border-radius: var(--r-lg); }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
details.section > summary::after { content: ""; margin: 0 4px 0 auto; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transition: transform .15s; transform: rotate(-45deg); }
details.section[open] > summary::after { transform: rotate(45deg) translate(-2px, -2px); }
details.section > summary:hover { background: var(--surface-2); }
details.section > .section-body { padding: 0 var(--s-5) var(--s-5); min-width: 0; overflow-x: auto; }

/* ------------------------------------------------------------ KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: var(--s-4); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border);
       border-radius: var(--r-lg); padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); box-shadow: var(--shadow-sm); min-width: 0; overflow: hidden; color: var(--text); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent-line); }
.kpi.ok::before { background: var(--ok); } .kpi.warn::before { background: var(--warn); } .kpi.bad::before { background: var(--bad); }
.kpi-label { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 560; }
.kpi-label .i { width: 16px; height: 16px; }
.kpi-value { font-size: var(--fs-2xl); font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: var(--s-1); }
.kpi-value small { font-size: .5em; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.kpi-sub { color: var(--muted); font-size: var(--fs-xs); }
.kpi .meter { margin-top: var(--s-2); }
.kpi-value.small { font-size: var(--fs-lg); font-weight: 620; letter-spacing: 0; padding: 6px 0 4px; }

/* thin progress bar: svg with a track rect and a value rect (width attribute) */
.meter { display: block; width: 100%; height: 6px; }
.meter .track { fill: var(--surface-3); }
.meter .val { fill: var(--accent); }
.meter .val.ok { fill: var(--ok); } .meter .val.warn { fill: var(--warn); } .meter .val.bad { fill: var(--bad); }
.meter .tick { stroke: var(--text-2); stroke-width: 1.5; vector-effect: non-scaling-stroke; opacity: .55; }
.meter.stackbar { height: 8px; margin-top: var(--s-2); }

/* ------------------------------------------------------------ badges, tags, chips */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs);
         font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral); vertical-align: middle; }
h1 .badge { font-size: var(--fs-sm); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.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); }
.badge.neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge.outline { background: none; border: 1px solid var(--border-strong); color: var(--text-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; margin: 2px 4px 2px 0; padding: 0 8px; border-radius: var(--r-pill);
       border: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-xs); line-height: 20px; background: var(--surface-2);
       font-weight: 520; white-space: nowrap; }
a.tag:hover { border-color: var(--accent-line); color: var(--accent); text-decoration: none; }
.tag.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.tag.bad { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.tag.small { font-size: .7rem; line-height: 17px; padding: 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-pill);
        border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 540; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .n { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on .n { color: inherit; opacity: .75; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.neutral { background: var(--neutral); }
.dot.info { background: var(--info); } .dot.accent { background: var(--accent); }
a.badge:hover { text-decoration: none; filter: brightness(.96); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.toolbar form { display: flex; gap: var(--s-2); align-items: center; margin: 0; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; height: 34px; }

/* ------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
     background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono.small { white-space: nowrap; } /* versions like 1.6.1-pyres11 must not break at the hyphen */
td.mono.small .cell-sub { white-space: normal; word-break: break-all; }
.card > .table-wrap, .card > table { margin: 0 calc(var(--s-5) * -1); width: calc(100% + 2 * var(--s-5)); }
.card > .table-wrap:last-child { margin-bottom: calc(var(--s-5) * -1); }
.card > .table-wrap th:first-child, .card > .table-wrap td:first-child { padding-left: var(--s-5); }
.card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: var(--s-5); }
.card.flush > .table-wrap { margin: 0; width: 100%; }
.card.flush > .table-wrap th:first-child, .card.flush > .table-wrap td:first-child { padding-left: var(--s-5); }
table.compact th, table.compact td { padding: 6px 10px; }
table.regs td { padding: 3px 10px; border: 0; font-family: var(--mono); }
.cell-title { font-weight: 560; color: var(--text); }
.cell-sub { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.dev-cell { display: flex; align-items: flex-start; gap: var(--s-3); min-width: 200px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--neutral); box-shadow: 0 0 0 3px var(--neutral-soft); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

dl.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 8px var(--s-4); margin: 0 0 var(--s-3); font-size: var(--fs-sm); }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; min-width: 0; }

/* ------------------------------------------------------------ forms and buttons */
label { display: block; margin-bottom: var(--s-3); font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
input, textarea, select { width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; resize: vertical; }
input[type=file] { padding: 6px; background: var(--surface-2); }
input[type=file]::file-selector-button { margin-right: 10px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: var(--s-2); height: 34px;
  padding: 0 14px; border: 1px solid transparent; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-fg);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s; }
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn { margin-top: 0; }
.btn-secondary, button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover, button.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
button.danger, .btn-danger { background: var(--bad); color: #fff; }
button.danger:hover, .btn-danger:hover { background: var(--bad); filter: brightness(.92); }
button.danger-ghost { background: none; color: var(--bad); border-color: var(--bad); }
button.danger-ghost:hover { background: var(--bad-soft); }
.btn-sm, button.small { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
button.link { background: none; color: var(--accent); padding: 0; margin: 0; height: auto; border: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
.icon-btn { margin: 0; width: 36px; height: 36px; padding: 0; background: none; color: var(--text-2); border: 1px solid transparent; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
form.inline { display: inline; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: flex-end; margin-top: var(--s-2); }
.row > input, .row > select { flex: 1 1 200px; width: auto; }
.row > button { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 0 var(--s-4); }
.hint { color: var(--muted); font-size: var(--fs-xs); margin-top: var(--s-2); }

/* popover menus built on <details> */
.pop { position: relative; display: inline-block; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: max(280px, 100%); padding: var(--s-3);
            background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.pop-body form { margin: 0; }
.pop-body .menu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: 7px var(--s-2); border-radius: var(--r-sm);
                       color: var(--text); font-size: var(--fs-sm); background: none; border: 0; margin: 0; height: auto; font-weight: 500; justify-content: flex-start; }
.pop-body .menu-item:hover { background: var(--surface-3); text-decoration: none; }
.pop-body .menu-item.danger { color: var(--bad); }
.pop-body .menu-item .i { color: var(--muted); }
.pop-body hr { margin: var(--s-2) 0; }

/* ------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 0 0 var(--s-4);
        scrollbar-width: none; position: sticky; top: 0; z-index: 5; background: var(--bg); }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); font-weight: 560; font-size: var(--fs-sm);
       border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .i { width: 16px; height: 16px; }
.tab .n { font-size: var(--fs-xs); padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); }
.tab .n.bad { background: var(--bad-soft); color: var(--bad); }
.tab-panel { scroll-margin-top: 60px; }
.tab-panel + .tab-panel { margin-top: var(--s-6); }
.js .tab-panel + .tab-panel { margin-top: 0; }
/* with JS, only the first panel shows until app.js has picked the tab (no flash of every panel) */
.js .tab-panels:not([data-ready]) > .tab-panel + .tab-panel { display: none; }

/* ------------------------------------------------------------ device header */
.dev-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.dev-title { display: flex; gap: var(--s-4); align-items: flex-start; min-width: 0; }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; flex: none;
          background: var(--accent-soft); color: var(--accent); }
.avatar .i { width: 26px; height: 26px; stroke-width: 1.5; }
.dev-title h1 { word-break: break-word; }
.dev-meta { display: flex; flex-wrap: wrap; gap: 6px var(--s-4); margin-top: var(--s-2); color: var(--muted); font-size: var(--fs-sm); align-items: center; }
.dev-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.dev-meta .i { width: 15px; height: 15px; }
.dev-meta .mono { color: var(--text-2); }
.dev-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ------------------------------------------------------------ gauges (health) */
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: var(--s-4); }
.gauge { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); box-shadow: var(--shadow-sm); min-width: 0; }
.gauge-label { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 560; }
.gauge-label .i { width: 16px; height: 16px; }
.gauge-value { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-2) 0; font-size: var(--fs-xl);
               font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.gauge-value small { font-size: var(--fs-sm); color: var(--muted); font-weight: 560; }
.gauge-sub { color: var(--muted); font-size: var(--fs-xs); margin-top: var(--s-2); }
.bars4 { width: 38px; height: 26px; }
.bars4 rect { fill: var(--surface-3); }
.bars4.ok rect.on { fill: var(--ok); } .bars4.warn rect.on { fill: var(--warn); } .bars4.bad rect.on { fill: var(--bad); }
.segs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-top: var(--s-2); }
.seg { height: 8px; border-radius: 3px; background: var(--surface-3); }
.segs.ok .seg.on { background: var(--ok); } .segs.warn .seg.on { background: var(--warn); } .segs.bad .seg.on { background: var(--bad); }
.segs.neutral .seg.on { background: var(--neutral); }
.seg-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; font-size: .68rem; color: var(--muted); text-align: center; margin-top: 3px; }
.split { display: block; width: 100%; height: 8px; margin-top: var(--s-2); }
.split .tx { fill: var(--accent); } .split .rx { fill: var(--info); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.legend-dot.tx { background: var(--accent); } .legend-dot.rx { background: var(--info); }

/* ------------------------------------------------------------ charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: var(--s-4); }
.chart { margin: 0; border: 1px solid var(--border); border-radius: var(--r); padding: var(--s-3) var(--s-4); background: var(--surface); min-width: 0; }
.chart figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-2); margin-bottom: var(--s-2); font-size: var(--fs-sm); }
.chart figcaption .name { color: var(--muted); font-weight: 560; }
.chart figcaption strong { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.chart figcaption .stats { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .09; }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart .axis, .chart .gridline { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spread { display: flex; justify-content: space-between; gap: var(--s-2); color: var(--muted); font-size: var(--fs-xs); margin-top: 4px; }
.period { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--surface-3); }
.period a { padding: 3px 10px; border-radius: 5px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.period a:hover { color: var(--text); text-decoration: none; }
.period a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* bar chart of crashes per day */
.daybars { width: 100%; height: auto; display: block; margin-bottom: var(--s-2); }
.daybars .bar { fill: var(--bad); opacity: .85; }
.daybars .bar.zero { fill: var(--surface-3); opacity: 1; }
.daybars .base { stroke: var(--border); }
.daybars text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
/* sparkline of crash recency (14 days) */
.spark { width: 84px; height: 22px; display: block; }
.spark rect { fill: var(--surface-3); }
.spark rect.on { fill: var(--bad); }
/* horizontal distribution bars (firmware versions) */
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.dist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s-3); font-size: var(--fs-sm); align-items: center; }
.dist .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-2); }
.dist .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--fs-xs); }
.dist .meter { grid-column: 1 / -1; height: 8px; }

/* simple link lists (dashboard) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { display: block; font-weight: 560; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
a.title:hover { color: var(--accent); }
.list .sub { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .end { flex: none; color: var(--muted); font-size: var(--fs-xs); text-align: right; white-space: nowrap; }
.list .ic { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.list .ic.bad { background: var(--bad-soft); color: var(--bad); } .list .ic.warn { background: var(--warn-soft); color: var(--warn); }
.list .ic.ok { background: var(--ok-soft); color: var(--ok); } .list .ic.info { background: var(--info-soft); color: var(--info); }
.list .ic .i { width: 16px; height: 16px; }

/* empty states */
.empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-6) var(--s-4); text-align: center; color: var(--muted); }
.empty .i { width: 34px; height: 34px; stroke-width: 1.4; color: var(--border-strong); }
.empty-title { color: var(--text); font-weight: 600; }
.empty p { margin: 0; max-width: 56ch; font-size: var(--fs-sm); }
.callout { margin-bottom: var(--s-3); display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--surface-2);
           border: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-2); }
.callout .i { color: var(--muted); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); } .callout.warn .i { color: var(--warn); }
.callout.bad { background: var(--bad-soft); border-color: transparent; color: var(--text); } .callout.bad .i { color: var(--bad); }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 60; right: var(--s-5); bottom: var(--s-5); display: grid; gap: var(--s-2); width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-radius: var(--r);
         background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); box-shadow: var(--shadow-lg);
         font-size: var(--fs-sm); animation: toast-in .22s ease-out; }
.toast.err { border-left-color: var(--bad); }
.toast > .i { margin-top: 1px; color: var(--ok); }
.toast.err > .i { color: var(--bad); }
.toast-msg { flex: 1; color: var(--text); padding-top: 1px; }
.toast-x { margin: 0; width: 26px; height: 26px; padding: 0; background: none; color: var(--muted); border-radius: 6px; }
.toast-x:hover { background: var(--surface-3); color: var(--text); }
.toast-x .i { width: 15px; height: 15px; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ maps */
.map { position: relative; width: 100%; height: 340px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-3);
       overflow: hidden; z-index: 0; }
.map.sm { height: 300px; }
.map.full { height: calc(100vh - 170px); min-height: 420px; border-radius: var(--r-lg); }
.card > .map:last-child { margin-bottom: 0; }
.leaflet-container { font: inherit; font-size: var(--fs-sm); background: var(--surface-3); }
.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-bar a, .leaflet-control-layers { background: var(--surface); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: var(--r); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); font-weight: 560; }
.leaflet-tooltip-top::before { border-top-color: var(--surface); }
/* device markers (L.circleMarker className) coloured by status */
path.mk { stroke: #fff; stroke-width: 2.5; fill-opacity: 1; }
path.mk-ok { fill: var(--ok); } path.mk-silent { fill: var(--warn); } path.mk-crashed { fill: var(--bad); }
path.mk-revoked, path.mk-never { fill: var(--neutral); }
path.acc { stroke-width: 1; stroke-opacity: .55; fill-opacity: .1; pointer-events: none; }
path.acc-ok { fill: var(--ok); stroke: var(--ok); } path.acc-silent { fill: var(--warn); stroke: var(--warn); }
path.acc-crashed { fill: var(--bad); stroke: var(--bad); } path.acc-revoked, path.acc-never { fill: var(--neutral); stroke: var(--neutral); }
/* position history (track) */
path.track { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-opacity: .45; stroke-dasharray: 4 5; }
path.fix { stroke-width: 2; fill-opacity: 1; }
path.fix-gnss { fill: var(--accent); stroke: #fff; }
path.fix-cell { fill: var(--surface); stroke: var(--info); stroke-width: 2.5; }
path.fix-newest { stroke-width: 3; }
path.fix-newest.fix-gnss { fill: var(--accent); }
path.fix-newest.fix-cell { fill: var(--info); stroke: #fff; }
path.halo { fill: var(--accent); fill-opacity: .18; stroke: var(--accent); stroke-opacity: .5; stroke-width: 1.5; pointer-events: none; }
path.acc-gnss { fill: var(--accent); stroke: var(--accent); }
path.acc-cell { fill: var(--info); stroke: var(--info); stroke-dasharray: 5 4; }
path.acc.old { fill-opacity: .03; stroke-opacity: .25; }
.map-legend { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px;
              box-shadow: var(--shadow); font-size: var(--fs-xs); line-height: 1.7; }
.map-legend .lg { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.map-legend .sw { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); flex: none; }
.sw.ok { background: var(--ok); } .sw.silent { background: var(--warn); } .sw.crashed { background: var(--bad); } .sw.revoked, .sw.never { background: var(--neutral); }
.sw.gnss { background: var(--accent); } .sw.cell { background: var(--surface); border-color: var(--info) !important; }
.sw.newest { background: var(--accent); box-shadow: 0 0 0 4px rgba(37, 84, 212, .25); }
.map-msg { position: absolute; inset: auto 0 0 0; top: 50%; transform: translateY(-50%); z-index: 500; margin: 0 auto; width: max-content;
           max-width: 85%; padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--surface); color: var(--text-2);
           border: 1px solid var(--border); box-shadow: var(--shadow); font-size: var(--fs-sm); text-align: center; }
.pop-card { display: grid; gap: 6px; font-size: var(--fs-sm); }
.pop-card .pc-title { font-weight: 650; font-size: var(--fs); color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pop-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0; }
.pop-card dt { color: var(--muted); }
.pop-card dd { margin: 0; }
.pop-card a.btn { margin-top: 4px; color: var(--accent-fg); height: 30px; }
.map-stats { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ------------------------------------------------------------ events timeline */
.timeline { display: grid; gap: var(--s-5); }
.tl-day h3 { position: sticky; top: 0; z-index: 2; margin: 0 0 var(--s-2); padding: var(--s-2) 0; background: var(--bg);
             font-size: var(--fs-sm); color: var(--muted); font-weight: 600; text-transform: capitalize; }
.tl-day ol { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.tl-item { display: grid; grid-template-columns: 58px 22px minmax(0, 1fr); gap: 0 var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); }
.tl-item:first-child { border-top: 0; }
.tl-item > time { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl-mark { width: 10px; height: 10px; border-radius: 50%; margin: 5px auto 0; background: var(--neutral); box-shadow: 0 0 0 3px var(--neutral-soft); }
.tl-mark.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); } .tl-mark.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.tl-mark.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); } .tl-mark.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.tl-mark.accent { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-head { display: flex; flex-wrap: wrap; gap: 4px var(--s-2); align-items: center; font-size: var(--fs-sm); }
.tl-kind { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600; color: var(--text); }
.tl-detail { color: var(--text-2); font-size: var(--fs-sm); word-break: break-word; margin-top: 2px; }

/* ------------------------------------------------------------ terminal */
.term { background: var(--term-bg); color: var(--term-fg); border-radius: var(--r-lg); border: 1px solid #1e2632; overflow: hidden; box-shadow: var(--shadow); }
.term-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: 10px var(--s-4); background: rgba(255, 255, 255, .04);
            border-bottom: 1px solid rgba(255, 255, 255, .07); font-size: var(--fs-xs); color: var(--term-dim); }
.term-bar .lights { display: inline-flex; gap: 6px; margin-right: var(--s-2); }
.term-bar .lights span { width: 10px; height: 10px; border-radius: 50%; background: #3a4352; }
.term-bar .lights span:first-child { background: #ff5f57; } .term-bar .lights span:nth-child(2) { background: #febc2e; } .term-bar .lights span:nth-child(3) { background: #28c840; }
.term-bar .title { font-family: var(--mono); color: var(--term-fg); }
#term-state { margin-left: auto; }
.term-log { height: min(62vh, 640px); overflow-y: auto; padding: var(--s-4); font-family: var(--mono); font-size: 13px; line-height: 1.55; scroll-behavior: smooth; }
.term-entry + .term-entry { margin-top: var(--s-4); }
.term-cmd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-3); }
.term-prompt { color: var(--term-ok); font-weight: 700; }
.term-prompt b { color: var(--term-cmd); font-weight: 600; }
.term-meta { color: var(--term-dim); font-size: 11.5px; font-family: var(--font); }
.term-status { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .08); color: var(--term-dim); }
.term-status.done { color: var(--term-ok); background: rgba(111, 211, 155, .12); }
.term-status.pending, .term-status.sent { color: #f2c46d; background: rgba(242, 196, 109, .12); }
.term-status.expired, .term-status.cancelled { color: var(--term-bad); background: rgba(255, 138, 128, .1); }
.term-out { margin: 6px 0 0; padding: 0 0 0 var(--s-3); border: 0; border-left: 2px solid rgba(255, 255, 255, .1); border-radius: 0;
            background: none; color: var(--term-fg); font-size: 12.5px; white-space: pre-wrap; max-height: none; }
.term-wait { color: #f2c46d; font-family: var(--font); font-size: var(--fs-xs); margin-top: 4px; }
.term-wait::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.term-cancel { margin: 0; height: 22px; padding: 0 8px; font-size: 11px; background: rgba(255, 255, 255, .08); color: var(--term-fg); border: 0; }
.term-cancel:hover { background: rgba(255, 138, 128, .2); }
.term-form { display: flex; gap: var(--s-2); align-items: center; padding: var(--s-3) var(--s-4); border-top: 1px solid rgba(255, 255, 255, .07); background: rgba(255, 255, 255, .03); }
.term-form label { margin: 0; color: var(--term-ok); font-family: var(--mono); font-weight: 700; }
.term-form input { flex: 1; background: transparent; border: 0; color: var(--term-fg); font-family: var(--mono); font-size: 13.5px; padding: 6px 2px; box-shadow: none; }
.term-form input:focus-visible { box-shadow: none; outline: none; }
.term-form:focus-within { background: rgba(122, 162, 255, .07); }
.term-form button { margin: 0; }
.term-empty { color: var(--term-dim); font-family: var(--font); font-size: var(--fs-sm); }

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5) var(--s-4);
              background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login { width: min(400px, 100%); }
.login .card { padding: var(--s-6); box-shadow: var(--shadow); }
.login .logo { width: 44px; height: 44px; border-radius: 12px; margin-bottom: var(--s-4); }
.login .logo .i { width: 26px; height: 26px; }
.login h1 { margin-bottom: var(--s-1); }
.login button { width: 100%; height: 40px; margin-top: var(--s-2); }
.login-foot { margin-top: var(--s-4); text-align: center; color: var(--muted); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ crash report */
.crash-title { word-break: break-word; }
.frames td { font-size: var(--fs-xs); }
.frames .fn { font-family: var(--mono); color: var(--text); font-weight: 600; }
.frames .loc { font-family: var(--mono); color: var(--text-2); }
.frames .locals div { font-family: var(--mono); white-space: pre-wrap; word-break: break-word; }
.board-msg { background: var(--bad-soft); border-color: transparent; color: var(--text); }
.globals p { margin: 0 0 4px; }
.print-only { display: none; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  body.app { padding-left: 0; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 40; align-items: center; gap: var(--s-2); height: 56px; padding: 0 var(--s-3);
            background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar .side-brand { padding: 0; }
  .topbar .logo { width: 30px; height: 30px; }
  .topbar .spacer { flex: 1; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%);
             transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar, .sidebar:target { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(8, 12, 20, .45); }
  .main { padding: var(--s-4) var(--s-4) var(--s-7); }
  .tabs { top: 56px; }
  .tl-day h3 { top: 56px; }
  .toasts { right: var(--s-4); left: var(--s-4); bottom: var(--s-4); width: auto; }
}
@media (max-width: 640px) {
  :root { --fs-2xl: 1.5rem; }
  .card { padding: var(--s-4); border-radius: var(--r); }
  .card > .table-wrap, .card > table { margin: 0 calc(var(--s-4) * -1); width: calc(100% + 2 * var(--s-4)); }
  .card > .table-wrap:last-child { margin-bottom: calc(var(--s-4) * -1); }
  .card > .table-wrap th:first-child, .card > .table-wrap td:first-child { padding-left: var(--s-4); }
  .card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: var(--s-4); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .kpi { padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); }
  .page-head { margin-bottom: var(--s-4); }
  .map.full { height: calc(100vh - 210px); }
  .dev-actions { width: 100%; }
  .pop-body { position: fixed; left: var(--s-4); right: var(--s-4); top: auto; width: auto; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 160px; }
  dl.kv { grid-template-columns: minmax(96px, max-content) 1fr; }
  .tl-item { grid-template-columns: 46px 18px minmax(0, 1fr); padding: var(--s-3); }
  details.section > summary { padding: var(--s-3) var(--s-4); }
  details.section > .section-body { padding: 0 var(--s-4) var(--s-4); }
  /* tables become stacked cards; app.js copies each column header into data-label */
  .table-wrap table.stack-sm thead { display: none; }
  .table-wrap table.stack-sm, .table-wrap table.stack-sm tbody, .table-wrap table.stack-sm tr { display: block; width: 100%; }
  .table-wrap table.stack-sm tr { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table-wrap table.stack-sm tbody tr:last-child { border-bottom: 0; }
  .table-wrap table.stack-sm td { display: block; position: relative; min-height: 26px; padding: 4px 0 4px 36% !important; border: 0;
    text-align: left; background: none !important; max-width: none; white-space: normal; }
  .table-wrap table.stack-sm td::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 33%; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: var(--font); font-size: var(--fs-xs); font-weight: 560; }
  .table-wrap table.stack-sm td:first-child, .table-wrap table.stack-sm td:not([data-label]) { padding-left: 0 !important; padding-bottom: 6px !important; }
  .table-wrap table.stack-sm td:first-child::before, .table-wrap table.stack-sm td:not([data-label])::before { content: none; }
  .table-wrap table.stack-sm td:empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------ print (crash reports) */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f6f6f6; --text: #000; --muted: #555; --border: #ccc; --shadow-sm: none; --shadow: none; }
  body.app { padding-left: 0; }
  .sidebar, .topbar, .scrim, .toasts, .page-actions, .no-print, form, .tabs, .skip { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card, details.section, .kpi { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  details.section > summary::after { display: none; }
  pre, pre.tall { max-height: none; overflow: visible; white-space: pre-wrap; }
  a { color: #000; }
  .print-only { display: block; }
  .tab-panel[hidden] { display: block !important; }
}
/* Data budget: share column */
td.share { white-space: nowrap; min-width: 120px; }
td.share .meter { display: inline-block; width: 80px; margin-right: var(--s-2); vertical-align: middle; }
