:root {
  --bg: #0e1116; --panel: #151a21; --panel2: #1b222b; --line: #2a333e; --text: #e6ebf1; --muted: #8b97a6;
  --accent: #4cc2ff; --ok: #3ecf8e; --warn: #f5b84a; --bad: #ff6b6b; --unk: #8b97a6; --stale: #c792ea;
  --rf: #4cc2ff; --fiber: #f5b84a; --fdb: #9aa7b8; --sub: #3ecf8e;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); display: grid;
  grid-template: "top top" 52px "side main" 1fr / 168px 1fr; height: 100vh; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--accent); color: #04121b; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { border-color: var(--accent); }
input, select { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--muted); }
.top { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--accent); font-weight: 700; }
.logo { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--accent); position: relative; display: inline-block; }
.logo::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 2px; background: var(--accent); transform-origin: 0 50%; transform: rotate(-35deg); }
.rev { color: var(--muted); font-size: 12px; white-space: nowrap; }
#search { flex: 1; max-width: 420px; margin-left: auto; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.who form { margin: 0; }
.side { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.side button { background: transparent; color: var(--muted); text-align: left; font-weight: 500; padding: 9px 12px; }
.side button.active, .side button:hover { background: var(--panel2); color: var(--text); }
.side button.active { box-shadow: inset 3px 0 0 var(--accent); }
main { grid-area: main; overflow: auto; position: relative; }
.view { display: none; padding: 16px; }
.view.active { display: block; }
#view-topology.active { display: flex; flex-direction: column; height: 100%; padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.tile .v { font-size: 26px; font-weight: 700; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); cursor: default; }
.list li:last-child { border-bottom: 0; }
.list li.click { cursor: pointer; }
.list li.click:hover { color: var(--accent); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; }
table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr.click { cursor: pointer; }
table.grid tr.click:hover td { background: var(--panel2); }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.st-up, .st-fresh, .st-confirmed, .st-ok { color: var(--ok); }
.st-down, .st-failed { color: var(--bad); }
.st-degraded, .st-observed, .st-waiting_for_input { color: var(--warn); }
.st-stale, .st-historical { color: var(--stale); }
.st-unknown, .st-unavailable, .st-reachable { color: var(--unk); }
.st-inferred, .st-candidate { color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar label { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.seg-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.spacer { flex: 1; }
.canvas-wrap { flex: 1; position: relative; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; cursor: grab; background:
  radial-gradient(circle, #1d2530 1px, transparent 1px) 0 0 / 22px 22px; }
#canvas.drag { cursor: grabbing; }
.legend { position: absolute; left: 12px; bottom: 12px; background: rgba(21,26,33,.94); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; grid-template-columns: auto auto; gap: 4px 10px; align-items: center; }
.legend svg { width: 44px; height: 10px; }
.node rect { fill: var(--panel2); stroke: var(--line); stroke-width: 1.2; }
.node.sel rect { stroke: var(--accent); stroke-width: 2; }
.node.match rect { stroke: var(--warn); stroke-width: 2; }
.node text { fill: var(--text); font-size: 12px; }
.node text.sub { fill: var(--muted); font-size: 10.5px; }
.node .glyph { font-size: 11px; font-weight: 700; }
.node .badge { font-size: 10px; font-weight: 700; }
.node { cursor: pointer; }
.node .tog { fill: var(--muted); font-size: 12px; font-weight: 700; }
.edge { fill: none; stroke-width: 1.6; }
.edge.t-wireless_peer { stroke: var(--rf); }
.edge.t-mac_reachable_via_port { stroke: var(--fdb); }
.edge.t-pon_contains_onu { stroke: var(--fiber); }
.edge.t-subscriber_candidate { stroke: var(--sub); }
.edge.t-same_segment, .edge.t-tree { stroke: #3a4552; }
.edge.s-confirmed { stroke-width: 2.4; }
.edge.s-observed { stroke-dasharray: none; }
.edge.s-inferred { stroke-dasharray: 7 5; }
.edge.s-reachable { stroke-dasharray: 2 5; opacity: .55; }
.edge.s-candidate { stroke-dasharray: 3 3; }
.edge.extra { opacity: .8; }
.elabel { fill: var(--muted); font-size: 10px; }
.detail { position: fixed; right: 0; top: 52px; bottom: 0; width: 420px; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; padding: 16px; box-shadow: -10px 0 30px rgba(0,0,0,.35); z-index: 5; }
.detail h3 { margin: 0 0 4px; font-size: 18px; }
.detail h4 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.detail .close { position: absolute; right: 12px; top: 12px; padding: 2px 8px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.detail a, .card a { color: var(--accent); text-decoration: none; font-weight: 600; }
.detail a:hover { text-decoration: underline; }
.ev { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; font-size: 12px; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.chatlog { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 10px; }
.msg { max-width: 88%; padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; font-size: 13px; }
.msg.you { align-self: flex-end; background: #12384d; }
.msg.radar { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); }
.msg.event { align-self: flex-start; background: transparent; color: var(--muted); border-left: 2px solid var(--line); border-radius: 0; padding: 2px 10px; font-size: 12px; }
.msg.event.question { color: var(--warn); border-color: var(--warn); }
.chatform { display: flex; gap: 8px; }
.chatform input { flex: 1; }
.notice { background: #3a2a10; border: 1px solid var(--warn); color: var(--warn); padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; }
body.login { display: grid; place-items: center; grid-template: none; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.toolbar.flat { background: transparent; border: 0; padding: 0 0 10px; }
h2.inline { margin: 0; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
button:disabled { opacity: .45; cursor: not-allowed; }
dialog.wizard { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(620px, 94vw); padding: 18px 20px; }
dialog.wizard::backdrop { background: rgba(0,0,0,.55); }
dialog.wizard h3 { margin: 0 0 6px; }
dialog.wizard fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0 0; padding: 8px 12px 10px; }
dialog.wizard legend { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 0 4px; }
dialog.wizard label.row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
dialog.wizard .ad-override { display: flex; gap: 8px; margin: 4px 0 0 24px; }
dialog.wizard .ad-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.small { font-size: 12px; margin: 6px 0 0; }
.kc-form { display: flex; flex-direction: column; gap: 10px; }
.kc-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.kc-form fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.kc-form legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.kc-fams { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.kc-fams label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.incident { border: 1px solid var(--line); border-left: 3px solid var(--bad); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
@media (max-width: 900px) { body { grid-template: "top" 52px "side" auto "main" 1fr / 1fr; } .side { flex-direction: row; overflow: auto; } .cols { grid-template-columns: 1fr; } .detail { width: 100%; } }
