/* Visual language of the KeeneticOS web panel (its .dark / .light theme tokens): navy surfaces, 1px grey card
   borders, upper-case bold card titles, #0097dc accent, status chips with a dot, pickers and toggles as in the panel.
   Only the look is borrowed: no Keenetic logos or icons. Theme follows the OS setting.
   Roboto, as in the panel: latin + cyrillic subsets from @fontsource/roboto 5.1.0 (Apache-2.0, fonts/LICENSE). */
@font-face { font-family: Roboto; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/roboto-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/roboto-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/roboto-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/roboto-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  color-scheme: dark;
  --background: #1b2434;      /* cards, header, page */
  --page: #1b2434;
  --menu: #161c27;            /* navigation, inset blocks */
  --menu-active: #2e3d57;
  --menu-border: #2e3d57;
  --stroke: #4d545f;          /* card borders, separators, inputs */
  --table-header: #2f3745;
  --text: #c2c2c2;
  --text-gray: #949b9f;
  --help-text: #6f737b;
  --primary: #0097dc;
  --primary-hover: #1c6c9a;
  --outline-bg: #1b2434;
  --outline-border: #0097dc;
  --error: #de3d3d;
  --toggle-on: #3d5073; --toggle-on-thumb: #0097dc;
  --toggle-off: #2e3d57; --toggle-off-thumb: #808b96;
  --progress: #3d5073; --progress-error: #ea4c4c;
  --st-success-text: #25c478; --st-success-border: #3a634f; --st-success-bg: #40484f;
  --st-info-text: #c8c8c8;    --st-info-border: #767676;    --st-info-bg: #444851;
  --st-warning-text: #ff6565; --st-warning-border: #705551; --st-warning-bg: #45464e;
  --st-caution-text: #ffbb57; --st-caution-border: #70633c; --st-caution-bg: #383730;
  --sp-warning-border: #705551; --sp-warning-bg: #3b2f39;
  --sp-info-border: #70633c;    --sp-info-bg: #383730;
  --notify-bg: #263041; --notify-border: #2f394a; --notify-text: #fff;
  --online: #7dce70; --offline: #6c7c85;
  --disabled-bg: #333a48; --disabled-line: #687378;
  --card-border: #4d545f;
  --shadow-1: 0 0 18px 0 #06080b;
  --tooltip-shadow: 0 0 18px 0 rgba(6, 8, 11, .5);
  --scroll-thumb: #3d5073; --scroll-bg: #2e3d57;
  --series: #0097dc;
  --grid: #2f3745;
  /* categorical series (validated: dataviz validate_palette, dark surface #1b2434) */
  --c1: #0097dc; --c2: #e76624; --c3: #00a888; --c4: #d28e05; --c5: #e24d8b; --c6: #0aac23; --c7: #9887ef;
  --c-other: #6b7078;
  /* form controls and tables */
  --field-idle: #4d545f;       /* label inside an empty field */
  --input-disabled-bg: #2f3745; --input-disabled-text: #6f737b;
  --check-stroke: #3d5073; --check-hover: #77bce4; --check-disabled: #2e3d57;
  --radio-on: #0097dc; --radio-dot: #fff;
  --table-border: #4d545f; --table-row-hover: #161c27;
  --backdrop: rgb(0 0 0 / 32%);
  --header-h: 64px;
  --menu-w: 72px;
  font-family: Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --background: #fff;
    --page: #edeef0;
    --menu: #fafafa;
    --menu-active: #ebebeb;
    --menu-border: #ebebeb;
    --stroke: #bdb7b7;
    --table-header: #fafafa;
    --text: #000;
    --text-gray: #6e6e6e;
    --help-text: #949b9f;
    --outline-bg: #fff;
    --outline-border: #c1dded;
    --toggle-on: #cce6f5; --toggle-on-thumb: #0097dc;
    --toggle-off: #d6d8d9; --toggle-off-thumb: #fff;
    --progress: #cce6f5; --progress-error: #ff6d54;
    --st-success-text: #1e7049; --st-success-border: #cbf2df; --st-success-bg: #e4faef;
    --st-info-text: #686868;    --st-info-border: #ededed;    --st-info-bg: #fafafa;
    --st-warning-text: #de3d3d; --st-warning-border: #ffded9; --st-warning-bg: #ffece9;
    --st-caution-text: #b86e00; --st-caution-border: #f9ecc5; --st-caution-bg: #fff7e1;
    --sp-warning-border: #ffe5de; --sp-warning-bg: #ffece9;
    --sp-info-border: #f9ecc5;    --sp-info-bg: #fff7e1;
    --notify-bg: #fff; --notify-border: #ededed; --notify-text: #000;
    --online: #03b25a; --offline: #949b9f;
    --disabled-bg: #fff; --disabled-line: #c1dded;
    --card-border: transparent;
    --shadow-1: 0 5px 20px rgb(0 0 0 / 5%);
    --tooltip-shadow: 0 0 10px rgb(0 0 0 / 16%);
    --scroll-thumb: #d6d8d9; --scroll-bg: #f0f0f0;
    --series: #0086c4;
    --grid: #ebebeb;
    /* same hues, light steps (validated on #fff) */
    --c1: #0086c4; --c2: #f47230; --c3: #00b894; --c4: #f2a600; --c5: #ee7fac; --c6: #008a17; --c7: #6a4ce2;
    --c-other: #a3a8af;
    --field-idle: #949b9f;
    --input-disabled-bg: #fafafa; --input-disabled-text: #949b9f;
    --check-stroke: #bdb7b7; --check-hover: #77bce4; --check-disabled: #f0f0f0;
    --radio-on: #cce6f5; --radio-dot: #0097dc;
    --table-border: #ebebeb; --table-row-hover: #f5fafc;
    --backdrop: rgb(0 0 0 / 25%);
  }
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--scroll-thumb) var(--scroll-bg); }
body { margin: 0; background: var(--page); color: var(--text); font-size: 14px; line-height: 22px; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }

/* ---------- frame: header, navigation (left rail; bottom bar on phones) ---------- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(var(--header-h) + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 16px; padding: env(safe-area-inset-top) 24px 0;
  background: var(--background); box-shadow: var(--shadow-1); clip-path: inset(0 0 -24px 0);
}
.appbar h1 { margin: 0; flex: 1; min-width: 0; font-size: 20px; line-height: 24px; font-weight: 700; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .brand { color: var(--primary); letter-spacing: .04em; text-transform: none; }
.appbar .model { color: var(--text); font-weight: 400; }
.health:empty { display: none; }

nav#tabs {
  position: fixed; z-index: 19; top: var(--header-h); bottom: 0; left: 0; width: var(--menu-w);
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--menu); border-right: 1px solid var(--menu-border);
}
nav#tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  flex: none; height: 72px; padding: 0 2px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 10px; line-height: 14px; color: var(--text-gray);
  border-top: 1px solid; border-image: linear-gradient(to right, var(--primary) 0%, transparent 100%) 1;
}
nav#tabs button:first-child { border-top-width: 0; }
nav#tabs svg { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav#tabs span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav#tabs button:hover { background: var(--background); color: var(--text); }
nav#tabs button[aria-current="page"] { background: var(--menu-active); color: var(--text); }
nav#tabs button:focus-visible { outline: 1px solid var(--primary); outline-offset: -1px; border-radius: 4px; }

main { max-width: calc(1000px + var(--menu-w)); margin-left: var(--menu-w); padding: calc(var(--header-h) + 24px) 32px 64px; }
@media (min-width: 600px) { main[data-layout="cards"] { padding-left: 24px; padding-right: 24px; } }
/* list pages (tables) take the whole width, as in the panel */
main[data-layout="page"] { max-width: none; }
/* two columns of cards, as the panel's dashboard; notices, headings and notes span both */
@media (min-width: 1240px) {
  /* columns rather than a grid: a short card does not leave a hole beside a tall one */
  main[data-layout="cards"] { max-width: calc(1440px + var(--menu-w)); columns: 2; column-gap: 24px; }
  main[data-layout="cards"] > .card { break-inside: avoid; }
  main[data-layout="cards"] > :not(.card) { column-span: all; }
}

@media (max-width: 599px) {
  .appbar { padding: env(safe-area-inset-top) 16px 0; height: calc(56px + env(safe-area-inset-top)); }
  .appbar h1 { font-size: 15px; letter-spacing: 0; }
  nav#tabs {
    top: auto; right: 0; width: auto; flex-direction: row; overflow: visible;
    padding-bottom: env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--menu-border);
  }
  nav#tabs button { flex: 1 1 0; min-width: 0; height: 60px; border-top: 0; border-left: 1px solid; border-image: linear-gradient(to top, var(--primary) 0%, transparent 100%) 1; }
  nav#tabs button:first-child { border-left-width: 0; }
  main { margin-left: 0; padding: calc(56px + env(safe-area-inset-top) + 12px) 8px calc(60px + env(safe-area-inset-bottom) + 24px); }
}

/* ---------- page and block headers, as the panel's list and settings pages ---------- */
.page-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 8px; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.page-desc { margin: 0 0 24px; line-height: 24px; color: var(--text); }
.page-block { margin-bottom: 40px; }
.block-head { display: flex; align-items: center; gap: 8px; margin: 0 0 24px; }
.block-head h3 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; color: var(--text); }
.block-head + .block-desc { margin: -16px 0 24px; }
.block-desc { color: var(--text); }
.page-desc, .block-desc, .page-block > dl.kv { max-width: 800px; }
.page-block > dl.kv { margin: 0; }
.page-block > dl.kv + .lan-state, .page-block > dl.kv + p.note { margin-top: 16px; }
/* «О модуле»: the feature list reads as the README's, one feature per line */
ul.features { max-width: 800px; margin: 0; padding-left: 20px; }
ul.features li { margin: 0 0 8px; }
ul.features li::marker { color: var(--primary); }
@media (max-width: 599px) {
  .page-head h1 { font-size: 22px; line-height: 30px; }
  .block-head h3 { font-size: 18px; line-height: 26px; }
}
/* «?» next to a title: the explanation is in the tooltip */
.help { display: inline-flex; flex: none; width: 16px; height: 16px; color: var(--text-gray); cursor: help; border-radius: 50%; }
.help svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; }
.help:hover { color: var(--primary); }
/* an empty or informational inset, as the panel's «Нет данных» */
.spacer { padding: 24px; border: 1px solid var(--stroke); border-radius: 4px; background: var(--menu); text-align: center; }

/* ---------- cards and text ---------- */
h2 { font-size: 14px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-gray); margin: 32px 4px 12px; }
.card {
  background: var(--background); border: 1px solid var(--card-border); border-radius: 8px;
  padding: 24px; margin-bottom: 24px; transition: box-shadow var(--t, .1s) linear;
}
.card:hover { box-shadow: var(--shadow-1); }
@media (max-width: 599px) { .card { padding: 16px; margin-bottom: 12px; } }
.card.dim { opacity: .6; }
.row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-gray); font-size: 12px; line-height: 20px; }
.title { font-weight: 700; font-size: 16px; line-height: 24px; letter-spacing: 1px; text-transform: uppercase; color: var(--text); overflow-wrap: anywhere; }
.big { font-size: 24px; line-height: 32px; font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; }

/* neutral tags: applications, categories, notes */
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 8px; border-radius: 4px; font-size: 12px; line-height: 20px; background: var(--menu-active); color: var(--text); white-space: nowrap; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 15px; line-height: 1; }
/* status chips, as «● ПОДКЛЮЧЕНО» in the panel */
.chip.status {
  gap: 10px; padding: 0 12px; text-transform: uppercase;
  color: var(--st-info-text); background: var(--st-info-bg); border: 1px solid var(--st-info-border);
}
.chip.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.status.good { color: var(--st-success-text); background: var(--st-success-bg); border-color: var(--st-success-border); }
.chip.status.warn { color: var(--st-caution-text); background: var(--st-caution-bg); border-color: var(--st-caution-border); }
.chip.status.bad { color: var(--st-warning-text); background: var(--st-warning-bg); border-color: var(--st-warning-border); }
.health { font-size: 11px; }

.bar { height: 8px; background: var(--progress); border-radius: 4px; overflow: hidden; margin: 16px 0 8px; }
.bar > div { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }
.bar.over > div { background: var(--progress-error); }
.hosts { margin: 12px 0 0; padding: 0; list-style: none; }
.hosts li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--stroke); }
.hosts li:first-child { border-top: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.card .actions { gap: 8px; }
.nowrap { white-space: nowrap; }
/* «Сегодня»: a device in no group, one per line in its card */
.stranger { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stroke); overflow-wrap: anywhere; }
.stranger .actions { margin-top: 12px; }

/* ---------- buttons: 40px basic, 32px small (actions in lists and tables), 32×32 icon-only ---------- */
button.btn, summary.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  font: inherit; font-size: 14px; line-height: 22px; height: 40px; min-width: 64px; padding: 0 20px; border-radius: 4px;
  border: 1px solid var(--outline-border); background: var(--outline-bg); color: var(--primary); cursor: pointer; white-space: nowrap; text-decoration: none;
}
button.btn.small, summary.btn.small { height: 32px; padding: 0 16px; gap: 8px; }
button.btn.icon { width: 32px; min-width: 32px; height: 32px; padding: 0; }
button.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
summary.btn { list-style: none; width: max-content; }
summary.btn::-webkit-details-marker { display: none; }
button.btn:hover, summary.btn:hover, a.btn:hover { border-color: var(--primary-hover); background: var(--primary-hover); color: #fff; }
button.btn.primary, a.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.btn.primary:hover, a.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* the panel has no red outline buttons: deleting is an ordinary outline button; red is kept for the one
   irreversible action (.danger.solid) */
button.btn.danger.solid { background: var(--error); border-color: var(--error); color: #fff; }
button.btn.danger.solid:hover { filter: brightness(.9); }
button.btn:disabled, button.btn:disabled:hover { cursor: default; background: var(--disabled-bg); border-color: var(--disabled-line); color: var(--disabled-line); filter: none; }
button.btn.primary:disabled { border-color: var(--disabled-bg); }
button:focus-visible, summary:focus-visible, a.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--primary); outline-offset: 2px; }
@media (max-width: 599px) { button.btn, summary.btn, a.btn { padding: 0 14px; } button.btn.small { padding: 0 12px; } }

/* notices, as the panel's spacer blocks */
.banner { border-radius: 4px; padding: 16px 24px; margin-bottom: 16px; background: var(--sp-info-bg); border: 1px solid var(--sp-info-border); color: var(--text); }
.banner.bad { background: var(--sp-warning-bg); border-color: var(--sp-warning-border); }
.banner .btn { margin-top: 12px; }
.banner.hint { padding: 8px 12px; margin: 12px 0; font-size: 12px; line-height: 20px; }
@media (max-width: 599px) { .banner { padding: 12px; } }

/* ---------- form fields ---------- */
label.field { display: block; margin: 16px 0 6px; font-size: 12px; line-height: 20px; color: var(--text-gray); }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--background); border: 1px solid var(--stroke); border-radius: 4px;
  padding: 0 12px; height: 40px; width: 100%;
}
input::placeholder { color: var(--help-text); }
:is(input:not([type]), input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select):hover { border-color: var(--text-gray); }
:is(input:not([type]), input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select):focus { border-color: var(--primary); outline: none; }
:is(input:not([type]), input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select):disabled {
  background: var(--input-disabled-bg); color: var(--input-disabled-text); border-color: var(--stroke); cursor: default;
}
/* the panel's select: no native chrome, a small grey triangle */
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 5'%3E%3Cpath d='M0 0h7L3.5 5z' fill='%23949b9f'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 7px 5px;
}
select option { background: var(--background); color: var(--text); }
input[type=number] { max-width: 130px; }
input[type=time] { width: auto; }
@media (max-width: 599px) { :is(input:not([type]), input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select) { font-size: 16px; } }

/* outlined field with the label on its border, as the panel's inputs and selects: the control comes first,
   its <label> right after it. An input with placeholder=" " keeps the label inside while empty. */
.ofield { position: relative; max-width: 600px; margin: 0 0 16px; }
.ofield.narrow { max-width: 160px; }
.ofield > :is(input, select) { width: 100%; max-width: none; }
.ofield > label {
  position: absolute; left: 11px; top: -6px; padding: 0 2px; border-radius: 2px; pointer-events: none;
  font-size: 12px; line-height: 12px; color: var(--text-gray); background: var(--background);
  max-width: calc(100% - 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: top .1s, font-size .1s;
}
.ofield > input[placeholder=" "]:placeholder-shown:not(:focus) + label { top: 9px; font-size: 14px; line-height: 22px; color: var(--field-idle); }
.ofield > :is(input, select):disabled + label { background: linear-gradient(var(--background) 50%, var(--input-disabled-bg) 50%); }
.ofield > .hint { margin: 4px 0 0 4px; font-size: 12px; line-height: 16px; color: var(--text-gray); }
.ofield > .hint.err { color: var(--st-warning-text); }
.ofield.bad > :is(input, select) { border-color: var(--error); }

/* checkbox and radio: 16px, as in the panel (switches stay for turning a whole thing on or off) */
.check { display: inline-flex; align-items: flex-start; gap: 12px; min-height: 22px; cursor: pointer; color: var(--text); }
.check + .check { margin-left: 20px; }
.check > input {
  appearance: none; -webkit-appearance: none; flex: none; width: 16px; height: 16px; margin: 3px 0 0; cursor: pointer;
  border: 1px solid var(--check-stroke); border-radius: 4px; background: var(--background) center / 10px 8px no-repeat;
}
.check > input[type=radio] { border-radius: 50%; }
.check > input:hover { border-color: var(--check-hover); }
.check > input[type=checkbox]:checked {
  border-color: var(--primary); background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l3 3 5-6' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.check > input[type=checkbox]:checked:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); }
.check > input[type=radio]:checked { border-color: var(--primary); background: radial-gradient(circle, var(--radio-dot) 0 3px, var(--radio-on) 3.5px); }
.check > input:disabled { cursor: default; border-color: var(--check-stroke); background-color: var(--check-disabled); }
.check:has(> input:disabled) { cursor: default; color: var(--text-gray); }
.checks { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 0 0 16px; }
.checks .check + .check { margin-left: 0; }
.checks.col { flex-direction: column; }
.card > .muted + .row { margin-top: 12px; }

/* layout inside pages and dialogs */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 24px; }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin: 0 0 16px; }
.field-row > .ofield { flex: 0 1 160px; margin: 0; }
.field-row > .btn { align-self: center; }
.subhead { margin: 0 0 8px; color: var(--text-gray); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.seg-row { margin: 0 0 16px; }
p.note { margin: 0 0 16px; font-size: 12px; line-height: 16px; }
.limit + .limit { margin-top: 8px; }
.modal-body > section > :last-child { margin-bottom: 0; }
.modal-body .results { margin: -8px 0 16px; max-width: 600px; }

/* settings page: fields 352px wide, as the panel's forms; the save bar is pinned to the bottom while the form
   has unsaved changes */
main[data-tab="settings"] .page-block .ofield:not(.narrow) > :is(input, select) { max-width: 352px; }
.page-head + :is(.page-block, .banner) { margin-top: 24px; }
.check-item { margin: 0 0 16px; }
.check-desc { margin: 0 0 0 28px; font-size: 12px; line-height: 20px; color: var(--text-gray); }
.lan-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; overflow-wrap: anywhere; }
.savebar {
  position: fixed; z-index: 18; left: var(--menu-w); right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  min-height: 64px; padding: 12px 32px; background: var(--background); box-shadow: 0 -4px 18px 0 rgba(0, 0, 0, .25);
}
.savebar[hidden] { display: none; }
.savebar .btn { width: 160px; }
.savebar .err { flex: 1 1 100%; order: 1; margin: 0; }
.savebar .err:empty { display: none; }
main:has(.savebar:not([hidden])) { padding-bottom: 128px; }
body:has(.savebar:not([hidden])) #toast { bottom: 88px; }
@media (max-width: 599px) {
  main[data-tab="settings"] .page-block .ofield:not(.narrow) > :is(input, select) { max-width: none; }
  body:has(.savebar:not([hidden])) #toast { bottom: calc(60px + env(safe-area-inset-bottom) + 76px); }
  .savebar { left: 0; bottom: calc(60px + env(safe-area-inset-bottom)); padding: 12px 8px; gap: 8px 12px; }
  .savebar .btn { flex: 1 1 0; width: auto; }
  main:has(.savebar:not([hidden])) { padding-bottom: calc(60px + env(safe-area-inset-bottom) + 96px); }
}

/* toggle: 34×14 bar, 20px thumb overhanging it */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 34px; height: 20px; margin: 0; cursor: pointer; background: none; }
.switch input::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 14px; border-radius: 10px; background: var(--toggle-off); }
.switch input::after { content: ""; position: absolute; top: 0; left: -1px; width: 20px; height: 20px; border-radius: 50%; background: var(--toggle-off-thumb); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .1s, background .1s; }
.switch input:hover:not(:checked)::after { background: var(--primary); }
.switch input:checked::before { background: var(--toggle-on); }
.switch input:checked::after { transform: translateX(15px); background: var(--toggle-on-thumb); }
.switch input:disabled { opacity: .5; cursor: default; }

.results { border: 1px solid var(--stroke); border-radius: 4px; margin-top: 4px; max-height: 260px; overflow-y: auto; background: var(--background); box-shadow: var(--tooltip-shadow); }
.results button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: baseline; background: none; border: 0; border-top: 1px solid var(--stroke); padding: 8px 12px; color: var(--text); font: inherit; cursor: pointer; }
.results button:first-child { border-top: 0; }
.results button:hover { background: var(--menu-active); }
.results button:disabled, .results button:disabled:hover { cursor: default; background: none; color: var(--text-gray); }

/* pickers (segmented buttons): weekdays and the traffic switches */
.days, .seg { display: inline-flex; flex-wrap: wrap; }
.days button, .seg button {
  font: inherit; font-size: 14px; min-height: 32px; margin-left: -1px; border: 1px solid var(--stroke); border-radius: 0;
  background: var(--background); color: var(--text); cursor: pointer; white-space: nowrap; position: relative;
}
.days button { width: 40px; }
.seg button { min-width: 64px; padding: 1px 6px; }
.days button:first-child, .seg button:first-child { margin-left: 0; border-radius: 4px 0 0 4px; }
.days button:last-child, .seg button:last-child { border-radius: 0 4px 4px 0; }
.days button:hover, .seg button:hover { z-index: 1; border-color: var(--text-gray); }
.days button[aria-pressed="true"], .seg button[aria-pressed="true"] { z-index: 2; border-color: var(--primary); background: var(--menu-active); color: var(--primary); }
.window { padding: 0 0 16px; }
.window + .window { padding-top: 16px; border-top: 1px solid var(--stroke); }
.window .row { margin-top: 8px; }
.window .field-row { margin: 16px 0 0; }

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--offline); flex: none; }
.dot.on { background: var(--online); }
.err { white-space: pre-wrap; color: var(--st-warning-text); font-size: 12px; line-height: 20px; margin-top: 8px; }
.warnline { color: var(--st-caution-text); font-size: 12px; line-height: 20px; }
details > summary.muted { cursor: pointer; margin-top: 16px; }
pre { background: var(--menu); border: 1px solid var(--stroke); border-radius: 4px; padding: 12px; font-size: 12px; line-height: 18px; overflow-x: auto; }

/* ---------- tables, key-value ---------- */
/* as the panel's tables: 48px bold header on its own background, 56px rows, a muted second line (.subline),
   clickable rows (tr.click) open the edit dialog */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--background); border-bottom: 1px solid var(--table-border); }
th, td { text-align: left; vertical-align: middle; }
th { height: 48px; padding: 6px 12px; background: var(--table-header); color: var(--text); font-weight: 700; font-size: 14px; line-height: 22px; white-space: nowrap; }
td { height: 56px; padding: 6px 10px 6px 12px; border-top: 1px solid var(--table-border); }
td .subline { display: block; font-size: 12px; line-height: 16px; color: var(--text-gray); }
tbody tr:hover td { background: var(--table-row-hover); }
tr.click { cursor: pointer; }
tr.click:focus-visible { outline: 1px solid var(--primary); outline-offset: -1px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.acts { width: 1%; white-space: nowrap; text-align: right; }
td.acts .btn { vertical-align: middle; }
td.acts .btn + .btn { margin-left: 8px; }
/* the pencil shows on row hover, as in the panel; always on touch screens */
@media (hover: hover) { tr.click td.acts .btn.icon { visibility: hidden; } tr.click:hover td.acts .btn.icon, tr.click:focus-within td.acts .btn.icon { visibility: visible; } }
tr.off td { color: var(--text-gray); }
.devname { display: inline-flex; align-items: center; gap: 10px; }
td .devname ~ .subline { padding-left: 16px; }
td .subline.warnline { color: var(--st-caution-text); }
td .show-sm { display: none; }
/* journal: a header row per day, the time column as narrow as it can be, the event chip above its explanation */
table.journal tr.dayrow td { height: 40px; background: var(--table-header); font-weight: 700; }
table.journal tbody tr.dayrow:hover td { background: var(--table-header); }
table.journal td.jr-time { width: 1%; }
table.journal .jr-event .subline { margin-top: 4px; }
td .show-sm.jr-event { margin-top: 8px; }
@media (max-width: 599px) {
  th.hide-sm, td.hide-sm { display: none; }
  td .show-sm { display: block; }
  th, td { padding-left: 8px; padding-right: 8px; }
}
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 12px 0 0; }
dl.kv dt { color: var(--text-gray); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- charts ---------- */
.chart { position: relative; margin-top: 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--text-gray); font-size: 12px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .barmark { fill: var(--series); }
.chart .barmark.partial { fill-opacity: .5; }
.chart .hit { fill: transparent; cursor: default; }
.chart .barmark.hover { fill-opacity: .8; }
.chart .limit { stroke: var(--text); stroke-width: 2; stroke-dasharray: 4 3; fill: none; }
.chart .seg-mark { stroke: var(--background); stroke-width: 1; }
.chart .seg-mark.partial { fill-opacity: .55; }
.tip { position: absolute; pointer-events: none; background: var(--background); color: var(--text); border-radius: 4px; padding: 8px 12px; font-size: 12px; line-height: 20px; box-shadow: var(--tooltip-shadow); white-space: nowrap; z-index: 3; }
.sq { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; background: var(--series); }
.sq.partial { opacity: .5; }
.sw { display: inline-block; flex: none; width: 12px; height: 0; border-top: 2px dashed var(--text); }

/* chart pages (history, traffic), as the panel's traffic monitor: pickers in a row, the chart on the page and a
   framed summary with the legend beside it (under it on narrower screens), then the table */
.toolbar.pickers { gap: 12px 24px; }
.filters { margin: 0 0 24px; align-items: center; }
.filters > .ofield { flex: 0 1 260px; min-width: 0; }
.filters select { text-overflow: ellipsis; }
.chart-wrap { display: grid; gap: 24px 32px; align-items: start; margin: 0 0 40px; }
.chart-wrap > .chart { margin: 0; min-width: 0; }
@media (min-width: 1240px) { .chart-wrap { grid-template-columns: minmax(0, 1fr) 292px; } }
.statbox { border: 1px solid var(--table-border); border-radius: 8px; padding: 20px; background: var(--background); }
.statbox h4 { margin: 0 0 16px; font-size: 14px; line-height: 22px; font-weight: 700; text-transform: uppercase; color: var(--text-gray); }
.slist { margin: 16px 0 0; padding: 0; list-style: none; }
.slist li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--table-border); }
.slist li > .grow { overflow-wrap: anywhere; }
.slist li > .val { color: var(--text-gray); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-more { margin: 16px 0 0; }
p.table-note { margin: 12px 0 0; }

#toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(420px, 92vw);
  background: var(--notify-bg); color: var(--notify-text); border: 1px solid var(--notify-border); border-radius: 4px;
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, .25); padding: 12px 16px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.bad { border-left: 4px solid var(--error); }
@media (max-width: 599px) { #toast { left: 8px; right: 8px; max-width: none; bottom: calc(72px + env(safe-area-inset-bottom)); } }


/* traffic tab */
.tiprow { display: flex; align-items: center; gap: 8px; }
.tiprow b { margin-left: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.tiprow .grow { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
button.linkbtn { font: inherit; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
button.linkbtn:hover { text-decoration: none; }
table.pairs td { overflow-wrap: anywhere; }
table.pairs td.num { white-space: nowrap; }
table.pairs .cellname { display: flex; align-items: baseline; gap: 8px; }
table.pairs .cellname .sq { transform: translateY(1px); }

@media (max-width: 599px) {
  .big { font-size: 20px; line-height: 28px; }
  .filters > .ofield { flex: 1 1 100%; }
  .toolbar.pickers { gap: 12px; }
}
@media (max-width: 360px) {
  nav#tabs span { font-size: 9px; }
  .appbar h1 .model { display: none; }
}

/* ---------- sign-in, as the panel's login page: form on the left, accent panel on the right ---------- */
body.signin .appbar, body.signin nav#tabs, body.signin main, body.signin #toast { display: none; }
.login { position: fixed; inset: 0; z-index: 30; display: flex; background: var(--page); overflow-y: auto; }
.login[hidden] { display: none; }
.login-side { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-brand {
  flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--primary); color: #fff;
}
.login-brand span { font-size: 36px; line-height: 44px; font-weight: 400; letter-spacing: .08em; text-align: center; }
.login-card {
  width: 100%; max-width: 380px; padding: 40px; border: 1px solid var(--stroke); border-radius: 4px;
  background: var(--background); display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { margin: 0 0 8px; font-size: 26px; line-height: 34px; font-weight: 700; text-align: center; color: var(--text); }
.login-hint { margin: 0; text-align: center; }
.login-card .err { margin: 0; text-align: center; }
.login-card .err:empty { display: none; }
button.btn.block { width: 100%; }
.login-card .ofield { margin: 0; max-width: none; }
#login-pass { padding-right: 44px; }
.ofield .eye {
  position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; padding: 4px; border: 0; border-radius: 4px;
  background: none; color: var(--help-text); cursor: pointer;
}
.ofield .eye:hover { color: var(--text); }
.ofield .eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ofield .eye[aria-pressed="true"] .slash { display: none; }
@media (max-width: 799px) {
  .login-brand { display: none; }
  .login-side { flex-basis: 100%; }
}
@media (max-width: 599px) {
  .login-card { padding: 32px 16px; border: 0; background: transparent; }
  .login-card .ofield label { background: var(--page); }
  .ofield input { font-size: 16px; }
}

/* ---------- edit dialog, as the panel's: full-height sheet, title with ×, sections divided by a line,
   actions pinned to the bottom ---------- */
dialog.modal {
  width: min(1120px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0;
  border: 0; border-radius: 0 0 8px 8px; background: var(--background); color: var(--text); box-shadow: var(--tooltip-shadow);
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: var(--backdrop); }
dialog.modal:focus { outline: none; }
.modal-head { display: flex; align-items: flex-start; gap: 16px; padding: 40px 40px 16px; }
.modal-head h1 { flex: 1; min-width: 0; margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; overflow-wrap: anywhere; }
.modal-x { flex: none; width: 36px; height: 36px; margin: 0 -8px 0 0; padding: 8px; border: 0; border-radius: 4px; background: none; color: var(--text); cursor: pointer; }
.modal-x:hover { color: var(--primary); }
.modal-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 40px 24px; overscroll-behavior: contain; }
.modal-body > section + section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--stroke); }
.modal-body > section > h2 { margin: 0 0 24px; font-size: 20px; line-height: 28px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--text); }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 16px; padding: 12px 40px; border-top: 1px solid var(--stroke); background: var(--background); }
.modal-foot .err { flex: 1 1 100%; margin: 0; text-align: right; }
.modal-foot .err:empty { display: none; }
body:has(dialog.modal[open]) { overflow: hidden; }
/* a short form (a name) does not need the whole screen: a window sized by its content */
dialog.modal.compact { width: min(640px, calc(100vw - 32px)); height: fit-content; max-height: 88dvh; margin: 12vh auto auto; border-radius: 8px; }
dialog.modal.compact .modal-body { flex: 0 1 auto; }
@media (max-width: 599px) {
  dialog.modal { border-radius: 0; }
  dialog.modal.compact { width: 100vw; max-height: 100dvh; margin: 0 auto auto; border-radius: 0 0 8px 8px; }
  .modal-head { padding: calc(16px + env(safe-area-inset-top)) 16px 8px; }
  .modal-head h1 { font-size: 22px; line-height: 30px; }
  .modal-body { padding: 8px 16px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); gap: 12px; }
  .modal-foot .btn { flex: 1 1 0; }
  /* as the panel's save bar on phones: the delete action is an icon, the others share the row */
  .modal-foot .btn.del { flex: none; width: 40px; padding: 0; }
  .modal-foot .btn.del > span { display: none; }
  /* a picker takes the row, its options share it and wrap their text instead of breaking the group */
  .seg { display: flex; flex: 1 1 100%; flex-wrap: nowrap; }
  .seg button { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 18px; padding: 6px; }
}
