/* m3u-proxy appliance UI
   Visual language: a broadcast control room. Colour carries meaning only:
   green tally = signal, lit red tally = on air (someone watching), steady teal = standing by
   (an always-on channel, connected with nobody watching), hollow ring = no signal,
   amber = needs your attention. Everything else stays in cool studio greys. */

@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap;
  src: url(fonts/barlow-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap;
  src: url(fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }

:root {
  --ink: #1c2533;          /* deep blue-slate */
  --ink-2: #4a5668;
  --ink-3: #7a8596;
  --bg: #e8ecf0;           /* studio grey */
  --panel: #ffffff;
  --sunk: #f3f5f8;
  --line: #d4dae2;
  --line-strong: #b5bfcb;
  --signal: #13803f;
  --air: #d7261e;
  --air-glow: rgba(215, 38, 30, .32);
  --hot: #0b7285;          /* standing by: always on */
  --hot-glow: rgba(11, 114, 133, .22);
  --warn: #9a5300;
  --warn-bg: #fbefd9;
  --nosig: #8c96a5;
  --focus: #2457d6;
  --link: #2048b8;
  --btn: #1c2533;
  --btn-ink: #ffffff;
  --wall: #172029;         /* the On air monitor wall stays dark in both themes */
  --wall-ink: #e7ecf2;
  --wall-dim: #8b97a8;
  --wall-line: #2a3542;
  --logo-chip: #eef1f4;
  --radius: 5px;
  --font-ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-log: ui-monospace, "DejaVu Sans Mono", "Cascadia Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4e9f0;
    --ink-2: #a9b3c1;
    --ink-3: #7e8898;
    --bg: #12171f;
    --panel: #1a212b;
    --sunk: #151b24;
    --line: #2a3340;
    --line-strong: #3b4655;
    --signal: #3dba6a;
    --air: #ff4a3d;
    --air-glow: rgba(255, 74, 61, .35);
    --hot: #3bc4d8;
    --hot-glow: rgba(59, 196, 216, .25);
    --warn: #e6a23c;
    --warn-bg: #33270f;
    --nosig: #6f7a8a;
    --focus: #6e95ff;
    --link: #8fb0ff;
    --btn: #e4e9f0;
    --btn-ink: #12171f;
    --wall: #0b1016;
    --wall-edge: #2f3a48;
    --wall-line: #222c38;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-ui); }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
p { margin: 0 0 .75rem; }

h1 { font: 600 2.25rem/1.08 var(--font-display); margin: 0 0 .4rem; letter-spacing: .003em; }
h2 { font: 600 1.375rem/1.2 var(--font-display); margin: 0 0 .7rem; letter-spacing: .005em; }
h3 { font: 700 1rem/1.3 var(--font-ui); margin: 0 0 .4rem; }
.lede { color: var(--ink-2); max-width: 64ch; margin-bottom: 1.75rem; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.small { font-size: .8667rem; }
.nowrap { white-space: nowrap; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* ---- shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); padding: 22px 14px 18px; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: .6rem; padding: 2px 10px 24px;
  font: 600 1.625rem/1 var(--font-display); color: var(--ink); text-decoration: none; letter-spacing: .01em;
}
.brand .count { font: 500 1rem/1 var(--font-display); color: var(--air); margin-left: -.2rem; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: block; padding: .5rem .75rem; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none;
}
.nav a:hover { background: var(--sunk); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 700; background: var(--sunk); box-shadow: inset 3px 0 0 var(--ink); }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.nav-group { font-size: .8125rem; color: var(--ink-3); padding: .9rem .75rem .25rem; }
.nav-group:first-child { padding-top: 0; }
.nav-badge { font: 500 .95rem/1 var(--font-display); color: var(--air); font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; display: grid; gap: .7rem; padding: 0 .75rem; font-size: .8667rem; color: var(--ink-2); }
.rail-foot .btn { justify-self: start; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; justify-self: start; }

.content { min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1200px; padding: 38px 44px 40px; outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
section { margin-top: 2.6rem; }
section:first-child { margin-top: 0; }

/* ---- tally lights ------------------------------------------------------- */
.tally { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; vertical-align: middle; }
.tally.signal { background: var(--signal); }
.tally.air { background: var(--air); box-shadow: 0 0 0 3px var(--air-glow), 0 0 14px var(--air-glow); animation: on-air 2.6s ease-in-out infinite; }
.tally.nosig { border: 2px solid var(--nosig); }
.tally.unk { border: 2px dashed var(--nosig); }
.tally.warn { background: var(--warn); }
.tally.hot { background: var(--hot); box-shadow: 0 0 0 3px var(--hot-glow); }
.tally.big { width: 14px; height: 14px; }
@keyframes on-air { 50% { box-shadow: 0 0 0 6px transparent, 0 0 20px var(--air-glow); } }
.state { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }

/* ---- controls ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: 700 .9333rem/1 var(--font-ui); padding: .62rem 1rem; min-height: 38px;
  border-radius: var(--radius); border: 1px solid var(--btn); background: var(--btn); color: var(--btn-ink);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn.quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.quiet:hover { background: var(--sunk); filter: none; }
.btn.small { padding: .38rem .65rem; min-height: 30px; font-size: .8667rem; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: transparent;
  color: var(--ink-2); font: 700 .95rem/1 var(--font-ui); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }

input[type=text], input[type=search], input[type=url], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .48rem .65rem; min-height: 38px;
}
input:not([type=checkbox]):not([type=radio]), select { height: 38px; }
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
select { padding-right: 2rem; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[readonly] { background: var(--sunk); }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 40px; height: 23px; border-radius: 12px; background: var(--line-strong); position: relative;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch:checked { background: var(--signal); }
.switch:checked::after { transform: translateX(17px); }
.switch:disabled { opacity: .5; cursor: progress; }
.switch:focus-visible { outline-offset: 3px; border-radius: 12px; }

.field { display: grid; gap: .35rem; align-content: start; }
.field > label, .label { font-weight: 700; font-size: .9333rem; }
.hint { font-size: .8667rem; color: var(--ink-2); margin: 0; }
.check { display: flex; gap: .7rem; align-items: flex-start; }
.check .switch { margin-top: 1px; }
.check label { font-weight: 700; font-size: .9333rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem 1.4rem; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
form > .actions, form .form-grid + .actions, fieldset .form-grid + .actions { margin-top: 1.25rem; }
.field .btn { justify-self: start; margin-top: .2rem; }
.card-form { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 20px 22px 22px; max-width: 900px; }
.password-form { margin-top: 3.4rem; padding-top: 2.2rem; border-top: 1px solid var(--line); }
.password-form fieldset { margin-bottom: 0; }
.form-error { color: var(--air); font-weight: 700; margin: 0; min-height: 1.2em; }
fieldset { border: 0; margin: 0 0 2.6rem; padding: 0; min-width: 0; }
legend { font: 600 1.375rem/1.2 var(--font-display); padding: 0; margin-bottom: .2rem; }
fieldset > .hint { margin-bottom: 1.1rem; max-width: 70ch; }
.choices { display: grid; gap: .5rem; }
.choice { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .95rem; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.choice input { margin-top: .3rem; accent-color: var(--ink); }
.choice strong { display: block; }

/* ---- dashboard ---------------------------------------------------------- */
.headline { font: 600 2.6rem/1.08 var(--font-display); margin: 0 0 .5rem; max-width: 34ch; text-wrap: balance; }
.headline .off { color: var(--ink-2); }
.subline { display: flex; align-items: center; gap: .9rem 1.2rem; flex-wrap: wrap; color: var(--ink-2); }
.slate { display: flex; gap: .5rem; max-width: 760px; }
.slate input { font-size: 1.0667rem; min-height: 44px; }
.slate .btn { min-height: 44px; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; max-width: 520px; margin: .6rem 0 .2rem; }
.meter > i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s; }

.wall { background: var(--wall); color: var(--wall-ink); border-radius: 10px; overflow: hidden; border: 1px solid var(--wall-edge, var(--wall)); }
.wall-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 14px 20px; border-top: 1px solid var(--wall-line); }
.wall-row:first-child { border-top: 0; }
.wall-row .who { font: 600 1.45rem/1.15 var(--font-display); letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wall-row .meta { color: var(--wall-dim); font-size: .8667rem; }
.wall-row .viewers { font: 500 1.3rem/1 var(--font-display); text-align: right; white-space: nowrap; }
.wall-row .viewers small { font: 400 .8667rem var(--font-ui); color: var(--wall-dim); margin-left: .25rem; }
.wall-empty { padding: 26px 22px; color: var(--wall-dim); display: flex; gap: .9rem; align-items: center; }
.wall-empty .tally { border-color: var(--wall-dim); }

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2.4rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; }

.notice { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: .8rem 1rem; border-radius: 0 7px 7px 0; margin: 0 0 1rem; max-width: 820px; }
.notice p:last-child { margin: 0; }

/* ---- lists -------------------------------------------------------------- */
.rows { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.row, .rows-head { display: grid; align-items: center; gap: 14px; padding: 10px 16px; }
.row { border-top: 1px solid var(--line); min-height: 56px; }
.rows-head { font-size: .8667rem; color: var(--ink-2); border-bottom: 1px solid var(--line); padding-top: 9px; padding-bottom: 9px; }
.rows-head + .row, .rows > .row:first-child { border-top: 0; }
.rows-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; color: var(--ink-2); font-size: .8667rem; }
.rows-empty { padding: 28px 18px; color: var(--ink-2); }
.cell-main { min-width: 0; }
.cell-main .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main .sub { font-size: .8667rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .note { color: var(--ink-2); font-size: .8667rem; }
.row .note.warn { color: var(--warn); }

.logo { width: 44px; height: 30px; border-radius: 4px; background: var(--logo-chip); object-fit: contain; padding: 2px; display: block; }
.logo.ph { display: grid; place-items: center; padding: 0; font: 600 .78rem/1 var(--font-display); color: #6d7888; letter-spacing: .02em; overflow: hidden; }

.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.scanbar { display: flex; gap: 1rem 1.5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .9rem 1.1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.scanbar > div { flex: 1; min-width: 260px; }
.scanbar p { margin: 0 0 .2rem; }
.scanbar .meter { margin: .5rem 0 0; max-width: none; }
.groupbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.2rem; flex-wrap: wrap; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); }

.cat-row { grid-template-columns: 44px 44px minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, .8fr) 150px 64px; }
.lu-row { grid-template-columns: 56px 44px minmax(0, 2fr) 138px 72px minmax(0, 1fr) 74px 150px; }
.lu-row .c-actions { justify-content: flex-end; flex-wrap: nowrap; }
.lu-row .c-on { display: flex; justify-content: center; }
.chno { font: 500 1.75rem/1 var(--font-display); font-variant-numeric: tabular-nums; text-align: right; }
.chno.pos { color: var(--ink-3); font-size: 1.35rem; }
.rule-row { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.4fr) 140px 104px; }
.rule-what { display: flex; gap: .6rem; align-items: baseline; min-width: 0; }
.kind { font-size: .8125rem; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 4px; padding: .05rem .4rem; white-space: nowrap; }
.rule-value { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reorder { display: flex; gap: 4px; justify-content: flex-end; }
.src-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 170px auto; }
.fail-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }
.add-rule { display: grid; grid-template-columns: 190px minmax(0, 2fr) 170px minmax(0, 1.4fr) auto; gap: .6rem; align-items: end; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--sunk); border-radius: 0 0 9px 9px; }

/* ---- users + packages --------------------------------------------------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .7rem; }
.section-head h2 { margin: 0; }
.user-row { grid-template-columns: 24px minmax(0, 1.6fr) minmax(0, 1.4fr) 92px 120px 96px; min-height: 50px; padding-top: 6px; padding-bottom: 6px; }
.user-row.off .title { color: var(--ink-3); }
.pkg-row { grid-template-columns: minmax(0, 2.4fr) 130px 90px 150px; }
.now-row { grid-template-columns: 14px minmax(0, 1.3fr) minmax(0, 1.4fr) minmax(0, 1.2fr) 96px 70px 56px; min-height: 50px; padding-top: 6px; padding-bottom: 6px; }
.pkg-row .actions, .user-row .actions { justify-content: flex-end; }
.field.narrow input { max-width: 180px; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows-head .c-num { text-align: right; }
.at-limit { color: var(--warn); font-weight: 700; }
.user-row input[type=checkbox], .rows-head input[type=checkbox] { width: 17px; height: 17px; margin: 0; accent-color: var(--ink); }
.linkish.plain { color: var(--ink); text-decoration: none; text-align: left; font-weight: 700; display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish.plain:hover { text-decoration: underline; }

/* toolbars, filter chips, pager */
.toolbar { display: grid; grid-template-columns: minmax(220px, 2.2fr) repeat(2, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.toolbar.two { grid-template-columns: minmax(220px, 2.6fr) minmax(160px, 1fr); }
.toolbar.one { grid-template-columns: minmax(220px, 480px); }
.gap-top { margin-top: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .9rem; }
.chip { font: inherit; font-size: .9333rem; display: inline-flex; align-items: center; gap: .5rem; padding: .34rem .75rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink-2); cursor: pointer; }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--btn-ink); }
.chip-n { font: 500 1rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.pager span { margin-right: .4rem; }

/* access rules strip */
.policy { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.5rem; padding: .8rem 1rem; margin-bottom: 1.2rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.policy.warn { border-left: 4px solid var(--warn); }
.policy dl { display: flex; flex-wrap: wrap; gap: .4rem 2rem; margin: 0; flex: 1; }
.policy dt { font-size: .8125rem; color: var(--ink-2); }
.policy dd { margin: 0; font-weight: 700; }
.policy p { flex-basis: 100%; margin: 0; color: var(--warn); }

/* bulk actions: sticks to the bottom while users are selected */
.bulkbar { position: sticky; bottom: 0; z-index: 9; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem 1.2rem;
  margin-top: 1rem; padding: .8rem 1rem; border-radius: 9px; background: var(--ink); color: var(--panel); box-shadow: 0 -6px 18px rgba(14, 19, 26, .18); }
.bulkbar .bulk-count { display: flex; gap: .4rem 1rem; align-items: baseline; flex-wrap: wrap; }
.bulkbar .linkish { color: var(--panel); }
.bulkbar .btn { background: var(--panel); color: var(--ink); border-color: var(--panel); }
.bulkbar .btn.danger-solid { background: var(--air); border-color: var(--air); color: #fff; }

/* on-air bus: the busiest numbers, on the dark monitor wall */
.bus { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--wall-line); }
.bus-stat { padding: 16px 20px 14px; border-left: 1px solid var(--wall-line); display: grid; gap: .15rem; }
.bus-stat:first-child { border-left: 0; }
.bus-n { font: 600 2.4rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.bus-l { color: var(--wall-dim); font-size: .8667rem; }
.wall-row { grid-template-columns: 14px minmax(0, 1fr) minmax(80px, 180px) auto; }
.wall-bar { height: 6px; border-radius: 3px; background: var(--wall-line); overflow: hidden; }
.wall-bar > i { display: block; height: 100%; background: var(--air); opacity: .85; }
.wall-more { display: block; padding: 10px 20px 14px; color: var(--wall-dim); border-top: 1px solid var(--wall-line); }
.wall .wall-more:hover { color: var(--wall-ink); }

/* provider connection rack: one segment per connection the account allows */
.rack { display: grid; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 12px 16px 14px; }
.rack-key { display: flex; align-items: center; gap: .4rem .9rem; flex-wrap: wrap; font-size: .8125rem; color: var(--ink-2); margin-bottom: .5rem; }
.rack-key .seg { margin-right: -.45rem; }
.rack-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 96px; grid-template-areas: "name cells num" ". sub sub";
  align-items: center; gap: 2px 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.rack-row:first-of-type { border-top: 0; }
.rack-name { grid-area: name; font-weight: 700; }
.rack-num { grid-area: num; text-align: right; font: 500 1.25rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.rack-sub { grid-area: sub; font-size: .8125rem; color: var(--ink-2); }
.cells { grid-area: cells; display: flex; gap: 3px; align-items: center; min-height: 18px; }
.seg { display: inline-block; width: 14px; height: 18px; border-radius: 2px; flex: 0 1 14px; min-width: 4px; }
.seg.v { background: var(--air); }
.seg.c { background: var(--warn); }
.seg.w { background: var(--hot); }
.seg.f { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.cells.bar { display: block; height: 18px; border-radius: 3px; box-shadow: inset 0 0 0 1.5px var(--line-strong); overflow: hidden; white-space: nowrap; font-size: 0; }
.cells.bar .run { display: inline-block; height: 100%; }
.cells.bar .run.v { background: var(--air); }
.cells.bar .run.c { background: var(--warn); }
.cells.bar .run.w { background: var(--hot); }
.cells.open .dim { margin-left: .4rem; }
textarea.mono { font-family: var(--font-log); font-size: .8667rem; }
.pick-btn { width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.pick-btn:hover { background: var(--sunk); }
.mono { font-family: var(--font-log); }
.code-block { font: .8125rem/1.55 var(--font-log); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem 1rem; margin: 0 0 .4rem; overflow-x: auto; white-space: pre; max-width: 100%; }
.cert-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1fr) 110px minmax(0, 1.1fr) 120px; }
.cert-row .actions { justify-content: flex-end; }
code { font: .8667rem var(--font-log); background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: .05rem .35rem; overflow-wrap: anywhere; }
dialog.wide { width: min(800px, calc(100vw - 32px)); }
.dlg-grid { display: grid; gap: 1rem; }
.dlg-extra { margin-right: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.pick-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1.1rem; }
.pick-cols .hint { margin-bottom: .4rem; }
.picklist { border: 1px solid var(--line); border-radius: 7px; background: var(--sunk); max-height: 240px; overflow: auto; padding: 4px 0; }
.picklist.tall { max-height: 290px; margin-top: .45rem; }
.picklist.sub-choice { margin-left: 2.1rem; max-height: 200px; }
.pick { display: flex; align-items: center; gap: .55rem; padding: .32rem .75rem; cursor: pointer; font-size: .9333rem; min-width: 0; }
.pick:hover { background: var(--panel); }
.pick.off { color: var(--ink-3); }
.pick input { margin: 0; flex: none; accent-color: var(--ink); }
.pick .grow { flex: 1; }
.pick .small { flex: none; max-width: 45%; }
.chno-s { font: 500 .95rem/1 var(--font-display); color: var(--ink-3); min-width: 2.2ch; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.btn.danger { color: var(--air); }
.pad { padding: .6rem .8rem; margin: 0; }
.gap { margin-top: .6rem; }
.block { display: block; margin-top: .3rem; }
.warn-text { color: var(--warn); }

/* ---- dock: live checks / restart / progress ------------------------------ */
.dock {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap;
  padding: 14px 44px; background: var(--ink); color: var(--panel);
}
.dock p { margin: 0; max-width: 72ch; }
.dock .btn { background: var(--panel); color: var(--ink); border-color: var(--panel); }
.dock .meter { background: rgba(127, 127, 127, .35); flex: 1; min-width: 160px; margin: 0; }
.dock .meter > i { background: var(--panel); }

/* ---- logs --------------------------------------------------------------- */
.log { font: .8125rem/1.55 var(--font-log); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 12px 16px; height: 68vh; overflow: auto; }
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-line .t { color: var(--ink-3); margin-right: .8em; }
.log-line.WARNING .m { color: var(--warn); }
.log-line.ERROR .m, .log-line.CRITICAL .m { color: var(--air); font-weight: 700; }

/* ---- dialogs, toasts, gate ---------------------------------------------- */
dialog { border: 1px solid var(--line); border-radius: 11px; padding: 0; background: var(--panel); color: var(--ink); width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(14, 19, 26, .5); }
.dlg-body { padding: 22px 24px 8px; display: grid; gap: 1rem; }
.dlg-body h2 { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .6rem; padding: 16px 24px 20px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; justify-items: end; }
.toast { background: var(--ink); color: var(--panel); padding: .7rem 1rem; border-radius: 7px; max-width: 380px; box-shadow: 0 6px 22px rgba(0, 0, 0, .22); }
.toast.error { box-shadow: inset 4px 0 0 var(--air), 0 6px 22px rgba(0, 0, 0, .22); padding-left: 1.2rem; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-panel { width: min(400px, 100%); padding: 30px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 1rem; }
.gate-panel .brand { padding: 0 0 .2rem; }
.gate-panel .lede { margin: 0; }
.probe-out { display: flex; gap: .6rem; align-items: center; margin-top: .9rem; }
.result-box { margin-top: .9rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); }
.result-box ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---- small screens ------------------------------------------------------ */
@media (max-width: 1240px) {
  .lu-row { grid-template-columns: 56px 44px minmax(0, 2fr) 130px 64px 74px 150px; }
  .lu-row .c-src { display: none; }
}
@media (max-width: 1080px) {
  .cat-row { grid-template-columns: 44px 44px minmax(0, 2fr) minmax(0, 1.2fr) 140px 64px; }
  .cat-row .c-source { display: none; }
  .split { grid-template-columns: 1fr; }
  .add-rule { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px 0; border-right: 0; border-bottom: 1px solid var(--line); gap: 2px 8px; }
  .brand { padding: 4px 6px 8px; font-size: 1.4rem; }
  .nav { display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; gap: 0; margin: 0 -12px; padding: 0 6px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: .55rem .7rem .7rem; border-radius: 0; background: none !important; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--ink); }
  .nav-group { display: none; }
  .rail-foot { display: none; }
  main { padding: 24px 16px 32px; }
  .dock { padding: 12px 16px; }
  h1 { font-size: 1.95rem; }
  .headline { font-size: 2.05rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .f-search { grid-column: 1 / -1; }
  .cat-row { grid-template-columns: 44px 40px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .cat-row .c-group, .cat-row .c-source, .cat-row .c-edit { display: none; }
  .cat-row .c-state .word { display: none; }
  .lu-row { grid-template-columns: 40px 40px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .lu-row .c-src, .lu-row .c-watch { display: none; }
  .lu-row .c-on { grid-column: 3; justify-content: flex-start; }
  .lu-row .c-on::after { content: "Always on"; margin-left: .5rem; font-size: .8667rem; color: var(--ink-2); align-self: center; }
  .lu-row .c-actions { grid-column: 4; }
  .lu-row .c-actions .btn:not(.keep) { display: none; }
  .cert-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .cert-row .c-id, .cert-row .c-dev, .cert-row .c-seen { display: none; }
  .rule-row { grid-template-columns: minmax(0, 1fr) auto; }
  .rule-row .c-actions-sum, .rule-row .c-hits { grid-column: 1 / -1; }
  .src-row, .fail-row { grid-template-columns: 1fr; gap: 6px; }
  .user-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 4px 10px; }
  .user-row .c-pk, .user-row .c-seen, .user-row .c-actions { display: none; }
  .now-row { grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px 10px; }
  .now-row > :nth-child(3) { grid-column: 2; }
  .now-row .c-dev, .now-row .c-num { display: none; }
  .pkg-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 10px; }
  .pkg-row .actions { grid-column: 1 / -1; }
  .toolbar, .toolbar.two { grid-template-columns: 1fr 1fr; }
  .toolbar .f-search { grid-column: 1 / -1; }
  .bus { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bus-stat:nth-child(3) { border-left: 0; }
  .bus-stat:nth-child(n+3) { border-top: 1px solid var(--wall-line); }
  .bus-n { font-size: 1.9rem; }
  .wall-row .wall-bar { display: none; }
  .rack-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name num" "cells cells" "sub sub"; }
  .bulkbar { border-radius: 0; margin: 1rem -16px 0; }
  .pick-cols { grid-template-columns: 1fr; }
  .dlg-actions { flex-wrap: wrap; }
  .rows-head { display: none; }
  .wall-row { grid-template-columns: 18px minmax(0, 1fr) auto; padding: 12px 16px; }
  .wall-row .meta-col { display: none; }
  .slate { flex-direction: column; }
  .add-rule { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tally.air { animation: none; }
  *, *::before, *::after { transition: none !important; }
}
