:root {
  --ink: #0b2230;
  --sea: #0e3b52;
  --sea-line: #1d5873;
  --fibre: #45c4d6;
  --teal: #0b7a8f;
  --teal-strong: #095f70;
  --paper: #f3f6f8;
  --surface: #ffffff;
  --line: #d3dde3;
  --text: #13232d;
  --muted: #566a76;
  --ok: #13804a;
  --warn: #8f5f00;
  --bad: #b3261e;
  --bad-bg: #fbeceb;
  --focus: #0b7a8f;
  --in: #0b7a8f;
  --out: #b45f00;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1a22;
    --surface: #132430;
    --line: #26404f;
    --text: #e4edf1;
    --muted: #93a8b4;
    --teal: #45c4d6;
    --teal-strong: #7ad8e6;
    --ok: #4cc58a;
    --warn: #e0a93a;
    --bad: #ff8b82;
    --bad-bg: #3a1a1a;
    --focus: #7ad8e6;
    --in: #45c4d6;
    --out: #f0b45a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--paper); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.35rem; padding: 0.4rem 0.95rem; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 560;
}
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 1.95rem; padding: 0.15rem 0.65rem; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #06222b; } }

.field { display: grid; gap: 0.3rem; margin-bottom: 1rem; align-content: start; }
.field label { font-weight: 560; font-size: 0.92rem; }
.field input, .field select {
  min-height: 2.5rem; padding: 0.4rem 0.7rem; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface); width: 100%;
}
.field .hint { font-size: 0.85rem; color: var(--muted); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.error { color: var(--bad); background: var(--bad-bg); border-left: 3px solid var(--bad); padding: 0.55rem 0.75rem; margin-bottom: 1rem; border-radius: 0 4px 4px 0; }
.error:empty { display: none; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art { background: var(--sea); color: #e4f3f7; padding: 3rem 3rem 2rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: clamp(2rem, 3.4vw, 3rem); letter-spacing: -0.01em; max-width: 14ch; }
.login-art p { color: #a9cdd8; margin-top: 0.6rem; max-width: 34ch; }
.login-art svg { position: absolute; inset: auto 0 0 0; width: 100%; height: 62%; }
.login-art .path { fill: none; stroke: var(--fibre); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.login-art .path.faint { stroke: var(--sea-line); stroke-width: 2; }
.login-art .node { fill: var(--sea); stroke: var(--fibre); stroke-width: 2.5; }
.login-art .label { fill: #8fc4d2; font: 12px var(--mono); }
.login-art .tick { fill: #3ecf8e; }
.login-art .unk { fill: #f0b429; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem; }
.login-form { width: min(380px, 100%); }
.login-form h2 { font-size: 1.4rem; margin-bottom: 0.3rem; }
.login-form .sub { color: var(--muted); margin-bottom: 1.6rem; }
@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 1.6rem; min-height: 200px; }
  .login-art svg { display: none; }
}

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.side { background: var(--sea); color: #d7ebf1; display: flex; flex-direction: column; padding: 1.1rem 0.8rem; gap: 1.2rem; }
.brand { padding: 0 0.5rem; }
.brand b { display: block; font-size: 1.2rem; letter-spacing: 0.01em; color: #fff; }
.brand span { font-size: 0.85rem; color: #9bc3d0; overflow-wrap: anywhere; }
.nav { display: grid; gap: 0.2rem; }
.nav a { color: inherit; text-decoration: none; padding: 0.5rem 0.7rem; border-radius: 4px; border-left: 3px solid transparent; }
.nav a:hover { background: var(--sea-line); }
.nav a[aria-current="page"] { background: var(--sea-line); border-left-color: var(--fibre); color: #fff; font-weight: 600; }
.side .who { margin-top: auto; padding: 0.7rem 0.5rem 0; border-top: 1px solid var(--sea-line); font-size: 0.88rem; }
.side .who .btn { margin-top: 0.6rem; background: transparent; color: #d7ebf1; border-color: var(--sea-line); width: 100%; }
.side .who .btn:hover { border-color: var(--fibre); }
.side .who .muted { color: #9bc3d0; }
.main { padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 3rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head p { color: var(--muted); margin-top: 0.2rem; }
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand who" "nav nav"; align-items: center; gap: 0.5rem 0.8rem; padding: 0.7rem 0.9rem; }
  .brand { grid-area: brand; padding: 0; display: flex; gap: 0.6rem; align-items: baseline; }
  .side .who { grid-area: who; margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 0.6rem; }
  .side .who > div .muted { display: none; }
  .side .who .btn { width: auto; margin: 0; }
  .nav { grid-area: nav; display: flex; gap: 0.2rem; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .main { padding-top: 1.1rem; }
}

/* ---------- tables ---------- */
td select { min-height: 2rem; padding: 0.15rem 0.5rem; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--surface) 92%, var(--line)); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 0.35rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* status: a shape plus a word, never colour alone */
.status { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 560; }
.status::before { content: ""; width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--ok); }
.status.off { color: var(--warn); }
.status.off::before { background: var(--warn); border-radius: 2px; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 6px; padding: 0; width: min(520px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(6, 22, 31, 0.55); }
.dlg-head { padding: 1rem 1.2rem 0.4rem; }
.dlg-body { padding: 0.6rem 1.2rem 1.2rem; }
.dlg-body .row.end { margin-top: 0.4rem; }
.dlg-body p + p, .dlg-body .secret + p { margin-top: 0.5rem; }
.secret { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; background: var(--paper); border: 1px dashed var(--teal); border-radius: 4px; padding: 0.7rem 0.9rem; margin: 0.8rem 0; }
.secret .mono { font-size: 1.2rem; letter-spacing: 0.04em; user-select: all; }
fieldset { border: 1px solid var(--line); border-radius: 4px; margin: 0 0 1rem; padding: 0.7rem 0.9rem 0.2rem; }
legend { padding: 0 0.3rem; font-weight: 560; font-size: 0.92rem; }
.choice { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.7rem; }

/* ---------- overview ---------- */
.roles { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); max-width: 760px; }
.roles > div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); }
.roles > div:last-child { border-bottom: 0; }
.roles > div.you { border-left: 3px solid var(--teal); background: color-mix(in srgb, var(--surface) 94%, var(--teal)); }
.note { margin-top: 1.4rem; color: var(--muted); max-width: 62ch; }

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: border-color 0.12s, background-color 0.12s; }
}

/* ---------- device & link state: a shape plus a word, never colour alone ---------- */
.state { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 560; white-space: nowrap; }
.state::before { content: ""; width: 0.65rem; height: 0.65rem; background: var(--muted); }
.state.up { color: var(--ok); }
.state.up::before { background: var(--ok); border-radius: 50%; }
.state.down { color: var(--bad); }
.state.down::before { background: var(--bad); transform: rotate(45deg) scale(0.9); }
.state.unknown { color: var(--muted); }
.state.unknown::before { border-radius: 2px; }

a.strong { font-weight: 650; color: var(--teal-strong); text-decoration: none; }
a.strong:hover { text-decoration: underline; }
a.btn { text-decoration: none; margin-top: 0.8rem; }
.small { font-size: 0.85rem; }
.notice { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--surface) 90%, var(--warn)); padding: 0.65rem 0.9rem; margin-bottom: 1rem; border-radius: 0 4px 4px 0; max-width: 70ch; }
h2.section { margin: 2rem 0 0.8rem; }

/* ---------- device page ---------- */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; margin: 0 0 0.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.meta > div { padding: 0.7rem 0.95rem; border-right: 1px solid var(--line); min-width: 0; }
.meta > div:last-child { border-right: 0; }
.meta dt { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.15rem; }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.picker-tools { margin-bottom: 0.7rem; }
.picker-tools input[type="search"] { min-height: 2.2rem; padding: 0.3rem 0.65rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); min-width: 15rem; }
.picker-tools .choice { margin: 0; }
.table-wrap.picker { max-height: 26rem; overflow: auto; }
.table-wrap.picker th { position: sticky; top: 0; z-index: 1; }
.table-wrap.picker table { min-width: 560px; }
.adv { margin: 0 0 1rem; }
.adv summary { cursor: pointer; font-weight: 560; margin-bottom: 0.7rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 0.8rem; align-items: start; }
.test-result { padding: 0.65rem 0.85rem; border-radius: 4px; margin-bottom: 1rem; border-left: 3px solid var(--muted); background: var(--paper); }
.test-result[hidden] { display: none; }
.test-result.ok { border-left-color: var(--ok); }
.test-result.bad { border-left-color: var(--bad); background: var(--bad-bg); }

/* ---------- graphs ---------- */
.graph-list { display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1320px) { .graph-list.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.graph-card { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.9rem 1rem 1rem; min-width: 0; }
.graph-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.graph-body { min-height: 12rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg-btn { background: transparent; border: 0; border-right: 1px solid var(--line); padding: 0.28rem 0.8rem; cursor: pointer; min-height: 1.9rem; }
.seg-btn:last-child { border-right: 0; }
.seg-btn[aria-pressed="true"] { background: var(--teal); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg-btn[aria-pressed="true"] { color: #06222b; } }
.legend { display: flex; gap: 1.1rem; margin-bottom: 0.2rem; font-size: 0.88rem; }
.key::before { content: ""; display: inline-block; width: 1.4rem; height: 0.22rem; margin-right: 0.4rem; vertical-align: middle; border-radius: 2px; }
.key.in::before { background: var(--in); }
.key.out::before { background: var(--out); }
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--font); }
.chart .line { fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.in, .chart .dot.in { stroke: var(--in); }
.chart .line.out, .chart .dot.out { stroke: var(--out); }
.chart .area { stroke: none; opacity: 0.13; }
.chart .area.in { fill: var(--in); }
.chart .area.out { fill: var(--out); }
.chart .dot { fill: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; top: 0.2rem; transform: translateX(-50%); background: var(--ink); color: #eaf5f8; padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.85rem; pointer-events: none; white-space: nowrap; z-index: 2; }
.chart-tip[hidden] { display: none; }
.tip-time { color: #9bc3d0; margin-bottom: 0.15rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.8rem; margin-top: 0.7rem; }
.stat { padding: 0.55rem 0.8rem; border-left: 4px solid var(--line); background: var(--paper); border-radius: 0 4px 4px 0; }
.stat.in { border-left-color: var(--in); }
.stat.out { border-left-color: var(--out); }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-main { font-size: 1.25rem; font-weight: 650; }

.filter-row { margin-bottom: 0.8rem; gap: 0.6rem; }
.filter-row select { min-height: 2.2rem; padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.site-list { display: grid; gap: 0.1rem; max-height: 14rem; overflow: auto; margin: 0 0 0.8rem 1.4rem; }
.site-list[hidden] { display: none; }

/* ---------- maps ---------- */
.main.wide { max-width: none; }
.state.warn { color: var(--warn); }
.state.warn::before { background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.map-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.map-page.editing { grid-template-columns: minmax(0, 1fr) 19.5rem; }
@media (max-width: 1000px) { .map-page.editing { grid-template-columns: minmax(0, 1fr); } }
.map-main { min-width: 0; display: grid; gap: 0.7rem; }
.map-toolbar { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.btn[aria-pressed="true"]:not(.seg-btn) { background: var(--teal); border-color: var(--teal); color: #fff; }
@media (prefers-color-scheme: dark) { .btn[aria-pressed="true"]:not(.seg-btn) { color: #06222b; } }
.map-wrap { position: relative; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #0e4a66; }
.map-wrap.zoomed { overflow: auto; max-height: 78vh; }
.map-svg { display: block; width: 100%; height: auto; user-select: none; }
.map-bg { fill: #0e4a66; }
.map-grid { fill: url(#mapgrid); }
.map-gridline { fill: none; stroke: rgba(255, 255, 255, 0.045); stroke-width: 1; }
.map-svg text { font-family: var(--font); }
.mnode { cursor: pointer; touch-action: none; outline: none; }
.map-svg.editing .mnode { cursor: grab; }
.map-svg.linking .mnode { cursor: crosshair; }
.mnode:focus-visible .mn-bg { stroke: #fff; stroke-width: 3; }
.mn-bg { fill: #0e4a66; stroke: none; }
.mn-ring { fill: none; stroke: #7fa9bb; stroke-width: 2; stroke-dasharray: 4 3; }
.mn-ring.up { stroke: #3ecf8e; stroke-dasharray: none; }
.mn-ring.down { stroke: #ff6b5e; stroke-width: 4; stroke-dasharray: none; }
.mnode.sel .mn-bg { stroke: #fff; stroke-width: 2; stroke-dasharray: 5 3; }
.mnode.from .mn-bg { stroke: #f0b429; stroke-width: 3; }
.ic-body { fill: #1d6f96; stroke: #e6f4f9; stroke-width: 2; }
.ic-line { fill: none; stroke: #e6f4f9; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { fill: #e6f4f9; }
.ic-cloud { fill: #e9f2f6; stroke: none; }
.mn-label { fill: #fff; font-size: 12px; font-weight: 650; text-anchor: middle; paint-order: stroke; stroke: #0e4a66; stroke-width: 3px; }
.chip.ok { fill: #1f9d62; } .chip.bad { fill: #d6453b; } .chip.unk { fill: #b07d00; }
.chip-text { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; }
.lk { fill: none; stroke-width: 4.5; stroke-linecap: round; }
.lk.ok { stroke: #3ecf8e; } .lk.warn { stroke: #f0b429; } .lk.crit { stroke: #ff6b5e; }
.lk.down { stroke: #ff6b5e; stroke-dasharray: 2 9; }
.lk.nodata { stroke: #8fa9b5; }
.lk.plain { stroke: #b9d6e0; stroke-width: 2.5; }
.lk-hit { fill: none; stroke: transparent; stroke-width: 16; cursor: pointer; }
.lk-glow { fill: none; stroke: #fff; stroke-width: 10; opacity: 0; stroke-linecap: round; }
.lk-glow.on { opacity: 0.35; }
.lk-bg { fill: none; }   /* no dark box behind the text on a link: the text carries its own thin outline instead */
.lk-label { fill: #fff; font-size: 12px; font-weight: 650; }
.lk-live { fill: #cfe6ee; font-size: 11px; }
.lk-label-g { pointer-events: none; }
.gt-bg { fill: #f4f8fa; stroke: #8fb4c4; }
.gt-title { fill: #102a37; font-size: 11px; font-weight: 650; }
.gt-frame { fill: #fff; stroke: #c7d6dd; }
.gt-line { fill: none; stroke-width: 1.3; stroke-linejoin: round; }
.gt-line.in { stroke: #0b7a8f; } .gt-line.out { stroke: #b45f00; }
.gt-note { fill: #314b59; font-size: 11px; }
.map-tip { transform: none; top: auto; z-index: 3; }
.legend-row { gap: 1.1rem; font-size: 0.86rem; }
.lg::before { content: ""; display: inline-block; width: 1.5rem; height: 0.3rem; margin-right: 0.4rem; vertical-align: middle; border-radius: 2px; background: var(--muted); }
.lg.ok::before { background: #3ecf8e; } .lg.warn::before { background: #f0b429; } .lg.crit::before { background: #ff6b5e; }
.lg.down::before { background: repeating-linear-gradient(90deg, #ff6b5e 0 3px, transparent 3px 7px); }
.lg.nodata::before { background: #8fa9b5; } .lg.plain::before { background: #b9d6e0; height: 0.18rem; }
.summary { gap: 0.5rem; }
.pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.86rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.pill::before { content: ""; width: 0.6rem; height: 0.6rem; background: var(--muted); }
.pill.ok::before { background: #3ecf8e; border-radius: 50%; }
.pill.warn::before { background: #f0b429; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pill.crit::before { background: #ff6b5e; transform: rotate(45deg) scale(0.9); }
.pill.down::before { background: #ff6b5e; border-radius: 50%; }
.pill.nodata::before { border-radius: 2px; }
.link-table { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); padding: 0.5rem 0.8rem; }
.link-table summary { cursor: pointer; font-weight: 600; }
.link-table .table-wrap { margin-top: 0.6rem; }
.map-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.9rem 1rem; min-width: 0; }
.map-panel[hidden] { display: none; }
.map-panel h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.map-panel hr { border: 0; border-top: 1px solid var(--line); margin: 0.9rem 0; }
.panel-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 0.5rem; margin-bottom: 0.7rem; align-items: center; }
.panel-add label { grid-column: 1 / -1; font-size: 0.86rem; font-weight: 560; }
.panel-add select, .panel-add input { min-height: 2.1rem; padding: 0.2rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); min-width: 0; }

[hidden] { display: none !important; }
.dlg-body form > p { margin-bottom: 0.8rem; }

/* ---------- alerts & overview ---------- */
h2.section.first { margin-top: 0.4rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.8rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 4px; padding: 0.7rem 0.9rem; }
.card.up { border-left-color: var(--ok); }
.card.down { border-left-color: var(--bad); }
.card-n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.card-l { color: var(--muted); font-size: 0.88rem; }
.problems { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.problems li { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); }
.problems li:last-child { border-bottom: 0; }
.ok-line { padding: 0.75rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.row.between { justify-content: space-between; align-items: flex-end; }
.panel-form { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1rem 1.1rem; max-width: 46rem; }
.panel-form .row { margin-top: 0.4rem; }
.steps { margin: 0 0 0.5rem 1.1rem; padding: 0; display: grid; gap: 0.35rem; max-width: 46rem; }
.found { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.5rem 0; }
.spacer { height: 0.6rem; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }
td.actions .small { margin-right: 0.5rem; }

.panel-form > p { display: flex; gap: 0.8rem; align-items: center; margin-bottom: 0.8rem; }
.panel-form .choice { margin-bottom: 0.9rem; }

/* ---------- device page ---------- */
.device-page { display: grid; gap: 1.1rem; }
.dev-id { display: grid; gap: 0.5rem; }
.crumb { color: var(--muted); text-decoration: none; font-size: 0.9rem; width: fit-content; }
.crumb:hover { color: var(--teal-strong); text-decoration: underline; }
.dev-id-row { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.pill-state { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.15rem 0.7rem; border-radius: 999px; font-weight: 650; font-size: 0.88rem; border: 1px solid var(--line); background: var(--surface); }
.pill-state::before { content: ""; width: 0.6rem; height: 0.6rem; background: var(--muted); border-radius: 2px; }
.pill-state.up { color: var(--ok); } .pill-state.up::before { background: var(--ok); border-radius: 50%; }
.pill-state.down { color: var(--bad); } .pill-state.down::before { background: var(--bad); transform: rotate(45deg) scale(0.9); border-radius: 0; }
.pill-state.paused { color: var(--warn); } .pill-state.paused::before { background: var(--warn); clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100%, 65% 0); }
.chip { display: inline-flex; align-items: center; padding: 0.12rem 0.65rem; border-radius: 4px; background: color-mix(in srgb, var(--teal) 14%, var(--surface)); color: var(--teal-strong); font-size: 0.86rem; font-weight: 600; }
.chip.off { background: var(--paper); color: var(--muted); border: 1px dashed var(--line); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.8rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.8rem 1rem; box-shadow: 0 1px 2px rgba(10, 40, 55, 0.05); }
.kpi.up { border-top: 3px solid var(--ok); } .kpi.down { border-top: 3px solid var(--bad); }
.kpi-l { color: var(--muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-v { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }
.kpi-s { color: var(--muted); font-size: 0.86rem; }
.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 0.6rem 1rem; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--teal-strong); border-bottom-color: var(--teal); }
.tab-body { display: grid; gap: 1rem; min-width: 0; }
.empty-card { background: var(--surface); border: 1px dashed var(--line); border-radius: 6px; padding: 2.2rem 1.5rem; text-align: center; display: grid; gap: 0.6rem; justify-items: center; }
.empty-card h3 { font-size: 1.1rem; }
.toolbar2 { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: center; }
.toolbar2 input[type="search"], .toolbar2 select { min-height: 2.2rem; padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.toolbar2 input[type="search"] { min-width: 15rem; }
.chips-row { display: inline-flex; gap: 0.3rem; }
.chip-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.8rem; cursor: pointer; font-size: 0.88rem; min-height: 2rem; }
.chip-btn[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .chip-btn[aria-pressed="true"] { color: #06222b; } }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th:nth-child(6), th:nth-child(7) { text-align: right; }
.switch-input { appearance: none; -webkit-appearance: none; width: 2.5rem; height: 1.4rem; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, var(--surface)); position: relative; cursor: pointer; margin: 0; vertical-align: middle; flex: none; }
.switch-input::before { content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px); border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.switch-input:checked { background: var(--teal); }
.switch-input:checked::before { transform: translateX(1.1rem); }
.switch-input:disabled { opacity: 0.5; cursor: not-allowed; }
@media (prefers-reduced-motion: no-preference) { .switch-input, .switch-input::before { transition: background-color 0.15s, transform 0.15s; } }
.bar-wrap { display: inline-flex; align-items: center; gap: 0.5rem; }
.bar { width: 4.5rem; height: 0.55rem; border-radius: 99px; background: var(--line); overflow: hidden; display: inline-block; }
.bar-fill { display: block; height: 100%; border-radius: 99px; }
.bar-fill.ok { background: #2fb87a; } .bar-fill.warn { background: #e0a000; } .bar-fill.crit { background: #e0483c; }
.bar-n { font-variant-numeric: tabular-nums; font-size: 0.88rem; min-width: 2.6rem; }
.savebar { position: sticky; bottom: 0.8rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.7rem 1rem; background: var(--ink); color: #eaf5f8; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); z-index: 5; }
.savebar[hidden] { display: none; }
.savebar .btn:not(.primary) { background: transparent; color: #eaf5f8; border-color: rgba(255, 255, 255, 0.35); }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--ink); color: #eaf5f8; padding: 0.7rem 1.1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); z-index: 50; max-width: 22rem; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; max-width: 46rem; display: grid; gap: 0.7rem; }
.panel-card h3 { font-size: 1rem; }
.panel-card.danger-zone { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.kvs { display: grid; gap: 0; margin: 0; }
.kv { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
/* loading placeholders */
.skeleton-wrap { display: grid; gap: 1rem; }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 50%, var(--surface)) 50%, var(--line) 75%); background-size: 200% 100%; border-radius: 6px; height: 1.6rem; }
.skeleton.w40 { width: 40%; } .skeleton.card { height: 5.2rem; } .skeleton.tall { height: 14rem; }
.skeleton-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.8rem; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } @keyframes shimmer { to { background-position: -200% 0; } } }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

.toolbar2 input[type="search"] { min-width: 13rem; flex: 1 1 14rem; max-width: 20rem; }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .kpi { padding: 0.6rem 0.75rem; } .kpi-v { font-size: 1.3rem; }
  .table-wrap.picker table { min-width: 420px; }
  .picker th:nth-child(3), .picker td:nth-child(3), .picker th:nth-child(5), .picker td:nth-child(5) { display: none; }
  .toolbar2 input[type="search"] { max-width: none; flex-basis: 100%; }
  .dev-id-row { gap: 0.5rem; }
}

/* ---------- interface list: part of the page, not a box inside it ---------- */
@media (min-width: 900px) { .table-wrap.picker { max-height: none; overflow: visible; } .table-wrap.picker th { top: 0; } }
.table-wrap.picker table { min-width: 0; }
.table-wrap.dense th, .table-wrap.dense td { padding: 0.25rem 0.7rem; }
.table-wrap.dense .btn.small { min-height: 1.6rem; padding: 0.05rem 0.55rem; }
.table-wrap.dense .switch-input { width: 2.1rem; height: 1.2rem; }
.table-wrap.dense .switch-input::before { width: calc(1.2rem - 6px); height: calc(1.2rem - 6px); }
.table-wrap.dense .switch-input:checked::before { transform: translateX(0.9rem); }
td.spark-cell { width: 128px; padding-top: 0; padding-bottom: 0; }
.spark { width: 120px; height: 28px; display: block; }
.spark-area { fill: var(--in); opacity: 0.14; stroke: none; }
.spark-line { fill: none; stroke-width: 1.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-line.in { stroke: var(--in); } .spark-line.out { stroke: var(--out); }
.spark-dot.in { fill: var(--in); } .spark-dot.out { fill: var(--out); }
.spark-empty { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
@media (max-width: 640px) { .picker th:nth-child(9), .picker td:nth-child(9) { display: none; } }

/* ---------- tighter interface list ---------- */
.tabs { overflow-y: hidden; }
.picker td, .picker th { white-space: nowrap; }
.picker td:nth-child(3) { white-space: normal; }
.table-wrap.dense th, .table-wrap.dense td { padding: 0.12rem 0.65rem; font-size: 0.9rem; }
.table-wrap.dense .state, .table-wrap.dense .btn.small { font-size: 0.86rem; }
.table-wrap.dense .btn.small { min-height: 1.5rem; }
td.spark-cell { padding-top: 0; padding-bottom: 0; }
.device-page.slim .kpis { gap: 0.5rem; }
.device-page.slim .kpi { padding: 0.4rem 0.8rem; }
.device-page.slim .kpi-v { font-size: 1.15rem; }
.device-page.slim .kpi-s { display: none; }

/* ---------- overview cards and interface detail ---------- */
a.if-link { color: var(--teal-strong); text-decoration: none; font-weight: 600; }
a.if-link:hover { text-decoration: underline; }
.if-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0.8rem; }
.if-card { display: grid; gap: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.9rem 0.6rem; color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(10, 40, 55, 0.05); min-width: 0; }
.if-card:hover { border-color: var(--teal); box-shadow: 0 2px 8px rgba(10, 40, 55, 0.12); }
.if-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.if-card-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.88rem; }
.if-card-name { font-weight: 700; overflow-wrap: anywhere; }
.if-card-alias { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.if-card-rates { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.rate.in b { color: var(--in); } .rate.out b { color: var(--out); }
.if-card-load { min-height: 1.1rem; }
.if-card-spark .spark { width: 100%; height: 34px; }
.detail-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.detail-title { display: grid; gap: 0.35rem; }
.detail-title h2 { font-size: 1.35rem; overflow-wrap: anywhere; }
.detail-alias { margin: 0; font-size: 1.02rem; }
.kpis.slimk { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis.slimk .kpi-v { font-size: 1.35rem; }

a.btn { color: var(--text); margin-top: 0; }

/* ---------- broadcast ---------- */
.bcast-card, .optics-card { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.9rem 1rem 1rem; min-width: 0; }
.warn-text { color: var(--warn); font-weight: 600; }
th:nth-child(8) { text-align: right; }
.if-card-bc { font-size: 0.86rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.if-card-bc b { color: var(--text); font-weight: 600; }
.pill-state.lvl-normal { color: var(--ok); } .pill-state.lvl-normal::before { background: var(--ok); border-radius: 50%; }
.pill-state.lvl-elevated { color: var(--warn); } .pill-state.lvl-elevated::before { background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.pill-state.lvl-high { color: #b34700; } .pill-state.lvl-high::before { background: #d4631a; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.pill-state.lvl-storm { color: var(--bad); } .pill-state.lvl-storm::before { background: var(--bad); transform: rotate(45deg) scale(0.9); border-radius: 0; }
.pill-state.lvl-nodata { color: var(--muted); }
.analysis { margin-top: 1rem; padding: 0.9rem 1.1rem; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 4px; background: var(--paper); display: grid; gap: 0.5rem; }
.analysis.lvl-normal { border-left-color: var(--ok); } .analysis.lvl-elevated { border-left-color: var(--warn); }
.analysis.lvl-high { border-left-color: #d4631a; } .analysis.lvl-storm { border-left-color: var(--bad); }
.analysis-head { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.analysis-head h3 { font-size: 1rem; }
.analysis-summary { margin: 0; font-weight: 560; }
.analysis h4 { margin: 0.5rem 0 0.3rem; font-size: 0.92rem; }
.analysis-facts, .analysis-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.35rem; }
.analysis code { font-family: var(--mono); font-size: 0.88em; background: color-mix(in srgb, var(--line) 55%, var(--surface)); padding: 0.05rem 0.3rem; border-radius: 3px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .picker th:nth-child(9), .picker td:nth-child(9) { display: table-cell; }
  .picker th:nth-child(8), .picker td:nth-child(8), .picker th:nth-child(10), .picker td:nth-child(10) { display: none; }
}

.panel-add.stack select { grid-column: 1 / -1; }
.panel-add.stack .hint { grid-column: 1; font-size: 0.82rem; color: var(--muted); }

/* ---------- Graphs page: sites > switches > graphs ---------- */
.acc-list { display: grid; gap: 0.6rem; }
.acc-h { margin: 0; font-size: inherit; font-weight: inherit; }
.acc-head { width: 100%; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 1rem; cursor: pointer; min-height: 2.8rem; }
.acc-head:hover { border-color: var(--teal); }
.acc-head:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.acc-head-site .acc-title { font-size: 1.05rem; }
.acc-head-device { background: var(--paper); padding: 0.55rem 0.9rem; min-height: 2.4rem; }
.acc-chev { width: 0.7rem; height: 0.7rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); flex: none; margin-right: 0.2rem; }
.acc-head[aria-expanded="true"] .acc-chev { transform: rotate(45deg); }
@media (prefers-reduced-motion: no-preference) { .acc-chev { transition: transform 0.15s; } }
.acc-sum { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.acc-body[hidden] { display: none; }
.acc-body-site { display: grid; gap: 0.5rem; padding: 0.6rem 0 0.4rem 1.3rem; }
.acc-body-device { padding: 0.7rem 0 0.4rem 0.2rem; }

/* ---------- several ports on one chart ---------- */
dialog.wide { width: min(1120px, 96vw); max-width: none; }
.ports-dialog { display: grid; grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .ports-dialog { grid-template-columns: 1fr; } }
.ports-pick { display: grid; gap: 0.5rem; min-width: 0; }
.ports-filters { display: grid; gap: 0.4rem; }
.ports-pick input[type="search"] { min-height: 2.1rem; padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.port-list { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); max-height: 15rem; overflow: auto; padding: 0.2rem; }
.port-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.45rem; border-radius: 3px; cursor: pointer; flex-wrap: wrap; }
.port-row:hover { background: var(--paper); }
.port-name { font-weight: 600; }
.port-alias { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.chosen { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.chosen li { display: flex; align-items: center; gap: 0.5rem; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 0.2rem 0.5rem; font-size: 0.9rem; }
.chosen li span:not(.sw) { flex: 1; overflow-wrap: anywhere; }
.chip-x { background: none; border: 0; cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--muted); min-width: 1.8rem; min-height: 1.8rem; }
.chip-x:hover { color: var(--bad); }
.sw { flex: none; vertical-align: middle; }
.compare { display: grid; gap: 0.7rem; min-width: 0; }
.compare-controls { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: space-between; }
.compare-body { display: grid; gap: 0.6rem; min-width: 0; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; font-size: 0.9rem; }
.chart-legend li { display: flex; align-items: center; gap: 0.4rem; }
.tip-row { display: flex; align-items: center; gap: 0.3rem; }
.compare-stats td.num, .compare-stats th:not(:first-child) { text-align: right; }
.ports-actions { margin-top: 1rem; display: grid; gap: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.gt-leg { font-size: 10px; fill: var(--text); }

/* ---------- fibre health ---------- */
.card.warn { border-left-color: var(--warn); }
.pill-state.opt-ok { color: var(--ok); } .pill-state.opt-ok::before { background: var(--ok); border-radius: 50%; }
.pill-state.opt-warn { color: #a85d00; } .pill-state.opt-warn::before { background: #d4891a; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.pill-state.opt-alarm { color: var(--bad); } .pill-state.opt-alarm::before { background: var(--bad); transform: rotate(45deg) scale(0.9); border-radius: 0; }
.pill-state.opt-nolight { color: var(--bad); } .pill-state.opt-nolight::before { content: "×"; background: none; width: auto; height: auto; line-height: 1; font-weight: 800; color: var(--bad); }
.pill-state.opt-nopower, .pill-state.opt-absent, .pill-state.opt-unknown, .pill-state.opt-norx, .pill-state.opt-laseroff { color: var(--muted); }
.optic-banner { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; padding: 0.55rem 0.9rem; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--muted); margin-bottom: 0.5rem; }
.optic-banner.optic-ok { border-left-color: var(--ok); } .optic-banner.optic-warn { border-left-color: var(--warn); }
.optic-banner.optic-alarm, .optic-banner.optic-nolight { border-left-color: var(--bad); }
.vline { fill: none; stroke-width: 2; stroke-linejoin: round; }
.vline.rx { stroke: var(--in); } .vline.tx { stroke: var(--out); stroke-dasharray: 7 3; }
.vlimit { stroke-width: 1; stroke-dasharray: 4 3; }
.vlimit.warn { stroke: #d4891a; } .vlimit.alarm { stroke: #d6453c; }
.vlimit-label { font-size: 10px; } .vlimit-label.warn { fill: #a85d00; } .vlimit-label.alarm { fill: #b3261e; }
.fibre-page { display: grid; gap: 1rem; }

/* ---------- fibre health v2 ---------- */
.health { display: grid; gap: 0.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1.1rem; box-shadow: 0 1px 2px rgba(10, 40, 55, 0.05); }
.health-bar { display: flex; height: 0.9rem; border-radius: 99px; overflow: hidden; background: var(--line); }
.hseg { height: 100%; min-width: 3px; }
.hseg-alarm { background: #d6453c; } .hseg-warn { background: #e0a000; } .hseg-ok { background: #2fb87a; } .hseg-nodata { background: #9aa9b2; }
.health-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; font-size: 0.9rem; align-items: center; }
.hl { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.hl::before { content: ""; width: 0.65rem; height: 0.65rem; border-radius: 2px; }
.hl-alarm::before { background: #d6453c; } .hl-warn::before { background: #e0a000; } .hl-ok::before { background: #2fb87a; } .hl-nodata::before { background: #9aa9b2; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; }
.kpi-btn { display: grid; gap: 0.1rem; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 6px; padding: 0.55rem 0.9rem; cursor: pointer; min-height: 3.4rem; }
.kpi-btn:hover { border-color: var(--teal); }
.kpi-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.kpi-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--teal) 10%, var(--surface)); border-color: var(--teal); border-left-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.kpi-btn.tone-alarm { border-left-color: #d6453c; } .kpi-btn.tone-warn { border-left-color: #e0a000; } .kpi-btn.tone-ok { border-left-color: #2fb87a; } .kpi-btn.tone-nodata { border-left-color: #9aa9b2; } .kpi-btn.tone-attention { border-left-color: #8a5a00; }
.kpi-n { font-size: 1.5rem; font-weight: 700; line-height: 1.1; } .kpi-t { color: var(--muted); font-size: 0.86rem; }
.fibre-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem 0.8rem; align-items: center; }
.fibre-toolbar select, .fibre-toolbar input[type="search"] { min-height: 2.3rem; padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.fibre-toolbar select[hidden] { display: none; }
.fibre-toolbar input[type="search"] { min-width: 14rem; flex: 1 1 14rem; max-width: 22rem; }
.fgroups { display: grid; gap: 0.7rem; }
.fgroup-head { width: 100%; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 1rem; cursor: pointer; min-height: 3rem; }
.fgroup-head:hover { border-color: var(--teal); }
.fgroup-head:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fgroup-head[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.fgroup-head[aria-expanded="true"] .acc-chev { transform: rotate(45deg); }
.fgroup-name { font-size: 1.02rem; }
.fgroup-sum { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; }
.fgroup-body { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; background: var(--surface); }
.fgroup-body[hidden] { display: none; }
.fgroup-body .table-wrap { border: 0; border-radius: 0 0 8px 8px; }
.fibre-table th, .fibre-table td { padding: 0.45rem 0.8rem; white-space: nowrap; }
.fibre-table td.port-cell { white-space: normal; min-width: 14rem; }
.fibre-table th:nth-child(n+3), .fibre-table td.num { text-align: right; }
.fibre-table th:nth-child(3), .fibre-table td.light-cell { text-align: left; }
.fibre-table tbody tr:hover { background: var(--paper); }
.light-cell { min-width: 11rem; } .light-n { display: block; font-variant-numeric: tabular-nums; }
.gauge { width: 120px; height: 12px; display: block; margin-top: 2px; }
.g-bad { fill: #d6453c; opacity: 0.55; } .g-warn { fill: #e0a000; opacity: 0.55; } .g-ok { fill: #2fb87a; opacity: 0.55; }
.g-dot { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.trend { width: 96px; height: 24px; display: block; margin-left: auto; }
.trend-line { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.trend-line.sev-ok { stroke: var(--teal-strong); } .trend-line.sev-warn { stroke: #c27c00; } .trend-line.sev-alarm { stroke: #d6453c; } .trend-line.sev-nodata { stroke: var(--muted); }
.trend-empty { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.chip.qsfp { margin-left: 0.5rem; font-size: 0.78rem; }
@media (max-width: 820px) {
  .fibre-table th:nth-child(4), .fibre-table td:nth-child(4), .fibre-table th:nth-child(6), .fibre-table td:nth-child(6), .fibre-table th:nth-child(8), .fibre-table td:nth-child(8) { display: none; }
  .fgroup-sum { margin-left: 0; }
}

/* ---------- four-lane modules ---------- */
.lane-dots { display: inline-flex; gap: 3px; margin-top: 3px; }
.light-cell .lane-dots { display: flex; }
.ld { width: 0.9rem; height: 0.55rem; border-radius: 2px; background: var(--muted); }
.ld-ok { background: #2fb87a; } .ld-warn { background: #e0a000; } .ld-alarm, .ld-nolight { background: #d6453c; } .ld-unknown { background: #9aa9b2; }
.module-line { margin: 0 0 0.5rem; }
.lane-table { width: 100%; border-collapse: collapse; }
.lane-table th, .lane-table td { padding: 0.4rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lane-table td.num, .lane-table th:nth-child(n+2):nth-child(-n+4) { text-align: right; }
.lane-table tr.lane-worst { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.lane-table .trend { margin-left: 0; }

/* ---------- port page ---------- */
.pane-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; padding: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; }
.pane-tab { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 999px; padding: 0.4rem 1.1rem; min-height: 2.3rem; cursor: pointer; }
.pane-tab:hover { color: var(--text); }
.pane-tab:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pane-tab[aria-selected="true"] { background: var(--teal); color: #fff; }
.pane { display: grid; gap: 1rem; min-width: 0; }
.pane[hidden] { display: none; }
.detail-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.opt-chip { text-decoration: none; font-weight: 600; }
.opt-chip.opt-ok { color: #0e6b45; background: #e3f5ec; } .opt-chip.opt-warn { color: #8a5a00; background: #fdf1d6; }
.opt-chip.opt-alarm, .opt-chip.opt-nolight { color: #a1261c; background: #fde7e5; }
.light-kpi.opt-warn .kpi-v { color: #8a5a00; } .light-kpi.opt-alarm .kpi-v, .light-kpi.opt-nolight .kpi-v { color: #a1261c; } .light-kpi.opt-ok .kpi-v { color: #0e6b45; }
.graph-body:has(> p.muted:only-child) { min-height: 0; }

/* ---------- audit fixes ---------- */
/* a wide table must scroll inside its own box, never stretch the whole page */
.fibre-page, .fgroups { grid-template-columns: minmax(0, 1fr); }
.fgroup, .fgroup-body, .fibre-page > * { min-width: 0; }
.bot-row { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; }
.devlist-bar { margin-bottom: 0.8rem; }
.devlist-bar input[type="search"] { min-height: 2.2rem; padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: 4px; min-width: 14rem; flex: 1 1 14rem; max-width: 22rem; background: var(--surface); }
.devlist-bar .filter-row { margin: 0; }
/* Overview */
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.dash-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; box-shadow: 0 1px 2px rgba(10, 40, 55, 0.05); min-width: 0; }
.dash-card h2 { font-size: 1.05rem; margin: 0 0 0.7rem; }
.dash-card p { margin: 0.7rem 0 0; }
.health-flat { border: 0; padding: 0; box-shadow: none; background: none; }
.mini-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
details.adv { margin-top: 1.2rem; }
/* tables become cards on a phone */
@media (max-width: 640px) {
  .table-wrap.stack { overflow: visible; border: 0; background: none; }
  .table-wrap.stack table, .table-wrap.stack tbody { display: block; min-width: 0; width: 100%; }
  .table-wrap.stack thead { position: absolute; left: -9999px; }
  .table-wrap.stack tbody tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin: 0 0 0.7rem; padding: 0.35rem 0; }
  .table-wrap.stack td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.3rem 1rem; border: 0; padding: 0.3rem 0.9rem; text-align: right; white-space: normal; }
  .table-wrap.stack td > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .table-wrap.stack td[data-label=""] { justify-content: flex-start; gap: 0.4rem; text-align: left; }
  .table-wrap.stack td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-weight: 600; color: var(--muted); }
  .table-wrap.stack td[data-label=""]::before { content: none; }
  .table-wrap.stack td:empty { display: none; }
  .table-wrap.stack td > * { max-width: 100%; }
  .devlist-bar input[type="search"] { max-width: none; }
  .pane-tabs { border-radius: 14px; width: 100%; }
  .pane-tab { flex: 1 1 auto; text-align: center; }
}

.notice.unsupported ul { margin: 0.4rem 0 0.2rem 1.1rem; padding: 0; } .notice.unsupported p { margin: 0.3rem 0 0; }

.unsupported-note { margin: 0.15rem 0 0.5rem 0; max-width: 60rem; } .notice.unsupported li { margin-bottom: 0.3rem; }

.diag-out { max-height: 26rem; overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.9rem; margin-top: 0.7rem; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; }
#optdiagport { min-width: 18rem; flex: 1 1 18rem; }

/* ================= the page that opens when you click an interface ================= */
/* the device's own title becomes a quiet breadcrumb, and its buttons, tabs and identity bar step aside while one port is open */
body.port-mode .page-head { margin-bottom: 0.2rem; }
body.port-mode .page-head h1 { font-size: 0.92rem; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
body.port-mode .page-head h1::before { content: "Devices  \203A  "; font-weight: 500; }
body.port-mode .page-head > :nth-child(2) { display: none; }
body.port-mode .dev-id, body.port-mode .device-page > .tabs { display: none; }
.port-page { display: grid; gap: 1rem; min-width: 0; }
.port-page > * { min-width: 0; }

/* header card with a coloured edge: green healthy, amber warning, red down or alarm */
.port-hero { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(10, 40, 55, 0.06), 0 10px 28px rgba(10, 40, 55, 0.05); }
.port-hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--line); }
.port-hero.st-ok::before { background: linear-gradient(90deg, #2fb87a, #6fdcae); }
.port-hero.st-warn::before { background: linear-gradient(90deg, #e0a000, #f2c75a); }
.port-hero.st-bad::before { background: linear-gradient(90deg, #d6453c, #ec8780); }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; padding: 1.4rem 1.5rem 1.1rem; }
.port-hero .detail-title { min-width: 0; }
.port-hero .detail-title h2 { font-size: 1.75rem; line-height: 1.15; margin: 0; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.port-hero .detail-alias { font-size: 1.02rem; font-weight: 500; margin: 0.3rem 0 0.7rem; color: var(--text); }
.port-hero .detail-title > p.muted { margin: 0.3rem 0 0.7rem; }
.hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.hero-actions .btn[hidden] { display: none; }
/* the five figures become one stat bar, divided by hairlines */
.port-hero .kpis.slimk { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; border-top: 1px solid var(--line); background: #fbfcfd; margin: 0; }
.port-hero .kpis.slimk .kpi { border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; padding: 0.95rem 1.3rem; min-height: 0; min-width: 0; }
.port-hero .kpis.slimk .kpi:last-child { border-right: 0; }
.port-hero .kpis.slimk .kpi[hidden] { display: none; }
.port-hero .kpi-l { font-size: 0.7rem; letter-spacing: 0.08em; }
.port-hero .kpi-v { font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.port-hero .kpi-s { font-size: 0.82rem; }

/* tabs: underlined, and they stay in view while the section scrolls */
.port-page .pane-tabs { position: sticky; top: 0; z-index: 6; width: 100%; gap: 1.6rem; padding: 0 0.2rem; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: color-mix(in srgb, var(--paper) 90%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-x: auto; }
.port-page .pane-tab { border-radius: 0; padding: 0.85rem 0.1rem 0.75rem; min-height: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.port-page .pane-tab:hover { color: var(--text); }
.port-page .pane-tab[aria-selected="true"] { background: none; color: var(--teal-strong); border-bottom-color: var(--teal); }

/* every card in this page shares one look */
.port-page .graph-card, .port-page .optics-card, .port-page .bcast-card, .port-page .panel-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(10, 40, 55, 0.05); padding: 1.1rem 1.3rem 1.3rem; max-width: none; }
.port-page .graph-head { margin-bottom: 0.8rem; }
.port-page .graph-head b { font-size: 1.05rem; }
.detail-panels .panel-card h3 { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
.chart-skel { display: grid; gap: 0.8rem; }
.chart-skel .skeleton.chart { height: 15rem; }

/* optical: the chart on the left, the module and its limits on the right; a level gauge on every lane */
.optic-grid { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.3rem; align-items: start; margin-top: 0.4rem; }
.optic-main { min-width: 0; }
.optic-side { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; min-width: 0; }
.optic-side h3 { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
.optic-side h3:not(:first-child) { margin-top: 1rem; }
.facts { margin: 0; display: grid; gap: 0.45rem; }
.fact { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 0.92rem; }
.fact dt { color: var(--muted); flex: 0 0 auto; }
.fact dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.lane-table .gauge-cell { min-width: 140px; }
.lane-table .gauge { margin: 0; }
.optics-card .optic-banner { border-radius: 10px; }
.optics-card .module-line { margin: 0.1rem 0 0.8rem; }

@media (max-width: 1100px) { .optic-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .port-page .pane-tabs { position: static; } }
@media (max-width: 640px) {
  .hero-top { padding: 1.1rem 1.1rem 0.9rem; }
  .port-hero .detail-title h2 { font-size: 1.45rem; }
  .hero-actions { width: 100%; }
  .port-hero .kpis.slimk { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .port-hero .kpis.slimk .kpi { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); }
  .port-hero .kpis.slimk .kpi:nth-child(2n) { border-right: 0; }
  .port-page .graph-card, .port-page .optics-card, .port-page .bcast-card, .port-page .panel-card { padding: 0.9rem 0.9rem 1rem; border-radius: 12px; }
}

/* the module's temperature and laser current are in the side panel, so the fourth figure is not repeated beside the chart */
.optic-grid .optic-main .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.optic-grid .optic-main .stats .stat:nth-child(4) { display: none; }
.optic-side .facts + h3 + .facts .fact dd { white-space: nowrap; }

body.port-mode .page-head h1 a { color: inherit; text-decoration: none; font-weight: 700; } body.port-mode .page-head h1 a:hover { text-decoration: underline; }

/* Details: the two cards keep their natural height (no stretched, gappy list), and links match the rest of the app */
.detail-panels { align-items: start; }
.detail-panels .kvs { align-content: start; grid-auto-rows: min-content; }
.detail-panels .panel-card a { color: var(--teal-strong); text-underline-offset: 2px; }
.detail-panels .panel-card a:hover { color: var(--teal); }

/* map: link text without a box; a thin dark outline keeps it readable over the lines */
.lk-label, .lk-live { paint-order: stroke fill; stroke: rgba(4, 24, 36, 0.92); stroke-width: 3.4px; stroke-linejoin: round; }
/* map: the red "x N" badge is a link to the exact port that is down */
.chip-link { cursor: pointer; outline: none; }
.chip-link:hover .chip.bad, .chip-link:focus-visible .chip.bad { fill: #f06a60; }
.chip-link:focus-visible .chip { stroke: #fff; stroke-width: 2; }
.down-list { margin: 0 0 0.9rem; padding-left: 1.2rem; display: grid; gap: 0.5rem; }
/* full-page mode (a map link ending in ?view=full): no menu, a slim bar to get back */
body.bare .side { display: none; }
body.bare .shell { grid-template-columns: minmax(0, 1fr); }
body.bare .main { max-width: none; padding-top: 0.7rem; }
.bare-bar { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; padding: 0.2rem 0 0.7rem; margin-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.bare-bar b { font-size: 1rem; letter-spacing: 0.01em; }
.bare-spacer { flex: 1 1 auto; }

/* link quality */
.optic-banner.q-flapping, .optic-banner.q-errors { border-left-color: var(--bad); }
.optic-banner.q-watch { border-left-color: #d4891a; }
.q-h { font-size: 0.95rem; margin: 1.1rem 0 0.3rem; }
.q-events td, .q-events th { padding: 0.45rem 0.7rem; }
.quality-card .stats { margin-top: 0.9rem; }

/* the Link quality table has nine columns: tighter cells and headers that wrap, so it fits without sideways scrolling */
.q-page th, .q-page td { padding: 0.55rem 0.6rem; }
.q-page th { white-space: normal; line-height: 1.2; vertical-align: bottom; }
.q-page td.num { white-space: nowrap; }

/* topology */
.t-page .cb { width: 2rem; }
.t-page .pill-state { margin-right: 0.35rem; }
.t-bar { align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.t-bar #tsel { margin-right: auto; }
.t-how summary { cursor: pointer; font-weight: 600; }
.paste-preview { margin: 0.8rem 0; }
.paste-preview .notice { margin: 0.5rem 0; }
dialog textarea.mono { width: 100%; font-size: 0.85rem; }
.t-page a.mono { color: var(--teal-strong); text-decoration: none; } .t-page a.mono:hover { text-decoration: underline; }
.t-page input[type=search] { min-width: 18rem; flex: 1 1 18rem; }
.t-how { width: 100%; box-sizing: border-box; }

/* weekly report: on screen it is a clean white page; printed, it is the whole page */
.report { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 2rem 2.2rem; max-width: 62rem; margin: 0 auto; color: #12202a; }
.rhead { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; border-bottom: 4px solid var(--teal); padding-bottom: 1.1rem; margin-bottom: 1.3rem; }
.rbrand { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal-strong); font-weight: 700; }
.rhead h1 { font-size: 1.9rem; margin: 0.2rem 0; letter-spacing: -0.01em; }
.rtenant { font-size: 1.1rem; color: var(--muted); }
.rperiod { text-align: right; font-size: 0.95rem; } .rl { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); } .rgap { margin-top: 0.6rem; }
.rkpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.7rem; margin-bottom: 1.4rem; }
.rkpi { border: 1px solid var(--line); border-top: 4px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; }
.rkpi.good { border-top-color: #2fb87a; } .rkpi.warn { border-top-color: #e0a000; }
.rkpi-l { font-size: 0.7rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); } .rkpi-v { font-size: 1.7rem; font-weight: 700; line-height: 1.2; } .rkpi-s { font-size: 0.78rem; color: var(--muted); }
.rsec { margin-top: 1.5rem; break-inside: avoid-page; }
.rsec h2 { font-size: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem; margin: 0 0 0.6rem; display: flex; align-items: center; gap: 0.55rem; }
.rnum { background: var(--teal); color: #fff; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.rsub { font-size: 0.9rem; margin: 1rem 0 0.3rem; } .report-none { margin: 0.4rem 0; }
.rfoot { margin-top: 2rem; padding-top: 0.8rem; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); display: grid; gap: 0.3rem; }
.report table { font-size: 0.88rem; } .report th { background: #f3f6f8; }
@media (max-width: 640px) { .report { padding: 1.1rem; } .rperiod { text-align: left; } }
@media print {
  @page { size: A4; margin: 13mm; }
  body { background: #fff !important; }
  .side, .bare-bar, .page-head, .no-print, .toast { display: none !important; }
  .shell { display: block !important; } .main { padding: 0 !important; max-width: none !important; }
  .report { border: 0; border-radius: 0; padding: 0; max-width: none; font-size: 10.5pt; }
  .rhead, .rkpi, .rnum, .report th, .pill-state { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report tr, .rkpi { break-inside: avoid; } .report thead { display: table-header-group; }
}

@media print {
  .report .table-wrap { overflow: visible !important; }
  .report table { font-size: 9pt; width: 100%; table-layout: auto; }
  .report th, .report td { padding: 0.3rem 0.45rem; }
  .report th { white-space: normal; }
  .rkpis { grid-template-columns: repeat(3, 1fr); }
}
.rsite { margin-top: 0.35rem; font-size: 1.05rem; font-weight: 700; color: var(--teal-strong); }
.report-bar select { min-width: 14rem; }

/* onboarding */
.code-box { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.code-head { padding: 0.5rem 0.8rem; background: #f3f6f8; align-items: center; gap: 0.5rem; }
.code { margin: 0; padding: 0.8rem 1rem; font-size: 0.82rem; line-height: 1.45; overflow: auto; max-height: 26rem; white-space: pre; background: #fff; border-top: 1px solid var(--line); font-family: ui-monospace, Consolas, monospace; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.7rem 1rem; }
.ok-text { color: #0f6b3f; font-weight: 600; }
.only-print { display: none; }
.row-bad td { background: #fdecea; }
@media print { .only-print { display: block; } }

/* system health */
.hbar { height: 0.7rem; background: #e6edf0; border-radius: 99px; overflow: hidden; margin-top: 0.3rem; } .hfill { height: 100%; border-radius: 99px; } .hfill.ok { background: #2fb87a; } .hfill.warn { background: #e0a000; } .hfill.bad { background: #d6453c; }
.hmeter { margin-bottom: 0.9rem; } .hbanner.ok { border-left: 5px solid #2fb87a; } .hbanner.warn { border-left: 5px solid #e0a000; } .hbanner.bad { border-left: 5px solid #d6453c; }
.hrec.act { border-left: 5px solid #d6453c; } .hrec.watch { border-left: 5px solid #e0a000; }

/* wall monitors: the map fills the screen and nothing on it can be clicked, hovered or focused */
body.kiosk { overflow: hidden; background: #0e1a21; }
body.kiosk, body.kiosk * { pointer-events: none !important; cursor: none !important; user-select: none !important; }
body.kiosk .side, body.kiosk .bare-bar, body.kiosk .page-head, body.kiosk .map-panel, body.kiosk .toast { display: none !important; }
body.kiosk .shell { display: block !important; } body.kiosk .main { padding: 0 !important; max-width: none !important; margin: 0 !important; }
body.kiosk .map-main > :not(.map-wrap) { display: none !important; }
body.kiosk .map-page { display: block !important; padding: 0 !important; }
body.kiosk .map-wrap { width: 100vw !important; height: 100vh !important; max-height: none !important; border: 0 !important; border-radius: 0 !important; overflow: hidden !important; }
body.kiosk .map-svg { width: 100% !important; height: 100% !important; }
.kiosk-title { position: fixed; top: 0.7rem; left: 0.9rem; z-index: 5; padding: 0.35rem 0.8rem; border-radius: 6px; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 1.15rem; font-weight: 600; white-space: pre; }
.kiosk-badge { position: fixed; top: 0.7rem; right: 0.9rem; z-index: 5; padding: 0.3rem 0.7rem; border-radius: 6px; background: #b26a00; color: #fff; font-weight: 600; }
.kiosk-msg { display: flex; align-items: center; justify-content: center; height: 100vh; color: #fff; font-size: 1.6rem; text-align: center; padding: 2rem; }

/* phones count the address bar as screen: dvh is the part that can really be seen */
body.kiosk, body.kiosk .shell { height: 100vh; height: 100dvh; }
body.kiosk .map-wrap { height: 100vh !important; height: 100dvh !important; }

/* the total of in and out on a port's traffic graph */
.key.total::before { background: #3b4a54; } .chart .line.total { fill: none; stroke: #3b4a54; stroke-width: 2; stroke-dasharray: 6 3; } .chart .dot.total { stroke: #3b4a54; }
.stat.total { border-left-color: #3b4a54; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .key.total::before { background: #c9d4da; } :root:not([data-theme="light"]) .chart .dot.total, :root:not([data-theme="light"]) .chart .line.total { stroke: #c9d4da; } :root:not([data-theme="light"]) .stat.total { border-left-color: #c9d4da; } }
/* phones: the map area follows the height that can really be seen (set in script from the visual viewport), with a small margin at the bottom */
body.kiosk, body.kiosk .shell { height: var(--kh, 100dvh); }
body.kiosk .map-wrap { height: var(--kh, 100dvh) !important; }
@media (max-width: 900px), (max-height: 520px) { body.kiosk .map-wrap { height: calc(var(--kh, 100dvh) - 14px - env(safe-area-inset-bottom, 0px)) !important; } }

.chart .chart-tip .tip-row.total { color: #ffffff !important; font-weight: 700; margin-top: 0.25rem; padding-top: 0.25rem; border-top: 1px solid rgba(255, 255, 255, 0.3); }
/* how full the link is: green, amber, orange, red */
:root { --u-ok: #1f9d68; --u-busy: #e0a000; --u-high: #e8700a; --u-crit: #d6453c; }
.lvl-chip { float: right; padding: 0.05rem 0.55rem; border-radius: 99px; font-size: 0.75rem; font-weight: 700; color: #fff; }
.lvl-chip.lvl-ok { background: var(--u-ok); } .lvl-chip.lvl-busy { background: var(--u-busy); color: #1b1b1b; } .lvl-chip.lvl-high { background: var(--u-high); } .lvl-chip.lvl-crit { background: var(--u-crit); }
.stat.in.lvl-busy, .stat.out.lvl-busy { border-left-color: var(--u-busy); } .stat.in.lvl-high, .stat.out.lvl-high { border-left-color: var(--u-high); } .stat.in.lvl-crit, .stat.out.lvl-crit { border-left-color: var(--u-crit); background: rgba(214, 69, 60, 0.08); }
.util-verdict { border: 1px solid var(--line); border-left-width: 6px; border-radius: 10px; padding: 0.7rem 1rem 0.9rem; margin: 0.5rem 0 0.9rem; }
.util-verdict.lvl-ok { border-left-color: var(--u-ok); } .util-verdict.lvl-busy { border-left-color: var(--u-busy); } .util-verdict.lvl-high { border-left-color: var(--u-high); } .util-verdict.lvl-crit { border-left-color: var(--u-crit); background: rgba(214, 69, 60, 0.07); }
.util-top { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; } .util-pct { font-size: 1.9rem; line-height: 1; } .util-word { font-size: 1.15rem; font-weight: 700; }
.lvl-ok .util-word { color: var(--u-ok); } .lvl-busy .util-word { color: #a87400; } .lvl-high .util-word { color: #c25a00; } .lvl-crit .util-word { color: var(--u-crit); }
.util-note { color: var(--muted); font-size: 0.85rem; }
.util-gauge { position: relative; height: 0.75rem; border-radius: 99px; margin: 0.8rem 0 1.2rem; background: linear-gradient(to right, var(--u-ok) 0 70%, var(--u-busy) 70% 85%, var(--u-high) 85% 90%, var(--u-crit) 90% 100%); }
.util-mark { position: absolute; top: -0.3rem; width: 0.3rem; height: 1.35rem; margin-left: -0.15rem; border-radius: 2px; background: #12202a; box-shadow: 0 0 0 2px #fff; }
.util-tick { position: absolute; top: 0.95rem; transform: translateX(-50%); font-size: 0.7rem; color: var(--muted); }
.util-advice { font-weight: 600; }
.chart .thr { stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.9; } .chart .thr.busy { stroke: var(--u-busy); } .chart .thr.high { stroke: var(--u-high); } .chart .thr.crit { stroke: var(--u-crit); }
.chart .thr-label { font-size: 10px; font-weight: 600; } .chart .thr-label.busy { fill: #a87400; } .chart .thr-label.high { fill: #c25a00; } .chart .thr-label.crit { fill: var(--u-crit); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lvl-busy .util-word, :root:not([data-theme="light"]) .chart .thr-label.busy { color: #f0b429; fill: #f0b429; } :root:not([data-theme="light"]) .lvl-high .util-word, :root:not([data-theme="light"]) .chart .thr-label.high { color: #ff9340; fill: #ff9340; } :root:not([data-theme="light"]) .util-mark { background: #fff; box-shadow: 0 0 0 2px #12202a; } }
.confirm-box { max-width: 34rem; margin: 4rem auto; }

/* the fourth level (orange) on maps and load bars; shapes differ so colour is not the only cue */
.lk.high { stroke: #ff9340; } .lg.high::before { background: #ff9340; } .pill.high::before { background: #ff9340; border-radius: 2px; }
.bar-fill.busy { background: var(--u-busy); } .bar-fill.high { background: var(--u-high); }
.bar-n.lvl-text.lvl-busy { color: #a87400; font-weight: 600; } .bar-n.lvl-text.lvl-high { color: #c25a00; font-weight: 700; } .bar-n.lvl-text.lvl-crit { color: var(--u-crit); font-weight: 700; }
.mini-events .lvl-chip { float: none; display: inline-block; margin-right: 0.3rem; }

/* the map's graph tile looks like the full graph: filled areas, gridlines, a dashed total */
.gt-area.in { fill: #0b7a8f; opacity: 0.2; } .gt-area.out { fill: #b45f00; opacity: 0.25; }
.gt-grid { stroke: #dbe5ea; stroke-width: 1; } .gt-scale { fill: #44545f; font-size: 9px; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.gt-line.total { stroke: #3b4a54; stroke-width: 1.2; stroke-dasharray: 4 3; }
.gt-stat { font-size: 10.5px; } .gt-k { font-weight: 700; } .gt-k.in { fill: #0b7a8f; } .gt-k.out { fill: #b45f00; } .gt-k.total { fill: #3b4a54; }
