/* Layout: one-screen ops tool. Header with search, map on the left, focus and detail panel on the right; stacks on phones. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #16202b;
  --muted: #5a6877;
  --line: #dde3ea;
  --nav-bg: #101a26; --nav-ink: #c3cedb; --nav-muted: #7b8a9c; --nav-hover: #1a2636; --nav-on: #22324a;
  --shadow: 0 1px 2px rgb(16 26 38 / 0.06), 0 1px 3px rgb(16 26 38 / 0.04);
  --accent: #2456c4;
  --accent-ink: #ffffff;
  --node: #ffffff;
  --node-edge: #4b5a6a;
  --good: #23824f;
  --critical: #d03434;
  --warning: #b77b00;
  --layer-physical: #8794a2;
  --layer-ospf: #2f7dd6;
  --layer-ospfv3: #5b9fe6;
  --layer-isis: #7a55d4;
  --layer-eigrp: #0b8aa8;
  --layer-bgp: #c27510;
  --layer-ldp: #16897c;
  --layer-rsvp-lsp: #b1367b;
  --layer-te-tunnel: #9246c4;
  --layer-vrrp: #3d8a37;
  --layer-hsrp: #3d8a37;
  --layer-pim: #6e7d18;
  --layer-lacp: #4a5563;
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141b; --surface: #151d26; --surface-2: #121922; --ink: #e3e9ef; --muted: #91a0b0; --line: #283340;
    --nav-bg: #0a1017; --nav-hover: #141e2a; --nav-on: #1c2a3d; --shadow: none;
    --accent: #6f9bff; --accent-ink: #0e141b; --node: #1b2530; --node-edge: #9fb0c2;
    --good: #4cc387; --critical: #ff6b6b; --warning: #e0a52a;
    --layer-physical: #6f7d8c; --layer-ospf: #5aa2f5; --layer-ospfv3: #84bdf7; --layer-isis: #a185f0;
    --layer-eigrp: #38b9d6; --layer-bgp: #f0a13d; --layer-ldp: #3cc2b1; --layer-rsvp-lsp: #e464a8;
    --layer-te-tunnel: #bd7cf0; --layer-vrrp: #6cc263; --layer-hsrp: #6cc263; --layer-pim: #a9bb44; --layer-lacp: #8a96a3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141b; --surface: #151d26; --surface-2: #121922; --ink: #e3e9ef; --muted: #91a0b0; --line: #283340;
  --nav-bg: #0a1017; --nav-hover: #141e2a; --nav-on: #1c2a3d; --shadow: none;
  --accent: #6f9bff; --accent-ink: #0e141b; --node: #1b2530; --node-edge: #9fb0c2;
  --good: #4cc387; --critical: #ff6b6b; --warning: #e0a52a;
  --layer-physical: #6f7d8c; --layer-ospf: #5aa2f5; --layer-ospfv3: #84bdf7; --layer-isis: #a185f0;
  --layer-eigrp: #38b9d6; --layer-bgp: #f0a13d; --layer-ldp: #3cc2b1; --layer-rsvp-lsp: #e464a8;
  --layer-te-tunnel: #bd7cf0; --layer-vrrp: #6cc263; --layer-hsrp: #6cc263; --layer-pim: #a9bb44; --layer-lacp: #8a96a3;
  color-scheme: dark;
}

html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font-sans);
  display: flex; flex-direction: column; min-height: 0;
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--font-mono); }
.small { font-size: 12px; }

.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.mark {
  width: 18px; height: 18px; border-radius: 4px; background:
    radial-gradient(circle at 25% 30%, var(--accent) 0 3px, transparent 3.5px),
    radial-gradient(circle at 75% 30%, var(--accent) 0 3px, transparent 3.5px),
    radial-gradient(circle at 50% 78%, var(--accent) 0 3px, transparent 3.5px),
    linear-gradient(var(--line), var(--line));
}
.name { font-weight: 600; letter-spacing: 0.01em; }
.source {
  font: 500 11px var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
}
.search { position: relative; flex: 1 1 360px; min-width: 0; }
.search input {
  width: 100%; box-sizing: border-box; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); font-family: var(--font-mono); font-size: 13px;
}
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; max-height: min(60vh, 520px); overflow: auto;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);
}
.res-head, .res-foot { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 6px 8px 4px; }
.res-foot { text-transform: none; letter-spacing: 0; text-align: right; }
.res { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; border-radius: 6px; padding: 6px 8px; text-align: left; background: none; }
.res:hover, .res:focus-visible { background: var(--bg); }
.res-main { font-family: var(--font-mono); font-size: 13px; }
.res-sub { color: var(--muted); font-size: 12px; }
.res.bad .res-main::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--critical); margin-right: 6px; vertical-align: 1px; }
.stats { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.work { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.canvas { position: relative; min-width: 0; min-height: 0; }
#cy { position: absolute; inset: 0; }
.toolbar {
  position: absolute; top: 12px; left: max(12px, env(safe-area-inset-left, 0px)); display: flex; gap: 8px; flex-wrap: wrap;
}
.toolbar select, .toolbar > button, .hops { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.toolbar select { padding: 5px 8px; }
.hops { display: flex; align-items: center; gap: 2px; padding: 0 4px; }
.hops button { border: 0; background: none; padding: 4px 8px; font-size: 16px; line-height: 1; }
.hops .lbl { font-size: 12px; color: var(--muted); padding-left: 4px; }
.hops .val { font: 500 13px var(--font-mono); min-width: 1.2em; text-align: center; }
.canvas > .status {
  position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); right: 12px; bottom: 10px; margin: 0;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.canvas > .status.warn { color: var(--warning); }

.panel {
  border-left: 1px solid var(--line); background: var(--surface); overflow: auto; min-height: 0;
  padding-right: env(safe-area-inset-right, 0px);
}
.block { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
h2 { font-size: 13px; font-weight: 600; margin: 0; text-wrap: balance; }
h2.mono { font-size: 15px; }
h3 { font-size: 12px; font-weight: 600; margin: 4px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--accent); border-radius: 999px; overflow: hidden; }
.chip button { border: 0; border-radius: 0; background: none; padding: 2px 8px; }
.chip-name { font: 12px var(--font-mono); }
.chip-x { color: var(--muted); padding-left: 2px !important; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.examples button { font: 11px var(--font-mono); padding: 2px 8px; border-radius: 999px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--font-mono); overflow-wrap: anywhere; }
.adj { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.adj li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; font-size: 12px; }
.adj .extra { grid-column: 2 / -1; color: var(--muted); font-family: var(--font-mono); font-size: 11px; overflow-wrap: anywhere; }
.adj .extra:empty { display: none; }
.peer { border: 0; background: none; padding: 0; font-family: var(--font-mono); text-align: left; color: var(--accent); overflow-wrap: anywhere; }
.tag {
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--c); padding-left: 6px; color: var(--ink);
}
.pill { font: 500 11px var(--font-mono); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pill.ok { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.pill.bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 14%, transparent); }
.count { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.blast { background: color-mix(in srgb, var(--critical) 6%, var(--surface)); }
.layers { display: grid; gap: 4px; }
.layer { display: grid; grid-template-columns: auto 14px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.swatch { width: 14px; height: 3px; background: var(--c); border-radius: 2px; }
.layer .count { font-size: 12px; }

@media (max-width: 760px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .canvas { height: 62vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); padding-left: env(safe-area-inset-left, 0px); }
  .stats { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- views, settings and incidents ------------------------------------------------------- */
.who { font-size: 12px; color: var(--muted); white-space: nowrap; }
.who a { color: var(--accent); }
.page { flex: 1; overflow: auto; min-height: 0; padding: 0 28px 32px; }
.empty-state { max-width: 640px; margin: 40px auto; }
.empty-state pre { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font: 12px var(--font-mono); }
.sbody { display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 1400px; }
.shead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.shead h2 { font-size: 18px; }
.shead .hint { max-width: 72ch; margin-top: 4px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.off td { color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
td .sub { color: var(--muted); font: 11px var(--font-sans); margin-top: 2px; }
td.row-actions, td.order { white-space: nowrap; text-align: right; }
td.order { text-align: left; }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger { border-color: var(--critical); color: var(--critical); }
.kind { font: 500 11px var(--font-mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.kind[data-kind="netbox"] { border-color: var(--accent); color: var(--accent); }
.bad { color: var(--critical); }
.ok { color: var(--good); }
.error { color: var(--critical); margin: 0; white-space: pre-wrap; }
.empty { color: var(--muted); margin: 0; padding: 16px; border: 1px dashed var(--line); border-radius: 8px; }
.editor { border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.editor-head { display: flex; justify-content: space-between; align-items: center; }
.editor-head h3 { margin: 0; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide, .wide { grid-column: 1 / -1; }
.field-label { font-size: 12px; font-weight: 600; }
.field-hint { font-size: 11px; color: var(--muted); }
.field input:not([type="checkbox"]), .field select, .field textarea, .inline input, .inline select {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--bg); min-width: 0; }
.field textarea { font: 12px var(--font-mono); resize: vertical; }
.field input[type="checkbox"] { width: 16px; height: 16px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.roles, .profiles { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.role { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.order { color: var(--accent); font: 500 11px var(--font-mono); }
.explain { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.explain-out ol { margin: 8px 0 0; padding-left: 20px; }
.status-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.kv .k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kv .v { font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.errors p { margin: 2px 0; font-size: 12px; }
.settings-form { display: flex; flex-direction: column; gap: 12px; }
.pollers { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.poller { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 6px; width: 100%; }
.poller input { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: var(--bg); min-width: 0; }
.drift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.drift { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--surface); min-width: 0; }
.drift h3 { margin: 0; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.drift ul { margin: 8px 0 0; padding-left: 18px; max-height: 260px; overflow: auto; }
.test-out .sub { color: var(--muted); font-size: 12px; }
.toast { position: fixed; z-index: 50; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; max-width: 90vw; white-space: pre-wrap; }
.toast.bad { background: var(--critical); color: #fff; }

.incidents { max-width: 1400px; display: flex; flex-direction: column; gap: 14px; }
.inc-list { display: flex; flex-direction: column; gap: 10px; }
.inc { border: 1px solid var(--line); border-left: 4px solid var(--critical); border-radius: 8px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.inc.resolved { border-left-color: var(--good); opacity: 0.8; }
.inc.sim { border-left-style: dashed; border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.inc-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.inc-title h3 { margin: 0; font-size: 15px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink); }
.inc-side { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.layer { font: 500 11px var(--font-mono); padding: 2px 8px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.layer[data-layer="node"] { color: var(--critical); border-color: var(--critical); }
.layer[data-layer="physical"] { color: var(--warning); border-color: var(--warning); }
.layer[data-layer="igp"] { color: var(--layer-ospf); border-color: var(--layer-ospf); }
.layer[data-layer="bgp"] { color: var(--layer-bgp); border-color: var(--layer-bgp); }
.layer[data-layer="mpls"] { color: var(--layer-ldp); border-color: var(--layer-ldp); }
.conf { font: 600 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; border: 1px dashed var(--muted); color: var(--muted); border-radius: 999px; padding: 1px 8px; }
.inc-body .cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.inc-body h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.inc-body ul { margin: 0; padding-left: 18px; font-size: 13px; }
.sim { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.sim summary { cursor: pointer; font-weight: 600; }
.sim .inline { margin-top: 8px; }
.sim input { flex: 1 1 260px; font-family: var(--font-mono); }

@media (max-width: 760px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .sub { flex-direction: row; flex-wrap: wrap; position: static; }
  .inc-head { grid-template-columns: minmax(0, 1fr); }
  .inc-side { justify-content: flex-start; }
  .poller { grid-template-columns: 1fr 1fr; }
}
.inc-head > .layer { justify-self: start; }
.inc-body td.mono, .inc-body td:first-child { white-space: nowrap; overflow-wrap: normal; }

/* zoom to area */
#zoom-box { position: absolute; z-index: 3; pointer-events: none; border: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 2px; }
#cy.zoom-armed { cursor: crosshair; touch-action: none; }
#zoom-area[aria-pressed="true"], #vendors[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.canvas > .status { background: color-mix(in srgb, var(--bg) 88%, transparent); padding: 2px 6px; border-radius: 4px; z-index: 2; }

/* devices */
.devices { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; max-width: 1400px; }
.facets { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; box-shadow: var(--shadow); }
table.devlist td.mono { white-space: nowrap; }
.dmain { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dmain .actions { display: flex; gap: 8px; align-items: center; }
.dmain .actions input[type=search] { min-width: 260px; }
.facets { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; align-self: start; }
.facets h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.facet { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; font-size: 13px; padding: 2px 0; cursor: pointer; }
.facet .count { color: var(--muted); font: 11px var(--font-mono); }
table.devlist tbody tr { cursor: pointer; }
table.devlist tbody tr:hover td { background: var(--bg); }
/* device status: a coloured dot and the word (never colour alone) */
.status { font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
.status.s-up::before { background: var(--good); }
.status.s-down { color: var(--critical); font-weight: 500; }
.status.s-down::before { background: var(--critical); box-shadow: 0 0 0 3px color-mix(in srgb, var(--critical) 20%, transparent); }
.status.s-not-seen { color: var(--muted); }
.status.s-not-seen::before { background: var(--warning); }
.status.s-not-polled { color: var(--muted); }
.status.s-not-polled::before { border: 1.5px solid var(--muted); }
@media (max-width: 760px) {
  .devices { grid-template-columns: 1fr; }
  .facets { position: static; flex-direction: row; flex-wrap: wrap; }
  .dmain .actions input[type=search] { min-width: 0; width: 100%; }
}

/* link details on hover */
.edge-tip { position: absolute; z-index: 5; pointer-events: none; max-width: 340px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font: 12px var(--font-mono); line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.edge-tip strong { display: block; font-family: var(--font-sans, inherit); font-size: 12px; margin-bottom: 2px; }
.sbody h3.group { margin: 20px 0 8px; font-size: 15px; }
.facts dd.wide { grid-column: 1 / -1; margin: 6px 0 0; }
details.override summary { cursor: pointer; color: var(--muted, #666); font-size: 12px; }
form.ov { display: grid; gap: 6px; margin-top: 6px; }
form.ov label { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 6px; font-size: 12px; }

/* ---- app shell: side navigation, header, page title bar ----------------------------------- */
body { display: block; height: 100%; }
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.app.narrow { grid-template-columns: 60px minmax(0, 1fr); }
.sidenav { background: var(--nav-bg); color: var(--nav-ink); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sidenav .brand { padding: 16px 18px 14px; gap: 10px; border-bottom: 1px solid rgb(255 255 255 / 0.06); }
.sidenav .name { color: #fff; font-size: 15px; }
.sidenav .source { color: var(--nav-muted); border-color: rgb(255 255 255 / 0.14); }
.sidenav .mark { width: 26px; height: 26px; flex: none; background: none; }
.mark svg { width: 100%; height: 100%; display: block; }
.mark svg title { display: none; }
.name-rca { font-weight: 400; opacity: 0.85; }
.nav-list { flex: 1; overflow-y: auto; padding: 8px 10px; }
.nav-group { margin-bottom: 10px; }
.nav-label { font: 600 11px var(--font-sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--nav-muted); padding: 10px 10px 6px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 6px; color: var(--nav-ink); text-decoration: none; font-size: 14px; position: relative; white-space: nowrap; }
.nav-item:hover { background: var(--nav-hover); color: #fff; }
.nav-item[aria-current="page"] { background: var(--nav-on); color: #fff; font-weight: 500; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: #7aa5ff; }
.nav-item:focus-visible { outline: 2px solid #7aa5ff; outline-offset: -2px; }
.nav-icon { display: inline-flex; flex: none; opacity: 0.9; }
.nav-badge { margin-left: auto; background: var(--critical); color: #fff; font: 600 11px var(--font-sans); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.nav-collapse { margin: 8px 10px 12px; align-self: flex-start; background: none; border: 0; color: var(--nav-muted); padding: 6px; border-radius: 6px; display: inline-flex; }
.nav-collapse:hover { background: var(--nav-hover); color: #fff; }
.app.narrow .nav-text, .app.narrow .nav-label, .app.narrow .sidenav .name, .app.narrow .sidenav .source { display: none; }
.app.narrow .nav-collapse svg { transform: rotate(180deg); }
.app.narrow .nav-group { border-top: 1px solid rgb(255 255 255 / 0.06); padding-top: 8px; }
.app.narrow .nav-group:first-child { border-top: 0; }
.app.narrow .nav-badge { position: absolute; top: 1px; right: 0; padding: 0 5px; line-height: 15px; font-size: 10px; }
.app.narrow .sidenav .brand { padding-inline: 19px; }

.appmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { gap: 12px; flex-wrap: nowrap; padding: 10px 20px; min-height: 56px; box-sizing: border-box; }
.search { flex: 0 1 560px; display: flex; align-items: center; }
.search-icon { position: absolute; left: 10px; color: var(--muted); display: inline-flex; pointer-events: none; }
.search input { padding: 8px 64px 8px 36px; font-family: var(--font-sans); font-size: 14px; background: var(--surface-2); }
.kbd { position: absolute; right: 8px; font: 500 11px var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; background: var(--surface); pointer-events: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-right .pill { text-decoration: none; font: 500 12px var(--font-sans); padding: 4px 10px; border: 1px solid transparent; }
.top-right .pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: 1px; }
.pill.run { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pill.warn { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 8px; color: var(--muted); }
.iconbtn:hover { color: var(--ink); }
.nav-open { display: none; }
.work { border-top: 0; }
.map-head { position: absolute; bottom: 42px; right: 14px; z-index: 3; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; box-shadow: var(--shadow); }

.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 22px 0 18px; max-width: 1400px; }
.ph-text { min-width: 0; }
.crumbs { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.crumbs .sep { opacity: 0.6; }
.pagehead h1 { font-size: 22px; font-weight: 600; margin: 4px 0 0; letter-spacing: -0.005em; }
.ph-desc { margin: 6px 0 0; color: var(--muted); font-size: 13px; max-width: 90ch; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button.primary:hover { filter: brightness(1.08); }

@media (max-width: 900px) {
  .app, .app.narrow { grid-template-columns: minmax(0, 1fr); }
  .sidenav { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform 0.18s ease; }
  .app.nav-shown .sidenav { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.35); }
  .nav-open { display: inline-flex; }
  .nav-collapse { display: none; }
  .top { padding: 8px 12px; }
  .kbd, .top-right .pill { display: none; }
  .page { padding: 0 16px 24px; }
}
.app.demo { grid-template-columns: minmax(0, 1fr); } .app.demo .sidenav, .app.demo .top-right .pill { display: none; }

/* ---- buttons as links, cards, dashboard ---------------------------------------------------- */
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; font-size: 14px; }
a.btn:hover { border-color: var(--muted); }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.good { background: var(--good); } .dot.bad { background: var(--critical); } .dot.warn { background: var(--warning); }
.dot.sim { background: none; border: 2px dashed var(--muted); width: 5px; height: 5px; } .dot.off { background: var(--line); }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; max-width: 1400px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; min-width: 0; }
.kpi:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; max-width: 1400px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.span-4 { grid-column: span 4; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-12 { grid-column: span 12; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-link { font-size: 12px; color: var(--accent); text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.empty-ok { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); min-height: 180px; }

.dl-list { display: flex; flex-direction: column; }
.dl-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 9px 6px;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; border-radius: 4px; }
.dl-row.int { grid-template-columns: 10px minmax(0, 1fr) auto; }
.dl-row:last-child { border-bottom: 0; }
.dl-row:hover { background: var(--surface-2); }
.dl-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-meta { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.health { display: flex; flex-direction: column; gap: 9px; }
.health-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: 13px; }
.meter { display: flex; gap: 2px; height: 8px; }
.meter-ok { background: var(--good); border-radius: 4px; min-width: 2px; }
.meter-bad { background: var(--critical); border-radius: 4px; min-width: 4px; }
.health-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.bad-text { color: var(--critical); font-weight: 500; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.legend .key { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.legend .key:first-child { margin-left: 0; }
.key.key-real { background: var(--accent); }
.key.key-sim { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.legend-stats { margin-left: auto; }
.chart { position: relative; }
svg.trend { width: 100%; height: auto; display: block; overflow: visible; }
.trend .bar-real { fill: var(--accent); }
.trend .bar-sim { fill: color-mix(in srgb, var(--muted) 45%, transparent); }
.trend .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.trend .axis { stroke: var(--line); }
.trend .tick { fill: var(--muted); font: 11px var(--font-sans); }
.trend .hit { fill: transparent; }
.trend .hit:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.14); pointer-events: none; white-space: nowrap; }

.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 36px; gap: 10px; align-items: center; font-size: 13px; }
.hbar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 8px; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.cov { display: flex; flex-direction: column; gap: 14px; }
.cov-z { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; }
.cov-big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-k { font-size: 12px; color: var(--muted); }
.stat-v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span-4 { grid-column: span 6; } .span-8 { grid-column: span 12; } }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi-value { font-size: 22px; } .span-4, .span-6 { grid-column: span 12; } }

.ph-actions input[type=search], .ph-actions input:not([type]) { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-width: 260px; }
table.devlist { font-size: 13px; }
table.devlist td, table.devlist th { padding: 8px 10px; }
table.devlist td:last-child, table.devlist th:last-child { white-space: nowrap; }
.devices { grid-template-columns: 180px minmax(0, 1fr); gap: 16px; }

.sim-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 1400px; box-sizing: border-box; margin-bottom: 16px; padding: 10px 14px;
  border: 1px dashed var(--muted); border-radius: 8px; background: var(--surface); font-size: 13px; }
.sim-tag { font: 600 11px var(--font-sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.sim-text { flex: 1; min-width: 240px; }
a.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
.overview { margin: 0; font-size: 13px; }

.rca-legend { position: absolute; right: 14px; top: 62px; z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); padding: 10px 12px; font-size: 12px; max-width: 340px; display: flex; flex-direction: column; gap: 8px; }
.lg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.lg-head strong { font-size: 13px; color: var(--critical); }
.lg-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.lg { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.lg-key { flex: none; display: inline-block; }
.lg-key.root { width: 10px; height: 10px; border-radius: 50%; background: var(--critical); box-shadow: 0 0 0 4px color-mix(in srgb, var(--critical) 30%, transparent); }
.lg-key.failed { width: 18px; border-top: 3px solid var(--critical); }
.lg-key.affected { width: 10px; height: 10px; border-radius: 3px; border: 2.5px solid var(--warning); box-sizing: border-box; }
.lg-key.behind { width: 18px; border-top: 3px dotted var(--warning); }
@media (prefers-reduced-motion: reduce) { .lg-key.root { box-shadow: none; } }

/* device panel: open incidents the device is in */
.d-inc { display: flex; flex-direction: column; gap: 8px; }
.d-inc-row { border: 1px solid var(--line); border-left: 4px solid var(--warning); border-radius: 6px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--warning) 7%, var(--surface)); }
.d-inc-row.root { border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 7%, var(--surface)); }
.d-inc-row.sim { border-left-style: dashed; }
.d-inc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.d-inc-role { font: 600 11px var(--font-sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--warning); }
.d-inc-row.root .d-inc-role { color: var(--critical); }
.d-inc-title { color: var(--ink); font-weight: 600; text-decoration: none; font-size: 13px; }
.d-inc-title:hover { text-decoration: underline; }
.d-inc-sub { color: var(--muted); font-size: 12px; }
.d-inc-act { display: flex; gap: 6px; }

/* incident card: impact column */
.inc-head { grid-template-columns: 96px minmax(0, 1fr) 290px 400px !important; }
.inc-head > .inc-side { justify-content: flex-end; }
@media (max-width: 1250px) { .inc-head { grid-template-columns: 96px minmax(0, 1fr) 240px auto !important; } }
.impact { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
.impact-row { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; }
.impact-n { font-size: 20px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; grid-row: span 2; align-self: center; min-width: 2ch; }
.impact-row.unr .impact-n { color: var(--muted); }
.impact-label { font-size: 12px; color: var(--muted); }
.impact-kinds { font-size: 12px; color: var(--ink); grid-column: 2; max-width: 260px; }
@media (max-width: 760px) { .inc-head { grid-template-columns: auto minmax(0, 1fr) !important; } .impact { grid-column: 1 / -1; border: 0; padding: 0; } }

.d-inc-row.unr { border-left-color: var(--muted); background: color-mix(in srgb, var(--muted) 7%, var(--surface)); }
.d-inc-row.unr .d-inc-role { color: var(--muted); }
.lg-key.unreach { width: 10px; height: 10px; border-radius: 3px; border: 2px dashed var(--muted); box-sizing: border-box; }
.lg-key.behind { border-top-color: var(--muted); }

.impact-row.noexit .impact-n { color: var(--warning); }
.impact-row.risk .impact-n { color: var(--muted); font-weight: 500; }
.d-inc-row.noexit, .d-inc-row.risk { border-left-color: var(--warning); }
.d-inc-row.risk { background: var(--surface); }
.lg-key.noexit { width: 10px; height: 10px; border-radius: 3px; border: 2.5px dotted var(--warning); box-sizing: border-box; }
