/* NEXORA UI kit — shared by Agent and Master Control */
:root {
  --bg: #070c18; --bg2: #0b1222; --panel: #0f182b; --panel2: #13203a; --line: #1d2b47; --line2: #27385c;
  --text: #e6edf7; --muted: #8a9bb8; --dim: #5d6f8f;
  --accent: #22d3ee; --primary: #3b82f6; --primary2: #2563eb;
  --up: #22c55e; --up-bg: rgba(34,197,94,.12); --down: #ef4444; --down-bg: rgba(239,68,68,.13);
  --warn: #f59e0b; --warn-bg: rgba(245,158,11,.13); --unk: #8b5cf6; --unk-bg: rgba(139,92,246,.13); --paused: #64748b;
  --radius: 12px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[data-theme="light"] {
  --bg: #eef2f8; --bg2: #e6ebf3; --panel: #ffffff; --panel2: #f5f8fc; --line: #dde4ef; --line2: #c9d3e3;
  --text: #0f172a; --muted: #5b6b85; --dim: #8a98b0; --shadow: 0 8px 24px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.right { text-align: right; } .center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; } .gap4 { gap: 4px; } .gap16 { gap: 16px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.hide { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; } svg.i.lg { width: 22px; height: 22px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.side { background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, #38e1f7, #1d4ed8); box-shadow: 0 0 22px rgba(34,211,238,.35); color: #fff; }
.brand b { font-size: 16px; letter-spacing: .3px; display: block; }
.brand span { font-size: 11.5px; color: var(--muted); display: block; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { padding: 12px 10px; overflow: auto; flex: 1; }
.nav .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: var(--muted); font-weight: 500; margin: 1px 0; position: relative; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(34,211,238,.06)); color: var(--text); }
.nav a.on::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav .badge { margin-left: auto; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg2); flex: none; }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
.top .crumb { color: var(--muted); font-size: 13px; }
.content { flex: 1; overflow: auto; padding: 22px 24px 40px; }
.ribbon { display: flex; align-items: center; gap: 12px; padding: 9px 24px; background: linear-gradient(90deg, rgba(239,68,68,.28), rgba(239,68,68,.08)); border-bottom: 1px solid rgba(239,68,68,.4); color: #fecaca; font-weight: 500; cursor: pointer; }
[data-theme="light"] .ribbon { color: #991b1b; }
.ribbon .blip { width: 9px; height: 9px; border-radius: 50%; background: var(--down); box-shadow: 0 0 0 0 rgba(239,68,68,.7); animation: pulse 1.4s infinite; }

/* ---------- surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { display: none; } .g2 { grid-template-columns: 1fr; } }

.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi .val { font-size: 32px; font-weight: 650; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .glow { position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; opacity: .18; filter: blur(8px); }
.kpi.up .val { color: var(--up); } .kpi.up .glow { background: var(--up); }
.kpi.down .val { color: var(--down); } .kpi.down .glow { background: var(--down); }
.kpi.info .glow { background: var(--primary); } .kpi.acc .val { color: var(--accent); } .kpi.acc .glow { background: var(--accent); }
.kpi.down.alive { border-color: rgba(239,68,68,.55); box-shadow: 0 0 0 1px rgba(239,68,68,.2), 0 0 30px rgba(239,68,68,.15) inset; }

/* ---------- status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.up { color: var(--up); background: var(--up-bg); }
.pill.down { color: var(--down); background: var(--down-bg); }
.pill.down::before { animation: pulse 1.4s infinite; }
.pill.unknown { color: var(--unk); background: var(--unk-bg); }
.pill.paused { color: var(--paused); background: rgba(100,116,139,.15); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.plain::before { display: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.up { background: var(--up); box-shadow: 0 0 8px rgba(34,197,94,.6); } .dot.down { background: var(--down); animation: pulse 1.4s infinite; }
.dot.unknown { background: var(--unk); } .dot.paused { background: var(--paused); } .dot.off { background: var(--dim); }
.badge { background: var(--down); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.badge.blue { background: var(--primary); } .badge.gray { background: var(--line2); color: var(--text); }
.tag { display: inline-block; padding: 2px 7px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.65); } 70% { box-shadow: 0 0 0 9px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); font: 500 13px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.pri { background: linear-gradient(180deg, var(--primary), var(--primary2)); border-color: transparent; color: #fff; }
.btn.pri:hover { filter: brightness(1.1); }
.btn.danger { color: #fff; background: #b91c1c; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; } .btn.icon.sm { width: 28px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); height: 27px; padding: 0 11px; border-radius: 6px; font: 500 12.5px var(--font); cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line2); color: var(--text); border-radius: 8px; height: 34px; padding: 0 10px; font: 13px var(--font); outline: none; width: 100%; }
textarea { height: auto; padding: 8px 10px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.search { position: relative; } .search svg { position: absolute; left: 10px; top: 8px; color: var(--dim); } .search input { padding-left: 34px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--dim); }

/* switch */
.sw { position: relative; width: 38px; height: 21px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: var(--line2); border-radius: 99px; transition: .2s; cursor: pointer; }
.sw span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.sw input:checked + span { background: var(--up); } .sw input:checked + span::after { transform: translateX(17px); }

/* ---------- table ---------- */
.tbl-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: rgba(59,130,246,.05); }
table.t tr.down td { background: rgba(239,68,68,.06); }
table.t tr.sel td { background: rgba(59,130,246,.1); }
table.t td.act { white-space: nowrap; text-align: right; }
.dev-name { display: flex; align-items: center; gap: 10px; }
.dev-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); color: var(--accent); flex: none; }
.dev-ico.down { color: var(--down); border-color: rgba(239,68,68,.45); background: var(--down-bg); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--dim); margin-bottom: 10px; }

/* ---------- lists / feed ---------- */
.feed { max-height: 460px; overflow: auto; }
.fe { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.fe .ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.fe.down .ic { background: var(--down-bg); color: var(--down); } .fe.up .ic { background: var(--up-bg); color: var(--up); }
.fe.other .ic { background: var(--panel2); color: var(--muted); }
.fe b { font-weight: 600; } .fe .when { margin-left: auto; font-size: 11.5px; color: var(--dim); white-space: nowrap; text-align: right; }
.fe.fresh { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: rgba(34,211,238,.18); } to { background: transparent; } }

/* device heat-grid */
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--line); background: var(--panel2); border-radius: 9px; padding: 8px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; min-width: 0; }
.tile:hover { border-color: var(--accent); }
.tile .nm { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .ip { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tile.down { border-color: rgba(239,68,68,.6); background: var(--down-bg); }
.tile.unknown { border-style: dashed; }
.tile.paused { opacity: .55; }

/* type bars */
.tbar { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; }
.tbar .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; }
.tbar .bar i { display: block; height: 100%; }
.tbar .bar i.u { background: var(--up); } .tbar .bar i.d { background: var(--down); }

/* ---------- modal / toast / alert popups ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2,6,16,.66); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 80; padding: 20px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: min(620px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: min(980px, 100%); } .modal.xl { width: min(1280px, 100%); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 16px; }
.modal .mb { padding: 20px; overflow: auto; }
.modal .mf { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; pointer-events: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel2); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 9px; align-items: center; animation: rise .2s; }
.toast.err { border-color: var(--down); } .toast.ok { border-color: var(--up); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.alerts { position: fixed; top: 72px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: 380px; max-height: calc(100vh - 90px); overflow: auto; pointer-events: none; }
.alert { pointer-events: auto; border-radius: 12px; overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,.45); animation: slide .35s cubic-bezier(.2,.9,.3,1.2); background: var(--panel); border: 1px solid var(--line2); }
.alert .ah { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; font-weight: 700; letter-spacing: .5px; font-size: 12.5px; }
.alert.down .ah { background: linear-gradient(90deg, #dc2626, #991b1b); }
.alert.up .ah { background: linear-gradient(90deg, #16a34a, #166534); }
.alert .ab { padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.alert .ab .k { color: var(--muted); font-size: 12px; }
.alert .ab .nm { grid-column: 1 / -1; font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.alert .af { display: flex; gap: 8px; padding: 0 14px 12px; }
.alert.down { border-color: rgba(239,68,68,.7); }
.alert.down .ah svg { animation: shake 1s infinite; }
@keyframes slide { from { transform: translateX(110%); opacity: 0; } }
@keyframes shake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(ellipse at top, rgba(59,130,246,.18), transparent 60%), radial-gradient(ellipse at bottom right, rgba(34,211,238,.12), transparent 50%), var(--bg); }
.login .box { width: 380px; padding: 34px 32px; }
.login h2 { margin: 18px 0 4px; font-size: 22px; }

/* ---------- floor plan ---------- */
.fp-wrap { position: relative; overflow: auto; background: repeating-conic-gradient(var(--panel2) 0 25%, var(--panel) 0 50%) 0 0 / 22px 22px; border-radius: 10px; border: 1px solid var(--line); height: calc(100vh - 230px); min-height: 420px; }
.fp-stage { position: relative; transform-origin: 0 0; display: inline-block; min-width: 100%; }
.fp-stage img { display: block; width: 100%; user-select: none; -webkit-user-drag: none; }
.fp-stage.noimg { min-height: 600px; }
.mk { position: absolute; transform: translate(-50%, -50%); z-index: 2; cursor: pointer; }
.mk .pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.45); }
.mk .pin svg { width: 15px; height: 15px; }
.mk.up .pin { background: #16a34a; } .mk.down .pin { background: #dc2626; animation: pulse 1.2s infinite; } .mk.unknown .pin { background: #7c3aed; } .mk.paused .pin { background: #64748b; }
.mk .lb { position: absolute; top: 33px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(2,6,16,.82); color: #fff; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; pointer-events: none; }
.mk.down .lb { background: #dc2626; }
.fp-edit .mk { cursor: grab; } .fp-edit .mk:active { cursor: grabbing; }
.fp-tray { max-height: calc(100vh - 290px); overflow: auto; }
.fp-tray .tile { cursor: grab; }

/* charts */
.chart svg { width: 100%; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); } .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }
.ring { position: relative; width: 150px; height: 150px; }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .c b { font-size: 26px; display: block; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; cursor: pointer; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 13px; } .kv > div:nth-child(odd) { color: var(--muted); }
code.blk { display: block; background: var(--bg2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 2px solid var(--bg); } ::-webkit-scrollbar-track { background: transparent; }

/* ---------- NEXORA brand ---------- */
.nx-mark, .nx-word, .nx-tag { display: inline-flex; flex: none; line-height: 0; }
.nx-img { display: block; width: auto; user-select: none; }
.th-light { display: none !important; }
[data-theme="light"] .th-light { display: block !important; } [data-theme="light"] .th-dark { display: none !important; }
.brand { gap: 10px; }
.brand .nx-word { margin-bottom: 5px; }
.brand .sub { font-size: 10px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--accent); font-weight: 600; display: block; }
.nx-lockup { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.nx-lockup .nx-mark { filter: drop-shadow(0 8px 26px rgba(14,165,233,.35)); margin-bottom: 4px; }
.nx-lockup .tag-line { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-top: 4px; }
.nx-by { display: flex; align-items: center; gap: 10px; justify-content: center; }
.nx-by span { display: block; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 1.5px; }
.nx-by b { font-size: 12px; font-weight: 600; color: var(--muted); }
.side-foot .nx-by { justify-content: flex-start; } .side-foot .nx-by img { width: 26px; height: 26px; }

.alert.info { border-color: rgba(59,130,246,.7); } .alert.info .ah { background: linear-gradient(90deg, #2563eb, #1e40af); }
.ribbon.lic { background: linear-gradient(90deg, rgba(245,158,11,.28), rgba(245,158,11,.06)); border-bottom-color: rgba(245,158,11,.45); color: #fde68a; }
[data-theme="light"] .ribbon.lic { color: #92400e; }
.ribbon.lic .blip { background: var(--warn); animation: none; }
.lic-hero { display: flex; gap: 22px; align-items: center; }
.lic-state { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.lic-state.licensed { color: var(--up); } .lic-state.trial { color: var(--warn); } .lic-state.expired { color: var(--down); }
.lockwrap { max-width: 980px; margin: 0 auto; }
