/* goSIPBouncer console: an operator's view of one SBC.
   Readability first: 16 px body, 15 px in tables, contrast >= 4.5:1.
   Barlow Condensed carries headings and big figures; Barlow the rest.
   Numbers, hosts and addresses are monospaced so they line up in columns. */

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #1b2430;
  --ink-2: #4f5b6a;
  --line: #d6dce3;
  --line-strong: #b9c2cd;
  --accent: #1f5fd1;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --ok: #12805c;
  --ok-soft: #e3f4ec;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #c2362f;
  --bad-soft: #fbe7e5;
  --idle: #6b7684;
  --focus: #1f5fd1;
  --shadow: 0 1px 2px rgb(27 36 48 / 6%);
  --radius: 8px;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1a2028;
    --surface-2: #212833;
    --ink: #e7ecf2;
    --ink-2: #a8b3c0;
    --line: #2d3642;
    --line-strong: #3d4856;
    --accent: #6ea2ff;
    --accent-ink: #0d1520;
    --accent-soft: #1d2b44;
    --ok: #4cc38a;
    --ok-soft: #173327;
    --warn: #f0b44c;
    --warn-soft: #3a2c12;
    --bad: #ff7a70;
    --bad-soft: #3d1c1a;
    --idle: #8d98a6;
    --focus: #8fb8ff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1a2028; --surface-2: #212833; --ink: #e7ecf2; --ink-2: #a8b3c0;
  --line: #2d3642; --line-strong: #3d4856; --accent: #6ea2ff; --accent-ink: #0d1520; --accent-soft: #1d2b44;
  --ok: #4cc38a; --ok-soft: #173327; --warn: #f0b44c; --warn-soft: #3a2c12; --bad: #ff7a70; --bad-soft: #3d1c1a;
  --idle: #8d98a6; --focus: #8fb8ff; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: 0.93em; }
.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell: sidebar + main ---------- */

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 2px 12px; }
.brand img, .brand svg { width: 38px; height: 46px; flex: 0 0 38px; }
.brand strong { display: block; font: 600 21px/1.15 "Chakra Petch", var(--sans); letter-spacing: -0.045em; }
.brand small { display: block; margin-top: 5px; padding-left: 1px; color: var(--ink-2); font-size: 12px; line-height: 1.3; white-space: nowrap; }
.build-version { display: block; margin-bottom: 10px; color: var(--ink-2); font: 11px var(--mono); }

.nav-group h2 { margin: 0 0 4px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav-group a:hover { background: var(--surface-2); }
.nav-group a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-group a .count {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--ok); color: #fff; font: 600 12px/20px var(--sans); text-align: center;
}
.nav-group a .count[hidden] { display: none; }
.icon { width: 18px; height: 18px; flex: none; }

.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.sidebar-foot .who { font-weight: 600; }
.sidebar-foot button { margin-top: 8px; }

main { min-width: 0; padding: 24px 32px 48px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font: 600 34px/1.1 var(--display); letter-spacing: 0.005em; }
.topbar .lead { margin: 4px 0 0; color: var(--ink-2); max-width: 68ch; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* Connection lamp: is the live event stream up? */
.link-state { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.lamp { width: 10px; height: 10px; border-radius: 50%; background: var(--idle); flex: none; }
.lamp.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.lamp.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.lamp.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ---------- Sections ---------- */

.stack { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel > header h2 { margin: 0; font: 600 21px/1.2 var(--display); letter-spacing: 0.01em; }
.panel > header p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.panel > header .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.panel-foot { padding: 10px 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }

/* Key figures: one strip, not a wall of cards. */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.figure { padding: 16px 18px; border-left: 1px solid var(--line); }
.figure:first-child { border-left: 0; }
.figure .value { font: 600 40px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.figure .value small { font: 500 18px var(--display); color: var(--ink-2); margin-left: 3px; }
.figure .label { font-size: 14px; color: var(--ink-2); }

.empty { padding: 28px 18px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

/* ---------- Live map: the one dark "screen" in the console ---------- */

.topo {
  position: relative; overflow: hidden;
  background: #141920; border-color: #262e39; color: #e7ecf2;
  --t-up: #4cc38a; --t-down: #ff7a70; --t-idle: #6b7684; --t-ring: #f0b44c; --t-talk: #7ee2ae;
  --t-brass: #e2b47c;
}
.topo > header { border-bottom-color: #262e39; position: relative; z-index: 1; }
.topo > header p { color: #a8b3c0; }
/* A full-width scene gives the network room without obscuring live data. */
.topo-art {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #14192066, #14192010 45%, #14192099), url(/assets/topology-bg.jpg) center 46% / cover no-repeat;
  opacity: 0.48; filter: saturate(0.65);
  -webkit-mask-image: linear-gradient(90deg, #0009, #000 35%, #000 80%, #000b);
  mask-image: linear-gradient(90deg, #0009, #000 35%, #000 80%, #000b);
  pointer-events: none;
}
/* Stage: devices | SBC | devices, with the wires drawn over it. */
.topo-stage {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 300px) minmax(0, 1fr);
  gap: 28px clamp(24px, 4vw, 84px); align-items: center;
  min-height: clamp(440px, 49vh, 650px);
  padding: 40px 28px 32px;
}
.topo-side { display: grid; gap: 12px; align-content: center; min-width: 0; }
.topo-side.left { justify-items: start; }
.topo-side.right { justify-items: end; }
.topo-side > div[data-devs] { display: grid; gap: 12px; width: min(100%, 340px); }
.topo-side-title { font: 600 15px var(--display); color: #8d98a6; letter-spacing: 0.04em; }
.topo-wires { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

.dev, .sbc-card { background: rgb(20 25 32 / 90%); border: 1px solid #333d4a; border-radius: 10px; }
.dev-head, .sbc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 12px 6px; }
.dev-name { font: 600 21px/1.1 var(--display); color: #f1f4f8; letter-spacing: 0.01em; }
.dev-calls, .sbc-calls { font-size: 14px; color: #a8b3c0; white-space: nowrap; }
.dev ul, .ports { list-style: none; margin: 0; padding: 0 6px 6px; display: grid; gap: 2px; }
.dev-empty { color: #6b7684; font-size: 14px; }

/* A trunk: one address of a device. */
.via, .port {
  display: grid; align-items: center; gap: 2px 10px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; color: #dfe5ec;
}
.via { grid-template-columns: 10px minmax(0, 1fr) auto; }
.via .lamp { width: 9px; height: 9px; box-shadow: none; grid-row: span 2; }
.via.up .lamp { background: var(--t-up); }
.via.down .lamp { background: var(--t-down); }
.via-main { display: flex; gap: 8px; align-items: baseline; min-width: 0; flex-wrap: wrap; }
.via-name { font-weight: 600; }
.via .addr, .port .addr { font-size: 14px; color: #f1f4f8; overflow-wrap: anywhere; }
.via-stat { grid-column: 2 / -1; font-size: 13px; color: #a8b3c0; }
.via-stat:empty { display: none; }
.via:hover, .port:hover { background: rgb(255 255 255 / 5%); }
.via.selected, .port.selected { background: rgb(226 180 124 / 14%); outline: 1px solid rgb(226 180 124 / 50%); }

.sbc-card { border: 2px solid var(--t-brass); background: rgb(28 34 44 / 94%); }
.sbc-name { font: 600 26px/1.1 var(--display); color: #f6e4cb; letter-spacing: 0.01em; }
.port { grid-template-columns: auto minmax(0, 1fr) auto; }
.port .iface { font-size: 13px; color: #a8b3c0; }
.port.unused { opacity: 0.55; }

/* Network kinds: small tags, colour by kind. */
.kind {
  font: 600 12px/1 var(--sans); padding: 3px 6px; border-radius: 4px; white-space: nowrap;
  background: rgb(255 255 255 / 8%); color: #c7d0da;
}
.kind.k-public, .kind.k-dnsname { background: rgb(110 162 255 / 18%); color: #a9c7ff; }
.kind.k-private { background: rgb(160 170 185 / 16%); color: #d0d7e0; }
.kind.k-wireguard { background: rgb(136 57 239 / 24%); color: #d2b8ff; }
.kind.k-tailscale { background: rgb(76 195 138 / 18%); color: #9fe6c3; }
.kind.k-vpn { background: rgb(240 180 76 / 18%); color: #f6d39a; }

.wire { fill: none; vector-effect: non-scaling-stroke; stroke-width: 2; stroke-linecap: round; transition: stroke-width 0.3s, opacity 0.3s; }
.wire.up { stroke: var(--t-up); opacity: 0.95; }
.wire.down { stroke: var(--t-down); opacity: 0.75; stroke-dasharray: 6 7; }
.wire.idle { stroke: #a8b3c0; opacity: 0.9; }
.wire.busy { opacity: 1; stroke-width: 3; }
.wire-label {
  font: 500 13px var(--mono); fill: #f1f4f8;
  paint-order: stroke; stroke: #141920; stroke-width: 5px; stroke-linejoin: round;
}
.topo-wires .packets circle { filter: drop-shadow(0 0 4px currentColor); }
.topo-wires .packets .ring { color: var(--t-ring); fill: var(--t-ring); }
.topo-wires .packets .talk { color: var(--t-talk); fill: var(--t-talk); }

/* Hovering a call in the list: its wires stand out, the rest steps back. */
.topo-stage.focus .wire:not(.hl), .topo-stage.focus .packets g:not(.hl) { opacity: 0.15; }
.topo-stage.focus .wire.hl { opacity: 1; stroke-width: 3.5; }
.via.hl, .port.hl { background: rgb(126 226 174 / 12%); }

/* One call pinned from the list: only its packets, its wires and its
   addresses; everything else steps far back. */
.topo-stage.only .packets g:not(.hl) { display: none; }
.topo-stage.only .wire:not(.hl) { opacity: 0.08; }
.topo-stage.only .wire-label:not(.hl) { display: none; }
.topo-stage.only .via:not(.hl), .topo-stage.only .port:not(.hl) { opacity: 0.4; }
.topo-pinned {
  position: relative; z-index: 1; margin: 12px 22px 0; padding: 10px 14px;
  border-radius: 10px; background: rgb(126 226 174 / 10%); border: 1px solid rgb(126 226 174 / 40%);
  display: grid; gap: 6px; color: #dfe5ec;
}
.pinned-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.pinned-label { font: 600 17px var(--display); color: var(--t-talk); }
.pinned-nums { font-size: 16px; color: #f1f4f8; }
.pinned-state { color: #a8b3c0; }
.pinned-main .btn { margin-left: auto; background: transparent; color: #dfe5ec; border-color: #3d4856; }
.pinned-legs { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 14px; color: #a8b3c0; }
.pinned-legs strong { color: #dfe5ec; font-weight: 600; }

/* One column on narrow screens: wires run down the right-hand gutter. */
.topo-stage.stacked { min-height: 0; padding-top: 24px; padding-bottom: 24px; grid-template-columns: minmax(0, 1fr); padding-right: 44px; gap: 14px; }
.topo-stage.stacked .topo-side, .topo-stage.stacked .topo-side.right { justify-items: stretch; }
.topo-stage.stacked .topo-side > div[data-devs] { width: 100%; }

.topo-detail {
  position: relative; z-index: 1; margin: 0 22px 18px; padding: 14px 16px;
  border: 1px solid #333d4a; border-radius: 10px; background: rgb(20 25 32 / 94%); color: #dfe5ec;
}
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.detail-head h3 { margin: 0; font: 600 22px/1.2 var(--display); color: #f1f4f8; }
.detail-head .muted, .topo-detail .muted, .topo-detail dt { color: #a8b3c0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px 28px; align-items: start; }
.topo-detail dl.facts { align-content: start; }
.topo-detail h4 { margin: 0 0 6px; font: 600 16px var(--display); color: #c7d0da; letter-spacing: 0.02em; }
.topo-detail .chip { background: rgb(255 255 255 / 6%); border-color: #3d4856; }
.detail-calls { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.detail-calls li { display: grid; gap: 1px; font-size: 14px; }
.topo-detail .btn { background: transparent; color: #dfe5ec; border-color: #3d4856; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

.topo-legend {
  position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px 18px;
  padding: 10px 18px 14px; font-size: 14px; color: #a8b3c0;
}
.topo-legend span { display: inline-flex; align-items: center; gap: 7px; }
.topo-legend .dot { width: 18px; height: 3px; border-radius: 2px; background: var(--t-idle); }
.topo-legend .dot.up { background: var(--t-up); }
.topo-legend .dot.down { background: repeating-linear-gradient(90deg, var(--t-down) 0 5px, transparent 5px 8px); }
.topo-legend .pkt { width: 9px; height: 9px; border-radius: 50%; }
.topo-legend .pkt.ring { background: var(--t-ring); box-shadow: 0 0 6px var(--t-ring); }
.topo-legend .pkt.talk { background: var(--t-talk); box-shadow: 0 0 6px var(--t-talk); }
.topo-legend .hint { margin-left: auto; }

/* ---------- Live calls: each call is a signal path ---------- */

.calls { list-style: none; margin: 0; padding: 0; }
.call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1.3fr) minmax(0, 1fr) 92px;
  gap: 16px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--line);
  --state: var(--idle); --state-soft: var(--surface-2);
}
.call:first-child { border-top: 0; }
.call[data-state="answered"] { --state: var(--ok); --state-soft: var(--ok-soft); }
.call[data-state="ringing"], .call[data-state="dialing"] { --state: var(--warn); --state-soft: var(--warn-soft); }
.call.arrived { animation: arrive 1.2s ease-out; }
.call.leaving { opacity: 0.45; transition: opacity 0.6s; }
.calls.selectable .call { cursor: pointer; }
.calls.selectable .call:hover { background: var(--surface-2); }
.call.selected { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
@keyframes arrive { from { background: var(--accent-soft); } to { background: transparent; } }

.party .num { font-family: var(--mono); font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.party .trunk { font-size: 14px; color: var(--ink-2); }
.party.callee { text-align: right; }

.path { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.path::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px;
  background: var(--state);
}
.call[data-state="dialing"] .path::before, .call[data-state="ringing"] .path::before {
  background: repeating-linear-gradient(90deg, var(--state) 0 8px, transparent 8px 14px);
}
.path .hop, .path .node {
  position: relative; justify-self: center;
  background: var(--surface); padding: 1px 8px; border-radius: 4px;
  font-size: 13px; color: var(--ink-2);
}
.path .node {
  border: 2px solid var(--state); color: var(--ink); font-weight: 600; background: var(--state-soft);
  padding: 2px 10px;
}
.call .meta { text-align: right; }
.call .clock { font-family: var(--mono); font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.state-tag { font-size: 13px; font-weight: 600; color: var(--state); }

.rtp { grid-column: 1 / -1; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-top: -4px; }
.rtp .warn-text { color: var(--bad); font-weight: 600; }
.net { grid-column: 1 / -1; display: grid; gap: 2px; font-size: 13px; color: var(--ink-2); }
.net > div { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.net .leg { font-weight: 600; color: var(--ink); min-width: 78px; }
.call:focus-visible { outline-offset: -2px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left; font-weight: 600; color: var(--ink-2); font-size: 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
  background: var(--surface-2);
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 13px; color: var(--ink-2); }
td.actions, td.nowrap, td.nowrap .sub { white-space: nowrap; }
td.actions { text-align: right; }
tr.detail td { background: var(--surface-2); padding: 14px 18px 16px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 9px; border-radius: 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.plain::before { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-family: var(--mono); font-size: 13px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Number rewriting guide ---------- */

.journey { margin: 0; padding: 14px 18px 16px 44px; display: grid; gap: 6px; }
.journey li { padding-left: 4px; }
.journey li::marker { font: 600 16px var(--display); color: var(--accent); }
.scope-guide { border-bottom: 1px solid var(--line); padding: 10px 18px 12px; }
.scope-guide summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.scope-guide p { margin: 8px 0 10px; max-width: 80ch; }
table.examples { font-size: 14px; }
table.examples td, table.examples th { padding: 7px 10px; }
table.examples th { background: transparent; }

/* ---------- Help: example cards, cheat sheet ---------- */
/* Help looks like help: tinted, softer, with the numbers large — not
   another table of configuration. */

.example-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; margin: 4px 0 2px; }
.example-card {
  margin: 0; padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid transparent;
  display: grid; gap: 8px;
}
.before-after { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 18px; }
.before-after code { font-family: var(--mono); }
.before-after .after { font-weight: 600; color: var(--ok); }
.before-after span { color: var(--ink-2); }
.example-card figcaption { font-size: 15px; }
.example-card .which { font-size: 13px; font-weight: 600; color: var(--accent); }
.in-invite { display: grid; gap: 4px; }
.in-invite-title { font-size: 12px; color: var(--ink-2); }
.sip-lines { display: grid; gap: 4px; }
.sip-lines code {
  display: block; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 13px/1.45 var(--mono); padding: 4px 8px; border-radius: 4px; background: var(--surface);
}
.sip-lines .was { color: var(--ink-2); text-decoration: line-through; text-decoration-color: rgb(194 54 47 / 60%); }
.sip-lines .now { color: var(--ok); }
.rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--ink-2); }
.rule-line code { font-family: var(--mono); background: var(--surface); padding: 1px 6px; border-radius: 4px; color: var(--ink); }

.cheat-panel { border-bottom: 0; }
.cheat-intro { margin: 10px 0 14px; max-width: 80ch; }
.cheat-intro code, .sign code, .tester code { font-family: var(--mono); background: var(--surface-2); padding: 0 5px; border-radius: 4px; }
.cheat-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px 32px; }
.cheat h4 { margin: 0 0 8px; font: 600 17px var(--display); }
.signs { margin: 0 0 16px; display: grid; gap: 2px; }
.sign { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.sign:first-child { border-top: 0; }
.sign dt code { font-size: 16px; font-weight: 600; color: var(--accent); background: var(--accent-soft); }
.sign dd { margin: 0; }
.sign .eg { display: block; font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.tester { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.tester label { display: grid; gap: 3px; font-size: 13px; font-weight: 600; }
.tester input { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font-size: 15px; }
.tester output { min-height: 28px; display: block; }
.tester .big { font-size: 18px; font-weight: 600; color: var(--ok); background: none; padding: 0; }
.bad-text { color: var(--bad); }
.form-cheat { border-top: 1px solid var(--line); padding-top: 10px; }
.form-cheat summary, .cheat-panel summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.journey-note { margin: 0; padding: 0 18px 16px; color: var(--ink-2); font-size: 15px; }
@media (max-width: 860px) { .cheat-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Tabs, notices ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-strong); }
.tabs button {
  border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer;
  padding: 10px 16px; font: 600 19px var(--display); color: var(--ink-2); margin-bottom: -1px;
}
.tabs button small { font: 500 12px var(--sans); color: var(--ink-2); margin-left: 4px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }

.notice {
  margin-bottom: 16px; padding: 12px 16px; border-radius: 8px;
  background: var(--warn-soft); color: var(--ink); border-left: 4px solid var(--warn);
}
.notice.bad { background: var(--bad-soft); border-left-color: var(--bad); }
.notice a { font-weight: 600; margin-left: 6px; }

.chip.add { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.chip.add::before { content: "+ "; font-weight: 700; }
.chip.remove { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.chip small { font-family: var(--sans); color: var(--ink-2); }

/* ---------- Events ---------- */

.events { list-style: none; margin: 0; padding: 0; }
.event { display: grid; grid-template-columns: 76px 12px minmax(0, 1fr); gap: 10px; padding: 9px 18px; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event time { font-family: var(--mono); font-size: 13px; color: var(--ink-2); padding-top: 1px; }
.event .lamp { margin-top: 6px; width: 8px; height: 8px; box-shadow: none; }
.event .msg { font-weight: 500; }
.event .msg .trunk { font-weight: 400; color: var(--ink-2); }
.event .detail { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.event.fresh { animation: arrive 1.2s ease-out; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-size: 14px; }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.field { display: grid; gap: 5px; align-content: start; }
.field-label { display: flex; align-items: center; gap: 8px; }
.field-label label { font-weight: 600; font-size: 15px; }
.field > small, .check-help { color: var(--ink-2); font-size: 14px; }
.field input::placeholder, .field textarea::placeholder, input.search::placeholder { color: var(--ink-2); opacity: 0.6; font-style: italic; }

/* Chips: a list typed one value at a time. Looks like an input. */
.chips-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 44px; padding: 6px 8px; cursor: text;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
}
.chips-box:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.chip-list { display: contents; }
.chip-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 4px 2px 8px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 14px;
}
.chip-item small { color: var(--ink-2); font-size: 12px; }
.chip-item button {
  width: 20px; height: 20px; border: 0; border-radius: 50%; padding: 0;
  background: transparent; color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer;
}
.chip-item button:hover { background: var(--bad-soft); color: var(--bad); }
.chip-item.bad { border-color: var(--bad); background: var(--bad-soft); }
.chip-item.bad small { color: var(--bad); font-weight: 600; }
.chip-input { flex: 1; min-width: 180px; border: 0; outline: 0; background: transparent; padding: 4px 2px; font-size: 15px; }
.chip-input::placeholder { color: var(--ink-2); opacity: 0.6; font-style: italic; }
.field:has(input[type=hidden][aria-invalid]) .chips-box { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }

/* "?" next to a label: opens what the field does and how the SBC reacts. */
.info-btn {
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2);
  font: 700 12px/1 var(--sans); cursor: pointer; flex: none;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.field-info {
  font-size: 14px; line-height: 1.5; padding: 10px 12px; border-radius: 6px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.field-info p { margin: 0 0 6px; }
.field-info ul { margin: 0; padding-left: 18px; }
.field-info li { margin: 2px 0; }
.field-info code { font-family: var(--mono); font-size: 13px; background: var(--surface); padding: 0 4px; border-radius: 3px; }

/* A problem with one field, said next to it. */
.field > .field-error, .field-error { color: var(--bad); font-size: 14px; font-weight: 500; }
.field [aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.field input, .field select, .field textarea, input.search, select.inline {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; background-color: var(--surface);
  font-size: 16px; line-height: 1.4; color: var(--ink);
}
/* Selects drawn like inputs: the browser's own (Safari's especially) is
   smaller and differently styled. One chevron, in the ink colour. */
.field select, select.inline {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23808a97' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
}
.field select:disabled { cursor: not-allowed; opacity: 0.6; }
.field textarea { min-height: 76px; resize: vertical; font-family: var(--mono); font-size: 14px; }
.field input.mono { font-family: var(--mono); }
input.search { width: 240px; min-height: 36px; padding: 5px 10px; font-size: 15px; }
select.inline { width: auto; min-height: 36px; padding: 5px 34px 5px 10px; font-size: 15px; background-position: right 11px center; }
.field.check { grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; }
.field.check .check-help, .field.check .field-info, .field.check .field-error { grid-column: 2; }
.field.check input { width: 18px; height: 18px; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { color: var(--bad); background: var(--bad-soft); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.form-error:empty { display: none; }

/* Members editor in the group form */
.members { display: grid; gap: 8px; }
.member { display: flex; gap: 10px; align-items: flex-end; }
.member .field { flex: 1; min-width: 0; }
.member .field:first-child { flex: 2; }

/* ---------- Dialog ---------- */

dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgb(0 0 0 / 25%);
}
dialog::backdrop { background: rgb(18 22 28 / 45%); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
dialog header { padding: 16px 20px; border-bottom: 1px solid var(--line); }
dialog header h2 { margin: 0; font: 600 23px/1.2 var(--display); }
dialog .dialog-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 16px; }
dialog footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.secret {
  font-family: var(--mono); font-size: 15px; padding: 12px; border-radius: 6px;
  background: var(--surface-2); border: 1px dashed var(--line-strong); overflow-wrap: anywhere;
}

/* ---------- Toast ---------- */

#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 10;
  max-width: 420px; padding: 12px 16px; border-radius: 8px;
  background: var(--ink); color: var(--surface); font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); color: #fff; }

/* ---------- Sign-in ---------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin .panel { width: min(440px, 100%); }
.signin .panel-body { display: grid; gap: 16px; }
.signin h1 { margin: 0; font: 600 28px/1.1 var(--display); }
.signin p { margin: 0; color: var(--ink-2); }

/* ---------- Narrow screens ---------- */

.menu-toggle { display: none; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .topo-art { background-size: auto 100%; background-position: 70% 50%; opacity: 0.18; -webkit-mask-image: none; mask-image: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: 260px;
    transform: translateX(-100%); transition: transform 0.2s;
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 30%); }
  .menu-toggle { display: inline-flex; }
  main { padding: 16px 16px 40px; }
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 28px; }
  .call { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
  .call .path { grid-column: 1 / -1; grid-row: 2; }
  .call .meta { grid-column: 2; grid-row: 1; }
  .call .party.callee { grid-column: 1 / -1; grid-row: 3; text-align: left; }
  .figure { border-left: 0; border-top: 1px solid var(--line); }
  .figures .figure:nth-child(-n + 2) { border-top: 0; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  input.search { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Bound map density independently of the size of the inventory. */
.map-controls { position: relative; z-index: 2; display: flex; align-items: end; flex-wrap: wrap; gap: 14px 20px; padding: 16px 22px; background: rgb(15 20 27 / 78%); border-bottom: 1px solid #303b48; }
.map-controls label { display: grid; gap: 5px; color: #a8b3c0; font-size: 13px; }
.map-search { flex: 1 1 230px; max-width: 360px; }
.map-controls input, .map-controls select { width: 100%; min-height: 40px; padding: 7px 11px; color: #e7ecf2; background: #1a222d; border: 1px solid #435064; border-radius: 6px; font: 15px var(--sans); color-scheme: dark; }
.map-controls input::placeholder { color: #a8b3c0; }
.map-controls :disabled { opacity: .5; }
.map-capacity { margin-left: auto; padding-bottom: 9px; color: #b8c6d7; font-size: 14px; }
/* The network is a continuous canvas; controls never paginate its nodes. */
.map-camera { display: flex; gap: 7px; align-items: center; }
.map-camera .btn { color: #e7ecf2; background: #1a222d; border-color: #435064; min-width: 34px; }
.map-camera output { color: #bdc9d8; font: 12px var(--mono); min-width: 44px; text-align: center; }
.map-viewport { position: relative; height: clamp(360px, 52dvh, 760px); overflow: hidden; touch-action: none; cursor: grab; }
.map-viewport.panning { cursor: grabbing; user-select: none; }
.map-viewport .topo-stage { position: absolute; left: 0; top: 0; width: max(1160px, 100%); min-height: 490px; transform-origin: 0 0; align-items: center; }
.map-viewport .topo-side { align-content: center; }
.map-viewport .topo-side > div[data-devs] { align-content: center; }
.map-viewport .topo-side-title { width: min(100%, 340px); }
.traffic-workspace { min-height: calc(100dvh - 150px); display: flex; flex-direction: column; }
.traffic-workspace [data-topology] { position: relative; flex: 1; }
.workspace-calls { position: relative; z-index: 1; border-top: 1px solid #384352; background: #171e27; color: #e7ecf2; }
.workspace-calls > header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 20px; }
.workspace-calls h2 { margin: 0; font: 600 21px var(--display); }
.workspace-calls header p { margin: 2px 0 0; font-size: 14px; color: #a8b3c0; }
.workspace-calls .calls { max-height: 230px; overflow-y: auto; }
.workspace-calls .empty { padding: 16px 20px 22px; color: #a8b3c0; text-align: left; }
.workspace-calls .empty strong { color: #e7ecf2; }
.workspace-calls .call { border-color: #384352; }
.workspace-calls .party .num, .workspace-calls .clock { color: #e7ecf2; }
.workspace-calls .trunk { color: #a8b3c0; }
.workspace-calls .btn { color: #e7ecf2; background: #1a222d; border-color: #435064; }
@media (max-width: 760px) {
  .map-capacity { flex-basis: 100%; margin-left: 0; padding: 0; }
  .map-controls { padding: 14px; }
  .map-viewport { height: 55dvh; min-height: 320px; }
}

/* Keep the hub centered while its scale responds more gently to zoom. */
.map-viewport .topo-center { transform-origin: center; position: relative; z-index: 1; }

.wire-halo { fill: none; stroke: #10161e; stroke-width: 5px; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .85; }
.topo-stage.focus .wire-halo:not(.hl) { opacity: .15; }
.topo-stage.only .wire-halo:not(.hl) { opacity: .08; }

.brand { color: var(--ink); text-decoration: none; border-radius: 5px; }
.brand:hover strong { color: var(--accent); }
.map-viewport .topo-art { inset: -8%; background-position: center; transform-origin: center; }

/* Quiet architectural texture across the console, beneath opaque content. */
.shell > main { position: relative; isolation: isolate; }
.shell > main::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url(/assets/topology-bg.jpg) center / cover no-repeat;
  opacity: .045; filter: saturate(.35);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 35%, #000);
  mask-image: linear-gradient(180deg, transparent, #000 35%, #000);
}
/* Long explanations use a wider reading face, separate from display headings. */
.reading-page { --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font: 400 16px/1.7 var(--sans); --ink-2: color-mix(in srgb, var(--ink) 78%, var(--surface)); }
.reading-page .panel > header { padding: 20px 24px; }
.reading-page .panel > header h2 { font: 650 20px/1.35 var(--sans); letter-spacing: -.02em; }
.reading-page .panel > header p { font-size: 15px; line-height: 1.65; max-width: 78ch; margin-top: 7px; }
.reading-page .journey { padding: 22px 28px 22px 54px; gap: 14px; max-width: 95ch; }
.reading-page .journey li { padding-left: 8px; }
.reading-page .journey li::marker { font: 650 16px var(--sans); }
.reading-page .journey strong { font-weight: 650; }
.reading-page .journey-note { max-width: 90ch; padding: 0 24px 24px; font-size: 15px; line-height: 1.7; }
.reading-page .scope-guide { padding: 16px 24px 20px; }
.reading-page summary { line-height: 1.65; font-weight: 600; }
.reading-page .scope-guide p, .reading-page .cheat-intro { max-width: 72ch; margin: 18px 0 22px; }
.reading-page .example-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.reading-page .example-card { padding: 20px; gap: 16px; border-color: var(--line); background: var(--surface-2); align-content: start; }
.reading-page .which { font-size: 14px; line-height: 1.5; }
.reading-page .before-after { font-size: 19px; line-height: 1.7; gap: 8px 12px; }
.reading-page figcaption { font-size: 16px; line-height: 1.7; }
.reading-page .in-invite-title { font-size: 14px; margin-bottom: 8px; }
.reading-page .sip-lines { gap: 6px; }
.reading-page .sip-label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.reading-page .sip-lines code { font-size: 14px; line-height: 1.75; padding: 10px 12px; }
.reading-page .sip-lines .was { text-decoration: none; color: var(--ink); }
.reading-page .sip-lines .now { color: var(--ink); border-left: 3px solid var(--ok); }
.reading-page .rule-line { font-size: 14px; line-height: 1.8; padding-top: 12px; border-top: 1px solid var(--line); }
.reading-page .rule-line code { padding: 3px 8px; }
.reading-page .cheat-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 40px; }
.reading-page .cheat h4 { font: 650 17px/1.5 var(--sans); margin: 0 0 14px; }
.reading-page .sign { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; padding: 14px 0; }
.reading-page .sign dt code { font-size: 17px; display: inline-block; padding: 2px 7px; }
.reading-page .sign .eg { font-size: 14px; line-height: 1.8; margin-top: 7px; }
.reading-page .tester { padding: 20px; gap: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.reading-page .tester label { gap: 7px; font-size: 14px; }
.reading-page .tester input { min-height: 46px; font: 15px/1.6 var(--mono); }
.reading-page .empty { font-size: 16px; }
@media (max-width: 1100px) { .reading-page .cheat-grid, .reading-page .example-cards { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .reading-page .scope-guide { padding: 14px; } .reading-page .sign { grid-template-columns: 88px minmax(0, 1fr); gap: 10px; } }

/* Account setup */
.setup-form { display: grid; gap: 16px; }
.qr { width: 200px; padding: 8px; background: #fff; border-radius: 8px; margin: 6px 0; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { margin-top: 4px; font-size: 15px; letter-spacing: .04em; user-select: all; }
.backup-codes { columns: 2; margin: 0; padding-left: 1.6em; font-size: 16px; line-height: 1.8; }
.signin .form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
