/* fpv-hub: the dashboard design (docs/fpv-hub Dashboard.html). The same
   family as the receiver's own app (fpv-web): dark first, light for
   daylight. Colour is for state, always with a word. */

:root {
  --bg: #101214;
  --panel: #171a1d;
  --raised: #1e2227;
  --line: #2c3136;
  --text: #dde2e6;
  --dim: #8a939b;
  --green: #3fb58f;
  --amber: #e8a33d;
  --red: #e05252;
  --on-accent: #101214;
  --green-soft: rgba(63, 181, 143, .14);
  --amber-soft: rgba(232, 163, 61, .14);
  --red-soft: rgba(224, 82, 82, .14);
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --raised: #eceef1;
    --line: #d3d8de;
    --text: #1b1f24;
    --dim: #5b6570;
    --green: #237a5e;
    --amber: #9c6512;
    --red: #b83a3a;
    --on-accent: #ffffff;
    --green-soft: rgba(35, 122, 94, .12);
    --amber-soft: rgba(156, 101, 18, .14);
    --red-soft: rgba(184, 58, 58, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font-family: inherit; }
h1 { margin: 0; font-size: 20px; font-weight: 600; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
.mono, code { font-family: var(--mono); font-size: 13px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.grow { flex-grow: 1; }
.hidden { display: none !important; }

/* --- the sidebar ---------------------------------------------------------------- */

/* the hub's pages down the left, in groups; the page beside it. On a phone
   the sidebar is the 52px header bar: the page's title and a menu. */
body.app { flex-direction: row; }
.shell { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.side {
  width: 224px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px 12px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 30;
}
.side-head { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; padding: 0 6px; white-space: nowrap; flex: none; }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--green); }
.side .title, .side .menu { display: none; }
.side-nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; color: var(--dim); padding: 0 10px 4px; }
.nav-group a { height: 32px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border-radius: 4px; color: var(--dim); font-size: 13px; }
.nav-group a:hover { color: var(--text); background: var(--raised); text-decoration: none; }
.nav-group a.on { color: var(--text); background: var(--raised); font-weight: 600; }
.nav-group a:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.nav-group a .count { margin-left: auto; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex-grow: 1; font-size: 13px; }
.count.green { background: var(--green-soft); color: var(--green); }
.count.amber { background: var(--amber-soft); color: var(--amber); }

/* the hub's live link (Action Cable): a dot and a word */
.live { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); min-width: 0; }
/* (a longer word, in another language: shortened, not pushing the brand) */
.live [data-live-target="word"] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- the page ------------------------------------------------------------------ */

main {
  flex-grow: 1;
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head .meta { font-size: 13px; color: var(--dim); }
section.block { display: flex; flex-direction: column; gap: 8px; }
section.block > .title { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.note { font-size: 12px; color: var(--dim); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.card.attention { border-color: var(--amber); }
.card.padded { padding: 16px; }

/* a table as rows of a CSS grid: the page sets --cols */
.grid-table .row, .grid-table .head {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 16px;
  padding: 0 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.grid-table .head {
  height: 36px;
  font-size: 12px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.grid-table .row { min-height: 48px; font-size: 13px; }
.grid-table .row:last-child { border-bottom: 0; }
.grid-table .row.tall { min-height: 56px; height: auto; } /* (not .tall's 40px: a row grows with what's in it) */
.grid-table .row.error { background: var(--red-soft); }
/* a failed or rolled-back update's row: tinted, its text as any row's (.error colours text) */
.grid-table .row.bad { background: color-mix(in srgb, var(--red-soft) 50%, transparent); }
.grid-table .end { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.grid-table .foot { height: 36px; display: flex; align-items: center; gap: 16px; padding: 0 16px; font-size: 12px; color: var(--dim); }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* --- state ----------------------------------------------------------------------- */

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex-shrink: 0; display: inline-block; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.state { display: inline-flex; align-items: center; gap: 7px; }
.count {
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 600;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--raised); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--dim); flex-shrink: 0;
}
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .name { font-weight: 500; }

.banner {
  min-height: 32px;
  padding: 6px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.banner.stale { background: var(--amber-soft); }
.banner.notice { background: var(--green-soft); }
.banner.alert { background: var(--red-soft); }

/* --- controls --------------------------------------------------------------------- */

.btn {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--dim); }
.btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); }
.btn.danger:hover { color: var(--red); border-color: var(--red); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--on-accent); font-weight: 600; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.big { height: 44px; border-radius: 6px; font-size: 15px; width: 100%; }
.btn.wide { width: 100%; height: 36px; border-radius: 6px; }

/* buttons side by side on a hairline: a segmented control */
.seg { display: inline-flex; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg > *, .seg form > button { height: 30px; padding: 0 12px; border: 0; border-radius: 0; background: var(--panel); color: var(--dim); font-size: 13px; cursor: pointer; }
.seg > .on, .seg form > button.on { background: var(--raised); color: var(--text); font-weight: 500; }
.seg.raised > *, .seg.raised form > button { background: var(--raised); color: var(--text); height: 32px; }
.seg > *:hover, .seg form > button:hover { color: var(--text); }
.seg form { display: contents; }
.seg > a { display: inline-flex; align-items: center; }
.seg > a:hover { text-decoration: none; }

input[type=text], input[type=email], input[type=search], input[type=number], select {
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}
select { padding: 0 8px; }
select.on-bg { background: var(--bg); }
input:focus-visible, select:focus-visible, .btn:focus-visible, .seg > *:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.locked {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px;
  border-radius: 4px; border: 1px solid var(--line); background: var(--raised);
}
form.inline, form.button_to { display: inline; }
input.search { width: 220px; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- sign-in pages ------------------------------------------------------------------ */

body.bare main { align-items: center; justify-content: center; gap: 24px; }
.signin {
  width: 380px;
  max-width: 100%;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.signin.wide { width: 420px; gap: 18px; }
.signin .brand { font-size: 20px; gap: 10px; }
.signin p { color: var(--dim); line-height: 1.5; }
.signin .dev { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
.signin form { margin: 0; }
.signin .heading { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.ring { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber); flex-shrink: 0; }
.facts {
  display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px;
  padding: 12px 14px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
}
.facts > :nth-child(odd) { color: var(--dim); }
.foot-note { font-size: 12px; color: var(--dim); text-align: center; }
/* the authenticator's code (otp/show) */
.otp-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 20px; }
.otp-steps > li { counter-increment: step; position: relative; padding-left: 34px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.otp-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  background: var(--raised); border: 1px solid var(--line); color: var(--dim);
}
.otp-steps b { font-weight: 600; }
.otp-qr { line-height: 0; border-radius: 6px; overflow: hidden; align-self: flex-start; }
.otp-key { display: flex; flex-direction: column; gap: 4px; }
.otp-key .form-row { flex-wrap: nowrap; padding: 8px 8px 8px 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.otp-key code { display: flex; flex-direction: column; letter-spacing: .08em; user-select: all; }
.otp-form { display: flex; flex-direction: column; gap: 10px; }
/* the digits spaced out, the trailing space made up on the left so they sit in the middle */
input.otp-code {
  height: 48px; padding: 0 10px 0 calc(10px + .4em); border-radius: 6px; background: var(--bg);
  font: 600 24px/1 var(--mono); letter-spacing: .4em; text-align: center;
}
input.otp-code::placeholder { color: var(--line); }
input.otp-code.bad { border-color: var(--red); }
.otp-error { color: var(--red); }
.otp-who { border-top: 1px solid var(--line); padding-top: 14px; }

/* --- phones ------------------------------------------------------------------------- */

@media (max-width: 720px) {
  body.app { flex-direction: column; }
  .side {
    width: auto; height: 52px; flex-direction: row; align-items: center; gap: 12px;
    padding: 0 4px 0 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible;
  }
  .side-head { flex-grow: 1; gap: 12px; }
  .side .brand, .side-nav, .side-foot { display: none; }
  .side .title { display: block; font-weight: 600; font-size: 17px; }
  .side .menu { display: block; }
  .side .menu summary {
    list-style: none; width: 44px; height: 44px; display: flex;
    align-items: center; justify-content: center; color: var(--dim); cursor: pointer;
  }
  .side .menu summary::-webkit-details-marker { display: none; }
  .side .menu[open] .sheet {
    position: absolute; top: 52px; left: 0; right: 0; z-index: 10; max-height: calc(100vh - 52px); overflow-y: auto;
    background: var(--panel); border-bottom: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 8px; padding: 8px 0;
  }
  .side .menu .sheet .nav-label { padding: 4px 16px 0; }
  .side .menu .sheet a, .side .menu .sheet button {
    height: 44px; padding: 0 16px; display: flex; align-items: center; border-radius: 0;
    font-size: 15px; color: var(--text); background: none; border: 0; text-align: left; width: 100%;
  }
  .side .menu .sheet a.on { background: var(--raised); }
  .side .menu .sheet .who { color: var(--dim); font-size: 13px; height: 32px; }
  main { padding: 12px; gap: 10px; }
  .device > .tabs { margin: 0 -12px; padding: 0 12px; }
  .page-head > h1 { display: none; }
  .page-head input[type=search] { width: 100%; }
  .device-head > .grow { display: none; }
  .signin { padding: 24px; }
  .seg.fill { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .seg.fill > *, .seg.fill form > button { height: 44px; }
}

/* narrow screens (phones, tablets upright): a table's rows as cards */
@media (max-width: 940px) {
  .status-cards { grid-template-columns: 1fr; }
  .grid-table .head { display: none; }
  .grid-table .row { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; }
  .grid-table .row > .wide-only { display: none; }
}

/* --- Add device ------------------------------------------------------------------- */

.add-device {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr) 380px;
  gap: 16px 20px;
  align-items: start;
}
.add-head { grid-column: 1 / 4; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.add-head .meta { font-size: 13px; color: var(--dim); }
.step { display: flex; flex-direction: column; gap: 14px; }
.step.faded > :not(.step-title) { color: var(--dim); }
.step-title { display: flex; align-items: center; gap: 10px; }
.num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
#arrival .num { background: var(--raised); color: var(--dim); }
#arrival .num.done { background: var(--green); color: var(--on-accent); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.field input.big { height: 38px; font-size: 15px; background: var(--bg); }
.options { border-top: 1px solid var(--line); padding-top: 10px; }
.options summary { cursor: pointer; font-size: 13px; color: var(--dim); list-style: none; display: flex; align-items: center; gap: 6px; }
.options summary::-webkit-details-marker { display: none; }
.options > .stack { padding-top: 12px; font-size: 13px; }
.pair { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: center; gap: 10px; color: var(--dim); }
.pair input { height: 34px; background: var(--bg); }
/* (Rails gives a text field with a maxlength that many characters' size: 1600px for 200) */
.pair > input[size] { width: 100%; min-width: 0; }
/* a select as wide as its column, not as its longest option (the network form's Ethernet modes in Ukrainian or English) */
.pair > select { width: 100%; min-width: 0; }
.with-hint { display: flex; align-items: center; gap: 8px; }
.with-hint input { width: 130px; }
.btn.tall { height: 38px; border-radius: 6px; }
.error, .warn { color: var(--amber); }
.error { color: var(--red); font-size: 13px; }
.code-box {
  display: flex; align-items: center; gap: 20px; padding: 14px 16px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); flex-wrap: wrap;
}
.code-box .code { font-family: var(--mono); font-size: 34px; font-weight: 600; letter-spacing: .12em; }
.code-box .valid { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 13px; color: var(--dim); }
.code-box .valid .mono { font-size: 20px; color: var(--text); }
.cmd-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cmd { display: flex; align-items: stretch; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); overflow: hidden; }
.cmd pre {
  margin: 0; flex-grow: 1; padding: 12px 14px; font-family: var(--mono); font-size: 13px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-all; min-width: 0;
}
.cmd button {
  width: 56px; border: 0; border-left: 1px solid var(--line); background: var(--raised); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; cursor: pointer; flex-shrink: 0;
}
.notes {
  display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim);
  border-top: 1px solid var(--line); padding-top: 12px; line-height: 1.5;
}
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 22px 1fr; gap: 12px; min-height: 64px; }
.tl .rail { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tl .knob { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); margin-top: 3px; flex-shrink: 0; }
.tl .line { width: 2px; flex-grow: 1; background: var(--line); }
.tl:last-child .line { display: none; }
.tl > .stack { padding-bottom: 14px; }
.tl-title { font-weight: 500; }
.tl.future .tl-title { color: var(--dim); }
.tl.done .knob { background: var(--green); border-color: var(--green); }
.tl.done .line { background: var(--green); }
.tl.current .knob { background: var(--amber); border-color: var(--amber); }

@media (max-width: 1200px) {
  .add-device { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .add-head { grid-column: 1 / 3; }
  .add-device > .step:nth-of-type(2) { grid-column: 1 / 3; grid-row: 3; }
}
@media (max-width: 720px) {
  .add-device { grid-template-columns: minmax(0, 1fr); }
  .add-head, .add-device > .step:nth-of-type(2) { grid-column: auto; grid-row: auto; }
  .code-box .code { font-size: 28px; }
  .pair { grid-template-columns: 1fr; gap: 4px; }
}

/* --- roles and device state ---------------------------------------------------------- */

/* live-rendered parts carry every control, marked with the permission it
   needs (data-needs); the layout leaves out what the viewer may not do
   (ApplicationHelper#permission_css, against the body's data-can) */
/* the device page: controls while the device is online, a notice while not */
body:has(.pill[data-online="false"]) .online-only { display: none !important; }
body:has(.pill[data-online="true"]) .offline-only { display: none !important; }

.green { color: var(--green); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.right { text-align: right; }
.none { min-width: 0; }
.nowrap { flex-wrap: nowrap; }
.chips { display: flex; gap: 6px; }
.empty-state { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; gap: 6px; }

/* --- fleet --------------------------------------------------------------------------- */

/* the fleet: the controls' column is empty for a viewer; a narrower table
   drops the version, then the health, then the channels (their columns go
   from --cols, their cells by class). The breakpoints: the table's own
   width (a container) where the columns' least widths stop fitting. */
.fleet-main { container: fleet / inline-size; }
.fleet { --ctl: 210px; --cols: minmax(140px, 1fr) 110px minmax(150px, 1.2fr) minmax(140px, 1.2fr) 150px 80px minmax(120px, 1.4fr) var(--ctl); }
body:not([data-can~="control.mode"]):not([data-can~="watch"]) .fleet { --ctl: 0px; }
@container fleet (max-width: 1216px) {
  .fleet { --cols: minmax(140px, 1fr) 110px minmax(150px, 1.2fr) minmax(140px, 1.2fr) 150px minmax(120px, 1.4fr) var(--ctl); }
  .fleet .f-version { display: none; }
}
@container fleet (max-width: 1124px) {
  .fleet { --cols: minmax(140px, 1fr) 110px minmax(150px, 1.2fr) minmax(140px, 1.2fr) minmax(120px, 1.4fr) var(--ctl); }
  .fleet .f-health { display: none; }
}
@container fleet (max-width: 962px) {
  .fleet { --cols: minmax(140px, 1fr) 110px minmax(150px, 1.2fr) minmax(120px, 1.4fr) var(--ctl); }
  .fleet .f-air { display: none; }
}
/* narrower still: its rows as cards, like every table on a phone */
@container fleet (max-width: 810px) {
  .fleet .head { display: none; }
  .fleet .row { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; }
  .fleet .row > :first-child { flex: 1 1 auto; }
  .fleet .f-alert { flex-basis: 100%; white-space: normal; }
  .fleet .f-alert:empty, .fleet .row > .end:not(:has(*)) { display: none; }
}
@media (max-width: 940px) {
  .fleet .row > :first-child { flex: 1 1 auto; }
  .fleet .f-alert { flex-basis: 100%; white-space: normal; }
  .fleet .f-alert:empty, .fleet .row > .end:not(:has(*)) { display: none; }
}
.fleet .end > * { flex-shrink: 0; }
.fleet .row { min-height: 46px; gap: 12px; }
.fleet .head { gap: 12px; }
.fleet .name { font-weight: 500; }
.seg.small-seg > *, .seg.small-seg form > button { height: 26px; padding: 0 9px; font-size: 12px; }
.seg .on, .seg form > button.on { background: var(--raised); color: var(--text); }

/* the Fleet page: the overview, then the table; the notifications down
   the right (sticky), hidden to a strip with their count (notices_controller) */
.fleet-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.fleet-page.notices-hidden { grid-template-columns: minmax(0, 1fr) 48px; }
.fleet-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.overview { display: flex; flex-direction: column; gap: 16px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.stat:hover { text-decoration: none; border-color: var(--dim); }
.stat .figure { display: flex; align-items: baseline; gap: 8px; }
.stat .figure b { font-size: 22px; font-weight: 600; }
.stat .meter { display: flex; gap: 3px; height: 4px; }
.stat .meter i { background: var(--line); border-radius: 1px; }
.stat .meter i.green { background: var(--green); }
.stat .meter i.red { background: var(--red); }
.card-head { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 12px 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); }
/* hairlines between the cells, none where a row runs short */
.air-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); border-top: 1px solid var(--line); }
.air-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 48px; padding: 4px 16px; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.air-row:hover { background: var(--raised); text-decoration: none; }
.air-level { display: inline-flex; align-items: center; gap: 6px; }
.air-empty { padding: 14px 16px; border-top: 1px solid var(--line); }
.pill-tone {
  display: inline-flex; align-items: center; justify-content: center; height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 12px; background: var(--raised); color: var(--dim); justify-self: start;
}
.pill-tone.red { background: var(--red-soft); }
.pill-tone.amber { background: var(--amber-soft); }
.count.red { background: var(--red-soft); color: var(--red); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--green); cursor: pointer; }
button.link:hover { text-decoration: underline; }

.notices { position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
/* each notification ruled above (not below: those the viewer may not see
   come last, hidden, and a last rule would double the card's edge) */
.notices-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; flex-shrink: 0; }
.notices-toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 4px; border: 0; border-radius: 4px;
  background: none; color: var(--text); font: inherit; cursor: pointer;
}
.notices-toggle svg { color: var(--dim); }
.notices-title { font-size: 15px; font-weight: 600; }
.notices-toggle:focus-visible, .notice .icon-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.notice-list { overflow-y: auto; display: flex; flex-direction: column; }
.notice { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.notice[hidden] { display: none; }
.notice-top { display: flex; align-items: center; gap: 8px; }
.notice .icon-btn { width: 24px; height: 24px; font-size: 12px; background: none; border: 0; color: var(--dim); cursor: pointer; border-radius: 4px; }
.notice .icon-btn:hover { color: var(--text); background: var(--raised); }
.notice .who { font-weight: 600; }
.notice-act { padding-top: 4px; }
.notice-empty, .notice-restore { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.notice-empty[hidden], .notice-restore[hidden] { display: none; }
.notice-group { font-size: 12px; color: var(--dim); padding: 10px 12px 2px; }
.notice-group[hidden] { display: none; }
.contents { display: contents; }
.field-role { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; color: var(--dim); }
/* hidden: a strip with the icon and the count, which shows them again */
.notices-hidden .notices { max-height: none; }
.notices-hidden .notices-head { flex-direction: column; padding: 8px 0; }
.notices-hidden .notices-toggle { flex-direction: column; height: auto; padding: 6px 4px; }
.notices-hidden .notices-title, .notices-hidden .notices-hide, .notices-hidden .notice-list { display: none; }
@media (max-width: 1100px) {
  .fleet-page, .fleet-page.notices-hidden { grid-template-columns: minmax(0, 1fr); }
  .fleet-page > .notices { grid-row: 1; position: static; max-height: none; }
  .notices-hidden .notices-head { flex-direction: row; padding: 8px 10px 8px 12px; }
  .notices-hidden .notices-toggle { flex-direction: row; height: 32px; }
  .notices-hidden .notices-title { display: inline; }
}
@media (max-width: 720px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .figure b { font-size: 20px; }
  .grid-table .toolbar input.search { width: 100%; }
  .fleet-page { gap: 10px; }
}

.grid-table .toolbar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.grid-table .toolbar select, .grid-table .toolbar input { height: 30px; }

/* --- device -------------------------------------------------------------------------- */

.device { display: flex; flex-direction: column; gap: 16px; }
.device-head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
h1.big { font-size: 22px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel);
  color: var(--dim); display: flex; align-items: center; justify-content: center; cursor: pointer; list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.rename { position: relative; }
.rename .pop { position: absolute; top: 34px; left: 0; z-index: 30; width: 360px; max-width: calc(100vw - 24px); }
/* (on a phone it starts at the name, ~100px in, and ran past the screen's edge: pinned to the screen's sides) */
@media (max-width: 720px) { .rename .pop { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; max-width: none; } }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px; border-radius: 4px; font-size: 13px; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.off { background: var(--raised); color: var(--dim); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.tags { gap: 6px; }
.tag { padding: 1px 6px; border-radius: 3px; border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; }
.btn.two-line { flex-direction: column; align-items: flex-start; line-height: 1.2; gap: 0; height: 36px; }
.btn.two-line .mono { font-size: 11px; }
/* the receiver's tabs stay at the top; the one shown is marked (tabs_controller) */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 0; z-index: 20; background: var(--bg); margin: 0 -24px; padding: 0 24px;
}
.tabs a { padding: 8px 12px; color: var(--dim); white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--green); }
.device [id] { scroll-margin-top: 48px; }
/* the tabs' panes (tabs_controller); until it starts, the first */
.device .pane { display: flex; flex-direction: column; gap: 16px; }
.device .pane[hidden], .device:not(.tabs-ready) .pane ~ .pane { display: none; }
.on-air-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.on-air-chip { gap: 8px; padding: 6px 10px; color: var(--text); }
.on-air-chip:hover { text-decoration: none; border-color: var(--dim); }
.on-air-chip.on { border-color: var(--green); }
.status-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.status-cards.stale .card { opacity: .75; }
.status-cards.stale .dot { background: var(--dim); }
/* phones: one a row (after the rule above, which an earlier phone rule lost to) */
@media (max-width: 720px) { .status-cards, .net-cards { grid-template-columns: 1fr; } }
.tight-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.tight-card.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-content: start; }
.span2 { grid-column: 1 / 3; }
.bigger { font-size: 17px; font-weight: 500; }
.card.dashed { border-style: dashed; }
.control { display: grid; grid-template-columns: 300px 1fr 1fr; gap: 16px 24px; align-items: start; }
.seg.fill4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg.fill4 form { display: contents; } /* (over form.inline's inline) */
.seg.fill4 form > button { width: 100%; height: 40px; font-weight: 500; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tall, input.tall, select.tall { height: 40px; }
.radio-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; font-size: 13px; }
.cmd-result { min-height: 16px; }
.channels { --cols: 130px minmax(0, 1fr) 90px 110px 100px 150px 110px; }
body:not([data-can~="control.mode"]) .channels { --cols: 130px minmax(0, 1fr) 90px 110px 100px 150px 0; }
.channels .row { min-height: 44px; gap: 12px; }
.channels .head { gap: 12px; }
/* the table narrower than its columns (a laptop, the sidebar beside it):
   tighter, and without the last-seen column */
/* a device's versions and updates (devices/_updates): beside the danger
   zone it's narrow, so its rows wrap like a phone's below 760px, an
   update's message on a line of its own */
.updates-table { --cols: 100px minmax(150px, 1fr) minmax(90px, 1fr) minmax(0, 1fr) auto; container-type: inline-size; }
.updates-table .rollout .msg { grid-column: 2 / -1; grid-row: 2; padding-bottom: 8px; margin-top: -8px; white-space: normal; }
@container (max-width: 760px) {
  .updates-table .row { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px 12px; }
  .updates-table .row > .end { margin-left: auto; }
  .updates-table .rollout .msg { flex-basis: 100%; order: 1; margin: 0; padding: 0; }
}
@media (max-width: 940px) { .grid-table .row > .msg { flex-basis: 100%; white-space: normal; } }
.channels { container-type: inline-size; }
@container (max-width: 860px) {
  .channels .row, .channels .head { --cols: 100px minmax(0, 1fr) 60px 110px 90px 110px; }
  .channels .row > :nth-child(6), .channels .head > :nth-child(6) { display: none; }
}
.btn.watching { background: var(--green-soft); color: var(--green); border-color: var(--line); cursor: default; }
.settings { padding: 0 14px; }
.settings > .fold > summary { padding: 0; }
@media (min-width: 941px) { .net-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.net-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px 16px; }
.net-form .form-row { grid-column: 1 / -1; }
.settings > .fold[open] { padding-bottom: 14px; }

/* a fold (fold_controller): the rest of a list, or a form, behind a quiet line */
.fold > summary {
  list-style: none; cursor: pointer; min-height: 38px; padding: 0 16px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--dim);
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; width: 10px; }
.fold[open] > summary::before { content: "▾"; }
.fold > summary:hover { color: var(--text); }
.fold[open] > summary { border-bottom: 1px solid var(--line); }
.fold > summary .strong { color: var(--text); }
.fold > summary .strong, .fold > summary .when-closed, .fold > summary .when-open { white-space: nowrap; flex-shrink: 0; }
.fold > summary .when-open, .fold[open] > summary .when-closed { display: none; }
.fold[open] > summary .when-open { display: inline; }
.settings-grid { display: grid; grid-template-columns: 280px 280px 1fr; gap: 12px; min-height: 46px; align-items: center; border-bottom: 1px solid var(--line); font-size: 13px; }
.settings-grid.head { min-height: 30px; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.settings-grid input, .settings-grid select { height: 34px; }
.settings-grid .changed { border-color: var(--amber); }
.settings-grid > label { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.settings-grid input.num { width: 120px; }
.settings-group { padding: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--dim); border-bottom: 1px solid var(--line); }
.pad { padding-top: 12px; }
.log {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7; max-height: 360px; overflow-y: auto;
}
#log-lines { display: flex; flex-direction: column; }
.log-line { display: flex; gap: 12px; }
.log-line > :first-child { flex-shrink: 0; }
.log-line .lvl { width: 44px; flex-shrink: 0; color: var(--dim); }
.log-line.warn { color: var(--amber); }
.log-line.warn .lvl { color: var(--amber); }
.log-line.error { color: var(--red); }
.log-line.error .lvl { color: var(--red); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; }
.danger { border-color: var(--red); }
.top-line { border-top: 1px solid var(--line); padding-top: 10px; }

@media (max-width: 1100px) {
  .control { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid > :last-child { display: none; }
}
.btn.on { background: var(--green-soft); color: var(--green); border-color: var(--green); }

/* --- channels (fleet) ---------------------------------------------------------------- */

.fleet-channels { --cols: 28px 110px 110px minmax(0, 1fr) 80px minmax(0, 1.6fr) 120px 120px 90px; }
.fleet-channels .row, .fleet-channels .head { gap: 12px; }
.fleet-channels .row { min-height: 50px; }
.strong { font-weight: 500; }
.star { width: 24px; height: 24px; border: 0; background: transparent; color: var(--dim); cursor: pointer; padding: 0; font-size: 15px; }
.star.on { color: var(--amber); }
.seen-by { display: flex; gap: 6px; flex-wrap: wrap; }
.seen { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); font-size: 12px; }
.seen .dot { width: 6px; height: 6px; }
.check-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; height: 32px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); }
.check-chip input { accent-color: var(--green); }
/* (by the table's own width: with the sidebar a laptop's is ~1000px) */
.fleet-channels { container-type: inline-size; }
@container (max-width: 1040px) { .fleet-channels .row, .fleet-channels .head { --cols: 28px 100px 90px minmax(0, 1fr) minmax(0, 1.6fr) 80px; } .fleet-channels .c-wide { display: none; } }

/* --- updates ------------------------------------------------------------------------- */

.rollout-form { gap: 14px; }
.deployment { display: flex; flex-direction: column; }
.dep-head { padding: 10px 14px; border-bottom: 1px solid var(--line); gap: 10px; }
.rollouts { --cols: 180px 220px 170px minmax(0, 1fr) 140px; }

/* a paused deployment (updates/_deployment): its card in the failure's
   colour, what happened in plain words beside what to do next */
.deployment.paused.tone-red { border-color: var(--red); }
.deployment.paused.tone-amber { border-color: var(--amber); }
.dep-why { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px 16px; padding: 0 16px 14px; }
.dep-why .story, .dep-why .next { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 6px; font-size: 13px; }
/* (tone-*: .red and .amber colour all the text) */
.dep-why .story.tone-red { background: var(--red-soft); }
.dep-why .story.tone-red > strong { color: var(--red); }
.dep-why .story.tone-amber { background: var(--amber-soft); }
.dep-why .story.tone-amber > strong { color: var(--amber); }
.dep-why .next { background: var(--raised); }
.dep-why .next .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.dep-why .next .form-row { gap: 8px; }
.dep-why .pill { font-size: 12px; padding: 1px 8px; }
@media (max-width: 940px) { .dep-why { grid-template-columns: 1fr; padding: 0 12px 12px; } }

/* the Updates page's releases and packages: narrower than their columns
   (a laptop, the sidebar beside it), without their notes (and the file count) */
.releases-table { --cols: 160px 130px 130px 130px minmax(0, 1fr) 150px; container-type: inline-size; }
.packages-table { --cols: 100px 110px 70px 100px minmax(0, 1fr) 170px 90px; container-type: inline-size; }
@container (max-width: 860px) {
  .releases-table .row, .releases-table .head { --cols: 140px 110px 110px minmax(0, 1fr) 130px; }
  .releases-table .row > :nth-child(5), .releases-table .head > :nth-child(5) { display: none; }
  .packages-table .row, .packages-table .head { --cols: 90px minmax(0, 1fr) 90px 150px 90px; }
  .packages-table .row > :nth-child(3), .packages-table .head > :nth-child(3),
  .packages-table .row > :nth-child(5), .packages-table .head > :nth-child(5) { display: none; }
}

/* firmware on the receivers (updates/_firmware): each one's two slots */
.fw-table { --cols: 140px 120px minmax(0, 1fr) minmax(0, 1fr) 220px; }
.fw-table .fw-unknown { grid-column: 3 / 5; }
.fw-table { container-type: inline-size; }
@container (max-width: 860px) {
  .fw-table .row, .fw-table .head { --cols: 110px 100px minmax(0, 1fr) minmax(0, 1fr); }
  .fw-table .fw-last { display: none; }
}
.fw-slot { max-width: 100%; }
.fw-slot { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.fw-slot b { font-weight: 600; }
.fw-slot .role { color: var(--dim); }
.fw-slot.good { border-color: var(--green); }
.fw-slot.good .role { color: var(--green); }
.fw-slot.failed { border-color: var(--red); }
.fw-slot.failed .role { color: var(--red); }
.fw-slot.trial { border-color: var(--amber); }
.fw-slot.trial .role { color: var(--amber); }
/* the same as tiles under a device's firmware row (devices/_updates) */
.updates-table .fw-tiles-row { display: block; padding: 0 16px 12px; min-height: 0; }
.fw-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fw-tile { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.fw-tile.good { border-color: var(--green); background: var(--green-soft); }
.fw-tile.good > .small:first-child { color: var(--green); }
.fw-tile.failed { border-color: var(--red); }
.fw-tile.failed > .small:first-child { color: var(--red); }
.fw-tile.trial { border-color: var(--amber); }
.updates-table .rollout .story-line { color: var(--text); }
.updates-table .rollout .story-line > a { white-space: nowrap; }
.rollouts .row { min-height: 38px; }
input[type=file] { font-size: 13px; color: var(--dim); }

/* --- users and grants ------------------------------------------------------------------ */

.roles { --cols: minmax(160px, 1fr) minmax(220px, 2fr) minmax(120px, 1fr) 90px 200px; }
.roles .perms { line-height: 1.5; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.perm-groups fieldset { margin: 0; min-width: 0; }
.perm-groups legend { padding: 0 4px; font-size: 13px; }
.check-line { display: flex; gap: 8px; align-items: baseline; font-size: 13px; cursor: pointer; }
.check-line input { accent-color: var(--green); }
.role-form .pair { grid-template-columns: 140px 1fr; }

/* (the role column fits "Суперадміністратор" and its select's longest role) */
.users { --cols: minmax(160px, 1fr) minmax(160px, 1fr) 170px 150px minmax(110px, 1fr) minmax(160px, 1.4fr) 120px 190px; overflow: visible; }
.users .row select, .users-waiting .row select { width: 100%; min-width: 0; }
.users-waiting { --cols: minmax(140px, 1fr) minmax(160px, 1fr) minmax(0, 1.2fr) 340px; container-type: inline-size; }
@container (max-width: 900px) {
  .users-waiting .row { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; }
}
/* by the table's own width (with the sidebar a 1440px window leaves it
   ~1170px): without the email, then without last seen, then as cards */
.users { container-type: inline-size; }
@container (max-width: 1370px) { .users .row, .users .head { --cols: minmax(160px, 1fr) 170px 150px minmax(110px, 1fr) minmax(160px, 1.4fr) 120px 190px; } .users .u-email { display: none; } }
@container (max-width: 1190px) { .users .row, .users .head { --cols: minmax(160px, 1fr) 170px 150px minmax(110px, 1fr) minmax(160px, 1.4fr) 190px; } .users .u-seen { display: none; } }
@container (max-width: 1060px) {
  .users .head { display: none; }
  .users .row { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; }
}
.teams { --cols: minmax(180px, 1.2fr) 120px minmax(120px, 1fr) minmax(110px, 1fr) minmax(140px, 1.2fr) 150px; }
.team-members { --cols: minmax(160px, 1fr) minmax(160px, 1fr) minmax(140px, 1fr) 110px; }

.grants { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: relative; }
.grants .x { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 0 2px; font-size: 13px; }
.grants .x:hover { color: var(--red); }
.add-grant summary { cursor: pointer; list-style: none; }
.add-grant summary::-webkit-details-marker { display: none; }
.add-grant .pop { position: absolute; z-index: 5; top: 28px; left: 0; width: max-content; }

/* --- custom antennas ------------------------------------------------------------------- */

.antennas { --cols: 64px minmax(160px, 1.2fr) minmax(180px, 1.5fr) 130px minmax(120px, 1fr) 210px; }
.antenna-model-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); gap: 12px; align-items: start; }
.polar .ring { fill: none; stroke: var(--line); stroke-width: 1; }
.polar .lobe { fill: color-mix(in srgb, var(--green) 25%, transparent); stroke: var(--green); stroke-width: 1.5; }
@media (max-width: 900px) { .antenna-model-form { grid-template-columns: 1fr; } }

/* --- field tests --------------------------------------------------------------------- */

.field-tests { --cols: minmax(160px, 1.4fr) 100px 110px minmax(140px, 1.4fr) 140px 90px; }
.field-page { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; margin-bottom: 16px; }
.field-page .field-map { height: min(520px, calc(100vh - 200px)); min-height: 320px; }
.field-page .field-map.armed { cursor: crosshair; outline: 2px solid var(--amber); }
.level-chart { width: 100%; height: 140px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.field-rx { --cols: minmax(160px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) 100px; }
.field-fit { --cols: minmax(80px, 1fr) 56px 100px 84px 72px 72px minmax(100px, 1fr); }
.field-fit .row, .field-fit .head { gap: 10px; }
.field-fixes { --cols: minmax(200px, 2fr) 90px 150px 100px; }
.leaflet-tooltip.field-label { background: var(--panel, #fff); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-size: 12px; padding: 1px 5px; }
@media (max-width: 900px) { .field-page { grid-template-columns: 1fr; } }

/* --- the map ------------------------------------------------------------------------- */

.map-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.map-area { padding: 0; min-height: 420px; }
.plan { position: relative; line-height: 0; user-select: none; }
.plan img { width: 100%; height: auto; display: block; }
.plan.armed, .world.armed { cursor: crosshair; outline: 2px solid var(--amber); }
.world { height: calc(100vh - 170px); min-height: 420px; }
.marker {
  position: absolute; transform: translate(-6px, -50%); display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12px; line-height: 1.4; white-space: nowrap; color: var(--text); cursor: pointer; touch-action: none;
}
.world .marker { position: static; transform: translate(-6px, -50%); }
.leaflet-container a.marker { color: var(--text); }
.marker:hover { text-decoration: none; border-color: var(--dim); }
.map-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.add-plan { position: relative; }
.add-plan summary { list-style: none; }
.add-plan summary::-webkit-details-marker { display: none; }
.add-plan .pop { position: absolute; right: 0; top: 38px; z-index: 1000; width: 320px; }
.leaflet-container { background: var(--bg); font: inherit; }
@media (max-width: 900px) { .map-page { grid-template-columns: 1fr; } }

/* --- On air (air/show) and a receiver's picked channel (devices/_picked) ------------------- */

.air { display: flex; flex-direction: column; gap: 16px; }
.air.with-map { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tiles .empty, .tiles .span-all { grid-column: 1 / -1; line-height: 1.5; }
.tile { display: flex; flex-direction: column; color: var(--text); }
.tile:hover { text-decoration: none; border-color: var(--dim); }
.tile:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.tile .about { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 10px; min-width: 0; }
.tile .line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tile .also { margin-left: auto; padding: 0 6px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); flex-shrink: 0; }
/* a channel's picture, 4:3: the receiver's frames over black (fpv-web's Frames) */
.pic { position: relative; aspect-ratio: 4 / 3; background: #000; overflow: hidden; }
.pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; visibility: hidden; }
.pic img.show { visibility: visible; }
.pic img.failed { display: none; }
.pic .none { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; font-size: 12px; color: #8a939b; }
.pic .osd { position: absolute; top: 7px; display: flex; align-items: center; gap: 4px; font: 700 14px/1.1 var(--mono); color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.pic .tl { left: 9px; }
.pic .tr { right: 9px; color: #2ee88a; filter: drop-shadow(0 0 1px #000); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle; flex-shrink: 0; }
.bars i { width: 3px; background: currentColor; opacity: .25; border-radius: 1px; }
.bars i.on { opacity: 1; }
.air-map { position: sticky; top: 16px; padding: 0; }
.air-map .world { height: min(560px, calc(100vh - 140px)); min-height: 300px; }
.marker.on { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.marker .on-air { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--raised); color: var(--dim); font-size: 11px; font-weight: 600; text-align: center; }
.marker .on-air.some { background: var(--green); color: var(--on-accent); }
/* the picture and the facts side by side while both fit, else the facts under it (by its own width: the sidebar takes some) */
.picked { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-start; }
.picked > .pic { flex: 1 1 280px; max-width: 360px; border-radius: 6px; }
.picked > .stack { flex: 1 1 300px; min-width: 0; }
@media (max-width: 960px) {
  .air.with-map { grid-template-columns: 1fr; }
  .air-map { position: static; order: -1; }
  .air-map .world { height: 220px; min-height: 0; }
}
@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .tile .about { padding: 6px 8px 8px; }
}

/* --- health (devices/_health_now, the health controller's charts) ----------------------- */

.health-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.health-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
/* (a long word, "перезавантаження", breaks inside its tile rather than pushing the page sideways) */
.health-tile .value { font-size: 17px; overflow-wrap: anywhere; hyphens: auto; }
.rails { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 2px; }
.alerts { display: flex; flex-direction: column; }
.alert-line { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.alert-line:last-child { border-bottom: 0; }
.alert-line.red { background: var(--red-soft); }
.alert-line.amber { background: var(--amber-soft); }
.charts-fold > .health-charts { padding: 16px; }
.health-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px 20px; }
.chart { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chart-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.chart-head .name { font-weight: 600; font-size: 13px; }
.chart-head .key { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); }
.chart-head .key i { width: 12px; height: 2px; display: inline-block; background: currentColor; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--dim); font-size: 10px; font-family: var(--mono); }
.chart .limit { stroke-width: 1; stroke-dasharray: 4 3; fill: none; }
.chart .limit.warn { stroke: var(--amber); }
.chart .limit.crit { stroke: var(--red); }
.chart .band { fill: var(--green-soft); }
.chart .series { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .maxline { fill: none; stroke-width: 1; stroke-dasharray: 2 2; opacity: .6; }
.chart .cursor line { stroke: var(--dim); stroke-width: 1; }
.chart .cursor text { fill: var(--text); font-size: 11px; font-family: var(--mono); }
.chart .cursor rect { fill: var(--raised); stroke: var(--line); }
.c0 { color: #5aa9e6; stroke: #5aa9e6; }
.c1 { color: #e8a33d; stroke: #e8a33d; }
.c2 { color: #3fb58f; stroke: #3fb58f; }
.c3 { color: #c678dd; stroke: #c678dd; }
.c4 { color: #e06c75; stroke: #e06c75; }
.c5 { color: #9aa5ae; stroke: #9aa5ae; }
@media (prefers-color-scheme: light) {
  .c0 { color: #2f7fc0; stroke: #2f7fc0; } .c1 { color: #b0731a; stroke: #b0731a; } .c2 { color: #237a5e; stroke: #237a5e; }
  .c3 { color: #9a4fb3; stroke: #9a4fb3; } .c4 { color: #c0444e; stroke: #c0444e; } .c5 { color: #6b7680; stroke: #6b7680; }
}
.health-events .row, .tunnel-events .row { min-height: 34px; }
.tunnels-table { --cols: minmax(0, 1.3fr) 150px 90px minmax(0, 1fr) 150px minmax(0, 1.6fr); }
.tunnels-table { container-type: inline-size; }
@container (max-width: 900px) { .tunnels-table .row, .tunnels-table .head { --cols: minmax(0, 1fr) 120px minmax(0, 1fr); } .tunnels-table .row > :nth-child(3), .tunnels-table .row > :nth-child(4), .tunnels-table .row > :nth-child(5), .tunnels-table .head > :nth-child(3), .tunnels-table .head > :nth-child(4), .tunnels-table .head > :nth-child(5) { display: none; } }
/* the fleet's Health column: the Zynq's temperature, its last hour, the hub round trip */
.health-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sparkline { flex-shrink: 0; }
.sparkline polyline { stroke: var(--dim); }
@media (max-width: 900px) { .health-charts { grid-template-columns: 1fr; } }

/* --- the antenna (devices/_antenna) ------------------------------------------------------ */

/* what it is, a label over each value; "type default" under one not set here */
.antenna-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 12px 16px; }
.antenna-facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.antenna-facts .k { font-size: 12px; color: var(--dim); }
.antenna-facts .d { font-size: 12px; color: var(--dim); }
.antenna-edit summary { cursor: pointer; color: var(--dim); }
.map-antenna { margin: -4px 0 2px 16px; }
/* labels over the fields, the fields their column's width: what it is, then where it points */
.antenna-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; margin-top: 12px; }
.antenna-form .field input, .antenna-form .field select { width: 100%; min-width: 0; height: 34px; background: var(--bg); }
.antenna-form .unit { color: var(--dim); opacity: .75; }
.antenna-form .wide, .antenna-form .form-row { grid-column: 1 / -1; }
@media (max-width: 900px) { .antenna-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* a channel's level trend (AirHelper#trend_arrow): approaching stands out */
.trend { font-weight: 700; white-space: nowrap; }
.trend.up { color: var(--amber); }
.trend.steady { color: var(--dim); }
.trend .small { font-weight: 500; }
/* its level over the sighting (AirHelper#level_graph) */
.level-graph .plot { position: relative; }
.level-graph svg { display: block; width: 100%; height: 100%; }
.level-graph .grid { stroke: var(--line); }
.level-graph .level { fill: none; stroke: var(--green); stroke-width: 2; }
.level-graph .fit { stroke: var(--dim); stroke-width: 2; stroke-dasharray: 5 4; }
.level-graph .fit.up { stroke: var(--amber); }
.level-graph .fit.down { stroke: var(--text); }
.level-graph .ax { position: absolute; left: 3px; font-size: 10px; color: var(--dim); }
.level-graph .ax.top { top: 0; }
.level-graph .ax.bot { bottom: 0; }
.level-graph .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 11px; }

/* the OSD (devices/_osd, osd_layouts): its state line, the constructor, the kept layouts */
.osd-state { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.osd-card .osd-actions { margin-top: 12px; flex-wrap: wrap; }
.osd-layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.osd-layout h2 { margin: 0; font-size: 15px; }
.osd-layout .form-row.wrap { flex-wrap: wrap; }

/* the Console tab's terminal (xterm.js, console_controller) */
.console-screen {
  height: 460px; padding: 8px; border-radius: 6px; background: #0d1117; border: 1px solid var(--line);
  font-family: var(--mono); overflow: hidden;
}
.console-screen:empty { display: none; }

/* --- rules and notifications ------------------------------------------------------ */

/* the bell in the sidebar's head: unread notifications */
.bell { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 4px; color: var(--dim); flex: none; }
.bell:hover { color: var(--text); background: var(--raised); text-decoration: none; }
.bell.on { color: var(--text); }
/* popups (top, until acknowledged) and toasts (bottom right, for a while) */
.popups, .toasts { position: fixed; z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.popups { top: 16px; left: 50%; transform: translateX(-50%); width: min(480px, calc(100vw - 32px)); }
.toasts { right: 16px; bottom: 16px; width: min(380px, calc(100vw - 32px)); }
.popups:empty, .toasts:empty { display: none; }
.note-card {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--dim);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  animation: note-in .18s ease-out;
}
.note-card.amber { border-left-color: var(--amber); }
.note-card.red { border-left-color: var(--red); }
.note-card.popup.red { border-color: var(--red); border-left-width: 4px; }
.note-card .note-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.note-card .note-text { font-size: 14px; }
.note-pic { display: block; border-radius: 4px; overflow: hidden; background: #000; }
.note-pic img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.note-pic.small-pic { width: 160px; margin-top: 4px; }
.note-card .icon-btn { border: 0; background: none; color: var(--dim); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
@keyframes note-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .note-card { animation: none; } }

.notes-table { --cols: 140px minmax(140px, 1fr) minmax(200px, 2.5fr) minmax(120px, 1fr); }
.btn.on-btn { color: var(--green); border-color: var(--green); }

/* the world map's zones panel */
.zones-panel { border-top: 1px solid var(--line); padding-top: 12px; }
.zone-form { padding: 10px; border: 1px dashed var(--green); border-radius: 6px; }
.zone-form input { height: 32px; }

/* the Rules page: figures, the rules as cards with their flow, the log beside */
.search { width: 220px; }
.rule-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-box { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-box b { font-size: 22px; font-weight: 600; }
.stat-box b .small { font-weight: 400; }
.rules-cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.rule-list { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.rules-aside { flex: 1 1 340px; min-width: 0; position: sticky; top: 16px; }
.rule-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; overflow: visible; }
.rule-card.off { opacity: .62; }
.rule-top { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.rule-name { font-weight: 600; }
.switch { width: 34px; height: 20px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); position: relative; flex: none; padding: 0; cursor: pointer; display: inline-block; }
.switch span { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--dim); transition: left .15s; }
.switch.on { background: var(--green-soft); border-color: var(--green); }
.switch.on span { left: 16px; background: var(--green); }
.chain { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.blk { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--raised); font-size: 12px; max-width: 260px; min-width: 0; }
.blk svg { color: var(--dim); flex: none; }
.blk.when { border-color: var(--green); background: var(--green-soft); }
.blk.when svg { color: var(--green); }
.blk.beside { border-style: dashed; background: transparent; }
.chain .arrow { color: var(--dim); font-size: 12px; }
.par { display: inline-flex; flex-direction: column; gap: 3px; padding: 3px; border: 1px dashed var(--line); border-radius: 6px; min-width: 0; }
.par .tag { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; padding-left: 2px; }
.rule-foot { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.templates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.template { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.template:hover { border-color: var(--dim); text-decoration: none; }
.log-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 8px; }
.log-empty { padding: 12px 16px; }
.log .ev { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.log .ev:last-child { border-bottom: 0; }
.log .ev .t { font-family: var(--mono); font-size: 12px; color: var(--dim); padding-top: 1px; }
.steps-mini { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.sm { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--raised); border: 1px solid var(--line); color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.sm.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.sm.wait { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.strong { font-weight: 600; }

/* the rule builder: the bar; the palette, the flow, the inspector */
main:has(> .builder) { padding: 0; gap: 0; }
main:has(> .builder) > .block { padding: 16px 24px 24px; }
.builder { display: flex; flex-direction: column; min-height: calc(100vh - 32px); }
.builder-bar { min-height: 56px; padding: 8px 20px; display: flex; align-items: center; gap: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.rule-name-input { height: 34px; min-width: 200px; flex: 0 1 340px; font-size: 16px; font-weight: 600; background: transparent !important; border-color: transparent !important; padding: 0 8px; }
.rule-name-input:hover, .rule-name-input:focus { border-color: var(--line) !important; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--dim); }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-input:checked + .switch { background: var(--green-soft); border-color: var(--green); }
.switch-input:checked + .switch span { left: 16px; background: var(--green); }
.switch-input:focus-visible + .switch { outline: 2px solid var(--green); outline-offset: 1px; }
.builder-error { padding: 8px 20px; background: var(--red-soft); }
.builder-work { flex-grow: 1; display: flex; flex-wrap: wrap; min-height: 0; }
.palette { flex: 0 0 232px; border-right: 1px solid var(--line); background: var(--panel); padding: 16px 12px; display: flex; flex-direction: column; gap: 16px; }
.palette.pick { animation: pick 1.2s ease-out; }
@keyframes pick { 0% { box-shadow: inset 0 0 0 2px var(--green); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
.palette-head { display: none; align-items: center; }
.pal-group { display: flex; flex-direction: column; gap: 4px; }
.pal-group h3, .ins-sub { margin: 0 0 2px; font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.pal { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; width: 100%; }
.pal svg { color: var(--dim); flex: none; }
.pal:hover { border-color: var(--dim); }
.pal.quiet { background: transparent; color: var(--dim); }
.pal .grip { margin-left: auto; color: var(--dim); font-size: 11px; letter-spacing: -1px; }
.flow-area { flex: 999 1 480px; min-width: 0; padding: 24px 28px 40px; background-color: var(--bg); background-image: radial-gradient(circle, color-mix(in srgb, var(--line) 80%, transparent) 1px, transparent 1.2px); background-size: 20px 20px; }
.flow { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; }
.flow .node-fields { display: none; }
.steps { display: flex; flex-direction: column; }
.step { display: flex; flex-direction: column; align-items: stretch; }
.step.moving { opacity: .4; }
.node { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.node:hover { border-color: var(--dim); }
.node:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.node.sel { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.node.when { border-color: var(--green); }
.node.when svg { color: var(--green); }
.node-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.node-head svg { color: var(--dim); flex: none; }
.node-head strong { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .chips { flex-wrap: wrap; gap: 6px; }
.node .chips:empty { display: none; }
.node .chip { height: 22px; padding: 0 7px; font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 20px; }
.step-num { width: 20px; height: 20px; border-radius: 50%; background: var(--raised); border: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--dim); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.step.beside .node, .step.beside .beside-label { margin-left: 48px; }
.step.beside .node { border-style: dashed; }
.beside-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 4px; }
.add-here { align-self: center; position: relative; width: 22px; height: 34px; border: 0; background: none; color: transparent; cursor: pointer; padding: 0; }
.add-here::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.add-here::after { content: "+"; position: absolute; left: 1px; top: 7px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); color: var(--dim); font-size: 14px; line-height: 18px; text-align: center; }
.add-here:hover::after, .add-here:focus-visible::after { border-color: var(--green); color: var(--green); }
.node .grip { margin-left: auto; padding: 4px 2px 4px 8px; color: var(--dim); font-size: 12px; letter-spacing: -1px; cursor: grab; touch-action: none; user-select: none; }
.node:hover .grip { color: var(--text); }
.drop-line { height: 3px; margin: 6px 0; border-radius: 2px; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--green); background: var(--panel); color: var(--text); font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); white-space: nowrap; }
.drag-ghost.nowhere { border-color: var(--line); opacity: .7; }
.builder.dragging, .builder.dragging * { cursor: grabbing !important; user-select: none; }
@media (pointer: fine) { .node { cursor: grab; } .pal[data-kind] { cursor: grab; } }
.end-drop { margin-top: 12px; border: 1px dashed var(--line); border-radius: 6px; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--dim); font-size: 13px; flex-wrap: wrap; padding: 6px; }
.builder.dragging .end-drop { border-color: var(--green); }
.flow-note { margin-top: 12px; text-align: center; }
.inspector { flex: 0 0 380px; border-left: 1px solid var(--line); background: var(--panel); padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ins-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ins-head h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-tools { display: inline-flex; gap: 2px; }
.ins-tools[hidden], .step-num[hidden] { display: none; }
.ins-body .node-fields { gap: 12px; }
.ins-body .field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--dim); }
.ins-body .field > span:first-child { font-size: 12px; }
.ins-body .field .input, .ins-body .field select, .ins-body textarea { width: 100%; min-width: 0; height: 34px; background: var(--bg); color: var(--text); font-size: 13px; }
.ins-body textarea { height: auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; font: 12px/1.45 var(--mono); resize: vertical; }
.ins-body select[multiple] { height: auto; padding: 4px; }
.ins-body .check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.ins-body .check input { width: 16px; height: 16px; accent-color: var(--green); }
.ins-body .row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ins-body .row3 { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 10px; }
.ins-body .row2[hidden], .ins-body .field[hidden] { display: none; }
.ins-body .url-row { display: flex; gap: 6px; }
.ins-body .url-row select { width: auto; flex: none; }
.ins-sub { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.node-fields:has(.do-select option[value="back"]:checked) .not-back,
.node-fields:has(.do-select option:not([value="watch"]):checked) .watch-only { display: none; }
.vars summary { cursor: pointer; }
.vars .chips { gap: 4px; flex-wrap: wrap; padding-top: 8px; }
.vars .chip { font-size: 11px; cursor: pointer; color: var(--text); padding: 2px 6px; }
.vars .chip:hover { border-color: var(--dim); }
.test-result { margin: 0; max-height: 320px; overflow: auto; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; }
.test-result.ok { border-color: var(--green); }
.test-result.bad { border-color: var(--red); }

/* an if step's lanes in the flow: yes and else, side by side */
.lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.lane { border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px 10px; display: flex; flex-direction: column; min-width: 0; }
.lane.yes { border-color: color-mix(in srgb, var(--green) 55%, transparent); }
.lane.else { border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.lane.loop { border-color: color-mix(in srgb, var(--dim) 70%, transparent); }
.lanes.one { grid-template-columns: 1fr; }
.lane-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.lane.yes > .lane-label { color: var(--green); }
.lane.else > .lane-label { color: var(--amber); }
.lane.loop > .lane-label { color: var(--text); }
.lane-steps { display: flex; flex-direction: column; min-height: 8px; }
.lane-add { margin-top: 8px; align-self: flex-start; height: 26px; padding: 0 9px; border-radius: 4px; border: 1px dashed var(--line); background: transparent; color: var(--dim); font: inherit; font-size: 12px; cursor: pointer; }
.lane-add:hover { border-color: var(--green); color: var(--green); }
.builder.dragging .lane { border-style: solid; }
/* the list's chain: an if with its lanes under it */
.if-chain { display: inline-flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.if-lane { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding-left: 6px; border-left: 2px solid var(--line); }
.if-lane.yes { border-left-color: var(--green); }
.if-lane.else { border-left-color: var(--amber); }
.if-lane.loop { border-left-color: var(--dim); }
.if-lane .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); }

/* the condition editor (condition controller): groups of rows, AND / OR, NOT */
.cond-summary { display: none; }
.cond-group { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.cond-group .cond-group { background: var(--panel); }
.cond-group.negated { border-color: var(--amber); }
.cond-head, .cond-foot, .cond-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.cond-row { padding: 4px; border-radius: 4px; }
.cond-row.negated { background: var(--amber-soft); }
.cond-row select, .cond-row input, .cond-head select { height: 30px !important; width: auto !important; min-width: 0; font-size: 12px !important; }
.cond-field { max-width: 160px; }
.cond-v.num { width: 80px !important; }
.cond-v[type=text] { flex: 1 1 100px; width: 100px !important; }
.cond-not { height: 24px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); background: transparent; color: var(--dim); font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .04em; cursor: pointer; }
.cond-not[aria-pressed="true"] { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.cond-x { margin-left: auto; border: 0; background: none; color: var(--dim); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.cond-x:hover { color: var(--red); }
.cond-join { align-self: flex-start; font-size: 11px; font-weight: 600; letter-spacing: .05em; color: var(--dim); padding-left: 6px; }
.cond-empty { padding: 2px 4px; }

@media (max-width: 1100px) {
  .inspector { flex-basis: 100%; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  /* the palette: a sheet from the bottom, opened by a + */
  .palette { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; max-height: 75vh; overflow-y: auto; border-right: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .45); transform: translateY(105%); transition: transform .2s; }
  .palette.open { transform: none; }
  .palette-head { display: flex; }
  .palette-head .palette-close { margin-left: auto; }
  .flow-area { padding: 16px 12px 28px; }
  .rule-name-input { flex-basis: 100%; order: 1; }
}
@media (max-width: 720px) {
  .lanes { grid-template-columns: 1fr; }
  .rule-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .templates { grid-template-columns: 1fr; }
  .rules-aside { position: static; }
  .search { width: 100%; }
  .notes-table { --cols: 1fr; }
  .notes-table .head { display: none; }
  .step.beside .node, .step.beside .beside-label { margin-left: 24px; }
}
@media (prefers-reduced-motion: reduce) { .palette, .switch span { transition: none; } .palette.pick { animation: none; } }

/* the API page: the calls beside the request builder */
.api-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.api-steps code, .api-detail code, .api-line code { font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); }
.api-bases { margin-top: 6px; }
.api-builder { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.api-builder [hidden] { display: none !important; }
.api-calls { padding: 8px; display: flex; flex-direction: column; gap: 1px; max-height: 80vh; overflow-y: auto; position: sticky; top: 16px; }
.api-group { padding: 10px 8px 4px; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); }
.api-call { display: flex; align-items: baseline; gap: 8px; min-height: 30px; line-height: 1.35; padding: 4px 8px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.api-call:hover { background: var(--raised); }
.api-call.on { background: var(--raised); font-weight: 500; }
.api-call:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.api-method { flex-shrink: 0; min-width: 46px; padding: 1px 0; border-radius: 3px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-align: center; background: var(--green-soft); color: var(--text); }
.api-method.post, .api-method.put, .api-method.patch { background: var(--amber-soft); }
.api-method.delete { background: var(--red-soft); }
.api-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.api-line code { font-size: 14px; padding: 3px 8px; }
.api-detail { margin: 0; color: var(--dim); line-height: 1.5; }
.api-pair { grid-template-columns: 110px minmax(0, 1fr); flex: 1 1 260px; }
.api-pair.mono { font-family: var(--mono); font-size: 12.5px; }
.api-panel textarea { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 12.5px; line-height: 1.5; resize: vertical; }
.api-panel .cmd pre { white-space: pre-wrap; word-break: break-word; }
.api-result { margin: 0; max-height: 420px; overflow: auto; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.api-picture { max-width: 480px; width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.partner-toggle { cursor: pointer; color: var(--text); }
.partner-toggle.off { color: var(--dim); border-style: dashed; background: none; }
@media (max-width: 900px) {
  .api-builder { grid-template-columns: 1fr; }
  .api-calls { position: static; max-height: 260px; }
}

/* the API reference: its contents beside it, a bar for every "Try it" */
.api-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; }
.api-bar .api-pair { flex: 1 1 240px; }
.api-ref { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.api-toc { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 1px; }
.api-toc a { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 4px; color: var(--text); font-size: 12px; }
.api-toc a:hover { background: var(--raised); text-decoration: none; }
.api-toc-section { margin-top: 8px; font-size: 11px !important; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim) !important; }
.api-toc .api-method { min-width: 40px; font-size: 9.5px; }
.api-doc { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.api-entry { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); scroll-margin-top: 70px; }
.api-doc section { scroll-margin-top: 70px; }
.api-entry h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; line-height: 1.6; }
.api-try { margin: 8px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.api-try summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; }
.api-try summary::-webkit-details-marker { display: none; }
.api-try summary:hover { background: var(--raised); }
.api-try summary:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.api-try[open] summary { border-bottom: 1px solid var(--line); }
.api-try-body { padding: 12px; }
.api-try [hidden] { display: none !important; }
.api-try textarea { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12.5px; line-height: 1.5; resize: vertical; }
.api-try .cmd { background: var(--panel); }
.api-try .cmd pre { white-space: pre-wrap; word-break: break-word; }
.md { line-height: 1.6; font-size: 14px; }
.md h2 { margin: 0 0 8px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.md code, .api-try summary code, .api-entry h3 code { font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); word-break: break-word; }
.api-try summary code { background: none; border: 0; padding: 0; font-size: 13px; }
.md-code { margin: 10px 0; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); overflow-x: auto; line-height: 1.5; }
.md-code code { padding: 0; border: 0; background: none; word-break: normal; white-space: pre; }
.md-table { width: 100%; margin: 10px 0; border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { padding: 6px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.md-table th { color: var(--dim); font-weight: 500; }
@media (max-width: 1000px) {
  .api-ref { grid-template-columns: 1fr; }
  .api-toc { position: static; max-height: 220px; }
}

/* the SAPIENT page: the nodes, and what they report */
.sapient-nodes { --cols: minmax(0, 1.2fr) 130px minmax(0, 1.4fr) 70px 80px minmax(0, 1.3fr); }
.sapient-objects { --cols: minmax(0, 1fr) minmax(0, 1.2fr) 90px 70px minmax(0, 1.2fr) 60px minmax(0, 1fr); }
.sapient-nodes, .sapient-objects { container-type: inline-size; }
@container (max-width: 800px) {
  .sapient-nodes .row, .sapient-nodes .head { --cols: minmax(0, 1fr) 120px 60px; }
  .sapient-nodes .row > :nth-child(3), .sapient-nodes .row > :nth-child(5), .sapient-nodes .row > :nth-child(6),
  .sapient-nodes .head > :nth-child(3), .sapient-nodes .head > :nth-child(5), .sapient-nodes .head > :nth-child(6) { display: none; }
  .sapient-objects .row, .sapient-objects .head { --cols: minmax(0, 1fr) minmax(0, 1fr) 80px; }
  .sapient-objects .row > :nth-child(n+4), .sapient-objects .head > :nth-child(n+4) { display: none; }
}

/* --- fpv-auth: its own pages (the rest is the hub's sheet) -------------------------- */

input[type=password], input[type=datetime-local], input[type=url], textarea {
  height: 32px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px;
}
textarea { height: auto; padding: 8px 10px; font-family: inherit; line-height: 1.4; resize: vertical; }
textarea.mono { font-family: var(--mono); }
textarea:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.field input, .field select, .field textarea { color: var(--text); }
.field input[type=password].big { height: 38px; font-size: 15px; background: var(--bg); }
.field .hint { font-size: 12px; }
section.narrow, form.narrow { max-width: 720px; }
.card.padded.stack > form { margin: 0; }
.end-self { align-self: flex-end; }
.facts.wide-keys { grid-template-columns: 130px 1fr; align-items: center; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.check input { margin-top: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.field > input:not([type=checkbox]), .field > select, .field > textarea { width: 100%; min-width: 0; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }
.people { --cols: minmax(170px, 1.2fr) minmax(170px, 1.2fr) 150px minmax(120px, 1.4fr) 100px 140px; }
.apps { --cols: minmax(160px, 1fr) 110px minmax(200px, 1.4fr) minmax(140px, 1.4fr) minmax(120px, 1fr); }
.audit-log { --cols: 140px minmax(130px, 1fr) 150px minmax(130px, 1fr) minmax(160px, 2fr) 120px; }
.grid-table a.row:hover { background: var(--raised); text-decoration: none; }
@media (max-width: 940px) {
  .people { --cols: minmax(0, 1fr) 100px; }
  .apps { --cols: minmax(0, 1fr) 110px; }
  .audit-log { --cols: 120px minmax(0, 1fr) minmax(0, 1fr); }
  .people .wide-only, .apps .wide-only, .audit-log .wide-only, .people .head, .apps .head, .audit-log .head { display: none; }
}
.secret-box { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--amber); border-radius: 6px; background: var(--amber-soft); }
.secret-box code { display: block; padding: 8px 10px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); overflow-wrap: anywhere; user-select: all; }
pre.env { margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font: 13px/1.5 var(--mono); overflow-x: auto; user-select: all; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field-errors { color: var(--red); font-size: 13px; }
