/* Wirebook. Design language: the comms cupboard.
   Steel-grey workspace, a navy rack across the top, patch-lead blue as the accent, the cable pair
   colours (orange, green, brown) as functional coding, and printed label tape on everything that is
   physically labelled in real life: device names, lead labels, outlets. */

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

:root {
  --bg: #edf0f3;          /* steel */
  --surface: #ffffff;
  --raised: #f6f8fa;
  --text: #17202a;        /* graphite */
  --muted: #5a6878;
  --line: #d6dde5;
  --line-strong: #b8c3cf;
  --accent: #2160d4;      /* patch-lead blue */
  --accent-deep: #174ba8;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecfb;
  --orange: #e2731b;      /* pair colours, used for meaning, not decoration */
  --green: #2e9a58;
  --brown: #86573a;
  --danger: #c62828;
  --ok-bg: #e6f4ec; --ok-line: #9fd2b3;
  --err-bg: #fcebea; --err-line: #f0b2ad;
  --info-bg: #e8effb; --info-line: #a8c1ec;
  --warn-bg: #fdf0e3; --warn-line: #f2c08f; --warn-ink: #9a4a0b;
  --rack: #121c27;        /* the top bar and dark panels */
  --rack-2: #1b2735;
  --rack-line: #2b3a4b;
  --rack-ink: #d9e2ec;
  --tape: #fbfaf4;        /* label tape stays light in both themes */
  --tape-ink: #15191e;
  --tape-edge: #cdd3da;
  --radius: 6px;
  --radius-sm: 4px;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b; --surface: #151e28; --raised: #1a2532; --text: #e6ebf0; --muted: #94a3b3;
    --line: #253241; --line-strong: #364659;
    --accent: #5b8ff0; --accent-deep: #3f74db; --accent-ink: #07132a; --accent-soft: #15264a;
    --orange: #f08a3a; --green: #4cbf7b; --brown: #b07a56; --danger: #f07167;
    --ok-bg: #11291c; --ok-line: #2b6a45; --err-bg: #2e1517; --err-line: #7a2e2a;
    --info-bg: #12203a; --info-line: #2d4c80; --warn-bg: #2e1f0e; --warn-line: #7a4a1c; --warn-ink: #f6b26b;
    --rack: #0a1018; --rack-2: #121a24; --rack-line: #223040;
    --tape: #ece9de; --tape-ink: #121417; --tape-edge: #b9b5a8;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* never let a component's display rule show something marked hidden */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15.5px/1.5 var(--sans); font-feature-settings: "tnum" 1; }
/* The animated network behind every page (assets/background.js). Sits under all content. */
.bg-net { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 1.6s ease; }
.bg-net.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .bg-net { transition: none; } }
@media print { .bg-net { display: none; } }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }
h1, h2, h3, h4 { font-family: var(--cond); font-weight: 700; line-height: 1.12; letter-spacing: 0; }
h1 { font-size: 2.1rem; margin: 0 0 .6rem; }
h2 { font-size: 1.45rem; margin: 0 0 .7rem; }
h3 { font-size: 1.15rem; margin: 1.3rem 0 .5rem; }
h4 { font-size: 1.02rem; margin: 1.1rem 0 .4rem; }
p { max-width: 75ch; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 26px; padding-bottom: 44px; min-height: 70vh; }
/* Diagram pages use the whole window width. */
.main.wide { max-width: none; padding-left: 24px; padding-right: 24px; }
.main.wide .topo-svg { height: calc(100vh - 290px); min-height: 520px; }
.main.wide .dg-svg { height: calc(100vh - 270px); min-height: 520px; }
.main.wide .dg-side { max-height: calc(100vh - 268px); }
.main.wide .dg-body { grid-template-columns: 370px minmax(0, 1fr); }
@media (max-width: 900px) { .main.wide .dg-body { grid-template-columns: 1fr; } .main.wide .dg-side { max-height: none; } }
@media (max-width: 640px) { .main.wide { padding-left: 16px; padding-right: 16px; } }
.muted { color: var(--muted); }
/* Management address: opens the device's web interface; "http" is the plain-HTTP fallback. */
.mgmt-link { white-space: nowrap; }
.mgmt-link a.mono { font-family: var(--mono); font-size: .9em; }
.mgmt-http { margin-left: 6px; font-size: .72em; color: var(--muted); text-decoration: none; border: 1px solid var(--line-strong);
  border-radius: 3px; padding: 0 4px; vertical-align: 1px; }
.mgmt-http:hover { color: var(--accent); border-color: var(--accent); }
@media print { .mgmt-http { display: none; } }
.mono { font-family: var(--mono); font-size: .9em; }
.small { font-size: .84em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------- Label tape: names that are printed on a label in real life ---------- */
.brand-mark, .lead-label, .tag, h2.mono, .mono.big {
  font-family: var(--mono); background: var(--tape); color: var(--tape-ink);
  border: 1px solid var(--tape-edge); border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), inset 0 -1px 0 rgba(0, 0, 0, .04);
}
h2.mono, .mono.big { display: inline-block; font-weight: 600; letter-spacing: .01em; padding: .12em .5em .14em; line-height: 1.25; }
h2.mono.big { font-size: 1.45rem; margin: 2px 0 4px; }
a .mono.big, .mono.big a, h2.mono a { color: inherit; text-decoration: none; }
.lead-label { padding: 0 .4em; margin-left: 4px; font-size: .78rem; border-style: solid; }

/* ---------- Top bar: the rack ---------- */
.topbar { background: var(--rack); color: var(--rack-ink); border-bottom: 3px solid var(--accent); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 12px; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px;
  font: 700 1.35rem/1 var(--cond); letter-spacing: .01em; }
.brand:hover { color: #fff; }
.brand-mark { font-size: .78rem; font-weight: 700; padding: 3px 6px; letter-spacing: .04em; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: .95rem; }
.topnav a, .topnav .btn, .topnav .link { color: #c3cfdb; text-decoration: none; white-space: nowrap; }
.topnav a:hover { color: #fff; }
.who { color: #8798aa; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topnav .link { color: #c3cfdb; text-decoration: none; }
.topnav .link:hover { color: #fff; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent-deep); border-bottom-width: 2px; border-radius: var(--radius-sm);
  padding: 9px 16px; font: 600 .95rem/1.2 var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent-deep); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); border-bottom-width: 1px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-small { padding: 5px 11px; font-size: .86rem; }
.topnav .btn { color: var(--accent-ink); }
.brand { white-space: nowrap; }
.btn-ghost { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-deep); }
.btn-danger { background: var(--danger); border-color: color-mix(in srgb, var(--danger) 70%, #000); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--danger); }
form.inline { display: inline; margin: 0; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card.narrow { max-width: 520px; }
.card.narrow.center { margin-left: auto; margin-right: auto; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
.card-link:hover { border-color: var(--accent); color: inherit; }
.card-link h3 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.grid .card { margin-bottom: 0; }
.grid:has(> .stat) { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-left: 4px solid var(--line-strong); }
.stat-num { font: 700 2.3rem/1 var(--cond); }
a.stat:hover { border-left-color: var(--accent); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.form small { font-weight: 400; color: var(--muted); }
.form-row { grid-template-columns: 1fr auto; align-items: end; }
.form-row:has(> label + label) { grid-template-columns: 1fr 1fr auto; }
input, select, textarea { font: 400 .95rem/1.4 var(--sans); color: var(--text); background: var(--raised);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; }
input.mono, .mono input { font-family: var(--mono); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); background: var(--surface); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: auto; }
input[type=file] { background: transparent; border-style: dashed; }
textarea { resize: vertical; }
td select { width: auto; padding: 4px 8px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; background: var(--raised); }
legend { font: 700 1.02rem var(--cond); padding: 0 6px; }
.form-grid { grid-template-columns: 1fr 1fr; align-items: end; }
fieldset .form-grid { display: grid; gap: 14px; }
fieldset .form-grid label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-actions { display: flex; gap: 16px; align-items: center; }
.danger-zone { border-color: var(--err-line); background: color-mix(in srgb, var(--err-bg) 45%, var(--surface)); }
.check-row { display: flex !important; flex-direction: row; gap: 8px; align-items: center; align-self: end; padding-bottom: 10px; font-weight: 500 !important; }
.check-row input { width: auto; }
.narrow-input { width: 110px !important; }
details > summary { cursor: pointer; }
details > summary::marker { color: var(--accent); }
details[open] > summary { margin-bottom: 12px; }

/* ---------- Messages ---------- */
.flash { border: 1px solid; border-left-width: 4px; border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.flash-success { background: var(--ok-bg); border-color: var(--ok-line); border-left-color: var(--green); }
.flash-error { background: var(--err-bg); border-color: var(--err-line); border-left-color: var(--danger); }
.flash-info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--accent); }

/* ---------- Tables: a datasheet ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font: 600 .95rem var(--cond); color: var(--muted); border-bottom: 2px solid var(--line-strong); padding: 8px 8px 6px; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--raised); }
.table tbody tr:last-child td { border-bottom: 0; }
.card:has(> .table) { overflow-x: auto; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty { color: var(--muted); padding: 22px 8px; }
.row-muted td { color: var(--muted); }
.kv th { width: 30%; font: 600 .93rem var(--sans); color: var(--text); border-bottom: 1px solid var(--line); }

/* Pills are small printed tags: square-ish, not bubbles */
.pill { display: inline-block; font: 600 .74rem/1.5 var(--sans); background: var(--accent-soft); color: var(--accent-deep);
  border-radius: 3px; padding: 0 6px; vertical-align: 1px; white-space: nowrap; }
.pill-warn { background: var(--err-bg); color: var(--danger); }
.pill-soon { background: var(--warn-bg); color: var(--warn-ink); }
.status-active { background: var(--ok-bg); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.status-spare, .status-planned, .status-reserved { background: var(--info-bg); color: var(--text); }
.status-retired { background: var(--line); color: var(--muted); }
.status-used { background: var(--accent-soft); color: var(--accent-deep); }
.pill-client { background: #e7eaf3; color: #3f4f73; margin-left: 4px; }
@media (prefers-color-scheme: dark) { .pill-client { background: #232c45; color: #b4c0e0; } }
a.stat.stat-on { border-left-color: var(--accent); background: var(--accent-soft); }
.status-dhcp { background: #efe6fb; color: #5b2a9e; }
@media (prefers-color-scheme: dark) {
  .status-dhcp { background: #2a1d45; color: #cdb4f5; }
  .pill { color: var(--accent); }
  .status-active { color: var(--green); }
}

/* ---------- Organisation pages ---------- */
.eyebrow { font: 600 .98rem var(--cond); color: var(--muted); margin: 0 0 2px; }
.eyebrow a { color: inherit; }
.org-head { margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; }
.org-search input { width: 300px; max-width: 100%; padding-left: 30px; background: var(--surface)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6878' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='m15.5 15.5 5 5'/%3E%3C/svg%3E") no-repeat 9px center; }
@media (max-width: 640px) { .org-search, .org-search input { width: 100%; } }
.search-big { display: flex; gap: 8px; margin: 4px 0 12px; }
.search-big input { flex: 1; font-size: 1.05rem; padding: 10px 12px; }
.search-group h2 { font-size: 1.2rem; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-results li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.search-results li:last-child { border-bottom: 0; }
.search-results mark, .search-page mark { background: color-mix(in srgb, var(--orange) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
kbd { font: 600 .82em var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: var(--raised); }
.org-head h1 { font-size: 2rem; margin-bottom: 4px; }
.tabs { display: flex; gap: 2px; box-shadow: inset 0 -1px 0 var(--line-strong); margin-bottom: 22px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a, .tabs span { padding: 9px 14px 8px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
  white-space: nowrap; font: 600 1.05rem var(--cond); }
.tabs a:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-soon { opacity: .45; cursor: default; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 8px; padding-left: 4px; }
.steps li::marker { font: 700 1rem var(--cond); color: var(--muted); }
.steps li.done strong { text-decoration: line-through; color: var(--muted); }
.steps li.done::marker { content: "✓  "; color: var(--green); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.page-head p { margin: 4px 0 0; }
h2.big { font-size: 1.9rem; margin: 0; }
h3.first { margin-top: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
a.plain { color: inherit; text-decoration: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 22px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; }
.facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts > div > .small:first-child { font: 600 .9rem var(--cond); }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.prewrap { white-space: pre-wrap; margin: 0; }
.type { white-space: nowrap; }

/* ---------- IP plan ---------- */
.subnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: -10px 0 18px; }
.subnav nav { display: flex; gap: 4px; }
.subnav nav a { padding: 4px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font: 600 1rem var(--cond); }
.subnav nav a:hover { color: var(--text); background: var(--surface); }
.subnav nav a.active { background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line-strong); }
.search input { width: 320px; max-width: 100%; padding: 7px 11px; background: var(--surface); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-right { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.inline-form label { display: flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; padding: 6px 10px; }
.tree td.depth-1 { padding-left: 26px; } .tree td.depth-2 { padding-left: 44px; } .tree td.depth-3 { padding-left: 62px; }
.tree td.depth-4 { padding-left: 80px; } .tree td.depth-5 { padding-left: 98px; } .tree td.depth-6 { padding-left: 116px; }
.branch { color: var(--line-strong); margin-right: 4px; }
.usage { display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
meter { width: 92px; height: 9px; }
meter::-webkit-meter-bar { background: var(--line); border: 0; border-radius: 2px; }
meter::-webkit-meter-optimum-value { background: var(--green); border-radius: 2px; }
meter::-webkit-meter-suboptimum-value { background: var(--orange); border-radius: 2px; }
meter::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: 2px; }

/* ---------- Devices ---------- */
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat-bad { border-left-color: var(--danger); } .stat-bad .stat-num { color: var(--danger); }
.stat-warn { border-left-color: var(--orange); } .stat-warn .stat-num { color: var(--warn-ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[name=q] { width: 230px; padding: 7px 11px; background: var(--surface); }
.filters select { width: auto; padding: 7px 10px; background: var(--surface); }
.filters .check { display: flex; gap: 6px; align-items: center; font-size: .92rem; }
.filters .check input { width: auto; }
.filters-right { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.kv-form { margin-top: 14px; grid-template-columns: 1fr 2fr auto; }
.table td.place { white-space: nowrap; }
.table td.place .small { display: block; }

/* ---------- Port map: the faceplate ---------- */
.faceplate { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px 5px; max-width: 920px;
  background: linear-gradient(#26313d, #1b242e); border: 1px solid #0d131a; border-radius: 4px; padding: 12px 14px;
  margin-bottom: 8px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
/* Patch a run: preview rows */
.run-pairs .run-mine-taken td, .run-pairs .run-theirs-taken td { background: var(--warn-bg); }
.run-pairs .run-already td { color: var(--muted); }
.warn-text { color: var(--warn-ink); }
.link-help { margin: 0; }
/* Patch panels: always 24 ports to a row, like the real thing, in blocks of six. Narrow screens scroll. */
.faceplate-panel { grid-template-columns: repeat(24, minmax(30px, 1fr)); column-gap: 4px; max-width: 1180px; overflow-x: auto; }
.faceplate-panel .fp-port { min-width: 0; }
.faceplate-panel .fp-port:nth-child(6n):not(:nth-child(24n)) { margin-right: 8px; }
/* An RJ45 socket: square with the latch notch at the bottom. */
.fp-port { display: inline-flex; align-items: center; justify-content: center; height: 30px; min-width: 32px; padding-bottom: 6px;
  font: 700 .7rem var(--mono); text-decoration: none; border: 0;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 72% 78%, 72% 100%, 28% 100%, 28% 78%, 0 78%); }
.fp-free { background: #0b1118; color: #6f8193; }
.fp-free:hover { background: #121b25; color: #c3cfdb; }
.fp-used { background: var(--green); color: #fff; }
.fp-linked { background: #2f6fe0; color: #fff; }
.fp-off { background: #3a2626; color: #b07f7f; text-decoration: line-through; }
/* Live but undocumented: the switch saw a link, Wirebook has nothing recorded. Hazard stripes in the
   warning pair colour, so these stand out as "go and label me". */
.fp-live { background: repeating-linear-gradient(135deg, #9a5414 0 5px, #6f3b0c 5px 10px); color: #ffe6c7; }
.fp-live:hover { background: repeating-linear-gradient(135deg, #b5651a 0 5px, #87480f 5px 10px); color: #fff; }
.pill-live { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); margin-left: 4px; }
.pill-down { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); margin-left: 4px; }
.live-count { color: var(--warn-ink); }
.link-reported { margin: 0; }
.fp-trunk { box-shadow: inset 0 0 0 2px var(--orange); }
.fp-port:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 0 0 18px; }
.legend .fp-port { height: 20px; min-width: 22px; margin-right: 5px; padding-bottom: 4px; vertical-align: middle; }
.ports td { vertical-align: top; }
.via { color: var(--muted); white-space: nowrap; }
.via a { color: var(--brown); }

/* ---------- Rooms ---------- */
.site-heading { font: 700 1.2rem var(--cond); color: var(--brown); margin: 10px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--line-strong); }
.room-card { border-top: 4px solid var(--brown); }
.room-card h3 { margin-top: 0; font-size: 1.3rem; }
.room-counts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.room-counts strong { color: var(--text); font: 700 1.1rem var(--cond); }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; max-height: 340px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--raised); }
.checklist .check { display: flex; gap: 8px; align-items: baseline; font-weight: 400; }
.checklist .check input { width: auto; }
.cabinet h3 { display: flex; gap: 6px; align-items: baseline; font-size: 1.25rem; }
.cabinet { border-left: 4px solid var(--brown); }

/* ---------- Device images ---------- */
.device-images { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.device-images figure { margin: 0; flex: 1 1 380px; max-width: 760px; background: var(--rack); border-radius: var(--radius); padding: 14px 14px 10px; }
.device-images img { display: block; width: 100%; height: auto; border-radius: 2px; }
.device-images figcaption { color: #9fb0c0; margin-top: 8px; }
.device-images figcaption .link { color: #f2a19a; }
.device-images.generic figure { flex: 0 1 420px; }

/* Picking images from the NetBox library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.lib-pick { margin: 0; display: flex; flex-direction: column; gap: 8px; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; }
.lib-pick img { display: block; width: 100%; aspect-ratio: 5 / 2; object-fit: contain; background: #c7ced6; border-radius: 2px; }
.lib-pick figcaption { display: flex; flex-direction: column; gap: 1px; font-size: .9rem; }
.lib-pick form { margin-top: auto; }
.lib-search { margin-top: 6px; }
.image-prompt { margin: -4px 0 14px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); max-width: none; }
.more-ways { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.model-row-images { display: flex; gap: 6px; }
.suggest-row { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest { margin: 0; }
.suggest button { display: flex; flex-direction: column; gap: 4px; width: 150px; padding: 6px; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: 500 .8rem/1.25 var(--sans); color: var(--text); }
.suggest button:hover, .suggest button:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.suggest img { width: 100%; aspect-ratio: 5 / 2; object-fit: contain; background: #c7ced6; border-radius: 2px; }
.model-row-images img { height: 34px; width: auto; max-width: 140px; background: #c7ced6; border-radius: 2px; }

/* ---------- Power ---------- */
.power-tree { list-style: none; margin: 0; padding: 0 0 0 4px; }
.power-tree .power-tree { padding-left: 22px; border-left: 2px solid color-mix(in srgb, var(--orange) 45%, var(--line)); margin: 4px 0 6px 12px; }
.power-tree li { padding: 3px 0; }
.power-tree li.spare > .outlet + span { font-style: italic; }
.outlet { display: inline-block; min-width: 2.4em; text-align: center; background: var(--rack-2); color: #e6ebf0;
  border-radius: 2px; padding: 0 5px; margin-right: 7px; font: 700 .76rem/1.6 var(--mono); }
.power-tree li.spare > .outlet { background: var(--line); color: var(--muted); }
.feed-list { padding-left: 18px; }
.feed-list li { margin-bottom: 6px; }
.ups-card { border-top: 4px solid var(--orange); }
.ups-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ups-stats { display: flex; gap: 16px; color: var(--muted); font-size: .92rem; }
.ups-stats strong { color: var(--text); font: 700 1.2rem var(--cond); }
.add-outlet { margin-top: 14px; }
.range-form { margin-top: 12px; grid-template-columns: 1fr 1fr auto; }

/* ---------- Bulk delete and recycle bin ---------- */
.select-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 0 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.select-bar .check { display: flex; gap: 6px; align-items: center; }
.select-bar .check input { width: auto; }
.select-bar .btn-danger { margin-left: auto; }
.table th.sel, .table td.sel { width: 28px; padding-right: 0; }
.table td.sel input { width: auto; }
.trash-card { border-color: var(--warn-line); background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface)); }
.trash-list { list-style: none; padding: 0; margin: 0; }
.trash-list li { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trash-list li:last-child { border-bottom: 0; }
.trash-list li form { margin-left: auto; }
.confirm-card { border-left: 4px solid var(--danger); }
/* Retiring a device: one ticked section per thing it is unplugged from. */
.retire-part { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 10px 14px; margin: 0 0 10px; }
.retire-part p { margin: 6px 0 0; }
.retire-list { margin: 6px 0 0 26px; padding: 0; columns: 2 260px; column-gap: 24px; }
.retire-list li { break-inside: avoid; }
.btn-retire { color: var(--warn-ink); border-color: var(--warn-line); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--orange); }
.retired-banner form { margin-left: 8px; }
.confirm-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 14px 0; background: var(--surface); }
.confirm-actions { margin-top: 8px; }

/* ---------- Topology ---------- */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg label { padding: 6px 12px; cursor: pointer; font: 600 .98rem var(--cond); display: flex; align-items: center; gap: 4px; color: var(--muted); }
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg label.on { background: var(--accent); color: var(--accent-ink); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.topo-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.topo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.topology { position: relative; background-color: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; }
.topo-svg { display: block; width: 100%; height: 70vh; min-height: 420px; cursor: grab; touch-action: none; user-select: none; }
.topo-svg.panning { cursor: grabbing; }
.topo-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.topo-help { margin-top: 8px; }
.topo-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 24px; color: var(--muted); }
.topo-legend span { display: inline-flex; align-items: center; gap: 6px; }
.topo-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 2px; }
.topo-line { stroke: #7f90a3; stroke-width: 2.2; }
.k-cable .topo-line { stroke: #4f7fd8; }
.k-power .topo-line { stroke: var(--orange); stroke-dasharray: 7 4; }
.topo-arrow { fill: var(--orange); }
.topo-hit { stroke: transparent; stroke-width: 14; }
.topo-edge:hover .topo-line { stroke: var(--accent); stroke-width: 3.2; }
.topo-edge-label { font: 600 10px var(--mono); fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
/* Off-screen box used while exporting a diagram (assets/svg-export.js): always the light colours. */
.svg-paper {
  position: fixed; left: -30000px; top: 0; visibility: hidden; pointer-events: none;
  --bg: #edf0f3; --surface: #ffffff; --raised: #f6f8fa; --text: #17202a; --muted: #5a6878; --line: #d6dde5; --line-strong: #b8c3cf;
  --accent: #2160d4; --accent-deep: #174ba8; --accent-soft: #e3ecfb; --orange: #e2731b; --green: #2e9a58; --brown: #86573a; --danger: #c62828;
}
.topo-arrange { min-width: 14.5em; justify-content: center; text-align: center; }
/* Room / type groups in the grouped layouts: brown is the "places" pair colour. Drag to move. */
.topo-group { cursor: grab; }
.topo-group.dragging { cursor: grabbing; }
.topo-group-box { fill: color-mix(in srgb, var(--brown) 6%, transparent); stroke: var(--brown); stroke-width: 1.5; stroke-dasharray: 7 5; stroke-opacity: .6; }
.topo-group:hover .topo-group-box, .topo-group.dragging .topo-group-box { stroke-opacity: 1; stroke-dasharray: none; fill: color-mix(in srgb, var(--brown) 10%, transparent); }
.topo-group-label { font: 700 16px var(--cond); fill: var(--brown); }
/* Simulate failure. One colour per kind of impact, used the same way on the diagram, the tiles,
   the key and the lists: red failed, orange no power, magenta cut off, amber at risk. */
:root { --sim-failed: #d32f2f; --sim-power: #e2731b; --sim-net: #b0368f; --sim-risk: #c99a12; }
@media (prefers-color-scheme: dark) { :root { --sim-failed: #f2645a; --sim-power: #f08a3a; --sim-net: #db5fb8; --sim-risk: #e2b83a; } }
.svg-paper { --sim-failed: #d32f2f; --sim-power: #e2731b; --sim-net: #b0368f; --sim-risk: #c99a12; }
.k-failed { --k: var(--sim-failed); } .k-power { --k: var(--sim-power); } .k-net { --k: var(--sim-net); } .k-risk { --k: var(--sim-risk); } .k-ok { --k: var(--line-strong); }

.sim-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 8px; padding: 8px 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--sim-failed); border-radius: var(--radius-sm); background: var(--surface); }
.sim-pick { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.sim-pick select { min-width: 260px; }

/* Headline above the diagram */
.sim-head { margin: 0 0 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-left: 5px solid var(--sim-failed); border-radius: var(--radius); }
.sim-headline { font-size: 1.12rem; line-height: 1.45; margin: 0 0 10px; max-width: none; }
.sim-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.sim-tile { display: flex; align-items: baseline; gap: 8px; padding: 8px 12px; min-width: 150px; text-decoration: none; color: var(--text);
  border: 1px solid var(--line); border-top: 4px solid var(--k); border-radius: var(--radius-sm); background: var(--raised); }
.sim-tile:hover { border-color: var(--k); color: var(--text); }
.sim-tile .sim-n { font: 700 1.7rem/1 var(--cond); color: var(--k); }
.sim-tile.zero { opacity: .55; }
.sim-tile.zero .sim-n { color: var(--muted); }
.sim-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; color: var(--muted); }
.sim-key span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--k); vertical-align: -1px; margin-right: 4px; }
.sw.k-risk { background: transparent; border: 2px dashed var(--k); }
.sw.k-ok { opacity: .5; }

/* The diagram while simulating: unaffected things fade right back */
.topo-svg.simulating .topo-node, .topo-svg.simulating .topo-edge, .topo-svg.simulating .topo-group { opacity: .18; transition: opacity .2s; }
.topo-svg.simulating .topo-node.sim-failed, .topo-svg.simulating .topo-node.sim-power, .topo-svg.simulating .topo-node.sim-net,
.topo-svg.simulating .topo-node.sim-risk, .topo-svg.simulating .topo-edge.sim-cut { opacity: 1; }
.sim-failed .topo-box { stroke: var(--sim-failed); stroke-width: 4; fill: color-mix(in srgb, var(--sim-failed) 18%, var(--surface)); }
.sim-power .topo-box { stroke: var(--sim-power); stroke-width: 3.5; fill: color-mix(in srgb, var(--sim-power) 16%, var(--surface)); }
.sim-net .topo-box { stroke: var(--sim-net); stroke-width: 3.5; fill: color-mix(in srgb, var(--sim-net) 14%, var(--surface)); }
.sim-risk .topo-box { stroke: var(--sim-risk); stroke-width: 3; stroke-dasharray: 6 3; }
.topo-edge.sim-cut .topo-line { stroke: var(--sim-failed); stroke-dasharray: 6 4; stroke-width: 2.4; }
.sim-tag-box { fill: var(--sim-failed); }
.sim-power .sim-tag-box { fill: var(--sim-power); }
.sim-net .sim-tag-box { fill: var(--sim-net); }
.sim-risk .sim-tag-box { fill: var(--sim-risk); }
.sim-tag-text { font: 700 13px var(--cond); fill: #fff; letter-spacing: .06em; }
.sim-risk .sim-tag-text { fill: #2a2000; }

/* Details below the diagram */
.sim-panel { border-left: 5px solid var(--sim-failed); }
.sim-panel h2 { margin-top: 2px; }
.sim-panel section { margin-top: 6px; }
.sim-panel h3 { display: flex; align-items: center; }
.sim-list { margin: 0; padding-left: 0; list-style: none; columns: 2 340px; column-gap: 28px; }
.sim-list li { margin: 0 0 8px; break-inside: avoid; }
.sim-why { font-size: .86rem; color: var(--muted); }
.sim-rooms td { vertical-align: top; }
.sim-chip { display: inline-block; margin: 1px 2px 3px 0; padding: 0 6px; border-radius: 3px; font: 600 .78rem var(--mono); text-decoration: none;
  color: #fff; background: var(--k); }
.sim-chip.sim-failed { --k: var(--sim-failed); } .sim-chip.sim-power { --k: var(--sim-power); } .sim-chip.sim-net { --k: var(--sim-net); }
.sim-chip.sim-risk { background: transparent; color: var(--text); border: 1px dashed var(--sim-risk); }
.sim-chip:hover { color: #fff; filter: brightness(1.1); }
.sim-chip.sim-risk:hover { color: var(--text); }
.topo-node { cursor: pointer; }
.topo-node:focus { outline: none; }
.topo-node:focus .topo-box, .topo-node:hover .topo-box { stroke: var(--accent); stroke-width: 2.5; }
.topo-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.topo-name { font: 600 12.5px var(--mono); fill: var(--text); }
.topo-sub { font: 10px var(--mono); fill: var(--muted); }
.topo-glyph { font: 700 11px var(--cond); fill: #fff; letter-spacing: .02em; }
.s-retired .topo-box, .s-spare .topo-box { stroke-dasharray: 4 3; opacity: .7; }
.t-firewall .topo-badge, .topo-swatch.t-firewall { fill: #c62828; background: #c62828; }
.t-router .topo-badge, .t-vpn .topo-badge, .topo-swatch.t-router { fill: #6d44c9; background: #6d44c9; }
.t-switch .topo-badge, .topo-swatch.t-switch { fill: #2160d4; background: #2160d4; }
.t-load_balancer .topo-badge { fill: #8a3fc2; }
.t-server .topo-badge, .t-storage .topo-badge, .topo-swatch.t-server { fill: #0e7c86; background: #0e7c86; }
.t-vm .topo-badge { fill: #3f9aa3; }
.t-desktop_windows .topo-badge, .t-desktop_linux .topo-badge, .t-mac .topo-badge, .t-printer .topo-badge { fill: #4a5f8a; }
.t-cctv_camera .topo-badge { fill: #3d6b8c; }
.t-access_control .topo-badge { fill: #7a5c2e; }
.t-web_filter .topo-badge { fill: #a3322b; }
.t-access_point .topo-badge, .t-wlc .topo-badge, .topo-swatch.t-access_point { fill: #2e9a58; background: #2e9a58; }
.t-ups .topo-badge, .topo-swatch.t-ups { fill: #e2731b; background: #e2731b; }
.t-pdu .topo-badge, .topo-swatch.t-pdu { fill: #86573a; background: #86573a; }
.t-other .topo-badge, .t-patch_panel .topo-badge, .topo-swatch.t-other { fill: #5f6f80; background: #5f6f80; }

/* ---------- Drawings (hand-drawn diagrams) ---------- */
.dg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.dg-toolbar .check { display: inline-flex; gap: 6px; align-items: center; margin-left: 4px; }
.dg-spacer { flex: 1; }
.dg-body { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.dg.read-only .dg-body { grid-template-columns: minmax(0, 1fr); }
.dg-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 14px;
  max-height: calc(72vh + 2px); overflow-y: auto; }
.dg-side h3 { font-size: 1.1rem; margin: 0 0 6px; }
.dg-search { padding: 6px 9px; margin-bottom: 6px; }
.dg-devices { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dg-devices li { display: flex; gap: 8px; align-items: center; padding: 5px 8px; cursor: grab; border-bottom: 1px solid var(--line); }
.dg-devices li:last-child { border-bottom: 0; }
.dg-devices li:hover, .dg-devices li:focus { background: var(--accent-soft); outline: none; }
.dg-devices li.placed { opacity: .45; }
.dg-devices li span { display: flex; flex-direction: column; min-width: 0; }
.dg-devices li strong { font: 600 .86rem var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-devices li small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-devices li.more { cursor: default; }
.dg-mini { width: 26px; height: 26px; flex: none; }
.dg-shapes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.dg-shape span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-side { overflow-x: hidden; }
.dg-shape { display: flex; gap: 6px; align-items: center; padding: 4px 6px; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font: 500 .8rem var(--sans); color: var(--text); cursor: grab; text-align: left; }
.dg-shape:hover { border-color: var(--accent); }
.dg-shape .dg-mini { width: 22px; height: 22px; }
.dg-extras { display: flex; gap: 6px; margin-top: 8px; }
.dg-inspector { border-top: 2px solid var(--accent); padding-top: 10px; }
.dg-inspector .form { gap: 10px; }
.dg-inspector p { margin: 0; }
.dg-canvas { position: relative; }
.dg-svg { display: block; width: 100%; height: 72vh; min-height: 460px; background-color: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); background-image: radial-gradient(var(--line) 1.2px, transparent 1.2px); background-size: 20px 20px;
  touch-action: none; user-select: none; cursor: default; }
.dg-svg.panning { cursor: grabbing; }
.dg-svg.connecting .dg-node { cursor: crosshair; }
.dg-hint { min-height: 1.4em; margin: 6px 2px 0; }
.dg-help { margin-top: 8px; }
/* icon colours: one variable per kind */
.dg-k-firewall { --k: #c62828; } .dg-k-router, .dg-k-vpn { --k: #6d44c9; } .dg-k-switch { --k: #2160d4; }
.dg-k-access_point { --k: #2e9a58; } .dg-k-lb { --k: #8a3fc2; } .dg-k-server, .dg-k-storage { --k: #0e7c86; } .dg-k-vm { --k: #3f9aa3; }
.dg-k-ups { --k: #e2731b; } .dg-k-pdu { --k: #86573a; } .dg-k-patch_panel, .dg-k-other { --k: #5f6f80; }
.dg-k-desktop, .dg-k-mac, .dg-k-phone, .dg-k-printer { --k: #4a5f8a; } .dg-k-camera { --k: #3d6b8c; } .dg-k-acu { --k: #7a5c2e; } .dg-k-cloud, .dg-k-isp { --k: #7f90a3; }
.dg-bg { fill: var(--k, #5f6f80); }
.dg-glyph { fill: none; stroke: #fff; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.dg-glyph .dg-fill { fill: #fff; stroke: none; }
.dg-glyph .dg-solid { fill: var(--k, #5f6f80); }
.dg-node { cursor: move; }
.dg.read-only .dg-node { cursor: pointer; }
.dg-halo { fill: none; stroke: transparent; stroke-width: 2.5; }
.dg-node:hover .dg-halo { stroke: var(--line-strong); }
.dg-node.sel .dg-halo { stroke: var(--accent); stroke-dasharray: 5 4; }
.dg-node.dg-from .dg-halo { stroke: var(--orange); stroke-width: 3.5; stroke-dasharray: none; }
.dg-node:focus { outline: none; }
.dg-missing { opacity: .45; }
.dg-name { font: 600 12px var(--mono); fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.dg-sub { font: 10px var(--mono); fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.dg-line { stroke: #4f7fd8; stroke-width: 2.6; stroke-linecap: round; }
.dg-l-fibre .dg-line { stroke: var(--orange); }
.dg-l-wireless .dg-line { stroke: var(--green); stroke-dasharray: 7 6; }
.dg-l-vpn .dg-line { stroke: #6d44c9; stroke-dasharray: 2 6; stroke-width: 3; }
.dg-hit { stroke: transparent; stroke-width: 14; cursor: pointer; }
.dg-link.sel .dg-line, .dg-link:hover .dg-line { stroke-width: 4; filter: drop-shadow(0 0 2px rgba(33, 96, 212, .45)); }
.dg-link-label { font: 600 10.5px var(--mono); fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; pointer-events: none; }
.dg-c-blue { --a: #2160d4; } .dg-c-green { --a: #2e9a58; } .dg-c-orange { --a: #e2731b; } .dg-c-brown { --a: #86573a; }
.dg-c-grey { --a: #6b7a8b; } .dg-c-red { --a: #c62828; }
.dg-area-box { fill: color-mix(in srgb, var(--a) 7%, transparent); stroke: var(--a); stroke-width: 1.6; stroke-dasharray: 8 5; cursor: move; }
.dg-area.sel .dg-area-box { stroke-width: 2.6; }
.dg-area-label { font: 700 15px var(--cond); fill: var(--a); pointer-events: none; }
.dg-resize { fill: var(--accent); cursor: nwse-resize; }
.dg-resize-hit { fill: transparent; cursor: nwse-resize; }
.dg-text { cursor: move; }
.dg-note { fill: var(--text); font-family: var(--sans); }
.dg-s-s { font-size: 12px; } .dg-s-m { font-size: 15px; } .dg-s-l { font: 700 22px var(--cond); }
.dg-text.sel .dg-note { fill: var(--accent); }
.row-menu { display: inline-block; text-align: left; }
.row-menu[open] { display: block; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
@media (max-width: 900px) { .dg-body { grid-template-columns: 1fr; } .dg-side { max-height: none; } }
@media print { .dg-svg { height: auto; aspect-ratio: 16 / 10; border: 0; background-image: none; } }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.18fr); gap: 44px; align-items: center; padding: 34px 0 30px; }
.hero h1 { font-size: 3.3rem; line-height: 1; margin: 0 0 16px; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 52ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-actions .btn { padding: 11px 20px; font-size: 1rem; }

/* The hero patch panel: two rows of 12 jacks, some patched with leads in the pair colours. */
.panel-1u { margin: 0; background: linear-gradient(#2a3542, #1a232d); border: 1px solid #0b1016; border-radius: 3px; padding: 16px 22px 14px;
  box-shadow: 0 18px 40px -22px rgba(9, 15, 22, .55), inset 0 1px 0 rgba(255, 255, 255, .07); position: relative; }
.panel-1u::before, .panel-1u::after { content: ""; position: absolute; top: 50%; width: 9px; height: 18px; margin-top: -9px;
  border-radius: 5px; background: #0b1016; box-shadow: inset 0 1px 1px rgba(255, 255, 255, .08); }
.panel-1u::before { left: 6px; } .panel-1u::after { right: 6px; }
@media (prefers-color-scheme: dark) {
  .panel-1u { border-color: #3a4a5b; box-shadow: 0 0 0 1px #0b1016, 0 24px 50px -24px #000, inset 0 1px 0 rgba(255, 255, 255, .09); }
}
.panel-rows { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 8px; }
.jack { position: relative; aspect-ratio: 1 / 1; background: #070b10;
  clip-path: polygon(0 0, 100% 0, 100% 80%, 70% 80%, 70% 100%, 30% 100%, 30% 80%, 0 80%); }
.jack-num { font: 700 .62rem var(--mono); color: #7a8a9b; text-align: center; margin-top: 3px; }
.jack.lead::after { content: ""; position: absolute; inset: 14% 18% 30%; border-radius: 1px; background: currentColor;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .25); }
.lead-blue { color: #2f6fe0; } .lead-green { color: #2e9a58; } .lead-orange { color: #e2731b; } .lead-brown { color: #9b6744; }
.lead-grey { color: #c9d1da; } .lead-yellow { color: #e8c33a; }
.panel-label { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: #91a2b4; font-size: .82rem; }
.panel-label .tag { font-size: .78rem; padding: 1px 7px; }
.led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3fd37a; margin-right: 6px; vertical-align: 1px;
  box-shadow: 0 0 6px #3fd37a; }
@media (prefers-reduced-motion: no-preference) {
  .led.blink { animation: link-activity 1.1s steps(2, jump-none) infinite; }
  @keyframes link-activity { 50% { opacity: .25; box-shadow: none; } }
}
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 0 6px; margin-right: 8px; vertical-align: 2px; }

/* Datasheet of what Wirebook records */
.spec { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); margin: 8px 0 30px; overflow: hidden; }
.spec > div { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.spec > div:nth-child(odd) { border-right: 1px solid var(--line); }
.spec > div:nth-last-child(-n+2) { border-bottom: 0; }
.spec h3 { margin: 0 0 4px; font-size: 1.3rem; }
.spec p { margin: 0; color: var(--muted); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 20px 0 28px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.feature h3 { margin-top: 0; }
.feature p { margin: 0; color: var(--muted); }
.note { border-left: 4px solid var(--green); background: var(--surface); padding: 14px 20px; max-width: 760px; border-radius: 0 var(--radius) var(--radius) 0; }
.note h2 { margin-bottom: 4px; }
.note p { margin: 0; color: var(--muted); }

/* ---------- Footer ---------- */
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .88rem;
  padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--line-strong); }

/* ---------- Print: room sheets, power trees, diagrams ---------- */
@media print {
  .topbar, .footer, .no-print, .flash { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card { border: 1px solid #999; break-inside: avoid; padding: 10px; }
  a { color: #000; text-decoration: none; }
  .main { padding: 0; }
  .topo-svg { height: auto; min-height: 0; aspect-ratio: 16 / 10; }
  .topology { border: 0; background-image: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 2.4rem; }
  .spec { grid-template-columns: 1fr; }
  .spec > div:nth-child(odd) { border-right: 0; }
  .spec > div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .panel-1u { padding: 12px 16px 10px; }
  .panel-rows { gap: 7px 4px; }
  .form-row, .form-row:has(> label + label) { grid-template-columns: 1fr; }
  .who { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .page-head { flex-direction: column; }
  .form-grid-4, .kv-form, .range-form { grid-template-columns: 1fr; }
  .filters-right { margin-left: 0; }
  .topnav { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Floor plans ---------- */
:root { --fp-cable: #2f6fe0; --fp-fibre: #0e9aa7; --fp-cabling: #86573a; --fp-power: #e2731b; --fp-recorded: #7a4bd0; }
@media (prefers-color-scheme: dark) { :root { --fp-cable: #6b9ef5; --fp-fibre: #33c3cf; --fp-cabling: #c08a64; --fp-power: #f08a3a; --fp-recorded: #a98bf0; } }
.fp-filters { margin-bottom: 8px; }
.fp-site { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.fp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 8px; }
.fp-floor-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.fp-tab { font: 600 .86rem var(--sans); padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.fp-tab:hover { border-color: var(--accent); }
.fp-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fp-spacer { flex: 1; }
.fp-3d-controls { display: inline-flex; align-items: center; gap: 10px; }
.fp-3d-controls input[type="range"] { vertical-align: middle; width: 130px; }
.fp-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; color: var(--muted); }
.fp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fpk { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--k); }
.fpk-cable { --k: var(--fp-cable); } .fpk-fibre { --k: var(--fp-fibre); } .fpk-cabling { --k: var(--fp-cabling); }
.fpk-power { --k: var(--fp-power); background: repeating-linear-gradient(90deg, var(--k) 0 5px, transparent 5px 8px); }
.fpk-recorded { --k: var(--fp-recorded); }
.fpk-riser { --k: var(--text); width: 14px; height: 14px; border-radius: 7px; background: var(--rack); border: 2px solid var(--accent); }

.fp-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
@media (max-width: 960px) { .fp-body { grid-template-columns: 1fr; } }
.fp-view { position: relative; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); min-height: 360px; overflow: hidden; }
.fp-2d { padding: 10px; }
.fp-loading { padding: 20px; }
.fp-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; position: sticky; top: 10px;
  max-height: calc(100vh - 40px); overflow-y: auto; }
.fp-side h4 { margin: 12px 0 6px; }
.fp-empty { text-align: left; }

/* One floor: the image with the rooms and lines drawn over it in the same 1000-unit space */
.fp-plane { position: relative; line-height: 0; user-select: none; }
.fp-plane img { width: 100%; height: auto; display: block; border-radius: 3px; background: #fff; }
.fp-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fp-svg.editing { cursor: crosshair; }
.fp-room-box { fill: color-mix(in srgb, var(--brown) 14%, transparent); stroke: var(--brown); stroke-width: 2.5; }
.fp-room { cursor: pointer; }
.fp-room:hover .fp-room-box, .fp-room.sel .fp-room-box { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 3.5; }
.fp-room:focus { outline: none; }
.fp-room:focus .fp-room-box { stroke: var(--accent); stroke-width: 3.5; }
.fp-room-name { font-family: var(--cond); font-weight: 700; fill: #2a1a0f; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 4px; }
.fp-room-sub { font-family: var(--sans); fill: #4b3a2e; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 3px; }
.editing .fp-room { cursor: move; }
.fp-handle { fill: var(--accent); stroke: #fff; stroke-width: 2; cursor: nwse-resize; }
.fp-riser-box { fill: var(--rack); stroke: var(--accent); stroke-width: 2; }
.fp-riser-text { font: 700 12px var(--cond); fill: #fff; }
.fpl-line { stroke: var(--k); stroke-width: 4; stroke-linecap: round; }
.fpl-hit { stroke: transparent; stroke-width: 16; }
.fpl-dot { fill: var(--k); stroke: #fff; stroke-width: 2; }
.fpl-n { font: 700 11px var(--cond); fill: #fff; pointer-events: none; }
.fpl-cable { --k: var(--fp-cable); } .fpl-fibre { --k: var(--fp-fibre); } .fpl-cabling { --k: var(--fp-cabling); }
.fpl-power { --k: var(--fp-power); } .fpl-power .fpl-line { stroke-dasharray: 10 7; }
.fpl-recorded { --k: var(--fp-recorded); } .fpl-recorded .fpl-line { stroke-width: 6; }
/* Focus on one room: everything else steps back */
.focusing .fp-room:not(.near), .focusing .fpl:not(.on), .focusing .fp3d-riser:not(.on) { opacity: .22; transition: opacity .15s; }
.focusing .fpl.on .fpl-line { stroke-width: 6; }

/* Edit panel */
.fp-room-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.fp-pick { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--raised); color: var(--text); font: 500 .9rem var(--sans); cursor: pointer; }
.fp-pick:hover { border-color: var(--accent); }
.fp-pick.armed { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, var(--surface)); }
.fp-pick.sel { border-color: var(--accent); background: var(--accent-soft); }
.fp-st { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.fp-st.here { color: var(--green); font-weight: 600; }
.fp-st.none { color: var(--warn-ink); }
.fp-selected { padding: 6px 8px; background: var(--accent-soft); border-radius: var(--radius-sm); }
.fp-conn { list-style: none; margin: 0; padding: 0; }
.fp-conn > li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.fp-conn details ul { margin: 4px 0 0 18px; padding: 0; }
.fp-totals { list-style: none; padding: 0; margin: 6px 0; }

/* 3D: the floors stacked in perspective; drag to turn */
.fp-3d { height: calc(100vh - 250px); min-height: 520px; background: radial-gradient(ellipse at 50% 40%, #223144, #0d141c 70%); }
.fp3d-stage { position: absolute; inset: 0; perspective: 2400px; perspective-origin: 50% 35%; cursor: grab; touch-action: none; }
.fp3d-stage.turning { cursor: grabbing; }
.fp3d-scene { position: absolute; left: 50%; top: 42%; width: 0; height: 0; transform-style: preserve-3d; transition: transform .05s linear; }
.fp3d-floor { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transition: opacity .2s; }
.fp3d-floor .fp-plane { box-shadow: 0 0 0 2px rgba(91, 143, 240, .6), 0 18px 40px rgba(0, 0, 0, .35); border-radius: 4px; }
/* The plan is see-through so floors below and the risers show; rooms and lines stay solid. */
.fp3d-floor .fp-plane img { opacity: .62; filter: saturate(.8); }
.fp3d-floor .fp-room-box { fill: color-mix(in srgb, var(--brown) 30%, transparent); stroke-width: 4; }
.fp3d-floor.dim { opacity: .1; pointer-events: none; }
.fp3d-floor.solo .fp-plane { opacity: 1; box-shadow: 0 0 0 3px var(--accent), 0 18px 40px rgba(0, 0, 0, .5); }
.fp3d-label { position: absolute; left: 0; top: -14px; transform: translate(0, -100%); font: 700 30px var(--cond); color: #fff;
  background: var(--rack); border: 2px solid var(--accent); border-radius: 6px; padding: 4px 14px; cursor: pointer; white-space: nowrap; }
.fp3d-label:hover { background: var(--accent); }
.fp3d-riser { position: absolute; left: 0; top: 0; height: 10px; margin-top: -5px; transform-origin: 0 50%; background: var(--k);
  box-shadow: 0 0 14px var(--k), 0 0 3px #fff; border-radius: 5px; }
.fp-floor-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fp-floor-form input[name="name"] { width: 220px; }
.fp-level { width: 70px; }
/* Buildings */
.fp-building-tabs { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.fp-btab { font: 700 .9rem var(--cond); letter-spacing: .02em; padding: 6px 14px; border: 0; border-right: 1px solid var(--line-strong);
  background: var(--raised); color: var(--text); cursor: pointer; }
.fp-btab:last-child { border-right: 0; }
.fp-btab:hover { background: var(--accent-soft); }
.fp-btab[aria-selected="true"] { background: var(--rack); color: #fff; }
.fp-across .fp-riser-box { fill: var(--brown); stroke: #fff; }
.fp-current td { background: var(--accent-soft); }
a.fp-on { font-weight: 700; text-decoration: none; color: var(--text); }
.fp-all { margin-right: 4px; }
/* Site layout: buildings from above */
.fp-sitemap { height: calc(100vh - 250px); min-height: 520px; background: var(--raised); }
.fp-site-svg { width: 100%; height: 100%; display: block; touch-action: none; }
.fp-site-gridline { fill: none; stroke: var(--line); stroke-width: 3; }
.fp-bld-img { opacity: .85; }
.fp-bld-empty { fill: var(--surface); }
.fp-bld-box { fill: none; stroke: var(--brown); stroke-width: 10; }
.fp-bld.main .fp-bld-box { stroke: var(--rack); stroke-width: 14; }
.fp-bld.movable { cursor: grab; }
.fp-bld.movable:hover .fp-bld-box, .fp-bld.dragging .fp-bld-box { stroke: var(--accent); stroke-width: 14; }
.fp-bld.dragging { cursor: grabbing; }
.fp-bld-tag { fill: var(--rack); }
.fp-bld.movable .fp-bld-tag { fill: var(--brown); }
.fp-bld-name { font: 700 42px var(--cond); fill: #fff; }
.fp-bld-off { font: 600 34px var(--sans); fill: var(--muted); }
.fp-site-line { stroke-width: 14; }
.fp-site-n { font-size: 34px; }
.fp-site-controls { display: inline-flex; align-items: center; gap: 10px; }
.fp-bld-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.fp-bld-grip { fill: var(--accent); stroke: #fff; stroke-width: 6; cursor: nwse-resize; opacity: .75; }
.fp-bld-grip:hover, .fp-bld.resizing .fp-bld-grip { opacity: 1; }
.fp-bld.resizing .fp-bld-box { stroke: var(--accent); stroke-width: 14; }

/* Members: which sites each member may see */
.member-sites { min-width: 180px; }
.member-sites-edit summary { cursor: pointer; color: var(--accent); }
.member-sites-edit .form { margin-top: 8px; gap: 6px; }
.member-sites-edit .check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.member-sites-edit .check input { width: auto; }
.member-site-list { display: grid; gap: 4px; padding-left: 22px; max-height: 260px; overflow: auto; }

/* Super admin */
.admin-orgs td, .admin-users td { vertical-align: top; }
.admin-orgs .pill, .admin-users .pill { margin: 0 4px 4px 0; display: inline-block; }
.fp-bld-turn { fill: var(--accent); stroke: #fff; stroke-width: 6; cursor: grab; opacity: .75; }
.fp-bld-turn-stem { stroke: var(--accent); stroke-width: 6; opacity: .6; }
.fp-bld-turn:hover, .fp-bld.turning .fp-bld-turn { opacity: 1; }
.fp-bld.turning .fp-bld-turn { cursor: grabbing; }
.fp-bld.turning .fp-bld-box { stroke: var(--accent); stroke-width: 14; }
.admin-delete { display: inline-block; margin-left: 8px; vertical-align: middle; }
.admin-delete summary { cursor: pointer; list-style: none; display: inline; }
.admin-delete summary::-webkit-details-marker { display: none; }
.admin-delete[open] { display: block; margin: 8px 0 0 auto; width: 300px; white-space: normal; text-align: left; }
.admin-delete[open] input { width: 100%; }
.admin-delete .form { margin-top: 6px; gap: 6px; }

/* Phone numbers */
.table-wrap { overflow-x: auto; }
.phone-delete summary { cursor: pointer; list-style: none; display: inline; }
.phone-delete summary::-webkit-details-marker { display: none; }
.phone-delete .form { margin-top: 10px; gap: 8px; max-width: 420px; }
.phone-delete input { width: 100%; }

/* Room types: the card's top edge takes the type's pair colour */
.room-kind { margin-bottom: 6px; background: transparent; border: 1px solid currentColor; }
.room-kind-classroom { color: color-mix(in srgb, var(--green) 80%, var(--text)); }
.room-kind-office { color: color-mix(in srgb, var(--brown) 85%, var(--text)); }
.room-kind-switching { color: color-mix(in srgb, var(--orange) 85%, var(--text)); }
.room-kind-other { color: var(--muted); }
.room-card:has(.room-kind-classroom) { border-top-color: var(--green); }
.room-card:has(.room-kind-switching) { border-top-color: var(--orange); }
.room-card:has(.room-kind-other) { border-top-color: var(--line-strong); }
#outlets h4 { margin: 18px 0 6px; }

/* Bulk room edit */
.bulk-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.bulk-actions label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.bulk-actions .btn-danger { margin-right: 0; }
.bulk-count { width: 5em; }
.bulk-table input:not([type=checkbox]), .bulk-table select { width: 100%; min-width: 9em; }
.bulk-table td { vertical-align: top; }
.row-error td { background: color-mix(in srgb, var(--err-bg) 60%, transparent); }
.field-error { display: block; color: var(--danger); margin-top: 3px; }
.page-head.tight { margin: 0 0 4px; align-items: center; }

/* Site picker in the organisation header: which site every page is showing */
.site-picker { margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.site-picker label { font: 600 .95rem/1 var(--cond); color: var(--text); }
.site-picker select { border: 0; border-radius: 4px; background-color: #000; color: #fff; color-scheme: dark;
  font-weight: 700; padding: 6px 10px; max-width: 280px; cursor: pointer; }
.site-picker select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-picker select option { background: #000; color: #fff; }
.site-picker.is-chosen { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.site-picker.is-chosen label { color: var(--accent-deep); }
@media (max-width: 640px) { .site-picker { margin-left: 0; width: 100%; } .site-picker select { flex: 1; max-width: none; } }

/* Circuits on a site page: one block per line, the circuit ID and fault line first */
.circuit { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 12px 14px; margin: 0 0 12px; }
.circuit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.circuit-head h3 { margin: 0; }
.circuit .facts { background: transparent; padding: 0; border: 0; margin-bottom: 0; }
.circuit .support .tel { font-weight: 700; font-size: 1.05rem; }
.circuit-notes { margin: 10px 0 0; }
#add-circuit, #add-supplier { margin-top: 12px; }
#add-circuit[open] > summary, #add-supplier[open] > summary { margin-bottom: 12px; }

/* History on each record: a timeline of who changed what */
.history { list-style: none; margin: 0; padding: 0; }
.history > li { border-left: 3px solid var(--line-strong); padding: 6px 0 10px 14px; margin-left: 4px; position: relative; }
.history > li::before { content: ""; position: absolute; left: -6px; top: 12px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); }
.history-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.history-head time { color: var(--muted); min-width: 9.5em; }
.history-other { font-weight: 600; }
.history-changes { list-style: none; margin: 4px 0 0; padding: 0; font-size: .92rem; }
.history-changes li { margin: 2px 0; }
.history-field { display: inline-block; min-width: 9em; color: var(--muted); }
.history-changes del { color: var(--danger); text-decoration: line-through; }
.history-changes ins { color: var(--text); text-decoration: none; font-weight: 600; }

/* Quick actions: a small menu in the organisation header */
.quick-actions { position: relative; }
.quick-actions > summary { list-style: none; }
.quick-actions > summary::-webkit-details-marker { display: none; }
.quick-actions > summary::after { content: ""; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin: 4px 0 0 2px; }
.quick-actions[open] > summary { margin-bottom: 0; background: var(--accent-soft); }
.quick-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 250px; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.quick-menu a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); }
.quick-menu a:hover, .quick-menu a:focus-visible { background: var(--accent-soft); color: var(--accent-deep); }
.quick-menu small { display: block; color: var(--muted); }

/* Map a cable route: the steps hang off one cable, drawn as an orange-white pair */
.route-site { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.route-site label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.route { list-style: none; margin: 0 0 6px; padding: 0 0 0 30px; position: relative; counter-reset: rstep; }
.route::before { content: ""; position: absolute; left: 11px; top: 18px; bottom: 30px; width: 4px; border-radius: 2px;
  background: repeating-linear-gradient(var(--orange) 0 12px, var(--tape) 12px 18px); }
.route-step { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 16px; margin-bottom: 12px; counter-increment: rstep; }
.route-step::before { content: counter(rstep); position: absolute; left: -31px; top: 14px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font: 700 .9rem/1 var(--cond); background: var(--rack); color: #fff; border: 2px solid var(--orange); }
.route-step h3 { margin: 0 0 2px; }
.route-step > p { margin: 0 0 10px; }
.route-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.route-fields label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.route-fields .js-rt-new { font-weight: 500; color: var(--muted); }
.route-more { margin: 0 0 18px 30px; }
.route-trace { list-style: none; margin: 4px 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 0; align-items: center; font: 600 1.05rem var(--cond); }
.route-trace li { background: var(--tape); color: var(--tape-ink); border: 1px solid var(--tape-edge); border-radius: 2px; padding: 2px 8px; font-family: var(--mono); font-size: .85rem; }
.route-trace li + li { margin-left: 28px; position: relative; }
.route-trace li + li::before { content: ""; position: absolute; left: -25px; top: 50%; width: 22px; height: 3px; margin-top: -1.5px;
  background: repeating-linear-gradient(90deg, var(--orange) 0 6px, var(--tape) 6px 9px); }
.route-changes { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.route-changes li { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.route-changes li:last-child { border-bottom: 0; }
.rc-tag { display: inline-block; min-width: 4.6em; font: 600 .78rem/1.5 var(--sans); text-align: center; border-radius: 3px; padding: 0 6px; margin-right: 6px; }
.rc-new .rc-tag { background: var(--ok-bg); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.rc-warn { background: var(--warn-bg); }
.rc-warn .rc-tag { background: var(--warn-line); color: var(--warn-ink); }
.rc-same { color: var(--muted); }
.rc-same .rc-tag { background: var(--line); color: var(--muted); }
.confirm-card:has(.route-trace) { border-left-color: var(--orange); }

/* ---------- Phones ----------
   One column, tighter cards, 16px inputs (so iOS does not zoom in), bigger tap targets, and tables
   as a stack of labelled cards (app.js adds the labels and the .stacked class). */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .main { padding-top: 14px; padding-bottom: 28px; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
  h2.big { font-size: 1.55rem; }
  h2.mono.big { font-size: 1.2rem; }
  .card { padding: 14px; margin-bottom: 14px; }
  .card .card { padding: 12px; }
  fieldset { padding: 10px 12px 12px; }
  .facts { padding: 12px 14px; gap: 10px 16px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  /* Top bar */
  .topbar-inner { height: 50px; }
  .brand { font-size: 1.2rem; gap: 8px; }
  .topnav { gap: 14px; font-size: .92rem; }
  .who { display: none; }

  /* Organisation header: name, then site and search side by side as far as they fit */
  .org-head { gap: 8px; margin-bottom: 4px; }
  .org-head > div:first-child { width: 100%; }
  .org-head .eyebrow { display: none; }
  .org-head h1 { font-size: 1.5rem; margin: 0; }
  .site-picker { padding: 3px 3px 3px 8px; }
  .site-picker select { padding: 8px 10px; }
  .tabs { margin: 0 -16px 16px; padding: 0 12px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a, .tabs span { padding: 10px 10px 9px; font-size: 1rem; }
  .subnav { margin: -6px 0 14px; }
  .subnav nav { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .subnav nav::-webkit-scrollbar { display: none; }
  .subnav nav a { white-space: nowrap; padding: 6px 10px; }

  /* Page headings and their buttons */
  .page-head { flex-wrap: wrap; }
  .page-head > :first-child { min-width: 0; flex: 1 1 100%; }
  .head-actions { width: 100%; }
  .toolbar, .toolbar-right { align-items: stretch; }
  .toolbar > *, .toolbar-right > * { max-width: 100%; }

  /* Forms: one column, inputs big enough to type in without zooming */
  input, select, textarea { font-size: 16px; padding: 9px 10px; }
  .btn { padding: 10px 16px; }
  .btn-small { padding: 7px 12px; font-size: .9rem; }
  .form-grid, .form-grid-4, .kv-form, .form-row, .form-row:has(> label + label) { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .check-row { align-self: start; padding-bottom: 0; }
  .form-actions { flex-wrap: wrap; }
  .narrow-input { width: 100% !important; }
  .filters input[name=q], .search input, .search, .search-big input { width: 100%; }
  .filters > *, .filters select { flex: 1 1 140px; }
  .filters-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .inline-form, .inline-form label { width: 100%; }
  .inline-form select { flex: 1; }
  .search-big { flex-wrap: wrap; }

  /* Tables become cards */
  .card:has(> .table.stacked), .card:has(> .table-wrap > .table.stacked) { padding: 10px; }
  .table.stacked, .table.stacked tbody, .table.stacked tr, .table.stacked td { display: block; width: 100%; }
  .table.stacked thead { display: none; }
  .table.stacked tr { position: relative; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 8px 12px 10px; margin-bottom: 8px; }
  .table.stacked tbody tr:last-child { margin-bottom: 0; }
  .table.stacked tbody tr:hover td { background: transparent; }
  .table.stacked td { border: 0; padding: 3px 0; text-align: left; white-space: normal; }
  .table.stacked td[data-label] { position: relative; padding-left: calc(min(36%, 9em) + 10px); min-height: 1.9em; }
  .table.stacked td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: min(36%, 9em);
    font: 600 .9rem/1.35 var(--cond); color: var(--muted); }
  .table.stacked td.cell-title { font-size: 1.05rem; font-weight: 600; padding: 2px 34px 4px 0; }
  .table.stacked td.cell-title .small { font-weight: 400; }
  .table.stacked td.cell-blank { display: none; }
  .table.stacked td.cell-pick { position: absolute; top: 6px; right: 8px; width: auto; padding: 4px; }
  .table.stacked td.cell-pick input { width: 20px; height: 20px; }
  .table.stacked td.cell-full { text-align: left; }
  .table.stacked td.actions { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
  .table.stacked td.actions::before { display: none; }
  .table.stacked td.actions a, .table.stacked td.actions .link { font-size: .95rem; padding: 2px 0; }
  .table.stacked.tree td:not([data-label]) { padding-left: 0; }
  .table.stacked .row-muted { opacity: .8; }
  .table.stacked .row-error { border-color: var(--err-line); background: color-mix(in srgb, var(--err-bg) 60%, var(--raised)); }
  .table.stacked .row-error td { background: transparent; }
  .table.stacked td select { width: 100%; }
  .bulk-table.stacked input:not([type=checkbox]), .bulk-table.stacked select { min-width: 0; }
  .table:not(.stacked) td, .table:not(.stacked) th { padding-left: 6px; padding-right: 6px; }

  select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
  .filters select, .filters .btn { min-width: 0; }
  .bulk-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
  .bulk-actions .bulk-count { width: 100%; }

  .sim-pick { flex-wrap: wrap; white-space: normal; width: 100%; }
  .sim-pick select { min-width: 0; flex: 1 1 200px; }

  .seg, .filters > .seg { display: flex; width: 100%; flex-basis: 100%; }
  .seg label { flex: 1 1 0; justify-content: center; text-align: center; padding: 8px 6px; line-height: 1.15; }
  .topo-actions { display: flex; flex-wrap: wrap; gap: 6px; }

  .quick-actions { width: 100%; }
  .quick-actions > summary { width: 100%; justify-content: center; }
  .quick-menu { left: 0; right: 0; min-width: 0; }
  .route { padding-left: 28px; }
  .route-step { padding: 12px 14px 14px; }
  .route-site { flex-wrap: wrap; }
  .route-site label { flex: 1 1 100%; }

  /* Odds and ends */
  .stat { padding: 12px 14px; }
  .stat-num { font-size: 1.9rem; }
  .grid:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .history-head time { min-width: 0; }
  .history-field { min-width: 0; margin-right: 6px; }
  .circuit-head { flex-wrap: wrap; }
  .footer { flex-direction: column; gap: 4px; }
}

/* Agents: the one-time token box */
.agent-token { border-color: var(--warn-line); background: var(--warn-bg); }
.agent-token label { display: block; max-width: 640px; }
.agent-token-value { width: 100%; font-size: 1rem; }

/* Agents: reviewing what an agent saw */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.review-stats { margin-top: 12px; }
.review-device h3 { margin-bottom: 2px; }
.review-items { list-style: none; margin: 12px 0 8px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.review-items > li { border-bottom: 1px solid var(--line); }
.review-items > li:last-child { border-bottom: 0; }
.review-item { display: flex !important; flex-direction: row; gap: 10px; align-items: baseline; padding: 9px 12px; font-weight: 400 !important; cursor: pointer; }
.review-item input { width: auto; flex: none; transform: translateY(2px); }
.review-item:hover { background: var(--raised); }
.review-what { min-width: 0; overflow-wrap: anywhere; }
.review-tag { flex: none; min-width: 4.8em; text-align: center; font: 600 .8rem/1.5 var(--cond); border-radius: 3px; padding: 0 6px; }
.review-tag-add { background: var(--ok-bg); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.review-tag-fill { background: var(--info-bg); color: var(--accent-deep); }
.review-tag-change { background: var(--warn-bg); color: var(--warn-ink); }
.review-tag-same { background: var(--line); color: var(--muted); }
.review-from { color: var(--muted); text-decoration: line-through; }
.review-to { font-weight: 600; }
.review-detail { margin: 0; padding: 0 12px 9px calc(12px + 13px + 10px + 4.8em + 10px); }
.review-detail summary { cursor: pointer; color: var(--accent); }
.review-warn { color: var(--warn-ink); }
.review-list { margin: 6px 0 0; }
.review-list td { padding: 3px 10px 3px 0; }
.review-new { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px 14px; align-items: end;
  margin: 12px 0 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--raised); }
.review-new .review-item-head { grid-column: 1 / -1; padding: 0; }
.review-new .review-item-head:hover { background: none; }
.review-new-facts { grid-column: 1 / -1; margin: 0; }
.review-notes { margin: 8px 0 0; padding-left: 20px; }
.review-notes li { margin-bottom: 6px; }
.review-actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between;
  margin: 0 0 18px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 -4px 14px rgba(0, 0, 0, .08); }
.review-actions .check-row { padding: 0; align-self: center; }
@media (max-width: 640px) {
  .review-new { grid-template-columns: 1fr; }
  .review-detail { padding-left: 12px; }
  .review-actions .btn { width: 100%; }
}

/* Agents: the config file builder */
.cfg [hidden] { display: none !important; }
.cfg-private { padding: 10px 14px; border-left: 4px solid var(--green); background: var(--ok-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.cfg-open { position: relative; overflow: hidden; }
.cfg-open input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cfg-open:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.cfg-more { margin-top: 12px; }
.cfg-more > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.cfg-checks .check-row { padding-bottom: 4px; }
.cfg-show-pw { margin-top: 2px; }
.cfg-devices { display: flex; flex-direction: column; gap: 8px; }
.cfg-device { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--raised); padding: 10px 12px; }
.cfg-device-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 10px 14px; align-items: end; }
.cfg-device-row .check-row { padding-bottom: 10px; }
.cfg-device-row .js-cfg-remove { padding-bottom: 12px; }
.cfg-device-snmp { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.cfg-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 14px; }
.cfg-pick .check-row { padding-bottom: 4px; }
.cfg-problems { margin: 0 0 12px; padding: 10px 14px 10px 30px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); color: var(--warn-ink); }
.cfg-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.cfg-actions .check-row { padding: 0; align-self: center; }
.cfg-preview { margin: 12px 0; padding: 14px 16px; max-height: 480px; overflow: auto; background: var(--rack); color: var(--rack-ink);
  border-radius: var(--radius-sm); font-size: .86rem; line-height: 1.5; white-space: pre; }
@media (max-width: 640px) {
  .cfg-device-row { grid-template-columns: 1fr; }
  .cfg-device-row .check-row, .cfg-device-row .js-cfg-remove { padding-bottom: 0; justify-self: start; }
}

/* Room wall ports: the same sockets on a white wall plate */
.faceplate-wall { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); max-width: 760px;
  background: linear-gradient(#f4f5f2, #e3e5df); border-color: #c9ccc4; box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0, 0, 0, .12); }
.faceplate-wall .fp-free { background: #2b3540; color: #b9c6d2; }
.faceplate-wall .fp-free:hover { background: #3a4653; color: #fff; }
