/* Demo City Fiber — RoamRock fiber manager demo.
   Dark navy UI, accent #2f9fe8. Layout: top bar, docked sidebar, map.
   Under 760px the sidebar becomes a bottom sheet. */
:root {
  --bg: #0b1424;
  --bg-2: #0e1a2e;
  --panel: #111d33;
  --panel-2: #16243f;
  --panel-3: #1c2d4d;
  --line: #263a5e;
  --text: #ffffff;
  --muted: #a9b8d0;
  --accent: #2f9fe8;
  --accent-2: #5bb6f0;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff6b6b;
  --lit: #3ddc97;
  --res: #ffb547;
  --radius: 12px;
  --radius-sm: 8px;
  --side-w: 380px;
  --top-h: 58px;
  --info-h: 30px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
small { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.sm-only { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.small { font-size: 12.5px; color: var(--muted); }
.pad { padding: 12px; }
.c-lit { color: var(--lit); font-weight: 600; }
.c-res { color: var(--res); font-weight: 600; }

/* ---------------------------------------------------------- top bar */
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark rect { fill: #13284a; stroke: none; }
.brand-mark path { stroke: var(--accent); stroke-width: 3; }
.brand-mark circle { fill: #fff; stroke: none; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.demo-badge { font-size: 11.5px; color: #ffe2b0; background: rgba(255, 181, 71, .12); border: 1px solid rgba(255, 181, 71, .45); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13px; }
.segmented button[aria-checked="true"] { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------------------------------------------------------- buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 7px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #35507f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #238ad0; border-color: #238ad0; }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .55); color: #ffc9c9; }
.btn-block { width: 100%; margin-top: 4px; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.btn-row.end { justify-content: flex-end; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--panel-3); }
.link { background: none; border: 0; padding: 0; color: var(--accent-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.field { display: block; margin: 8px 0; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=search], input[type=text], input[type=number], input[type=date], input:not([type]), select { width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text); min-height: 36px; }
input[type=file] { width: 100%; font-size: 12.5px; color: var(--muted); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47, 159, 232, .25); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: #b9f5da; border-color: rgba(61, 220, 151, .5); background: rgba(61, 220, 151, .1); }
.pill.warn, .pill.res { color: #ffe2b0; border-color: rgba(255, 181, 71, .55); background: rgba(255, 181, 71, .1); }
.pill.lit { color: #b9f5da; border-color: rgba(61, 220, 151, .5); background: rgba(61, 220, 151, .1); }
.pill.bad { color: #ffc9c9; border-color: rgba(255, 107, 107, .5); background: rgba(255, 107, 107, .1); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; }
.chip.is-on { background: rgba(47, 159, 232, .18); border-color: var(--accent); color: #fff; }
.fiber-chip { display: inline-flex; align-items: center; gap: 5px; }
.fiber-chip i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .5); }

/* ---------------------------------------------------------- layout */
/* live totals banner under the top bar */
.infobar { height: var(--info-h); display: flex; align-items: center; gap: 6px; padding: 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; font-size: 12px; color: var(--muted); }
.infobar::-webkit-scrollbar { display: none; }
.ib-live { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--lit); margin-right: 4px; }
.ib-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--lit); box-shadow: 0 0 0 0 rgba(61, 220, 151, .7); animation: ib-pulse 2s ease-out infinite; }
@keyframes ib-pulse { 70% { box-shadow: 0 0 0 6px rgba(61, 220, 151, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); } }
.ib-stat { flex: none; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font: inherit; line-height: 1.5; }
.ib-stat b { color: var(--text); font-weight: 700; }
button.ib-stat { cursor: pointer; }
button.ib-stat:hover { border-color: var(--accent); }
.ib-stat.is-changed { animation: ib-flash 1.6s ease; }
@keyframes ib-flash { 0%, 40% { border-color: var(--accent); background: rgba(47, 159, 232, .25); } }
@media (prefers-reduced-motion: reduce) { .ib-live i, .ib-stat.is-changed { animation: none; } }
.layout { display: grid; grid-template-columns: var(--side-w) 1fr; height: calc(100% - var(--top-h) - var(--info-h)); transition: grid-template-columns .25s ease; }
body.sidebar-collapsed .layout { grid-template-columns: 0 1fr; }
body.sidebar-collapsed .sidebar { visibility: hidden; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; overflow: hidden; z-index: 5; }
.sheet-handle { display: none; }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.tabs [role=tab] { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 4px 9px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tabs [role=tab][aria-selected="true"] { color: #fff; border-bottom-color: var(--accent); }
.tabs [role=tab]:hover { color: #fff; }
.panes { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.pane { padding: 12px 14px 24px; }
.back-btn { padding-left: 4px; margin-bottom: 4px; }
.map-wrap { position: relative; min-width: 0; }
.map { position: absolute; inset: 0; background: #0a1220; }
/* dark basemap = OSM tiles inverted and tinted navy (keeps OSM attribution, no API key) */
.basemap-dark canvas { filter: invert(1) hue-rotate(195deg) saturate(.45) brightness(.82) contrast(.92); }
.basemap-imagery canvas { filter: brightness(.8) saturate(.85); }
.map-error { padding: 40px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------- sidebar content */
.results { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.result { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; width: 100%; }
.result:hover { border-color: #3a5a8f; background: var(--panel-3); }
.result b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.result small { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; }
.result.ck.reserved { border-left: 3px solid var(--res); }
.result.ck.lit { border-left: 3px solid var(--lit); }
.kind { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--panel-3); color: var(--muted); align-self: center; }
.k-structure { color: #9fd3ff; background: rgba(47, 159, 232, .14); }
.k-cable { color: #a5f0ff; background: rgba(90, 209, 230, .12); }
.k-circuit, .k-lit { color: #b9f5da; background: rgba(61, 220, 151, .12); }
.k-reserved { color: #ffe2b0; background: rgba(255, 181, 71, .14); }
.k-device, .k-equipment { color: #e3ccff; background: rgba(199, 146, 255, .12); }
.k-conduit { color: #ffe9a8; background: rgba(255, 209, 102, .12); }
.k-dark { color: #c7d3e6; background: rgba(159, 179, 200, .14); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 16px; }
.stat span { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.sec-h { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 16px 0 6px; font-weight: 700; }
.sec-h small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.demo-intro { margin: 0 0 8px; font-size: 12.5px; }
.demo-list { display: flex; flex-direction: column; gap: 6px; }
.demo-item { text-align: left; background: linear-gradient(135deg, rgba(47, 159, 232, .14), rgba(47, 159, 232, .04)); border: 1px solid rgba(47, 159, 232, .35); border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer; }
.demo-item:hover { border-color: var(--accent); }
.demo-item b { display: block; font-size: 13.5px; }
.demo-item span { display: block; font-size: 12px; color: var(--muted); }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.card h3 { font-size: 14px; margin-bottom: 4px; }
.az-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: end; }
.az-grid .icon-btn { margin-bottom: 8px; }
.route { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.route.is-on { border-color: #ffd166; box-shadow: inset 3px 0 0 #ffd166; }
.route-h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.route-cables { margin: 6px 0; font-weight: 600; font-size: 13px; word-break: break-word; }
.kv { list-style: none; padding: 0; margin: 6px 0; }
.kv li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed rgba(38, 58, 94, .7); font-size: 13px; }
.kv li span { color: var(--muted); }
.kv li b { font-weight: 600; text-align: right; }
.kv.small li { font-size: 12.5px; }
.d-head { margin-bottom: 8px; }
.d-head h2 { font-size: 19px; margin: 4px 0 2px; word-break: break-word; }
.d-head p { margin: 2px 0 6px; color: var(--muted); font-size: 13px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.res-note { background: rgba(255, 181, 71, .1); border: 1px solid rgba(255, 181, 71, .4); color: #ffe2b0 !important; border-radius: var(--radius-sm); padding: 6px 9px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 4px; border-bottom: 1px solid rgba(38, 58, 94, .6); }
.tree, .tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree { padding-left: 0; }
.tree li { padding: 2px 0; font-size: 13px; }
.tree li::before { content: "▸ "; color: var(--accent); }
.tube-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; border: 1px solid rgba(255, 255, 255, .55); vertical-align: -1px; }
.fgrid { display: flex; flex-direction: column; gap: 3px; }
.fgrid-tube { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.fgrid-tube .tube-sw { width: 6px; height: 22px; margin-right: 2px; }
.fchip { width: 24px; height: 22px; border-radius: 4px; border: 2px solid transparent; font-size: 10px; font-weight: 700; padding: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.fchip.s-lit { border-color: var(--lit); box-shadow: 0 0 0 1px var(--bg), 0 0 6px rgba(61, 220, 151, .8); }
.fchip.s-reserved { border-color: var(--res); border-style: dashed; }
.fchip.s-dark { opacity: .55; }
.fchip:hover, .fchip:focus-visible { opacity: 1; transform: scale(1.12); }
.lg-row { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot.lit { background: var(--lit); }
.dot.res { background: var(--res); }
.dot.dark { background: #5a6d8c; }
.end-card { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin: 6px 0; }
.end-card b { display: block; font-size: 13px; }
.end-card small { display: block; font-size: 12px; }
.end-tag { flex: none; font-size: 11px; font-weight: 800; color: var(--bg); background: #ffd166; border-radius: 6px; padding: 3px 6px; }
.hops { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid rgba(255, 209, 102, .5); margin-left: 18px; }
.hop { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; position: relative; }
.hop-ic { flex: none; width: 14px; height: 14px; border-radius: 50%; margin-left: -23px; margin-top: 2px; border: 2px solid var(--bg); box-shadow: 0 0 0 1px rgba(255, 255, 255, .5); }
.hop-ic.sq { border-radius: 3px; background: #ffd166; }
.hop b { font-size: 13px; }
.hop small { display: block; font-size: 12px; }
.hop.splice .link { font-size: 12px; margin-left: 6px; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.totals div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; text-align: center; }
.totals span { display: block; font-size: 11px; color: var(--muted); }
.totals b { font-size: 13px; }
.assume { font-size: 12.5px; color: var(--muted); }
.assume summary { cursor: pointer; color: var(--accent-2); }
.otdr { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 10px 10px; margin: 10px 0; }
.otdr .sec-h { margin-top: 8px; }
.banner { padding: 8px 10px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 13px; }
.banner.ok { background: rgba(61, 220, 151, .1); border: 1px solid rgba(61, 220, 151, .45); }
.banner.bad { background: rgba(255, 107, 107, .1); border: 1px solid rgba(255, 107, 107, .45); }
.cd-list { padding-left: 20px; margin: 0; }
.cd-list li { margin: 4px 0; font-size: 13px; }
.cd-list li span { margin-left: 6px; }
.cd-list li small { display: block; }
.cd-list li.blocked { color: #ffc9c9; }
.health { list-style: none; padding: 0; margin: 10px 0 0; }
.health > li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(38, 58, 94, .7); }
.health b { font-size: 13px; display: block; }
.health small { display: block; }
.health ul { margin: 4px 0 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
.h-ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--bg); }
.h-ok .h-ic { background: var(--ok); }
.h-warn .h-ic { background: var(--warn); }
.h-error .h-ic { background: var(--bad); }

/* ---------------------------------------------------------- map chrome (OpenLayers) */
.ol-control { background: transparent; }
/* popups (and OL controls) must sit above the floating layer/legend panels */
.ol-overlaycontainer-stopevent { z-index: 4 !important; }
.ol-control button { background: var(--panel) !important; color: #fff !important; border: 1px solid var(--line) !important; border-radius: 8px !important; width: 34px !important; height: 34px !important; font-size: 18px !important; margin: 3px !important; }
.ol-control button:hover, .ol-control button:focus { background: var(--panel-3) !important; outline: none; }
.ol-scale-line { background: rgba(17, 29, 51, .85); border-radius: 6px; left: 12px; bottom: 12px; padding: 3px 6px; }
.ol-scale-line-inner { border-color: #dfe8f5; color: #dfe8f5; font-size: 11px; }
.ol-attribution { background: rgba(17, 29, 51, .85) !important; border-radius: 6px 0 0 0; max-width: calc(100% - 140px); }
.ol-attribution ul { color: #dfe8f5; font-size: 11px; text-shadow: none; }
.ol-attribution a { color: #9fd3ff; }
.ol-attribution button { width: 24px !important; height: 24px !important; font-size: 13px !important; margin: 2px !important; }
.map-panel { position: absolute; right: 12px; background: rgba(17, 29, 51, .94); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); z-index: 3; width: 204px; max-width: calc(100% - 24px); backdrop-filter: blur(6px); }
.layers-panel { top: 12px; }
.legend-panel { bottom: 48px; } /* clear of the attribution bar */
.map-panel-toggle { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.map-panel-toggle svg { width: 16px; height: 16px; color: var(--accent-2); }
.map-panel-body { padding: 0 12px 10px; }
.map-panel fieldset { border: 0; padding: 0; margin: 0 0 8px; }
.map-panel legend { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.map-panel label { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 2px 0; cursor: pointer; }
.map-panel input { accent-color: var(--accent); width: 15px; height: 15px; }
.legend { list-style: none; margin: 0 0 6px; padding: 0; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 2px 0; }
.legend .sw { flex: none; display: inline-block; width: 14px; height: 14px; }
.legend li .sw[style*="height:"] { width: 22px; }
.legend-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.ol-popup { position: relative; display: none; background: var(--panel); border: 1px solid #35507f; border-radius: var(--radius); padding: 10px 12px; width: 260px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.ol-popup.open { display: block; }
.ol-popup::after { content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: var(--panel); }
.ol-popup h3 { font-size: 16px; margin: 2px 0; padding-right: 20px; }
.ol-popup p { margin: 4px 0; font-size: 13px; color: var(--muted); }
.ol-popup .btn-row { margin: 6px 0 0; }
.pp-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-2); font-weight: 700; }
.popup-close { position: absolute; right: 6px; top: 4px; background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; width: 28px; height: 28px; }

/* ---------------------------------------------------------- dialogs */
.dialog { background: var(--panel); color: var(--text); border: 1px solid #35507f; border-radius: 16px; padding: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); max-width: calc(100vw - 24px); }
.dialog::backdrop { background: rgba(5, 10, 20, .65); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 18px; }
.dlg-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.form-dialog { width: 440px; }
.form-dialog form { padding: 16px; }
.form-dialog h2 { font-size: 18px; margin-bottom: 4px; }

/* ---------------------------------------------------------- splice editor */
.splice-dialog { width: min(1180px, calc(100vw - 24px)); height: min(860px, calc(100vh - 24px)); }
.splice-dialog[open] { display: flex; flex-direction: column; }
.sp-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; padding: 6px 16px 0; }
.sp-controls .icon-btn { margin-bottom: 8px; }
.sp-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 16px 8px; }
.sp-actions .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.tube-pick { display: inline-flex; align-items: center; gap: 4px; }
.tube-pick select { width: auto; min-height: 32px; padding: 5px 6px; font-size: 12.5px; }
.sp-status { min-height: 0; margin: 0 16px; font-size: 13px; border-radius: var(--radius-sm); }
.sp-status:not(:empty) { padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.sp-status.ok { border-color: rgba(61, 220, 151, .5); color: #c8f7e1; }
.sp-status.warn { border-color: rgba(255, 181, 71, .55); color: #ffe2b0; }
.sp-status.error { border-color: rgba(255, 107, 107, .6); color: #ffd0d0; background: rgba(255, 107, 107, .08); }
.sp-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 300px; border-top: 1px solid var(--line); }
.sp-board { overflow: auto; min-height: 0; background: radial-gradient(ellipse at center, #10203a 0%, #0c172a 70%); }
.sp-canvas { position: relative; display: grid; grid-template-columns: 1fr 150px 1fr; padding: 10px 12px 24px; min-width: 0; }
.sp-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.sp-lines path { fill: none; stroke-width: 2; stroke: #8aa4c8; opacity: .8; }
.sp-lines path.lit { stroke: var(--lit); opacity: .95; }
.sp-lines path.res { stroke: var(--res); stroke-dasharray: 6 4; opacity: .95; }
.sp-lines path.crossed { stroke-width: 2.4; }
.sp-lines path.sel { stroke: #ffffff; stroke-width: 3.5; opacity: 1; filter: drop-shadow(0 0 3px rgba(47, 159, 232, .9)); }
.sp-col { min-width: 0; }
.tube { margin-bottom: 6px; }
.tube-h { display: flex; align-items: center; gap: 4px; width: 100%; background: none; border: 0; border-bottom: 2px solid var(--tc); padding: 3px 2px; font-size: 11.5px; font-weight: 700; color: #dfe8f5; cursor: pointer; text-align: left; }
.sp-left .tube-h { flex-direction: row-reverse; text-align: right; }
.tube-h .tube-n { margin-left: auto; font-weight: 400; color: var(--muted); }
.sp-left .tube-h .tube-n { margin-left: 0; margin-right: auto; }
.tube-h .tube-sw { margin: 0 4px; }
.fb { display: flex; align-items: center; gap: 6px; width: 100%; height: 25px; margin: 1px 0; padding: 0; background: none; border: 0; cursor: pointer; color: var(--text); font-size: 11.5px; border-radius: 5px; user-select: none; -webkit-user-select: none; }
.sp-left .fb { flex-direction: row-reverse; }
.fb-bar { flex: none; width: 72px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .25); transition: transform .12s ease, box-shadow .12s ease; }
/* thumbs in the field: bigger targets on touch screens */
@media (pointer: coarse) {
  .fb { height: 34px; margin: 2px 0; }
  .fb-bar { height: 28px; font-size: 13px; }
}
/* drag to connect (mouse and pen) */
body:not(.role-viewer) .splice-dialog:not(.viewer) .fb-bar { cursor: grab; }
.splice-dialog.dragging, .splice-dialog.dragging * { cursor: grabbing !important; }
.fb.is-drag-src .fb-bar { transform: scale(1.12); box-shadow: 0 0 0 2px var(--accent), 0 0 12px rgba(47, 159, 232, .8); }
.fb.is-target-ok { background: rgba(61, 220, 151, .14); outline: 2px dashed var(--lit); outline-offset: -1px; }
.fb.is-target-ok .fb-bar { transform: scale(1.12); box-shadow: 0 0 0 2px var(--lit), 0 0 14px rgba(61, 220, 151, .9); }
.fb.is-target-bad { background: rgba(255, 107, 107, .14); outline: 2px dashed #ff6b6b; outline-offset: -1px; }
.fb.is-target-bad .fb-bar { box-shadow: 0 0 0 2px #ff6b6b; }
.sp-lines path.drag { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 8 6; opacity: 1; animation: sp-dash .5s linear infinite; filter: drop-shadow(0 0 4px rgba(47, 159, 232, .8)); }
.sp-lines path.drag.ok { stroke: var(--lit); filter: drop-shadow(0 0 5px rgba(61, 220, 151, .9)); }
.sp-lines path.drag.bad { stroke: #ff6b6b; filter: drop-shadow(0 0 4px rgba(255, 107, 107, .8)); }
@keyframes sp-dash { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) { .sp-lines path.drag { animation: none; } .fb-bar { transition: none; } }
.fb-bar.big { width: 42px; height: 26px; font-size: 13px; flex: none; }
.fb-code { flex: none; width: 40px; color: var(--muted); font-size: 10.5px; font-family: ui-monospace, Consolas, monospace; }
.sp-left .fb-code { text-align: right; }
.fb-tray { flex: none; width: 26px; color: #9fb4d3; font-size: 10px; font-family: ui-monospace, Consolas, monospace; }
.sp-left .fb-tray { text-align: right; }
.fb .jump { text-decoration: underline dotted; text-underline-offset: 2px; cursor: pointer; }
.fb .jump:hover { color: #fff; text-decoration-style: solid; }
.fb.is-dim { opacity: .28; }
.sp-lines path.dim { opacity: .12; }
.sp-view { display: inline-flex; gap: 4px; }
.sp-view select { width: auto; min-height: 32px; padding: 5px 6px; font-size: 12.5px; }
#sp-undo { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.linkish:hover { text-decoration: underline; }
.kv.trays li { align-items: center; }
.kv.trays .linkish { display: flex; flex-direction: column; min-width: 0; color: var(--text); }
.kv.trays .linkish span { color: var(--accent); font-weight: 700; }
.kv.trays .linkish small { color: var(--muted); font-size: 11.5px; }
.term-row { display: flex; gap: 6px; align-items: end; margin: 6px 0 10px; }
.term-row .field { flex: 1; margin: 0; }
.lg-code { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: #c7d3e6; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
.fb-badge { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10.5px; }
.sp-left .fb-badge { text-align: right; }
.ck-tag { font-weight: 700; padding: 0 4px; border-radius: 3px; margin: 0 4px; }
.ck-tag.lit { background: rgba(61, 220, 151, .2); color: #b9f5da; }
.ck-tag.res { background: rgba(255, 181, 71, .2); color: #ffe2b0; }
.fb:hover { background: rgba(255, 255, 255, .05); }
.fb.is-lit .fb-bar { box-shadow: 0 0 0 2px var(--lit), 0 0 8px rgba(61, 220, 151, .6); }
.fb.is-res .fb-bar { box-shadow: 0 0 0 2px var(--res); background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(0, 0, 0, .25) 4px 7px) !important; }
.fb.is-open .fb-badge { font-style: italic; opacity: .7; }
.fb.is-elsewhere .fb-badge { color: #c7d3e6; }
.fb.is-sel { background: rgba(47, 159, 232, .22); outline: 2px solid var(--accent); }
.fb.is-sel .fb-bar { transform: scaleY(1.15); }
.fb.is-flash { animation: flash 1s ease 2; background: rgba(255, 107, 107, .25); }
@keyframes flash { 50% { background: rgba(255, 107, 107, .55); } }
.fb:focus-visible { outline: 2px solid #fff; outline-offset: 0; }
.sp-info { border-left: 1px solid var(--line); padding: 12px 14px; overflow-y: auto; background: var(--panel); }
.sp-info h3 { font-size: 13px; margin: 6px 0; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.steps { padding-left: 18px; margin: 4px 0 12px; font-size: 13px; }
.steps li { margin: 3px 0; }
.fiber-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.fiber-head b { display: block; }
.fiber-head small { display: block; font-size: 12px; }
.ck-line { margin: 6px 0; padding: 5px 8px; border-radius: var(--radius-sm); font-size: 13px; }
.ck-line.lit { background: rgba(61, 220, 151, .1); border: 1px solid rgba(61, 220, 151, .4); }
.ck-line.res { background: rgba(255, 181, 71, .1); border: 1px solid rgba(255, 181, 71, .45); }
.ck-line.dark { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.path-line { font-size: 12.5px; color: #dfe8f5; margin: 8px 0; word-break: break-word; }
.sp-foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 7px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { display: inline-block; width: 22px; height: 0; border-top: 3px solid #8aa4c8; }
.lg-line.lit { border-color: var(--lit); }
.lg-line.res { border-color: var(--res); border-top-style: dashed; }
.kbd-help { margin-left: auto; }
.splice-dialog.viewer .sp-actions::after { content: "Viewer: read-only"; font-size: 12px; color: #ffe2b0; margin-left: auto; }

/* ---------------------------------------------------------- reports */
.report-dialog { width: min(980px, calc(100vw - 24px)); height: min(900px, calc(100vh - 24px)); }
.report-dialog[open] { display: flex; flex-direction: column; }
.report-body { flex: 1; overflow: auto; padding: 18px 22px; background: #fff; color: #111; border-radius: 0 0 16px 16px; }
.report-body h1 { font-size: 20px; }
.report-body h2 { font-size: 15px; margin: 18px 0 6px; border-bottom: 2px solid #2f9fe8; padding-bottom: 3px; }
.report-body h2 small { color: #555; font-weight: 400; }
.report-body p { color: #333; }
.report-body .small { color: #555; }
.report-body .pill { background: #eef4fb; color: #1d4f7a; border-color: #b9d4ee; }
.report-body .pill.res { background: #fff4e0; color: #8a5600; border-color: #f2c77a; }
.report-body .pill.lit { background: #e3f8ee; color: #0f6b43; border-color: #98dfbd; }
.rp-head { display: flex; justify-content: space-between; border-bottom: 1px solid #ccd; padding-bottom: 8px; }
.rp-head p { margin: 4px 0 0; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 18px; margin: 10px 0; }
.rp-grid dt { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .4px; }
.rp-grid dd { margin: 0; font-weight: 600; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rp-table.narrow { max-width: 560px; }
.rp-table th { text-align: left; background: #eef2f7; padding: 5px 6px; border-bottom: 1px solid #c5cfdb; }
.rp-table td { padding: 4px 6px; border-bottom: 1px solid #e3e8ef; vertical-align: top; }
.rp-table tr.tot td { font-weight: 700; border-top: 2px solid #c5cfdb; }
.sw-inline { display: inline-block; width: 9px; height: 9px; border: 1px solid #666; border-radius: 2px; margin-left: 2px; vertical-align: 0; }
.rp-sign { display: flex; gap: 30px; flex-wrap: wrap; margin-top: 26px; color: #333; }
.rp-foot { margin-top: 24px; font-size: 11px; color: #666 !important; border-top: 1px solid #dde; padding-top: 6px; }

/* splice diagram (print.js) */
.sd h3.sd-tray-h { font-size: 13.5px; margin: 14px 0 2px; color: #1b2a41; }
.sd h3 small, .sd h2 small { color: #555; font-weight: 400; }
.sd-tubes { margin: 0 0 4px; }
.sd-tube { white-space: nowrap; margin-right: 8px; }
.sd-svg { display: block; width: 100%; max-width: 760px; height: auto; font-family: system-ui, "Segoe UI", sans-serif; stroke: none; fill: #111; stroke-width: 1; }
.sd-svg .sd-hd { fill: #eef2f7; }
.sd-svg .sd-ht { font-size: 11px; font-weight: 700; fill: #1b2a41; }
.sd-svg .sd-muted { fill: #667; font-weight: 400; }
.sd-svg .sd-zebra { fill: #f5f7fa; }
.sd-svg .sd-t { font-size: 11px; fill: #111; }
.sd-svg .sd-code { font-size: 9.5px; fill: #556; font-family: ui-monospace, Consolas, monospace; }
.sd-svg .sd-fn { font-size: 9.5px; font-weight: 700; }
.sd-svg .sd-sw { stroke: #445; stroke-width: .6; }
.sd-svg .sd-line { fill: none; stroke-width: 1.6; stroke: #7a8799; }
.sd-svg .sd-line.lit { stroke: #12a150; stroke-width: 2.2; }
.sd-svg .sd-line.res { stroke: #d98a00; stroke-width: 2; stroke-dasharray: 5 3; }
.sd-svg .sd-joint { fill: #7a8799; }
.sd-svg .sd-joint.lit { fill: #12a150; }
.sd-svg .sd-joint.res { fill: #d98a00; }
.sd-svg .sd-joint.mech { fill: #fff; stroke: #333; stroke-width: 1.2; }
.sd-svg .sd-ck { font-size: 10px; font-weight: 700; fill: #556; }
.sd-svg .sd-ck.lit { fill: #0f7a3e; }
.sd-svg .sd-ck.res { fill: #9a6200; }
.sd-key-line .lg { margin-right: 10px; white-space: nowrap; }
.sd-k { display: inline-block; width: 22px; height: 0; border-top: 3px solid #7a8799; vertical-align: middle; margin-right: 4px; }
.sd-k.lit { border-color: #12a150; }
.sd-k.res { border-color: #d98a00; border-top-style: dashed; }
.sd-color-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.sd-color i { display: inline-block; min-width: 20px; padding: 1px 3px; margin-right: 4px; border: 1px solid #556; border-radius: 3px; text-align: center; font-style: normal; font-weight: 700; font-size: 11px; }
.sd-ports { font-size: 12px; }
.sd-ports td { padding: 2px 6px; }

/* map book (print.js): each sheet is one SVG, 10 x 7.5 in when printed */
.mb-page { margin: 0 0 18px; border: 1px solid #c5cfdb; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); padding: 10px; background: #fff; }
.mb-svg { display: block; width: 100%; height: auto; font-family: system-ui, "Segoe UI", sans-serif; overflow: visible; stroke: none; fill: #111; stroke-width: 1; }
.mb-svg .mb-bg { fill: #fff; }
.mb-svg .mb-title { font-size: 20px; font-weight: 700; fill: #0b1424; }
.mb-svg .mb-pid { font-size: 36px; font-weight: 800; fill: #0b1424; }
.mb-svg .mb-h { font-size: 11px; font-weight: 700; fill: #0b1424; text-transform: uppercase; letter-spacing: .5px; }
.mb-svg .mb-t { font-size: 10px; fill: #222; }
.mb-svg .mb-t.b { font-weight: 700; }
.mb-svg .mb-muted { fill: #667; }
.mb-svg .mb-frame { fill: none; stroke: #0b1424; stroke-width: 1.4; }
.mb-svg .mb-grid { fill: none; stroke: #0b1424; stroke-width: .8; stroke-dasharray: 4 3; }
.mb-svg .mb-cell { font-size: 16px; font-weight: 800; fill: #0b1424; }
.mb-svg .mb-hatch { stroke: #d5dbe3; stroke-width: 2; }
.mb-svg .mb-cd { fill: none; stroke-opacity: .5; stroke-linecap: butt; stroke-linejoin: round; }
.mb-svg .mb-cb { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mb-svg .mb-st > :not(.mb-ring) { stroke: #0b1424; stroke-width: .8; }
.mb-svg .mb-ring { fill: none; stroke: #f08a24; stroke-width: 1.6; }
.mb-svg .mb-lb { font-size: 9px; fill: #0b1424; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.mb-svg .mb-lb.site { font-size: 12px; font-weight: 800; }
.mb-svg .mb-lb.small { font-size: 8px; font-weight: 700; }
.mb-svg .mb-lb.sub { font-size: 8.5px; fill: #334; }
.mb-svg .mb-street { font-size: 9px; font-style: italic; letter-spacing: .6px; fill: #5b6b80; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.mb-svg .mb-cable { font-size: 8.5px; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.mb-svg .mb-edge-t { font-size: 11px; font-weight: 700; fill: #0b1424; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.mb-svg .mb-key { fill: #fff; stroke: #9aa3ad; stroke-width: .6; }
.mb-svg .mb-key.on { fill: #e3ecf7; }
.mb-svg .mb-key.cur { fill: #2f9fe8; stroke: #0b1424; }
.mb-svg .mb-key-t { font-size: 7px; fill: #445; }
.mb-svg .mb-key-t.cur { fill: #fff; font-weight: 700; }
.mb-svg .mb-bar { fill: #0b1424; stroke: #0b1424; stroke-width: .8; }
.mb-svg .mb-bar.w { fill: #fff; }
.mb-svg .mb-mbar { stroke: #0b1424; stroke-width: 2; }
.mb-svg .mb-north { fill: #0b1424; }
.mb-index h2 small { color: #555; font-weight: 400; }
.mb-ix { columns: 3 220px; column-gap: 18px; font-size: 11px; }
.mb-ix-row { display: flex; gap: 6px; break-inside: avoid; border-bottom: 1px solid #eef0f3; padding: 1px 0; }
.mb-ix-row span { flex: 1; color: #444; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-ix-row em { font-style: normal; font-weight: 700; }

/* ---------------------------------------------------------- toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--panel-3); border: 1px solid #35507f; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1000; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(61, 220, 151, .6); }
.toast.warn { border-color: rgba(255, 181, 71, .7); }

/* ---------------------------------------------------------- tablet / phone */
@media (max-width: 1100px) {
  .brand-sub { display: none; }
  .sp-body { grid-template-columns: 1fr 250px; }
  .sp-canvas { grid-template-columns: 1fr 110px 1fr; }
}
@media (max-width: 900px) {
  .demo-badge { position: absolute; top: calc(var(--top-h) + var(--info-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 6; background: rgba(40, 30, 10, .85); }
}
@media (max-width: 759px) {
  :root { --top-h: 52px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-mark { display: none; }
  .brand-name { font-size: 14.5px; }
  #btn-reset { padding: 6px 8px; font-size: 12px; }
  .lg-only { display: none; }
  .sm-only { display: inline !important; }
  .sp-trays { display: none; }
  .segmented button { padding: 4px 8px; font-size: 12px; }
  .layout { display: block; position: relative; }
  .map-wrap { position: absolute; inset: 0; }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; height: 46vh; border-right: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .45); transform: translateY(calc(100% - 96px)); transition: transform .25s ease, height .25s ease; z-index: 30; }
  body.sheet-open .sidebar { transform: none; }
  body.sidebar-collapsed .sidebar { visibility: visible; }
  .sheet-handle { display: block; width: 100%; height: 22px; background: none; border: 0; cursor: pointer; flex: none; }
  .sheet-handle span { display: block; width: 44px; height: 5px; border-radius: 3px; background: #46618f; margin: 8px auto 0; }
  .tabs { padding-top: 0; overflow-x: auto; }
  .tabs [role=tab] { font-size: 12.5px; padding: 8px 6px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .layers-panel { top: 10px; right: 10px; }
  .legend-panel { top: 56px; bottom: auto; right: 10px; }
  .map-panel { width: 196px; }
  .ol-scale-line { bottom: 104px; left: 10px; }
  .ol-attribution { bottom: 96px !important; }
  .ol-popup { width: 230px; }
  .splice-dialog, .report-dialog { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; margin: 0; }
  .sp-controls { grid-template-columns: 1fr auto 1fr; padding: 4px 10px 0; gap: 6px; }
  .sp-controls select { font-size: 12px; padding: 6px; }
  .sp-actions { padding: 4px 10px 6px; gap: 4px; }
  .sp-actions .btn { padding: 6px 8px; font-size: 12px; }
  .sp-actions .sep { display: none; }
  .sp-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sp-info { border-left: 0; border-top: 1px solid var(--line); max-height: 24vh; }
  .sp-canvas { grid-template-columns: 1fr 56px 1fr; padding: 8px 6px 20px; }
  .fb-bar { width: 52px; }
  .fb-code, .fb-tray, .sp-view label:first-child, .sp-foot .lg:has(.lg-code) { display: none; }
  #sp-undo { max-width: 120px; }
  .fb-badge { font-size: 9.5px; }
  .kbd-help { display: none; }
  .dlg-head { padding: 10px 12px 8px; }
  .report-body { padding: 12px; border-radius: 0; }
  .form-dialog { width: calc(100vw - 24px); }
  .totals { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------- print: only the report */
@media print {
  @page { margin: 14mm; }
  :root { color-scheme: light; }
  html, body { background: #fff; overflow: visible; height: auto; }
  body > *:not(#report-dialog) { display: none !important; }
  #report-dialog { position: static; display: block; border: 0; box-shadow: none; width: auto; height: auto; max-width: none; max-height: none; background: #fff; border-radius: 0; outline: none; margin: 0; padding: 0; }
  #report-dialog::backdrop { display: none; }
  .no-print { display: none !important; }
  .report-body { overflow: visible; padding: 0; border-radius: 0; }
  .rp-table tr { break-inside: avoid; }
  .report-body h2 { break-after: avoid; }
  .sw-inline { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sd, .mb { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sd-tray-h, .sd h2 { break-after: avoid; }
  .sd-svg, .sd-keep { break-inside: avoid; }
  .sd-colors, .rp-sign, .sd-tubes { break-inside: avoid; }
  /* map book: one sheet per printed page (the page itself is set landscape by print.js) */
  .mb-page { margin: 0; padding: 0; border: 0; box-shadow: none; break-after: page; break-inside: avoid; }
  .mb-svg { width: 10in; height: 7.5in; }
  .mb-index { break-before: page; }
  #report-dialog[data-kind=map-book] .rp-foot { display: none; }
}

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

/* ---------- Build tab ---------- */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role=tab] { padding-left: 2px; padding-right: 2px; }
.build-step h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; flex: none; }
.build-step .btn-row { margin: 8px 0 0; }
.build-alt { margin-top: 8px; font-size: 13px; }
.build-alt summary { cursor: pointer; color: var(--accent); }
.build-alt[open] summary { margin-bottom: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 6px 0; }
.check input { margin-top: 3px; }
.warn-text { color: #ffe2b0; }
.build-out { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; background: var(--panel-2); }
.build-out.ok { border-color: rgba(61, 220, 151, .5); }
.build-notes { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.build-row { align-items: center; padding-top: 8px; border-top: 1px dashed var(--line); }
.build-row-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.map-mode { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 999px;
  background: rgba(11, 20, 36, .92); border: 1px solid var(--accent); box-shadow: 0 6px 20px rgba(0, 0, 0, .4); font-size: 13px; max-width: calc(100% - 24px); }
.map-mode[hidden] { display: none; }
#map.mode-point, #map.mode-point canvas { cursor: crosshair !important; }
#map.mode-line, #map.mode-line canvas { cursor: copy !important; }

/* ---------- tube header: name, tray routing, counts ---------- */
.tube-name { display: inline-flex; align-items: center; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.tube-tray { width: auto; min-height: 0; height: 20px; padding: 0 4px; font-size: 10.5px; border-radius: 4px; background: var(--panel-2); color: #c7d3e6; border: 1px solid var(--line); margin: 0 6px; }
.tube-h { cursor: default; }

/* ---------- edit toolbar + flyout ---------- */
/* Two matching vertical toolbars on the left: navigation (zoom in, zoom out, home) on top,
   editing below it, 12px apart. Nav height = 3 x 34px buttons + 2 x 4px gaps + 2 x 4px padding + borders = 120px. */
.map-nav, .edit-tools { position: absolute; left: 12px; z-index: 4; display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 10px;
  background: rgba(17, 29, 51, .9); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.map-nav { top: 12px; }
.edit-tools { top: 144px; }
.map-nav button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: #dfe8f5; cursor: pointer; padding: 0; }
.map-nav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-nav button:hover { background: var(--panel-3); }
.map-nav button:focus-visible, .edit-tools button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.edit-tools[hidden] { display: none; }
.edit-tools button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: #dfe8f5; cursor: pointer; padding: 0; }
.edit-tools button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.edit-tools button:hover:not(:disabled) { background: var(--panel-3); }
.edit-tools button.is-on { background: var(--accent); color: #fff; box-shadow: 0 0 0 2px rgba(47, 159, 232, .35); }
.edit-tools button:disabled { opacity: .35; cursor: default; }
.et-sep { height: 1px; background: var(--line); margin: 2px 4px; }
.flyout { position: absolute; top: 12px; left: 62px; z-index: 5; width: 320px; max-width: calc(100% - 74px); max-height: calc(100% - 64px); display: flex; flex-direction: column;
  background: rgba(17, 29, 51, .97); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }
.flyout[hidden] { display: none; }
.fly-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.fly-head h2 { font-size: 14px; margin: 0; }
.fly-body { overflow-y: auto; padding: 10px 14px 12px; }
.fly-panel[hidden] { display: none; }
.fly-body .field { margin-bottom: 8px; }
.ed-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ed-head b { font-size: 15px; }
.ed-msg { font-size: 12.5px; padding: 6px 9px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel-2); margin: 0 0 8px; }
.ed-msg.ok { border-color: rgba(61, 220, 151, .5); color: #c8f7e1; }
.ed-msg.error { border-color: rgba(255, 107, 107, .6); color: #ffd0d0; }
.ed-form { margin-bottom: 6px; }
table.ducts td { vertical-align: middle; padding: 3px 4px; }
table.ducts select { min-height: 0; padding: 2px 4px; font-size: 12px; }
.btn-warn { border-color: rgba(255, 181, 71, .6) !important; color: #ffe2b0 !important; }
.btn-danger { border-color: rgba(255, 107, 107, .6) !important; color: #ffd0d0 !important; }
.btn-danger:disabled { opacity: .4; }
#map.mode-move, #map.mode-move canvas { cursor: grab !important; }
.map-mode { flex-wrap: wrap; justify-content: center; }
@media (max-width: 759px) {
  .map-nav { top: 44px; left: 10px; }
  .edit-tools { top: 176px; left: 10px; }
  .flyout { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-width: none; max-height: 52vh; border-radius: 14px 14px 0 0; }
}

/* ---------- right-hand map panels: one column, even gaps, the legend scrolls instead of overlapping ---------- */
.map-side { position: absolute; top: 12px; right: 12px; bottom: 48px; width: 204px; display: flex; flex-direction: column; gap: 12px; z-index: 3; pointer-events: none; }
.map-side .map-panel { position: static; width: auto; max-width: none; pointer-events: auto; flex: none; }
.map-side .legend-panel { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.map-side .legend-panel .map-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
/* When the legend scrolls, the edge with more hidden behind it fades out (classes set by map.js). */
.legend-panel .map-panel-body.fade-bottom { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
.legend-panel .map-panel-body.fade-top { -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to top, #000 calc(100% - 28px), transparent); }
.legend-panel .map-panel-body.fade-top.fade-bottom { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
@media (max-width: 759px) {
  .map-side { top: 10px; right: 10px; bottom: 104px; width: 196px; }
  .map-side .layers-panel, .map-side .legend-panel { top: auto; bottom: auto; right: auto; }
}

/* ---------- 1.3: branding, phone menu, three-stop bottom sheet, tool panel as the sheet ---------- */
.brand-text { min-width: 0; }
.brand-name, .brand-sub { overflow: hidden; text-overflow: ellipsis; }
.brand-sub #org-name { color: var(--text); opacity: .85; }
.app-menu { position: absolute; top: calc(var(--top-h) - 4px); left: 8px; z-index: 40; min-width: 220px; display: flex; flex-direction: column; padding: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.app-menu [role=menuitem] { display: block; text-align: left; background: none; border: 0; border-radius: var(--radius-sm); padding: 12px; min-height: 44px; color: var(--text); text-decoration: none; font-size: 14px; cursor: pointer; }
.app-menu [role=menuitem]:hover, .app-menu [role=menuitem]:focus-visible { background: var(--panel-3); }
.app-menu-note { margin: 4px 6px 4px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; color: #ffe2b0; }
/* the demo badge on the map: a small chip above the scale bar (narrow screens only) */
.map-badge { position: absolute; left: 10px; bottom: 34px; z-index: 4; font-size: 11px; line-height: 1; color: #ffe2b0; background: rgba(40, 30, 10, .88); border: 1px solid rgba(255, 181, 71, .45); padding: 4px 8px; border-radius: 999px; pointer-events: none; }
@media (min-width: 901px) { .map-badge { display: none !important; } }
@media (max-width: 900px) { .demo-badge { display: none !important; } }
/* tool hint: one line in the tool panel, "How to use" expands it */
.map-mode { position: static; transform: none; border-radius: var(--radius-sm); box-shadow: none; display: block; padding: 8px 10px; margin: 0 0 10px; max-width: none; background: var(--panel-2); border: 1px solid var(--accent); font-size: 13px; }
.map-mode .mm-line { display: block; font-weight: 600; }
.map-mode details { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.map-mode summary { cursor: pointer; color: var(--accent-2); min-height: 28px; display: flex; align-items: center; }
.map-mode .mm-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 4px 8px; margin-top: 4px; }
.map-mode .mm-row details { flex: 1 1 140px; margin-top: 0; }
.map-mode details[open] { flex-basis: 100%; }
.map-mode .mm-btns { display: flex; gap: 8px; margin-left: auto; }
.map-mode.on-map { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 15; max-width: min(460px, calc(100% - 24px)); background: rgba(11, 20, 36, .94); }
.fly-expand { display: none; }
@media (max-width: 759px) {
  :root { --peek-h: 84px; }
  /* phone top bar: Reset lives in the ☰ menu */
  .topbar-actions #btn-reset { display: none; }
  .brand-sub { display: block; font-size: 11px; }
  .brand-by { display: none; }
  .brand-name { font-size: 14px; }
  /* bottom sheet: peek / half / full, positioned by translateY; full sits just under the top bar */
  .sidebar { height: calc(100dvh - var(--top-h)); transform: translateY(calc(100% - var(--peek-h))); }
  body.sheet-half .sidebar { transform: translateY(calc(50dvh - var(--top-h))); }
  body.sheet-full .sidebar, body.sheet-open.sheet-full .sidebar { transform: none; }
  body.sheet-open:not(.sheet-full):not(.sheet-half) .sidebar { transform: translateY(calc(50dvh - var(--top-h))); }
  .sheet-handle { height: 44px; touch-action: none; position: relative; }
  .sheet-handle span { width: 56px; height: 6px; margin: 0 auto; position: absolute; left: 0; right: 0; top: 19px; }
  .tabs { height: 38px; touch-action: pan-x; padding-bottom: 0; }
  .ol-scale-line { bottom: calc(var(--peek-h) + 10px); }
  .ol-attribution { bottom: calc(var(--peek-h) + 4px) !important; }
  .map-badge { bottom: calc(var(--peek-h) + 36px); }
  .map-side { bottom: calc(var(--peek-h) + 12px); }
  /* an edit tool on a phone: the tool panel is the sheet; the main sheet steps aside */
  body.tool-on .sidebar { display: none; }
  body.tool-on .ol-scale-line, body.tool-on .map-badge, body.tool-on .ol-attribution { display: none; }
  .flyout { max-height: 32vh; display: flex; flex-direction: column; }
  .flyout.is-expanded { max-height: 72vh; }
  .flyout:not(.is-expanded) [data-more] { display: none !important; }
  .fly-head { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  .fly-body { padding-top: 8px; }
  .fly-body .field-label { font-size: 11.5px; }
  .fly-head h2 { flex: 1; }
  .fly-expand { display: inline-grid; }
  .fly-expand svg { transition: transform .2s ease; }
  .flyout.is-expanded .fly-expand svg { transform: rotate(180deg); }
  .fly-body { flex: 1 1 auto; min-height: 0; }
  /* splice editor: "How to use" folds into one row at the bottom */
  .sp-info { display: flex; flex-direction: column; }
  .sp-info .sp-howto { order: 99; }
}
.sp-howto summary { cursor: pointer; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.sp-howto summary::after { content: " ▸"; margin-left: 4px; }
.sp-howto[open] summary::after { content: " ▾"; }
.sp-howto summary::-webkit-details-marker { display: none; }
.sp-howto summary { list-style: none; }

/* ---------- 1.3: patch panels, reroute, history in the edit flyout ---------- */
table.panels td { vertical-align: middle; padding: 3px 4px; }
table.panels input { width: 100%; min-width: 0; padding: 3px 6px; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; }
table.panels select, #ed-pp-size { min-height: 0; padding: 2px 4px; font-size: 12px; }
.history { list-style: none; margin: 0 0 6px; padding: 0; font-size: 12.5px; }
.history > li { border-left: 2px solid var(--line); padding: 2px 0 6px 10px; margin-left: 3px; }
.history > li.h-origin { border-left-style: dashed; }
.history .h-meta { display: flex; flex-direction: column; }
.history .h-meta small { font-size: 11.5px; }
.history ul { margin: 2px 0 0; padding-left: 16px; color: var(--muted); }
.history s { opacity: .7; }
