/* ===========================================================================
   LSIT — "Beacon" network operations console
   Identity: a precision instrument, not a hacker terminal. Ink-slate canvas,
   indigo beacon accent + emerald live signal, Sora display + JetBrains Mono data.
   Signature: the propagation beacon in the header — a node emitting concentric
   rings while a single pulse sweeps the track (WiFi radiating across campus).
   =========================================================================== */
:root {
  /* canvas + layered surfaces (blue-ink slate, not black, not petrol) */
  --bg: #0c0e13;
  --bg-2: #0f1218;
  --surface: #14171d;
  --surface-2: #191d25;
  --border: #262b35;
  --border-soft: rgba(255, 255, 255, .055);

  /* ink */
  --text: #e7e9ef;
  --muted: #8a92a3;
  --faint: #565e6d;

  /* accents + semantics */
  --brand: #6f78ff;          /* indigo — interactive / primary / focus */
  --brand-strong: #5a63f0;
  --brand-soft: rgba(111, 120, 255, .14);
  --online: #33d1a3;         /* emerald — live / online */
  --online-soft: rgba(51, 209, 163, .13);
  --warn: #f2b03d;           /* amber — attention */
  --fault: #ff5d78;          /* rose — fault */

  /* vendor hues */
  --unifi: #7aa2ff;
  --omada: #22c9d6;
  --ruijie: #f2b03d;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 24px 60px -18px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 2px rgba(0, 0, 0, .35);

  --sans: 'Inter', system-ui, sans-serif;
  --display: 'Sora', 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 460px at 88% -10%, rgba(111, 120, 255, .10), transparent 62%),
    radial-gradient(760px 420px at 4% 2%, rgba(51, 209, 163, .05), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.006em;
}
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: #3a414f; background: #1f242d; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary {
  background: var(--brand); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 18px -6px rgba(111, 120, 255, .6);
}
.btn.primary:hover { background: var(--brand-strong); border-color: transparent; color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 8px 24px -6px rgba(111, 120, 255, .7); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; border-color: rgba(255, 93, 120, .42); color: var(--fault); }
.btn.danger:hover { border-color: var(--fault); background: rgba(255, 93, 120, .08); color: var(--fault); }
.btn.small { padding: 4px 10px; font-size: 11.5px; border-radius: var(--radius-xs); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ---- gate ---- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.gate[hidden] { display: none !important; }
.gate-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 38px 34px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.gate-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--online));
}
.gate-card h1 { font-family: var(--display); font-size: 24px; font-weight: 600; margin: 18px 0 6px; letter-spacing: -.02em; }
.gate-card label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.gate-card input, .modal input, .modal select {
  width: 100%; padding: 12px 13px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.gate-card input:focus, .modal input:focus, .modal select:focus,
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.gate-card .btn { width: 100%; margin-top: 24px; }
.gate-err { color: var(--fault); font-size: 13px; margin-top: 12px; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 700; letter-spacing: .01em; font-size: 20px; }
.brand-block { display: flex; flex-direction: column; gap: 3px; }
.brand-block .eyebrow { padding-left: 40px; }

/* ---- topbar ---- */
.app[hidden] { display: none !important; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 24, .72);
  backdrop-filter: blur(14px) saturate(1.2); position: sticky; top: 0; z-index: 10;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.last-update { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-right: 4px; }

/* ---- signature: propagation beacon ---- */
.beacon {
  flex: 1; max-width: 520px; height: 42px; position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
}
.beacon-track {
  position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 22%, var(--border) 78%, transparent);
}
.beacon-scan {
  position: absolute; top: 50%; transform: translateY(-50%); height: 2px; width: 130px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: beacon-scan 4.6s linear infinite;
}
@keyframes beacon-scan { 0% { left: -150px; } 100% { left: 100%; } }
.beacon-node {
  width: 8px; height: 8px; border-radius: 50%; background: var(--online);
  box-shadow: 0 0 10px rgba(51, 209, 163, .7), 0 0 0 1px rgba(51, 209, 163, .3), 0 0 0 6px rgba(51, 209, 163, .07), 0 0 0 12px rgba(51, 209, 163, .035);
  position: relative; z-index: 1;
}
.beacon-node::before, .beacon-node::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--online); animation: beacon-emit 3.2s ease-out infinite;
}
.beacon-node::after { animation-delay: 1.6s; }
@keyframes beacon-emit {
  0% { transform: scale(1); opacity: .65; }
  100% { transform: scale(6.5); opacity: 0; }
}

.content { padding: 28px; max-width: 1460px; margin: 0 auto; }
.section-label {
  display: flex; align-items: center; gap: 11px; margin: 6px 2px 18px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--muted);
}
.section-label .tick { width: 20px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--brand), transparent); }

/* ---- stats / instrument readouts ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; position: relative; overflow: hidden; box-shadow: var(--shadow-card);
}
.stat.accent { border-color: rgba(51, 209, 163, .28); }
.stat.accent::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--online), transparent 70%);
}
.stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--display); font-size: 36px; font-weight: 600; margin-top: 10px; line-height: 1; letter-spacing: -.03em; font-feature-settings: "tnum"; }
.stat .v .of { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--faint); letter-spacing: 0; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 9px; }
.stat.accent .v { color: var(--online); }

/* mini signal bars on the accent readout */
.sig-bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; margin-left: 11px; vertical-align: baseline; }
.sig-bars i { width: 3px; border-radius: 1px; background: var(--online); opacity: .85; }
.sig-bars i:nth-child(1) { height: 30%; }
.sig-bars i:nth-child(2) { height: 55%; }
.sig-bars i:nth-child(3) { height: 78%; }
.sig-bars i:nth-child(4) { height: 100%; }

.vendor-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 13px; }
.chip {
  font-family: var(--mono); font-size: 11px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface-2);
}

/* ---- panel ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-title { display: flex; flex-direction: column; gap: 5px; }
.panel-head h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: -.02em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 8px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text); font: inherit; font-size: 13px;
}

/* ---- table ---- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  text-align: left; padding: 10px 14px; color: var(--faint); font-family: var(--mono);
  font-weight: 500; font-size: 9.5px; text-transform: uppercase; letter-spacing: .15em;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: rgba(12, 14, 19, .5);
}
table.grid td { padding: 8px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; vertical-align: middle; }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover td { background: rgba(111, 120, 255, .05); }
table.grid tbody tr:last-child td { border-bottom: none; }

/* column discipline: truncate free text, right-align numerics */
.c-name { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 500; }
.c-ctl { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.c-model { max-width: 128px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; }
.c-num.mono { color: var(--muted); }
#apTable th:nth-child(9), #apTable th:nth-child(10) { text-align: right; }
.c-cli { color: var(--text); }
.c-cli.zero { color: var(--faint); }

.status-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12px; }
.status-badge .d { width: 7px; height: 7px; border-radius: 50%; position: relative; flex: none; }
.status-badge.online { color: var(--online); }
.status-badge.online .d { background: var(--online); box-shadow: 0 0 8px rgba(51, 209, 163, .8); }
.status-badge.online .d::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid var(--online); opacity: .5; animation: emit 2s ease-out infinite;
}
@keyframes emit { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(2.1); opacity: 0; } }
.status-badge.offline { color: var(--faint); }
.status-badge.offline .d { background: var(--faint); }

.vbadge { font-family: var(--mono); font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 6px; letter-spacing: .04em; text-transform: uppercase; }
.vbadge.unifi { background: rgba(122, 162, 255, .14); color: var(--unifi); }
.vbadge.omada { background: rgba(34, 201, 214, .14); color: var(--omada); }
.vbadge.ruijie { background: rgba(242, 176, 61, .15); color: var(--ruijie); }

.mono { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* RSSI signal strength bars (clients modal) */
.rssi { display: inline-flex; align-items: center; gap: 8px; }
.rssi .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.rssi .bars i { width: 3px; border-radius: 1px; background: var(--faint); }
.rssi .bars i:nth-child(1) { height: 35%; }
.rssi .bars i:nth-child(2) { height: 58%; }
.rssi .bars i:nth-child(3) { height: 79%; }
.rssi .bars i:nth-child(4) { height: 100%; }
.rssi.s3 .bars i:nth-child(-n+3),
.rssi.s4 .bars i:nth-child(-n+4) { background: var(--online); }
.rssi.s2 .bars i:nth-child(-n+2) { background: var(--warn); }
.rssi.s1 .bars i:nth-child(-n+1) { background: var(--fault); }
.rssi .val { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---- modals ---- */
.scrim { position: fixed; inset: 0; background: rgba(6, 8, 12, .68); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; backdrop-filter: blur(6px); }
.scrim[hidden] { display: none !important; }
.modal {
  width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); max-height: 90vh; display: flex; flex-direction: column;
  animation: modal-in .2s cubic-bezier(.2, .8, .2, 1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal.small { max-width: 480px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: -.02em; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 15px 24px; border-top: 1px solid var(--border); }
.modal-foot .spacer { flex: 1; }
.field { margin-bottom: 15px; }
.field label, .modal-body > label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.modal-body > label { margin-top: 15px; }
.modal-body > label input { margin-top: 8px; }
.field .hint, .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 8px; }
.check label { text-transform: none; letter-spacing: 0; font-family: var(--sans); }
.check input { width: auto; }
.test-result { font-family: var(--mono); font-size: 12.5px; }
.test-result.ok { color: var(--online); }
.test-result.err { color: var(--fault); }

/* ---- controller list ---- */
.ctl-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ctl-item { display: flex; align-items: center; gap: 12px; padding: 15px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; transition: border-color .15s; }
.ctl-item:hover { border-color: #3a414f; }
.ctl-item .meta { flex: 1; min-width: 0; }
.ctl-item .meta .n { font-weight: 600; }
.ctl-item .meta .u { font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ctl-item .badges { display: flex; gap: 6px; align-items: center; }
.pill { font-family: var(--mono); font-size: 10.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); letter-spacing: .04em; }
.pill.sim { color: var(--warn); border-color: rgba(242, 176, 61, .5); }
.pill.live { color: var(--online); border-color: rgba(51, 209, 163, .5); }
.pill.off { color: var(--faint); }

/* ---- toast ---- */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); padding: 13px 19px; border-radius: 13px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; animation: modal-in .2s ease-out; }
.toast[hidden] { display: none !important; }
.toast.ok { border-color: rgba(51, 209, 163, .55); }
.toast.err { border-color: rgba(255, 93, 120, .6); }

/* ---- AP config modal ---- */
.cfg-current { background: var(--brand-soft); border: 1px solid rgba(111, 120, 255, .28); border-radius: 12px; padding: 13px 15px; margin-bottom: 15px; }
.cfg-current-head { font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--brand); margin-bottom: 9px; }
.cfg-kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 3px 0; }
.cfg-kv span { color: var(--muted); }
.cfg-kv b { font-family: var(--mono); font-weight: 500; }
.cfg-row { display: flex; gap: 12px; }
.cfg-row label { flex: 1; }

/* ---- SSID & password modal ---- */
.pw { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.pw .dots { letter-spacing: 2px; color: var(--muted); }
.pw:hover .dots { color: var(--brand); }
.pw .txt { color: var(--text); }
.pw::after { content: "⧉"; font-size: 12px; color: var(--faint); }
.pw:hover::after { color: var(--brand); }
#ssidTable .off-row td { opacity: .5; }

/* ---- location grouping ---- */
.group-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; padding: 8px 4px; white-space: nowrap; }
.group-toggle input { width: auto; accent-color: var(--brand); }
tr.group-row td { background: linear-gradient(90deg, var(--brand-soft), rgba(111, 120, 255, .02) 58%, transparent); border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); padding: 9px 14px; box-shadow: inset 2px 0 0 var(--brand); }
tr.group-row:first-child td { border-top: none; }
tr.group-row:hover td { background: linear-gradient(90deg, var(--brand-soft), rgba(111, 120, 255, .02) 58%, transparent); }
.grp-name { font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: -.01em; color: var(--text); display: inline-flex; align-items: center; gap: 9px; }
.grp-name::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--brand); transform: rotate(45deg); box-shadow: 0 0 8px rgba(111, 120, 255, .5); }
.grp-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-left: 11px; letter-spacing: .04em; }
.loc-tag { font-family: var(--mono); font-size: 11px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: var(--radius-xs); padding: 2px 8px; cursor: pointer; transition: .15s; letter-spacing: .02em; }
.loc-tag:hover { border-color: var(--brand); color: var(--text); background: var(--brand-soft); }
.loc-tag.set { color: var(--text); border-color: var(--border); background: var(--brand-soft); }
.loc-tag.set:hover { border-color: var(--brand); }

/* ---- LSIT brand logo ---- */
.brand-logo { height: 30px; width: auto; display: block; }
.gate-card .brand { justify-content: center; flex-direction: column; gap: 12px; }
.gate-logo { height: 76px; }
.brand-block .brand-logo { height: 30px; }

/* ---- responsive ---- */
@media (max-width: 860px) { .beacon { display: none; } }
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .stat .v { font-size: 30px; }
  .brand-block .eyebrow { display: none; }
  .brand-logo { height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .beacon-scan, .beacon-node::before, .beacon-node::after, .status-badge.online .d::after, .modal, .toast { animation: none !important; }
  .beacon-scan { display: none; }
  .btn, table.grid tbody tr { transition: none; }
}
