/* FalconSDR web UI.
   Quiet, system-style chrome (semantic colors that follow the system light/dark
   setting) around one signature element: the "radio stack" - the frequency
   readout styled like an avionics COM display, and the spectrum below it.
   Contrast (WCAG AA): text #1d1d1f/#636366 on #fff = 16.8/5.9:1 (4.9:1 on the #ebebf0 fill); accent #0066cc 5.6:1; dark #f5f5f7/#98989d
   on #1c1c1e = 15.6/5.6:1; display amber #ffb340 on #0b0d10 = 11.3:1. */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --fill: #ebebf0;          /* inputs, secondary buttons */
  --fill-strong: #dedee3;
  --separator: #d1d1d6;
  --label: #1d1d1f;
  --secondary: #636366;
  --tertiary: #aeaeb2;      /* decoration only, never text you must read */
  --accent: #0066cc;
  --accent-tint: rgba(0, 102, 204, .11);
  --on-accent: #ffffff;
  --green: #1e7b34;  --green-fill: #34c759;
  --red: #d70015;    --red-fill: #ff3b30;
  --orange: #c93400; --orange-fill: #ff9500;
  --instrument: #0b0d10;    /* always dark: the radio display and spectrum */
  --instrument-line: #23272e;
  --amber: #ffb340;
  --amber-dim: #8a6a33;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  --radius: 12px;
  --radius-s: 8px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --fill: #2c2c2e; --fill-strong: #3a3a3c; --separator: #38383a;
    --label: #f5f5f7; --secondary: #98989d; --tertiary: #545458;
    --accent: #0a84ff; --accent-tint: rgba(10, 132, 255, .18); --on-accent: #ffffff;
    --green: #30d158; --green-fill: #30d158; --red: #ff453a; --red-fill: #ff453a; --orange: #ff9f0a; --orange-fill: #ff9f0a;
    --instrument: #0b0d10; --instrument-line: #262a31;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--label); font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
svg.ic { width: 17px; height: 17px; flex: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--secondary); }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--secondary); }
.faint { color: var(--secondary); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.grow > input, .grow > select { width: 100%; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- shell: toolbar with section tabs on desktop, tab bar on phones ----------- */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 8px 20px; position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; color: var(--label); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.brand small { color: var(--secondary); font-weight: 500; }
.nav { display: flex; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--radius-s);
  color: var(--secondary); font-weight: 550; text-decoration: none;
}
.nav a:hover { color: var(--label); background: var(--fill); }
.nav a.active { color: var(--accent); background: var(--accent-tint); }
.topbar .status { margin-left: auto; display: flex; align-items: center; gap: 8px; }
main { overflow: auto; padding: 24px 24px 40px; }
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; min-height: 40px; }
.page-head h1 { flex: 1; }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .shell { grid-template-rows: auto 1fr; }
  /* no backdrop-filter here: it would become the containing block of the fixed tab bar below */
  .topbar { padding: 8px 16px; gap: 10px; padding-top: max(8px, env(safe-area-inset-top)); backdrop-filter: none; background: var(--surface); }
  .brand small { display: none; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; justify-content: space-around; gap: 0;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--separator); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .nav a { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 500; padding: 6px 2px; min-height: 48px; justify-content: center; }
  .nav a.active { background: none; }
  .nav a svg.ic { width: 24px; height: 24px; }
  main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
}

/* ---- surfaces: grouped, inset content ----------------------------------------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.card-head h2 { flex: 1; }
.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid.listen { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1080px) { .grid.listen { grid-template-columns: minmax(0, 1fr); } }
.divider { height: 1px; background: var(--separator); }
.empty { padding: 40px 16px; text-align: center; color: var(--secondary); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg.ic { width: 36px; height: 36px; color: var(--tertiary); }

/* ---- controls -------------------------------------------------------------------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--fill);
  border: 0; border-radius: var(--radius-s); padding: 7px 13px; min-height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background-color .12s, opacity .12s;
}
button:hover, .btn:hover { background: var(--fill-strong); text-decoration: none; }
button:active, .btn:active { opacity: .7; }
button:disabled { opacity: .35; cursor: default; }
button svg.ic { width: 16px; height: 16px; }
button.primary { background: var(--accent); color: var(--on-accent); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
button.danger, .btn.danger { color: var(--red); }
button.danger.solid { background: var(--red-fill); color: #fff; }
button.ghost, .btn.ghost { background: transparent; }
button.ghost:hover, .btn.ghost:hover { background: var(--fill); }
button.icon { padding: 7px; min-width: 32px; }
button.big { padding: 11px 20px; font-size: 16px; border-radius: 10px; min-height: 44px; }
button.on { background: var(--accent-tint); color: var(--accent); }
button.recbtn.on { background: color-mix(in srgb, var(--red-fill) 16%, transparent); color: var(--red); }
button.recbtn.on svg.ic { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

input, select, textarea {
  font: inherit; color: var(--label); background: var(--fill); border: 0; border-radius: var(--radius-s);
  padding: 8px 11px; min-width: 0; min-height: 36px;
}
input::placeholder, textarea::placeholder { color: var(--secondary); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input[type="number"] { font-family: var(--mono); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
@media (max-width: 860px) { input, select, textarea { font-size: 16px; } }  /* below 16px iOS zooms in on focus */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--secondary); font-weight: 500; }
label.field > span.hint { color: var(--secondary); font-weight: 400; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; }

/* switch - only ever in a row next to what it controls */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; min-height: 32px; }
.switch input { appearance: none; width: 42px; height: 26px; border-radius: 13px; background: var(--fill-strong); position: relative; border: 0; padding: 0; margin: 0; cursor: pointer; transition: background .2s; flex: none; min-height: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--green-fill); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:disabled { opacity: .4; }
.switch .label { display: flex; flex-direction: column; }
.switch .label small { color: var(--secondary); font-size: 13px; }

/* segmented control */
.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.library aside .seg { display: flex; }
.library aside .seg button { flex: 1; padding: 5px 4px; }
.seg button { background: transparent; color: var(--label); padding: 5px 12px; min-height: 28px; border-radius: 7px; font-weight: 500; font-size: 13px; }
.seg button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.active { background: var(--fill-strong); } }

/* slider with live value */
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.slider .name { font-size: 14px; color: var(--label); display: flex; gap: 8px; align-items: center; }
.slider .value { font: 500 13px var(--mono); color: var(--secondary); text-align: right; }
.slider input[type="range"] { grid-column: 1 / -1; width: 100%; padding: 0; background: none; accent-color: var(--accent); min-height: 28px; }

/* status labels: text + a small dot, never color alone */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  background: var(--fill); font-size: 12px; font-weight: 600; color: var(--secondary); white-space: nowrap;
}
.chip.good { color: var(--green); background: color-mix(in srgb, var(--green-fill) 15%, transparent); }
.chip.warn { color: var(--orange); background: color-mix(in srgb, var(--orange-fill) 15%, transparent); }
.chip.bad { color: var(--red); background: color-mix(in srgb, var(--red-fill) 13%, transparent); }
.chip.accent { color: var(--accent); background: var(--accent-tint); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live .dot { animation: pulse 1.4s infinite; }
.chip svg.ic { width: 14px; height: 14px; }
.q { font: 600 12px var(--mono); padding: 2px 6px; border-radius: 6px; min-width: 34px; text-align: center; display: inline-block; }
.q.hi { color: var(--green); background: color-mix(in srgb, var(--green-fill) 14%, transparent); }
.q.mid { color: var(--orange); background: color-mix(in srgb, var(--orange-fill) 14%, transparent); }
.q.lo { color: var(--red); background: color-mix(in srgb, var(--red-fill) 12%, transparent); }

/* ---- listen: the radio stack (signature) ------------------------------------------ */
.hero { background: var(--instrument); color: #e8e8ea; box-shadow: inset 0 0 0 1px var(--instrument-line); padding: 20px 22px; gap: 14px; }
.hero .state { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.hero .chip { background: rgba(255,255,255,.08); color: #c7c7cc; }
.hero .chip.good { color: #30d158; background: rgba(48,209,88,.14); }
.hero .chip.warn { color: #ff9f0a; background: rgba(255,159,10,.14); }
.hero .chip.bad { color: #ff453a; background: rgba(255,69,58,.14); }
.hero .chip.accent { color: #64d2ff; background: rgba(100,210,255,.12); }
.hero .faint, .hero .muted { color: #8e8e93; }
.hero .freq {
  font: 600 clamp(40px, 8vw, 68px)/1 var(--mono); letter-spacing: -.02em; color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 179, 64, .28); font-variant-numeric: tabular-nums;
}
.hero .freq small { font-size: .3em; color: var(--amber-dim); margin-left: 8px; font-weight: 500; text-shadow: none; letter-spacing: .04em; }
.hero .freq-name { font-size: 16px; color: #c7c7cc; min-height: 22px; margin-top: 6px; }
.hero .others { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.hero .others .chip b { color: var(--amber); }
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--instrument-line); overflow: visible; }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #2c5c8a, #64d2ff 60%, #30d158 85%, #ff9f0a); transition: width .18s linear; }
.meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: #ff9f0a; }
.meter-legend { display: flex; justify-content: space-between; font: 11px var(--mono); color: #8e8e93; }
.hero button { background: rgba(255,255,255,.09); color: #f5f5f7; }
.hero button:hover { background: rgba(255,255,255,.15); }
.hero button.primary { background: #0a84ff; color: #fff; }
.hero button.danger { background: rgba(255,69,58,.18); color: #ff6961; }
.hero button.on { background: rgba(10,132,255,.25); color: #64d2ff; }
.hero button.recbtn.on { background: rgba(255,69,58,.22); color: #ff6961; }
.hero button.ghost { background: transparent; color: #8e8e93; }
.hero .switch input:not(:checked) { background: #3a3a3c; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls .big { min-width: 132px; }
.volume { display: flex; align-items: center; gap: 8px; color: #8e8e93; }
.volume input { width: 100px; accent-color: #0a84ff; padding: 0; background: none; min-height: 0; }

.spectrum-card { background: var(--instrument); box-shadow: inset 0 0 0 1px var(--instrument-line); color: #e8e8ea; }
.spectrum-card .faint { color: #8e8e93; }
.spectrum-wrap { position: relative; border-radius: 8px; overflow: hidden; background: #050709; }
.spectrum-wrap canvas { display: block; width: 100%; }
.spectrum-axis { display: flex; justify-content: space-between; font: 11px var(--mono); color: #8e8e93; }

/* list rows used for bands, settings, computers */
.band { border-top: 1px solid var(--separator); padding: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.band:first-of-type { border-top: 0; }
.band.disabled .band-main .grow { opacity: .45; }
.band.solo .title { color: var(--accent); }
.band-main { display: flex; align-items: center; gap: 10px; }
.band-main .title { font-weight: 600; }
.band-main .range { font: 13px var(--mono); color: var(--secondary); }
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-s); background: var(--accent-tint); font-size: 14px; }
.notice svg.ic { color: var(--accent); flex: none; }
input.time { width: auto; font-family: var(--mono); }
button.day { min-width: 44px; justify-content: center; color: var(--secondary); background: var(--fill); }
button.day.on { color: var(--on-accent); background: var(--accent); }
.band-edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: 12px; }
.overrides { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.override { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: var(--bg); }
@media (prefers-color-scheme: dark) { .override { background: var(--fill); } }

.feed { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; font-size: 14px; }
.feed div { display: flex; gap: 10px; }
.feed time { font: 12px var(--mono); color: var(--secondary); padding-top: 2px; flex: none; }

/* ---- recordings --------------------------------------------------------------------- */
.library { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.library aside { position: sticky; top: 0; max-height: calc(100vh - 140px); display: flex; flex-direction: column; }
.library aside > * { flex-shrink: 0; }  /* the mode switch must never be squeezed by a long list */
.library aside .list { overflow: auto; margin: 0 -8px; padding: 0 8px; flex: 1 1 auto; min-height: 0; flex-shrink: 1; }
@media (max-width: 980px) {
  .library { grid-template-columns: minmax(0, 1fr); }
  .library aside { position: static; max-height: none; }
  .library aside .list { max-height: 240px; }
}
.facet { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: var(--radius-s); cursor: pointer; }
.facet:hover { background: var(--fill); }
.facet.active { background: var(--accent-tint); }
.facet.active .label { color: var(--accent); }
.facet .count { font: 12px var(--mono); color: var(--secondary); }
.facet .label { min-width: 0; }
.facet .label b { font-family: var(--mono); font-weight: 600; }
.facet .label small { display: block; color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar select { flex: 0 1 auto; }
.toolbar .minq { flex: 0 1 180px; min-width: 140px; }
.search { flex: 1 1 220px; position: relative; min-width: 0; }
.search input { width: 100%; padding-left: 34px; }
.search svg.ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--secondary); }
.rec-list { display: flex; flex-direction: column; user-select: none; }
.rec {
  display: grid; grid-template-columns: 20px 112px minmax(0, 1fr) 56px 44px 36px; gap: 12px; align-items: center;
  padding: 10px 8px; border-top: 1px solid var(--separator); cursor: pointer;
}
.rec:first-child { border-top: 0; }
.rec:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
.rec.selected, tr.selected td { background: var(--accent-tint); }
.rec.active { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.rec.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--green-fill) 18%, transparent); } }
.rec .when { font: 13px var(--mono); color: var(--secondary); line-height: 1.3; }
.rec .when b { color: var(--label); font-weight: 600; display: block; }
.rec .what b { font-family: var(--mono); font-weight: 650; }
.rec .what .name { color: var(--secondary); margin-left: 6px; }
.rec .what p { margin: 2px 0 0; color: var(--secondary); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec .what p.none { font-style: italic; }
.rec .dur { font: 13px var(--mono); color: var(--secondary); text-align: right; }
.star { color: var(--tertiary); background: none; padding: 4px; min-width: 32px; }
.star:hover { background: var(--fill); }
.star.on { color: #ff9f0a; }
.star.on svg.ic { fill: currentColor; }
@media (max-width: 680px) {
  .rec { grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "c w q" "c t t"; gap: 4px 10px; padding: 12px 4px; }
  .rec .chk { grid-area: c; align-self: start; margin-top: 2px; } .rec .when { grid-area: w; } .rec .what { grid-area: t; } .rec .qcell { grid-area: q; }
  .rec .when b { display: inline; margin-right: 6px; }
  .rec .dur, .rec .star { display: none; }
}
.bulk { position: sticky; top: 0; z-index: 5; background: var(--surface); padding: 8px 0; border-bottom: 1px solid var(--separator); }
.player {
  position: sticky; bottom: 0; z-index: 10; margin: 0 -16px -16px; padding: 14px 16px;
  background: var(--surface);  /* opaque: list text ghosting through a translucent player was distracting */
  border-top: 1px solid var(--separator); border-radius: 0 0 var(--radius) var(--radius); display: flex; flex-direction: column; gap: 10px;
}
.wave { position: relative; height: 56px; cursor: pointer; border-radius: 8px; overflow: hidden; }
.wave canvas { width: 100%; height: 100%; display: block; }
.transcript { font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.transcript.none { color: var(--secondary); font-style: italic; }
@media (max-width: 680px) {
  /* compact player above the tab bar: the list stays usable behind it */
  .player { bottom: calc(60px + env(safe-area-inset-bottom)); gap: 8px; padding: 10px 12px; }
  .player .transcript { max-height: 4.8em; overflow: auto; font-size: 14px; }
  .player .lbl { display: none; }
  .player .row { gap: 4px; }
  .wave { height: 44px; }
}

/* ---- tables -------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--secondary); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--separator); }
td { padding: 9px 10px; border-bottom: 1px solid var(--separator); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--fill) 50%, transparent); }
td.mono, th.num, td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td .actions { display: flex; gap: 2px; justify-content: flex-end; }
.folder-row td { background: var(--bg); font-weight: 600; cursor: pointer; }
@media (prefers-color-scheme: dark) { .folder-row td { background: var(--fill); } }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 6px; }

/* ---- statistics ---------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi span { font-size: 13px; color: var(--secondary); }
.kpi b { display: block; font: 650 24px var(--mono); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--secondary); }
.bars { display: grid; align-items: end; gap: 3px; height: 150px; padding-top: 10px; }
.bars .bar { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.bars-axis { display: grid; gap: 3px; font: 11px var(--mono); color: var(--secondary); text-align: center; }
.usage { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; display: flex; }
.usage span { display: block; height: 100%; }

/* ---- settings: sidebar + grouped lists ------------------------------------------------- */
.settings { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.settings nav a { padding: 7px 12px; border-radius: var(--radius-s); color: var(--label); text-decoration: none; font-size: 14px; }
.settings nav a:hover { background: var(--fill); }
@media (max-width: 860px) { .settings { grid-template-columns: minmax(0, 1fr); } .settings nav { display: none; } }
.setting { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--separator); }
.card-head + .col > .setting:first-child, .setting:first-child { border-top: 0; padding-top: 0; }
.setting > div:first-child { flex: 1 1 240px; min-width: 0; }
.setting b { font-weight: 500; }
.setting p { margin: 2px 0 0; color: var(--secondary); font-size: 13px; }
.worker { border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
@media (prefers-color-scheme: dark) { .worker { background: var(--fill); } }
.worker pre { margin: 0; max-height: 130px; overflow: auto; font: 12px/1.45 var(--mono); color: var(--secondary); white-space: pre-wrap; }
code.cmd { display: block; font: 13px var(--mono); background: var(--fill); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* ---- sheets, toasts --------------------------------------------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(480px, 100%); max-height: 90vh; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
@media (prefers-color-scheme: dark) { .modal { background: #2c2c2e; } .modal input, .modal select, .modal textarea { background: #3a3a3c; } }
.modal h2 { font-size: 18px; }
.modal p { color: var(--secondary); white-space: pre-line; }
.modal .dirs { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.modal .dirs button { justify-content: flex-start; text-align: left; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; width: max-content; max-width: min(460px, calc(100vw - 32px)); }
@media (max-width: 860px) { #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.toast { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(20px); box-shadow: 0 8px 30px rgba(0,0,0,.18); border-radius: 12px; padding: 10px 16px; animation: fade .15s; font-size: 14px; }
.toast.bad { color: var(--red); }
.toast.good { color: var(--green); }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); text-align: center; align-items: stretch; padding: 28px; }
.login img { width: 64px; height: 64px; margin: 0 auto; border-radius: 14px; }

/* touch screens: 44 pt targets (last, so it wins over the component rules above) */
@media (pointer: coarse) {
  button, .btn, input, select { min-height: 44px; }
  button.icon { min-width: 44px; }
  .seg button { min-height: 40px; }  /* + the 2px track padding = 44 */
}
