:root {
  --side-w: 252px; --side-bg: #0d1b2a; --side-text: #b8c7d6; --side-muted: #6f8499; --side-hover: rgba(255,255,255,.06); --side-active: rgba(79,179,209,.16);
  --bg: #f3f5f8; --panel: #fff; --panel-2: #f8fafb; --line: #e3e8ed; --text: #17212b; --muted: #637282;
  --brand: #0f6e8c; --brand-soft: #e3f2f6;
  --up: #1f8a4c; --up-soft: #e3f4ea; --down: #c62f2f; --down-soft: #fbe6e6;
  --warn: #b26a00; --warn-soft: #fdf1dc; --new: #3159c9; --new-soft: #e6ecfb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b; --panel: #161e26; --panel-2: #1b252f; --line: #26323e; --text: #e4eaf0; --muted: #8b9bab;
    --brand: #4fb3d1; --brand-soft: #15303a;
    --up: #4cc67f; --up-soft: #153325; --down: #ef6b6b; --down-soft: #3a1c1e;
    --warn: #f0a83a; --warn-soft: #3a2c14; --new: #7d9cf5; --new-soft: #1d2643;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; cursor: pointer;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }
.btn.small { padding: 3px 8px; font-size: 12px; }
#refreshBtn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

.demo-bar, .error-bar { padding: 8px 24px; font-size: 13px; }
.demo-bar { background: var(--new-soft); color: var(--new); }
.error-bar { background: var(--down-soft); color: var(--down); }
.error-bar code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

main { padding: 22px 28px 56px; max-width: 1560px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.note, .hint { color: var(--muted); font-size: 12.5px; }
.hint { margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi > span { display: block; color: var(--muted); font-size: 12px; }
.kpi b { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi.up b { color: var(--up); } .kpi.down b { color: var(--down); } .kpi.warn b { color: var(--warn); }
.kpi small { color: var(--muted); font-size: 11px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 14px; }
.toolbar input[type=search] {
  font: inherit; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); min-width: 240px;
}
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* lines */
.line { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.line-head { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.line-head h2 { margin: 0; font-size: 15px; }
.line-head .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 14px; flex-wrap: wrap; }
.line-head .meta b { color: var(--text); font-weight: 600; }
.line-head .bar { flex: 1; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); max-width: 220px; margin-inline-start: auto; }
.bar i { display: block; height: 100%; }
.bar .b-up { background: var(--up); } .bar .b-warn { background: var(--warn); } .bar .b-down { background: var(--down); }
.chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; padding: 16px; row-gap: 14px; }
.node-router {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  width: 74px; border-radius: 10px; border: 1px dashed var(--line); color: var(--muted); font-size: 11.5px; padding: 8px;
}
.node-router svg { width: 22px; height: 22px; color: var(--brand); }
.link { width: 22px; align-self: center; height: 2px; background: var(--line); position: relative; }
.link.dead { background: repeating-linear-gradient(90deg, var(--down) 0 4px, transparent 4px 8px); }

.ap {
  position: relative; width: 210px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 8px;
  background: var(--panel); cursor: pointer; text-align: start; font: inherit; color: inherit;
  border-top: 3px solid var(--up); transition: transform .12s, box-shadow .12s;
}
.ap:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,24,40,.1); }
.ap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ap.down { border-top-color: var(--down); background: linear-gradient(var(--down-soft), var(--panel) 60%); }
.ap.degraded { border-top-color: var(--warn); }
.ap .row1 { display: flex; align-items: center; gap: 8px; }
.pos { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.ap .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap .ip { color: var(--muted); font-size: 12px; }
.ap .noreply { margin-top: 6px; font-size: 11px; color: var(--down); background: var(--down-soft); border-radius: 6px; padding: 3px 6px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.degraded { background: var(--warn-soft); color: var(--warn); }
.badge.new { background: var(--new-soft); color: var(--new); }
.badge.muted { background: var(--panel-2); color: var(--muted); font-weight: 500; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 8px 0 4px; }
.metrics div { font-size: 11px; color: var(--muted); }
.metrics b { display: block; white-space: nowrap; font-size: 14px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.metrics b.warn { color: var(--warn); } .metrics b.bad { color: var(--down); }
.spark { width: 100%; height: 30px; display: block; }
.spark .p { stroke: var(--brand); stroke-width: 1.6; }
.spark .x { stroke: var(--down); stroke-width: 2; }
.spark .t { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.ap .foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

/* table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 6px 10px; font-size: 13px; }

/* build */
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.build-line h3 { display: flex; justify-content: space-between; align-items: center; }
.build-list { list-style: none; margin: 0; padding: 0; }
.build-list li {
  display: grid; grid-template-columns: 18px 26px 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--panel);
}
.build-list li.drag { opacity: .4; }
.build-list li.over { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.build-list li.isnew { border-color: var(--new); }
.handle { cursor: grab; color: var(--muted); user-select: none; text-align: center; letter-spacing: -2px; }
.build-list input { font: inherit; width: 100%; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: var(--panel-2); color: var(--text); }
.build-list input:focus { border-color: var(--brand); outline: none; background: var(--panel); }
.build-list .ipcell { color: var(--muted); font-size: 12px; }
.arrows { display: flex; gap: 2px; }
.arrows button { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); cursor: pointer; font-size: 11px; padding: 0; }
.arrows button:hover:not(:disabled) { color: var(--brand); border-color: var(--brand); }
.arrows button:disabled { opacity: .3; cursor: default; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.msg.ok { background: var(--up-soft); color: var(--up); }
.msg.bad { background: var(--down-soft); color: var(--down); }

/* connection */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-all; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(10, 15, 20, .35); z-index: 20; display: flex; justify-content: flex-start; }
.drawer-panel { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--panel); padding: 22px 24px; position: relative; box-shadow: 0 0 30px rgba(0,0,0,.2); }
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.close { position: absolute; inset-inline-end: 16px; top: 14px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.chart { width: 100%; height: 220px; margin: 12px 0; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); stroke: none; font-size: 10px; }
.chart .p { stroke: var(--brand); stroke-width: 1.8; }
.chart .x { stroke: var(--down); stroke-width: 3; }
.chart .t { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 4; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 20px; width: min(380px, 92vw); }
dialog::backdrop { background: rgba(10, 15, 20, .45); }
dialog input { width: 100%; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
dialog menu { padding: 0; margin: 14px 0 0; display: flex; justify-content: flex-end; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  main { padding: 14px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .ap { width: 100%; }
  .link, .node-router { display: none; }
  .chain { gap: 10px; }
  .build-grid { grid-template-columns: 1fr; }
}

/* ---------- topology ---------- */
.toggles { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.toggles label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.topo-wrap {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; height: 640px; margin-bottom: 16px;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px;
}
.topo-wrap:fullscreen { height: 100vh; border-radius: 0; }
#topo { width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#topo.panning { cursor: grabbing; }
.legend {
  position: absolute; bottom: 10px; inset-inline-start: 10px; inset-inline-end: 10px; display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-size: 12px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; pointer-events: none;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.lg.up { background: var(--up); } .lg.degraded { background: var(--warn); }
.lg.down { background: repeating-linear-gradient(90deg, var(--down) 0 4px, transparent 4px 7px); }
.lg.conf { background: repeating-linear-gradient(90deg, #d9480f 0 5px, transparent 5px 8px); }
.q { font-size: 11px; padding: 0 6px; border-radius: 999px; font-weight: 600; }
.q.good { background: var(--up-soft); color: var(--up); } .q.fair { background: var(--warn-soft); color: var(--warn); }
.q.poor { background: var(--down-soft); color: var(--down); } .q.na { background: var(--panel-2); color: var(--muted); }

/* svg primitives */
#topo text { stroke: none; }
#topo .row-label { fill: var(--text); font-weight: 700; font-size: 15px; }
#topo .row-sub { fill: var(--muted); font-size: 12px; }
#topo .lane { fill: var(--panel-2); stroke: var(--line); }
#topo .wire { stroke-width: 3; fill: none; }
#topo .wire.up { stroke: var(--up); } #topo .wire.degraded { stroke: var(--warn); }
#topo .wire.down { stroke: var(--down); stroke-dasharray: 7 6; }
#topo .wire.flow { stroke: var(--up); stroke-width: 2; stroke-dasharray: 2 14; opacity: .9; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -16; } }
#topo .trunk { stroke: var(--brand); stroke-width: 3; fill: none; }
#topo .wlabel { fill: var(--muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; }
#topo .wlabel-bg { fill: var(--panel); stroke: var(--line); }
#topo .conf { stroke: #d9480f; stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
#topo .conf-label { fill: #d9480f; font-size: 11px; font-weight: 600; direction: ltr; }
#topo .conf.far { stroke-width: 1.2; opacity: .35; stroke-dasharray: 2 5; }
#topo .conf-bg { fill: var(--panel); stroke: #d9480f; }
@media (prefers-reduced-motion: reduce) { #topo .wire.flow { animation: none; } }

/* node cards (HTML inside foreignObject) */
.tn {
  box-sizing: border-box; width: 100%; height: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 2px 6px rgba(16,24,40,.08); overflow: hidden; line-height: 1.4; font-size: 12px; color: var(--text);
  direction: rtl; cursor: pointer; display: flex; flex-direction: column;
}
.tn:hover { border-color: var(--brand); box-shadow: 0 6px 16px rgba(16,24,40,.14); }
.tn .hd { display: flex; align-items: center; gap: 7px; padding: 7px 10px; background: var(--up-soft); border-bottom: 1px solid var(--line); }
.tn.down .hd { background: var(--down-soft); } .tn.degraded .hd { background: var(--warn-soft); }
.tn .hd b { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn .bd { padding: 7px 10px 6px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.tn .kvs { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; }
.tn .kvs span { color: var(--muted); font-size: 11px; }
.tn .kvs code { font-size: 11.5px; text-align: left; }
.tn .ping { display: flex; justify-content: space-between; gap: 4px; background: var(--panel-2); border-radius: 7px; padding: 4px 8px; }
.tn .ping div { text-align: center; font-size: 10.5px; color: var(--muted); }
.tn .ping b { display: block; font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; }
.tn .ping b.warn { color: var(--warn); } .tn .ping b.bad { color: var(--down); }
.tn .rad { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; }
.tn .rad.conflict { border-color: #d9480f; background: color-mix(in srgb, #d9480f 6%, var(--panel)); }
.tn .rad .r1 { display: flex; align-items: center; gap: 6px; }
.tn .rad .band { font-weight: 700; font-size: 11.5px; direction: ltr; }
.tn .rad .ch { direction: ltr; font-size: 11.5px; }
.tn .rad .q { margin-inline-start: auto; }
.tn .meter { height: 5px; border-radius: 3px; background: var(--line); margin: 4px 0 2px; overflow: hidden; }
.tn .meter i { display: block; height: 100%; background: var(--brand); }
.tn .meter i.hi { background: var(--warn); } .tn .meter i.vhi { background: var(--down); }
.tn .rad .r2 { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; direction: ltr; }
.tn .na { color: var(--muted); font-size: 11px; text-align: center; padding: 6px; border: 1px dashed var(--line); border-radius: 7px; }
.tn .ft { display: flex; justify-content: space-between; padding: 5px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.ccr { box-sizing: border-box; width: 100%; height: 100%; border-radius: 14px; background: var(--brand); color: #fff; padding: 12px; direction: rtl; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.ccr b { font-size: 15px; } .ccr small { opacity: .85; direction: ltr; text-align: right; }
.ccr svg { width: 34px; height: 34px; stroke: #fff; }

.topo-analysis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.topo-analysis .wide { grid-column: 1 / -1; }
.occ { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; direction: ltr; }
.occ .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 22px; }
.occ .c i { width: 100%; border-radius: 4px 4px 0 0; background: var(--brand); min-height: 2px; }
.occ .c.free i { background: var(--line); }
.occ .c.main span { font-weight: 700; color: var(--text); }
.occ .c.bad i { background: var(--warn); }
.occ .c span { font-size: 11px; color: var(--muted); }
.occ .c em { font-style: normal; font-size: 11px; font-weight: 700; }
.ap .chans { display: flex; gap: 6px; font-size: 11px; color: var(--muted); margin: 2px 0 4px; direction: ltr; justify-content: flex-end; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 3px; vertical-align: 1px; }
.dot.good { background: var(--up); } .dot.fair { background: var(--warn); } .dot.poor { background: var(--down); }
@media (max-width: 900px) { .topo-analysis { grid-template-columns: 1fr; } .toggles { flex-wrap: wrap; } }
.dr-h { font-size: 14px; margin: 18px 0 8px; }
.dr-radio { padding: 10px 12px; margin-bottom: 10px; box-shadow: none; }
.dr-radio .r1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* ---------- app shell: sidebar + topbar ---------- */
.side {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); z-index: 30;
  background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column;
  border-inline-end: 1px solid rgba(255,255,255,.06);
}
.side .brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.side .brand strong { display: block; color: #fff; font-size: 17px; letter-spacing: .3px; }
.side .brand small { color: var(--side-muted); font-size: 12px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #1aa0c4, #0f6e8c); color: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 21px; height: 21px; }
.logo circle { fill: currentColor; stroke: none; }
.nav { flex: 1; padding: 10px 12px; overflow-y: auto; }
.nav-h { margin: 16px 10px 6px; font-size: 11px; color: var(--side-muted); letter-spacing: .4px; }
.nav button {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; margin-bottom: 2px;
  border: 0; border-radius: 9px; background: none; color: var(--side-text); font: inherit; font-size: 14px; cursor: pointer; text-align: start;
}
.nav button svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav button span:not(.count):not(.dot-st) { flex: 1; }
.nav button:hover { background: var(--side-hover); color: #fff; }
.nav button[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.nav button[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #4fb3d1; }
.nav button[aria-current="page"] svg { opacity: 1; color: #4fb3d1; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #e5484d; color: #fff; font-size: 11px; text-align: center; line-height: 18px; }
.dot-st { width: 8px; height: 8px; border-radius: 50%; background: var(--side-muted); flex: none; }
.dot-st.ok { background: #3dd68c; box-shadow: 0 0 0 3px rgba(61,214,140,.18); }
.dot-st.bad { background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255,107,107,.18); }
.dot-st.warn { background: #f5a524; }
.side-foot { margin: 12px; padding: 12px 14px; border-radius: 10px; background: rgba(255,255,255,.05); font-size: 12px; }
.side-foot .rt { display: flex; align-items: center; gap: 8px; color: #fff; }
.side-foot .rt b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot small { display: block; margin-top: 3px; color: var(--side-muted); direction: ltr; text-align: right; }
.side-scrim { position: fixed; inset: 0; background: rgba(8,14,20,.45); z-index: 25; }

.shell { margin-inline-start: var(--side-w); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 14px 28px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.page-h { flex: 1; min-width: 0; }
.page-h h1 { margin: 0; font-size: 19px; font-weight: 700; }
.page-h p { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-area { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--up-soft); color: var(--up); } .pill.bad { background: var(--down-soft); color: var(--down); }
.pill.busy { background: var(--brand-soft); color: var(--brand); }
.icon-btn { display: none; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.demo-bar, .error-bar { padding: 9px 28px; }
.card { border-radius: 12px; }
.kpi { border-radius: 12px; padding: 14px 16px; }
.kpi b { font-size: 26px; }
.line, .topo-wrap { border-radius: 12px; }

/* forms */
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; }
.fld > span { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.fld input, .fld select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: var(--text); width: 100%;
}
.fld input:focus, .fld select:focus { outline: none; border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.fld input[dir="ltr"] { text-align: left; }
.fld small { color: var(--muted); font-size: 11.5px; }
.fld small.warn { color: var(--warn); }
.fld .seg { align-self: flex-start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.inline-msg { font-size: 13px; } .inline-msg.ok { color: var(--up); } .inline-msg.bad { color: var(--down); }
details.adv { margin: 4px 0 10px; font-size: 13px; }
details.adv summary { cursor: pointer; color: var(--brand); margin-bottom: 8px; }
.card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 12px; }
.sn { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }

/* connection page */
.stepper { list-style: none; display: flex; gap: 0; padding: 0; margin: 0 0 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.stepper li { flex: 1; display: flex; align-items: center; gap: 10px; padding: 13px 18px; color: var(--muted); font-size: 13.5px; position: relative; }
.stepper li + li { border-inline-start: 1px solid var(--line); }
.stepper li b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }
.stepper li.done { color: var(--up); } .stepper li.done b { background: var(--up); border-color: var(--up); color: #fff; }
.stepper li.done b::after { content: "✓"; } .stepper li.done b { font-size: 0; } .stepper li.done b::after { font-size: 13px; }
.stepper li.cur { color: var(--text); font-weight: 600; background: var(--brand-soft); }
.stepper li.cur b { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper li.err { color: var(--down); } .stepper li.err b { background: var(--down); border-color: var(--down); color: #fff; }
.conn-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.conn-layout .col > .card, #connGrid > .card { margin-bottom: 16px; }
#connGrid { display: block; }
.fp { margin: 14px 0 10px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.fp .fp-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.fp code { display: block; font-size: 14.5px; word-break: break-all; color: var(--text); text-align: left; }
.fp.changed { border-color: var(--down); background: var(--down-soft); }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin: 8px 0; cursor: pointer; }
.check input { margin-top: 3px; }
.result { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.result.ok { background: var(--up-soft); color: var(--up); }
.result.bad { background: var(--down-soft); color: var(--down); }
.result dl.kv { margin-top: 8px; color: var(--text); }
pre.code { background: #0d1b2a; color: #d6e4f0; padding: 12px 14px; border-radius: 9px; font-size: 12.5px; overflow-x: auto; white-space: pre; margin: 8px 0; text-align: left; }

/* build page additions */
.build-list li { grid-template-columns: 18px 26px 1fr auto auto auto; }
.row-acts { display: flex; gap: 2px; }
.row-acts button { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; }
.row-acts button svg { width: 14px; height: 14px; }
.row-acts button:hover { color: var(--brand); border-color: var(--brand); }
.row-acts button.del:hover { color: var(--down); border-color: var(--down); }
.badge.manual { background: #efe7fb; color: #6b3fc1; }
@media (prefers-color-scheme: dark) { .badge.manual { background: #2c2142; color: #b597f0; } }

dialog#apDlg { width: min(460px, 94vw); padding: 22px; }
dialog#apDlg h3 { margin: 0 0 14px; }
dialog menu { gap: 8px; }

@media (max-width: 1100px) { .conn-layout { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .side { transform: translateX(100%); transition: transform .2s; box-shadow: none; }
  html[dir="rtl"] .side { transform: translateX(100%); }
  body.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .shell { margin-inline-start: 0; }
  .icon-btn { display: grid; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .status-area .btn span { display: none; }
  .page-h p { display: none; }
  .demo-bar, .error-bar { padding: 8px 14px; }
  .stepper li span { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
.grid2:has(> [hidden]) { grid-template-columns: 1fr; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-left: 40px; }
.pw-eye { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.pw-eye svg { width: 18px; height: 18px; } .pw-eye:hover { color: var(--brand); }

/* links to each AP's own web page */
.ap-cell { position: relative; display: flex; }
.ap-cell .ap { padding-bottom: 8px; }
.ap-open, .tn-open, .row-open {
  display: inline-grid; place-items: center; color: var(--brand); border: 1px solid var(--line); background: var(--panel); border-radius: 7px; text-decoration: none;
}
.ap-open svg, .tn-open svg, .row-open svg { width: 14px; height: 14px; }
.ap-open { position: absolute; left: 8px; bottom: 6px; width: 26px; height: 24px; }
.ap-cell .ap .foot { padding-left: 30px; }
.ap-open:hover, .tn-open:hover, .row-open:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.tn-open { width: 24px; height: 22px; border-radius: 6px; flex: none; }
.tn-open svg { width: 13px; height: 13px; }
.tn .ip-link { color: var(--brand); text-decoration: none; text-align: left; direction: ltr; font-size: 11.5px; }
.tn .ip-link code { color: var(--brand); font-weight: 600; }
.tn .ip-link:hover code { text-decoration: underline; }
.row-open { width: 26px; height: 26px; border-radius: 6px; }
.open-btn { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; text-decoration: none; }
.open-btn code { margin-inline-start: auto; opacity: .85; font-size: 12px; }
.open-btn svg { width: 16px; height: 16px; }

/* ---------- ranges & discovery ---------- */
.bl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bl-head h3 { margin: 0; }
.bl-head .btn svg { width: 14px; height: 14px; }
.ranges-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 12px; padding: 8px 10px; border-radius: 9px; background: var(--panel-2); font-size: 12.5px; }
.ranges-row .rl { color: var(--muted); font-weight: 600; }
.rchip { background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.rchip.def { background: var(--panel); border: 1px dashed var(--line); color: var(--muted); }
.linkish { border: 0; background: none; color: var(--brand); cursor: pointer; font: inherit; font-size: 12.5px; padding: 0 4px; text-decoration: underline; }
.bl-main { min-width: 0; }
.ap-det { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.6; }
.ap-det code { font-size: 11px; }
.st-down { color: var(--down); font-weight: 600; }
.empty.small { padding: 10px; font-size: 13px; }
textarea { font: inherit; font-family: ui-monospace, Consolas, monospace; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: var(--text); width: 100%; resize: vertical; }
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
dialog.wide { width: min(1040px, 96vw); padding: 20px 22px; }
#rgDlg { width: min(480px, 94vw); padding: 22px; }
.sc-head { display: flex; align-items: center; justify-content: space-between; }
.sc-head h3 { margin: 0; }
.sc-head .close { position: static; }
.scan-wait { display: flex; align-items: center; gap: 10px; padding: 30px; justify-content: center; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.scan-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 8px; }
.scan-sum div { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.scan-sum b { display: block; font-size: 20px; }
.scan-sum span { color: var(--muted); font-size: 12px; }
.scan-sum .hl { background: var(--new-soft); } .scan-sum .hl b { color: var(--new); }
.scan-table td { vertical-align: middle; }
.scan-table tr.is-new { background: color-mix(in srgb, var(--new-soft) 55%, transparent); }
.scan-table .acts { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }
.ip-link { color: var(--brand); text-decoration: none; }
.ip-link:hover { text-decoration: underline; }
#scBody { max-height: 62vh; overflow: auto; }
@media (max-width: 700px) { .scan-sum { grid-template-columns: repeat(2, 1fr); } }

/* AP list item: name + details on top, controls on a second row */
.build-list li { grid-template-columns: 18px 26px minmax(0, 1fr); align-items: start; row-gap: 6px; padding: 8px 10px; }
.build-list li .handle, .build-list li .pos { margin-top: 5px; }
.build-list li .ctrls { grid-column: 3; display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.build-list li .bl-main input { width: 100%; }
.scan-table .acts { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

/* new AP announcements */
.new-bar { display: flex; align-items: center; gap: 10px; padding: 9px 28px; background: var(--new-soft); color: var(--new); font-size: 13px; flex-wrap: wrap; }
.new-bar b { color: var(--text); }
.nb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--new); animation: pulse 1.6s infinite; flex: none; }
.nb-acts { margin-inline-start: auto; display: flex; gap: 6px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--new) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.tn { position: relative; }
.tn.isnew { border: 2px solid var(--new); animation: pulse 2s infinite; }
.new-ribbon { position: absolute; top: -1px; left: 14px; background: var(--new); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 0 0 6px 6px; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .tn.isnew, .nb-dot { animation: none; } }
@media (max-width: 900px) { .new-bar { padding: 8px 14px; } }
