:root {
  --void: #0a1416;
  --void-2: #08110f;
  --panel: #0f1e22;
  --panel-2: #102a2e;
  --line: #1b3138;
  --line-soft: #142429;
  --fiber: #35c6d9;
  --fiber-dim: #1c6e79;
  --amber: #f2a63b;
  --ink: #dce9ea;
  --muted: #6e8a8f;
  --up: #4fd08a;
  --down: #ff5c6c;
  --warn: #f2a63b;
  --core: #35c6d9;
  --border: #7ad0e0;
  --dist: #8fb08f;
  --access: #b8a06a;
  --upstream: #f2a63b;
  --server: #a78bff;
  --radius: 4px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --disp: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, #0d2429 0%, transparent 60%),
    var(--void);
  color: var(--ink);
  font-family: var(--body);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.grid {
  display: grid;
  grid-template-columns: 240px 1fr 340px;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "top top top"
    "rail stage detail";
  height: 100vh;
  gap: 1px;
  background: var(--line-soft);
}

/* ---------- Topbar ---------- */
.topbar {
  grid-area: top;
  background: var(--void-2);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--fiber-dim));
}
.brand-mark {
  width: 14px; height: 22px;
  border-radius: 7px;
  background: linear-gradient(180deg, var(--fiber), transparent);
  box-shadow: 0 0 14px 1px var(--fiber-dim);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #fff, transparent 40%);
  opacity: .5; animation: pulse 2.6s ease-in-out infinite;
}
.brand-text h1 {
  font-family: var(--disp);
  font-size: 19px; font-weight: 700; letter-spacing: .32em;
}
.brand-text p {
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted); margin-top: 1px;
}
.vitals { display: flex; gap: 26px; margin-left: 8px; }
.vital { display: flex; flex-direction: column; }
.vital-num { font-family: var(--mono); font-size: 20px; font-weight: 700; line-height: 1; }
.vital-num.up { color: var(--up); }
.vital-num.down { color: var(--down); }
.vital-lbl { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
.conn {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); box-shadow: 0 0 8px var(--down); }
.conn.live .dot { background: var(--up); box-shadow: 0 0 8px var(--up); }
.conn.live #conn-text::after { content: ""; }

/* auth chip */
.authchip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.authchip + .conn { margin-left: 18px; }
.whoami { font-family: var(--mono); font-size: 11px; color: var(--fiber); letter-spacing: .06em; }
.login-link { font-family: var(--mono); font-size: 11px; color: var(--muted); background: transparent; border: 1px solid var(--line); padding: 5px 12px; border-radius: var(--radius); cursor: pointer; letter-spacing: .08em; }
.login-link:hover { color: var(--ink); border-color: var(--fiber-dim); }

/* login card */
.login-card { width: min(360px, 92vw); text-align: left; }
.login-mark { width: 20px; height: 30px; border-radius: 10px; margin-bottom: 14px; background: linear-gradient(180deg, var(--fiber), transparent); box-shadow: 0 0 20px 2px var(--fiber-dim); }
.login-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 14px; filter: drop-shadow(0 0 12px var(--fiber-dim)); }

/* ---------- Left rail ---------- */
.rail { grid-area: rail; background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.rail-head, .stage-head, .alerts h2, .detail-body h2 {
  display: flex; align-items: center; justify-content: space-between;
}
.rail-head {
  padding: 16px 16px 10px; 
}
.rail-head h2, .stage-head h2 {
  font-family: var(--disp); font-size: 12px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.add-btn {
  font-family: var(--mono); font-size: 11px; color: var(--fiber);
  background: transparent; border: 1px solid var(--fiber-dim);
  border-radius: var(--radius); padding: 4px 9px; cursor: pointer;
  transition: background .15s, color .15s;
}
.add-btn:hover { background: var(--fiber); color: var(--void); }
.rail-actions { display: flex; align-items: center; gap: 8px; }
.admin-link { font-family: var(--mono); font-size: 11px; color: var(--muted); text-decoration: none; letter-spacing: .04em; padding: 4px 6px; border-radius: var(--radius); }
.admin-link:hover { color: var(--fiber); }
.node-list { list-style: none; overflow-y: auto; flex: 1; padding: 4px 8px 16px; }
.node-item {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center;
  gap: 10px; padding: 10px 10px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
}
.node-item:hover { background: var(--panel-2); }
.node-item.active { background: var(--panel-2); border-color: var(--fiber-dim); }
.node-status { width: 8px; height: 8px; border-radius: 50%; }
.node-status.up { background: var(--up); box-shadow: 0 0 7px var(--up); }
.node-status.down { background: var(--down); box-shadow: 0 0 7px var(--down); animation: pulse 1.1s infinite; }
.node-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.node-bps { font-family: var(--mono); font-size: 11px; color: var(--fiber); text-align: right; }

/* ---------- Stage / topology ---------- */
.stage { grid-area: stage; background: var(--void); position: relative; display: flex; flex-direction: column; overflow: hidden; }
.stage-head { padding: 14px 20px; position: absolute; top: 0; left: 0; right: 0; z-index: 3; pointer-events: none; }
.legend { display: flex; gap: 14px; align-items: center; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.legend .lg { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.lg.core { background: var(--core); } .lg.border { background: var(--border); }
.lg.dist { background: var(--dist); } .lg.access { background: var(--access); }
.lg.upstream { background: var(--upstream); } .lg.server { background: var(--server); border-radius: 2px; }
#topo { flex: 1; width: 100%; display: block; cursor: grab; }
#topo:active { cursor: grabbing; }
.stage-hint {
  position: absolute; bottom: 12px; left: 20px; z-index: 3;
  font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .05em;
}

/* ---------- Right detail ---------- */
.detail { grid-area: detail; background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.detail-body { flex: 1; overflow-y: auto; padding: 18px; }
.detail-body h2 { font-family: var(--disp); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 14px; padding: 20px; }
.empty-mark { width: 30px; height: 30px; border: 1px dashed var(--line); border-radius: 50%; }
.empty p { font-size: 13px; max-width: 200px; }

.dev-head { margin-bottom: 16px; }
.dev-title { font-family: var(--disp); font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.dev-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
.dev-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge { font-family: var(--mono); font-size: 10px; padding: 3px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.badge.on { color: var(--up); border-color: var(--up); }
.badge.off { color: var(--down); border-color: var(--down); }
.badge.sim { color: var(--amber); border-color: var(--amber); }
.badge.mtik { color: var(--amber); border-color: var(--amber); background: rgba(242,166,59,.08); }
.badge.icmp { color: var(--up); border-color: var(--up); background: rgba(79,208,138,.08); }

.spark { width: 100%; height: 46px; margin: 4px 0 18px; display: block; }

/* live MRTG panel */
.live-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.live-head h2 { font-family: var(--disp); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.atur-btn { font-family: var(--mono); font-size: 11px; color: var(--fiber); background: transparent; border: 1px solid var(--fiber-dim); padding: 4px 12px; border-radius: var(--radius); cursor: pointer; letter-spacing: .06em; }
.atur-btn:hover { background: var(--fiber); color: var(--void); }
.atur-pop { background: var(--void-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.atur-title { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 8px; }
.atur-row { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; padding: 4px 0; cursor: pointer; }
.atur-row input { accent-color: var(--fiber); }

.live-graphs { display: flex; flex-direction: column; gap: 12px; }
.lg-card { background: var(--void-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 10px 8px; transition: border-color .2s; }
.lg-card:hover { border-color: var(--fiber-dim); }
.lg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.lg-name { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.lg-name .st { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.lg-cur { font-family: var(--mono); font-size: 11px; }
.lg-cur .rate-in { color: var(--fiber); } .lg-cur .rate-out { color: var(--amber); margin-left: 8px; }
.lg-cur .rate-in::before { content: "↓"; margin-right: 2px; } .lg-cur .rate-out::before { content: "↑"; margin-right: 2px; }
.lg-canvas { width: 100%; height: 84px; display: block; border-radius: 3px; }

.iface { padding: 11px 0; border-top: 1px solid var(--line-soft); }
.iface:first-of-type { border-top: none; }
.iface-top { display: flex; justify-content: space-between; align-items: baseline; }
.iface-name { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.iface-name .st { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.st.up { background: var(--up); } .st.down { background: var(--down); }
.iface-speed { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.iface-rates { display: flex; gap: 16px; margin: 6px 0 7px; font-family: var(--mono); font-size: 11px; }
.rate-in { color: var(--fiber); } .rate-out { color: var(--amber); }
.rate-in::before { content: "↓ "; } .rate-out::before { content: "↑ "; }
.util-bar { height: 4px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.util-fill { height: 100%; background: linear-gradient(90deg, var(--fiber), var(--amber)); border-radius: 3px; transition: width .4s ease; }
.del-btn { margin-top: 18px; width: 100%; font-family: var(--mono); font-size: 11px; color: var(--down); background: transparent; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; cursor: pointer; letter-spacing: .06em; }
.del-btn:hover { border-color: var(--down); background: rgba(255,92,108,.08); }
.detail-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.detail-actions .del-btn { margin-top: 0; }
.mrtg-btn, .edit-btn { font-family: var(--mono); font-size: 11px; text-align: center; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); cursor: pointer; letter-spacing: .06em; text-decoration: none; }
.mrtg-btn { color: var(--fiber); border-color: var(--fiber-dim); display: block; }
.mrtg-btn:hover { background: var(--fiber); color: var(--void); }
.edit-btn { color: var(--ink); background: transparent; }
.edit-btn:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- Alerts ---------- */
.alerts { border-top: 1px solid var(--line); padding: 14px 18px 16px; max-height: 40%; display: flex; flex-direction: column; }
.alerts h2 { font-family: var(--disp); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.alert-list { list-style: none; overflow-y: auto; }
.alert-item { display: grid; grid-template-columns: 3px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.alert-bar { border-radius: 2px; }
.alert-item.critical .alert-bar { background: var(--down); }
.alert-item.warn .alert-bar { background: var(--warn); }
.alert-item.info .alert-bar { background: var(--up); }
.alert-msg { line-height: 1.3; }
.alert-dev { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.alert-time { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.alert-empty { font-size: 12px; color: var(--muted); }

/* ---------- SLA monitor ---------- */
.sla { border-top: 1px solid var(--line); padding: 10px 16px 5px; display: flex; flex-direction: column; max-height: 45%; }
.sla-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.sla-head h2 { font-family: var(--disp); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.sla-add-btn { font-family: var(--mono); font-size: 10px; color: var(--fiber); background: transparent; border: 1px solid var(--fiber-dim); padding: 3px 10px; border-radius: var(--radius); cursor: pointer; letter-spacing: .06em; }
.sla-add-btn:hover { background: var(--fiber); color: var(--void); }
.sla-list { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; }
.sla-empty { font-size: 11px; color: var(--muted); line-height: 1.4; }
.sla-card { background: var(--void-2); border: 1px solid var(--line-soft); border-left: 2px solid var(--muted); border-radius: var(--radius); padding: 7px 9px; }
.sla-card.ok { border-left-color: var(--up); }
.sla-card.bad { border-left-color: var(--down); }
.sla-top { display: flex; align-items: center; gap: 8px; }
.sla-top .st { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.sla-id { flex: 1; min-width: 0; }
.sla-name { display: block; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sla-node { display: block; font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 1px; }
.sla-del { font-family: var(--mono); font-size: 14px; line-height: 1; color: var(--muted); background: transparent; border: none; cursor: pointer; padding: 0 2px; }
.sla-del:hover { color: var(--down); }
.sla-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 6px 0 5px; }
.sla-metric { text-align: center; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 4px 2px; }
.sla-val { display: block; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.sla-val.ok { color: var(--up); }
.sla-val.bad { color: var(--down); }
.sla-lbl { display: block; font-family: var(--mono); font-size: 8px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.sla-foot { font-family: var(--mono); font-size: 9px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(4,10,11,.72); display: flex; align-items: center; justify-content: center; z-index: 20; backdrop-filter: blur(3px); }
.modal-scrim[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: min(420px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal h3 { font-family: var(--disp); font-size: 17px; letter-spacing: .04em; }
.modal-sub { font-size: 12px; color: var(--muted); margin: 6px 0 16px; line-height: 1.4; }
.modal label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; }
.modal input, .modal select { display: block; width: 100%; margin-top: 5px; background: var(--void); border: 1px solid var(--line); color: var(--ink); font-family: var(--mono); font-size: 13px; padding: 9px 10px; border-radius: var(--radius); }
.modal input:focus, .modal select:focus { outline: none; border-color: var(--fiber); }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* agent picker — two ways into a device */
.field-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 2px 0 7px; }
.agent-pick { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.agent-opt { position: relative; display: block; margin: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--void); cursor: pointer; text-transform: none; letter-spacing: 0; transition: border-color .15s, background .15s; }
.agent-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.agent-name { display: block; font-family: var(--disp); font-size: 14px; font-weight: 600; color: var(--ink); }
.agent-desc { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; letter-spacing: .04em; }
.agent-opt:has(input:checked) { border-color: var(--fiber); background: rgba(53,198,217,.07); box-shadow: 0 0 0 1px var(--fiber-dim) inset; }
.agent-opt:has(input:checked) .agent-name { color: var(--fiber); }
.agent-opt.mtik:has(input:checked) { border-color: var(--amber); background: rgba(242,166,59,.08); box-shadow: 0 0 0 1px rgba(242,166,59,.4) inset; }
.agent-opt.mtik:has(input:checked) .agent-name { color: var(--amber); }
.agent-opt.icmp:has(input:checked) { border-color: var(--up); background: rgba(79,208,138,.08); box-shadow: 0 0 0 1px rgba(79,208,138,.4) inset; }
.agent-opt.icmp:has(input:checked) .agent-name { color: var(--up); }
.agent-fields[hidden] { display: none; }
.modal .check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink); }
.modal .check input { width: auto; margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-actions button { font-family: var(--mono); font-size: 12px; padding: 9px 16px; border-radius: var(--radius); cursor: pointer; border: 1px solid var(--line); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { color: var(--ink); }
.primary { background: var(--fiber); color: var(--void); border-color: var(--fiber); font-weight: 700; }
.primary:hover { filter: brightness(1.1); }
.modal-err { color: var(--down); font-size: 12px; margin-top: 10px; min-height: 14px; }

/* focus + motion + scrollbars */
button:focus-visible, .node-item:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--fiber); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

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

/* Responsive: collapse to stacked on narrow screens */
@media (max-width: 1000px) {
  body { overflow: auto; }
  .grid { grid-template-columns: 1fr; grid-template-rows: 64px 260px 320px auto; grid-template-areas: "top" "stage" "rail" "detail"; height: auto; min-height: 100vh; }
  .vitals { gap: 16px; }
  .topbar { gap: 16px; overflow-x: auto; }
}

/* Drag-to-place feedback: a low, quiet chip that rises from the map edge */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  z-index: 60;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink);
  background: rgba(8, 17, 15, 0.92);
  border: 1px solid var(--fiber-dim);
  border-radius: var(--radius);
  padding: 9px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(53, 198, 217, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fiber);
  margin-right: 9px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--fiber);
}
.toast.warn { border-color: var(--amber); }
.toast.warn::before { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity .2s ease; transform: translate(-50%, 0); }
}

/* ---------- Asisten AI ---------- */
.ai-btn {
  background: linear-gradient(135deg, rgba(53,198,217,.16), rgba(167,139,255,.16));
  border: 1px solid var(--fiber-dim);
  color: var(--fiber);
  font-family: var(--disp);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, border-color .18s, transform .18s;
}
.ai-btn:hover { background: linear-gradient(135deg, rgba(53,198,217,.28), rgba(167,139,255,.28)); border-color: var(--fiber); transform: translateY(-1px); }

.ai-drawer {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 12, .55);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity .2s ease;
}
.ai-drawer.show { opacity: 1; }
.ai-drawer[hidden] { display: none; }

.ai-panel {
  width: min(420px, 100%);
  height: 100%;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  transform: translateX(24px);
  transition: transform .22s ease;
}
.ai-drawer.show .ai-panel { transform: translateX(0); }

.ai-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.ai-title { display: flex; align-items: center; gap: 11px; }
.ai-spark {
  font-size: 20px; color: var(--fiber);
  filter: drop-shadow(0 0 8px rgba(53,198,217,.6));
}
.ai-title h3 { font-family: var(--disp); font-size: 15px; letter-spacing: .02em; }
.ai-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ai-close {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 28px; height: 28px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.ai-close:hover { color: var(--ink); border-color: var(--fiber-dim); }

.ai-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.ai-muted { color: var(--muted); }

.ai-score { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.ai-ring {
  --ai-ring-col: var(--fiber);
  width: 66px; height: 66px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--fiber) 0deg, rgba(255,255,255,.08) 0deg);
}
.ai-ring span {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--panel); display: grid; place-items: center;
  font-family: var(--disp); font-weight: 700; font-size: 18px; color: var(--ink);
}
.ai-score-meta { display: flex; flex-direction: column; gap: 3px; }
.ai-score-meta strong { font-family: var(--disp); font-size: 15px; }
.ai-score-meta span { font-size: 11px; }

.ai-summary { font-size: 13px; line-height: 1.6; color: var(--ink); margin-bottom: 8px; }
.ai-summary b { color: var(--fiber); }

.ai-section { margin-top: 16px; }
.ai-section h4 {
  font-family: var(--disp); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.ai-actions { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ai-actions li {
  font-size: 12.5px; line-height: 1.5; padding: 8px 10px;
  background: rgba(53,198,217,.06); border-left: 2px solid var(--fiber-dim); border-radius: 3px;
}
.ai-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.ai-item {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; line-height: 1.5; padding: 6px 8px; border-radius: 3px;
  background: rgba(255,255,255,.02);
}
.ai-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.ai-item.crit .ai-dot { background: var(--down); box-shadow: 0 0 6px var(--down); }
.ai-item.warn .ai-dot { background: var(--warn); }
.ai-item.info .ai-dot { background: var(--fiber); }

.ai-chat { border-top: 1px solid var(--line); padding: 12px 14px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ai-chip {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11px; padding: 4px 9px; border-radius: 20px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ai-chip:hover { color: var(--fiber); border-color: var(--fiber-dim); }
.ai-log { max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.ai-log:empty { display: none; }
.ai-msg { font-size: 12.5px; line-height: 1.5; padding: 8px 11px; border-radius: 10px; max-width: 90%; }
.ai-msg.me { align-self: flex-end; background: rgba(53,198,217,.14); color: var(--ink); border-bottom-right-radius: 3px; }
.ai-msg.ai { align-self: flex-start; background: rgba(255,255,255,.04); border: 1px solid var(--line-soft); border-bottom-left-radius: 3px; }
.ai-msg b { color: var(--fiber); }
.ai-ask { display: flex; gap: 8px; }
.ai-ask input {
  flex: 1; background: var(--void-2); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 11px; border-radius: var(--radius); font-family: var(--body); font-size: 12.5px;
}
.ai-ask input:focus { outline: none; border-color: var(--fiber-dim); }
.ai-ask .primary {
  background: var(--fiber); color: #04191c; border: none; font-weight: 600;
  padding: 0 14px; border-radius: var(--radius); cursor: pointer; font-size: 12.5px;
}
.ai-ask .primary:hover { filter: brightness(1.08); }

@media (max-width: 640px) { .ai-panel { width: 100%; } }

/* ---------- Network Throughput Overview ---------- */
.overview {
  background: linear-gradient(180deg, rgba(16,42,46,.6), rgba(15,30,34,.4));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px 10px;
  margin-bottom: 12px;
}
.ov-head {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px;
}
.ov-head h2 {
  font-family: var(--disp); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.ov-live {
  font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--fiber);
  text-shadow: 0 0 10px rgba(53,198,217,.35);
}
.ov-canvas { width: 100%; height: 92px; display: block; }
.ov-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px;
  border-top: 1px solid var(--line-soft); padding-top: 8px;
}
.ov-stat { display: flex; flex-direction: column; gap: 2px; }
.ov-k { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ov-v { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.ov-v.up { color: var(--up); }

/* ---------- NetWatch: DHCP asing & konflik IP ---------- */
.netwatch { margin-top: 14px; }
.nw-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.nw-head h2 {
  font-family: var(--disp); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.nw-scan-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11px; padding: 3px 9px; border-radius: var(--radius); cursor: pointer;
}
.nw-scan-btn:hover:not(:disabled) { color: var(--fiber); border-color: var(--fiber-dim); }
.nw-scan-btn:disabled { opacity: .5; cursor: default; }
.nw-empty, .nw-ok { font-size: 12px; color: var(--muted); padding: 8px 2px; }
.nw-ok { color: var(--up); }
.nw-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.nw-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,.02); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 7px 4px;
}
.nw-chip .nw-n { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--ink); }
.nw-chip .nw-l { font-size: 9px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); text-align: center; }
.nw-chip.crit .nw-n { color: var(--down); }
.nw-chip.warn .nw-n { color: var(--warn); }
.nw-chip.ok .nw-n { color: var(--up); }
.nw-sec { margin-top: 10px; }
.nw-sec h4 { font-size: 11px; margin-bottom: 6px; font-weight: 600; }
.nw-crit { color: var(--down); }
.nw-warn { color: var(--warn); }
.nw-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.nw-item {
  display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.4;
  padding: 6px 8px; border-radius: 3px; background: rgba(255,255,255,.02);
}
.nw-item b { color: var(--ink); word-break: break-all; }
.nw-meta { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.nw-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.nw-item.crit .nw-dot { background: var(--down); box-shadow: 0 0 6px var(--down); }
.nw-item.warn .nw-dot { background: var(--warn); }
.nw-item.ok .nw-dot { background: var(--up); }
.nw-item.off { opacity: .55; }
.nw-inv { margin-top: 10px; }
.nw-inv summary {
  font-size: 11px; color: var(--muted); cursor: pointer; padding: 5px 0;
  letter-spacing: .04em; text-transform: uppercase;
}
.nw-inv summary:hover { color: var(--fiber); }
.nw-inv[open] summary { color: var(--ink); }
.nw-inv .nw-list { margin-top: 6px; }
.nw-errs { font-size: 10.5px; color: var(--warn); margin-top: 8px; }
.nw-foot { font-size: 10px; color: var(--muted); margin-top: 8px; text-align: right; }

/* ---------- full-screen login gate + role visibility ---------- */
.app-gate {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: radial-gradient(1200px 700px at 50% -10%, var(--panel-2), var(--void) 60%);
  backdrop-filter: blur(2px);
}
.app-gate[hidden] { display: none; }
.gate-panel {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px 26px 24px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6);
  text-align: center;
}
.gate-logo { width: 54px; height: 54px; margin: 0 auto 10px; display: block; }
.gate-panel h2 { font-family: var(--disp); font-size: 20px; letter-spacing: .12em; margin: 0; }
.gate-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin: 4px 0 20px; }
.gate-panel label { display: block; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 14px; }
.gate-panel input { display: block; width: 100%; margin-top: 6px; background: var(--void); border: 1px solid var(--line); color: var(--ink); font-family: var(--mono); font-size: 13px; padding: 10px 11px; border-radius: var(--radius); }
.gate-panel input:focus { outline: none; border-color: var(--fiber); }
.gate-submit { width: 100%; font-family: var(--mono); font-size: 13px; padding: 11px; border-radius: var(--radius); cursor: pointer; margin-top: 4px; }
.gate-hint { font-size: 11px; color: var(--muted); margin: 14px 0 0; line-height: 1.5; }

/* Hide the dashboard behind the gate until signed in */
body:not(.authed) .grid { display: none; }
/* Read-only accounts cannot see edit controls */
body.role-viewer .admin-only { display: none !important; }

/* ---------- Kabupaten Enrekang emblem (real PNG, no cyan tint) ---------- */
.gate-logos { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 10px; }
.gate-logos .gate-logo, .gate-logos .login-logo { margin: 0; }
.brand-logo-kab { filter: none; }
.gate-logo-kab, .login-logo-kab { filter: none; }
.login-logo-kab { margin-bottom: 0; }
