/* PK service 0.1: an instrument-panel look of its own — warm paper and graphite, an amber accent for motion and
   power, tabular numerals everywhere a number moves; dark when the system or the operator wants it. No inline styles
   anywhere: the site is served with a CSP that allows none. */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --bg: #f3efe8;
  --surface: #fffcf7;
  --surface-2: #f7f3ec;
  --surface-3: #ece6dc;
  --border: #e0d8cc;
  --border-strong: #c9bfaf;
  --text: #1f1c17;
  --text-2: #4a443b;
  --muted: #7a7266;
  --accent: #c2591b;
  --accent-hover: #a84a13;
  --accent-soft: #f8e4d6;
  --on-accent: #ffffff;
  --ok: #2f7d4f;
  --ok-soft: #dff0e5;
  --warn: #9c6a00;
  --warn-soft: #f8ecd0;
  --err: #b3261e;
  --err-soft: #f9dedc;
  --rt: #c2591b;
  --stat: #4b5d9e;
  --rt-soft: #f8e4d6;
  --stat-soft: #e3e7f5;
  --mark: #ffe59a;
  --shadow-lg: 0 12px 40px rgba(40, 30, 15, .18);
  --radius: 10px;
  --radius-sm: 7px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f25;
  --surface-2: #22262d;
  --surface-3: #2b3038;
  --border: #30363f;
  --border-strong: #434b56;
  --text: #ebe6dd;
  --text-2: #c3bcb0;
  --muted: #8f8a80;
  --accent: #f0894a;
  --accent-hover: #f6a06b;
  --accent-soft: #3a2518;
  --on-accent: #1a0f08;
  --ok: #4fc47f;
  --ok-soft: #15301f;
  --warn: #e8b04a;
  --warn-soft: #352a12;
  --err: #f27a72;
  --err-soft: #3b1a18;
  --rt: #f0894a;
  --stat: #8da0e8;
  --rt-soft: #3a2518;
  --stat-soft: #23283d;
  --mark: #5c4a0b;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #22262d;
    --surface-3: #2b3038;
    --border: #30363f;
    --border-strong: #434b56;
    --text: #ebe6dd;
    --text-2: #c3bcb0;
    --muted: #8f8a80;
    --accent: #f0894a;
    --accent-hover: #f6a06b;
    --accent-soft: #3a2518;
    --on-accent: #1a0f08;
    --ok: #4fc47f;
    --ok-soft: #15301f;
    --warn: #e8b04a;
    --warn-soft: #352a12;
    --err: #f27a72;
    --err-soft: #3b1a18;
    --rt: #f0894a;
    --stat: #8da0e8;
    --rt-soft: #3a2518;
    --stat-soft: #23283d;
    --mark: #5c4a0b;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
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, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
svg { flex: none; }
code { font-family: var(--mono); }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 15px; }
.btn:disabled, .btn:disabled:hover { opacity: .45; cursor: default; border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.btn.primary:disabled { background: var(--accent); color: var(--on-accent); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg path.filled { fill: currentColor; stroke: none; }

.input, .select {
  height: 34px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.sm { height: 30px; padding: 0 6px; font-size: 13px; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: inherit; }
.chip.unknown .chip-label { font-style: italic; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font-weight: 600; font-size: 13px;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.seg .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.rt { background: var(--rt); }
.dot.stat { background: var(--stat); }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; text-transform: uppercase;
}
.tag.rt { background: var(--rt-soft); color: var(--rt); }
.tag.stat { background: var(--stat-soft); color: var(--stat); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.muted { background: var(--surface-3); color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }

kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
  font: 600 11px var(--mono); color: var(--muted); background: var(--surface-2);
}

.bar { position: relative; height: 10px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 40px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; transition: width .35s ease; }
.bar.stat > i { background: var(--stat); }
.bar.warn > i { background: var(--warn); }
.bar.err > i { background: var(--err); }

.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--rt); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.logo { width: 30px; height: 30px; }
.logo .rim { fill: none; stroke: var(--accent); stroke-width: 3.5; }
.logo .hub { fill: var(--accent); }
.logo .spokes { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: .01em; white-space: nowrap; text-transform: uppercase; }
.ver { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 4px; }

.unit-strip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  margin-left: 8px; padding-left: 16px; border-left: 1px solid var(--border);
}
.unit-name { font-weight: 700; white-space: nowrap; }
.unit-meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.beat { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex: none; }
.beat.on { animation: beat .9s ease-out; }
@keyframes beat { 0% { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { background: var(--border-strong); box-shadow: 0 0 0 8px transparent; } }

/* ---------------------------------------------------------------- tabs */
.tabs-bar {
  position: sticky; top: 56px; z-index: 20;
  display: flex; gap: 4px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
body.offline .tabs-bar { display: none; }
.tabs-bar button {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px;
  background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
  color: var(--muted); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; font-size: 12.5px; white-space: nowrap;
}
.tabs-bar button:hover { color: var(--text); }
.tabs-bar button[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs-bar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

main { min-width: 0; padding: 22px 20px 48px; }
.view { max-width: 1240px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13px; }
.view-head .sub { margin-top: 3px; }
.foot { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.sub.err { color: var(--err); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: var(--radius);
  padding: 16px 18px 18px; min-width: 0;
}
.card.hero { border-top-color: var(--accent); }
.card.bad { border-top-color: var(--err); }
.card-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-h h2 { font-size: 12.5px; font-weight: 800; color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; }
.card-h .sub { margin-left: auto; text-align: right; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd.err { color: var(--err); }
.def-note { display: block; color: var(--warn); font-weight: 500; font-size: 12.5px; }

.empty { padding: 42px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

.note { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- connect */
.connect { display: grid; place-items: start center; padding-top: 4vh; }
.connect-card {
  width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 14px;
  padding: 34px 38px; text-align: left;
}
.connect-art { width: 100%; max-width: 330px; height: auto; display: block; margin: 0 auto 22px; }
.connect-art .a-wheel { fill: var(--surface-3); stroke: var(--border-strong); stroke-width: 2; }
.connect-art .a-tyre { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; }
.connect-art .a-hub { fill: var(--accent); }
.connect-art .a-spokes { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; opacity: .7; }
.connect-art .a-cable, .connect-art .a-base { fill: none; stroke: var(--border-strong); stroke-width: 3; stroke-linecap: round; }
.connect-art .a-plug { fill: var(--surface-3); stroke: var(--border-strong); stroke-width: 2; }
.connect-art .a-laptop { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 2.5; }
.connect-art .a-pulse { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; animation: pulse 2.4s linear infinite; }
@keyframes pulse { from { stroke-dashoffset: 120; } to { stroke-dashoffset: 0; } }
.connect-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 8px; }
.lead { color: var(--text-2); font-size: 15px; margin-bottom: 18px; }
.steps { margin: 0 0 22px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-left: 36px; min-height: 24px; color: var(--text-2); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 12.5px;
}
.steps b { color: var(--text); }
.connect-row { display: flex; gap: 10px; }
.connect-row .select { flex: 1; height: 42px; }
.connect .note { margin-top: 12px; }

/* ---------------------------------------------------------------- wheel */
.wheel-grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: dense; align-items: start; }
.wheel-grid > .card { grid-column: span 4; }
.wheel-grid > .card.w6 { grid-column: span 6; }
.wheel-grid > .card.w12 { grid-column: span 12; }
.sep { height: 1px; background: var(--border); margin: 12px 0 8px; }
.flag-head { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.flag-group + .flag-group { margin-top: 14px; }

.now { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 12px; color: var(--text); }
.now .state-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.now.idle { color: var(--muted); font-weight: 700; font-size: 20px; }
.now.driving { color: var(--accent); }
.now.driving .state-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.now.braking { color: var(--warn); }
.now.braking .state-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.now.stopped { color: var(--err); }
.now.stopped .state-dot { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }

.gauge { display: grid; grid-template-columns: max-content minmax(60px, 1fr) 56px max-content; gap: 12px; align-items: center; margin: 6px 0 14px; font-size: 13.5px; }
.gauge .k { color: var(--muted); }
.gauge .v { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge .raw { color: var(--muted); font-family: var(--mono); font-size: 12px; }

.current { margin: 6px 0 10px; }
.big-value { display: flex; align-items: baseline; gap: 8px; }
.big-value .big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-value .u { color: var(--muted); font-size: 16px; font-weight: 700; }
.current svg.spark { width: 100%; height: 40px; margin-top: 4px; }

.meters { display: grid; gap: 2px; }
.meter { display: grid; grid-template-columns: minmax(0, 1.3fr) 90px 84px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13.5px; border-bottom: 1px dashed var(--border); }
.meter:last-child { border-bottom: 0; }
.meter .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.meter .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter .spark { width: 84px; }

.op { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.op:last-child { border-bottom: 0; }
.op .k { color: var(--muted); }
.op .v { font-weight: 600; text-align: right; }
.op.active .v { color: var(--accent); }
.op.alert .v { color: var(--err); }

.flagset { display: grid; gap: 7px; }
.flag { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.flag .led { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.flag.on .led { background: var(--accent); border-color: var(--accent); }
.flag.bad .led { background: var(--err); border-color: var(--err); }
.flag.bad { color: var(--err); font-weight: 700; }
.flag.ok { color: var(--ok); font-weight: 600; }
.flag.ok .led { background: var(--ok); border-color: var(--ok); }
.flag.off { color: var(--muted); }
details.more { margin-top: 10px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: none; }
details.more summary::before { content: "▸ "; }
details.more[open] summary::before { content: "▾ "; }
details.more .flagset, details.more .op { margin-top: 8px; }

.unit-hero { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.unit-hero .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.unit-hero .sub { font-family: var(--mono); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-left: 4px; letter-spacing: 0; }
.kpi .k { font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.kpi.warn .v { color: var(--warn); }

/* ---------------------------------------------------------------- data */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search {
  flex: 1 1 340px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; min-width: 0;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; height: 100%; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.filters { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 300px); min-height: 220px; }
table.vt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.vt th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; white-space: nowrap;
  padding: 9px 12px; color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.vt th.sortable { cursor: pointer; user-select: none; }
.vt th.sortable:hover { color: var(--text); }
.vt th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.vt th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.vt td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.vt tbody tr:last-child td { border-bottom: 0; }
.vt tbody tr:hover td { background: var(--surface-2); }
.vt tr.pinned td { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.vt .c-pin { width: 34px; padding-right: 0; }
.vt .c-src { width: 96px; }
.vt .c-id { width: 56px; color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.vt .c-name { min-width: 220px; }
.vt td.c-name .unnamed { color: var(--muted); font-style: italic; }
.vt .c-val { min-width: 150px; font-weight: 600; font-variant-numeric: tabular-nums; }
.vt .c-raw { width: 90px; color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.vt .c-trend { width: 110px; }
.vt .c-grp { width: 150px; color: var(--muted); font-size: 12.5px; }
.values:not(.show-raw) .c-raw { display: none; }
.vt td.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.flags-inline { display: flex; flex-wrap: wrap; gap: 4px; }
.flags-inline span { font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-weight: 500; }
.flags-inline span.on { background: var(--err-soft); color: var(--err); font-weight: 700; }
.pin {
  display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent;
  color: var(--border-strong);
}
.pin svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.pin:hover { color: var(--accent); background: var(--surface-3); }
.pin[aria-pressed="true"] { color: var(--accent); }
.pin[aria-pressed="true"] svg { fill: currentColor; }
tr.detail td { background: var(--surface-2); padding: 14px 16px 16px 58px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px 24px; }
.detail-grid .kv { font-size: 13px; }
.detail-chart { grid-column: 1 / -1; }
.detail-chart svg.spark { width: 100%; height: 64px; }
.vt tbody tr.vrow { cursor: pointer; }
.vt tbody tr.vrow.open td { background: var(--surface-2); }

/* ---------------------------------------------------------------- usage */
.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.usage-grid .card.wide, .usage-grid .foot { grid-column: 1 / -1; }
.mode { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 120px; gap: 12px; align-items: center; padding: 7px 0; font-size: 13.5px; border-bottom: 1px dashed var(--border); }
.mode:last-child { border-bottom: 0; }
.mode .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.mode.total .k, .mode.total .v { font-weight: 800; }
.mode .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranked { display: grid; gap: 2px; }
.slots { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.slots li { display: grid; grid-template-columns: 28px minmax(0, 1fr) max-content; gap: 10px; align-items: baseline; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.slots li:last-child { border-bottom: 0; }
.slots .n { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.slots .t { font-weight: 600; }
.slots .raw { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.slots li.empty .t { color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- line */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; }
.tile .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.tile.ok { border-top-color: var(--ok); }
.tile.warn { border-top-color: var(--warn); }
.tile.warn .v { color: var(--warn); }
.tile.err { border-top-color: var(--err); }
.tile.err .v { color: var(--err); }
.card.facts { margin-bottom: 14px; }
.trace .c-time { width: 110px; white-space: nowrap; }
.trace .c-seq { width: 56px; }
.trace .c-code { width: 130px; white-space: nowrap; }
.trace .c-bytes { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; min-width: 160px; }
.trace td.c-bytes .tag { margin-left: 8px; vertical-align: middle; }
.trace .c-out { width: 160px; }
.trace .c-ms { width: 70px; }
.trace tr.warn td.c-bytes, .trace tr.err td.c-bytes { color: var(--text-2); }
.unsolicited { margin-top: 14px; }
.bytes { display: block; overflow-wrap: anywhere; font-size: 12px; color: var(--text-2); }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 8px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out;
}
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast-x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 1100px) {
  .wheel-grid > .card, .wheel-grid > .card.w6 { grid-column: span 6; }
  .wheel-grid > .card.w12 { grid-column: span 12; }
}

@media (max-width: 900px) {
  main { padding: 16px 16px 48px; }
  .usage-grid { grid-template-columns: minmax(0, 1fr); }
  .wheel-grid > .card, .wheel-grid > .card.w6, .wheel-grid > .card.w12 { grid-column: span 12; }
  .unit-meta { display: none; }
  .table-card { max-height: none; }
  .tabs-bar { padding: 0 8px; }
  .tabs-bar button { padding: 0 10px; }
}

@media (max-width: 640px) {
  .top { gap: 8px; padding: 0 12px; }
  .brand-name, .ver, .beat { display: none; }
  .unit-strip { margin-left: 0; padding-left: 10px; gap: 8px; min-width: 0; }
  .unit-name { overflow: hidden; text-overflow: ellipsis; }
  .unit-strip .pill { font-size: 0; gap: 0; padding: 0 8px; height: 20px; } /* the dot says the state */
  #disconnectBtn { padding: 0 9px; }
  .tabs-bar button span { display: none; }
  .connect-card { padding: 24px 18px; border-radius: 12px; }
  .connect-row { flex-direction: column; }
  .view-head h1 { font-size: 20px; }
  .vt .c-src, .vt .c-grp, .vt .c-trend, .vt .c-id { display: none; }
  .vt .c-name { min-width: 150px; }
  .vt .c-val { min-width: 110px; }
  .meter { grid-template-columns: minmax(0, 1fr) 80px; }
  .meter .spark { display: none; }
  .gauge { grid-template-columns: max-content minmax(40px, 1fr) 50px; }
  .gauge .raw { display: none; }
  .mode { grid-template-columns: minmax(0, 1fr) 100px; }
  .mode .bar { display: none; }
  .trace .c-time, .trace .c-seq { display: none; }
  tr.detail td { padding-left: 16px; }
}

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