/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, #0c1220, #0a0f1a); border-right: 1px solid var(--line); padding: 18px 12px;
}
.side .brand { padding: 4px 8px 18px; }
.side .brand small { display: block; font: 600 11px var(--font); color: var(--dim); letter-spacing: .12em; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; position: relative;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--panel-2); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--lime); }
.nav .badge { margin-left: auto; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .me { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.side .me .who { min-width: 0; flex: 1; }
.side .me .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .me .who span { font-size: 12px; color: var(--dim); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-weight: 700; color: var(--lime); flex: none; }

.main { min-width: 0; padding: 28px 32px 60px; }
.top { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top .titles { flex: 1; min-width: 220px; }
.top .crumb { color: var(--dim); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.top .crumb a { color: var(--muted); }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; }

.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)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.card h2 { margin-bottom: 14px; }
.card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card .head h2 { margin: 0; flex: 1; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kpi .value { font: 700 34px/1.1 var(--display); margin-top: 6px; }
.kpi .sub { color: var(--dim); font-size: 13px; margin-top: 4px; }
.kpi.accent .value { color: var(--lime); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--dim); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--panel-2); }
.empty { padding: 40px; text-align: center; color: var(--dim); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.pill.ok { background: var(--lime-soft); color: var(--lime); border-color: rgba(182, 242, 58, .35); }
.pill.err { background: var(--danger-soft); color: #ff9da1; border-color: rgba(255, 93, 99, .4); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 184, 65, .4); }
.pill.info { background: var(--info-soft); color: var(--info); border-color: rgba(92, 200, 255, .35); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
.help { font-size: 12px; color: var(--dim); font-weight: 400; }
.search { max-width: 340px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: none; color: var(--muted); font: 700 14px var(--font); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--lime); }

/* ---------- kill switch ---------- */
.kill { display: flex; gap: 18px; align-items: center; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.kill.on { border-color: rgba(255, 93, 99, .6); background: linear-gradient(90deg, rgba(255, 93, 99, .16), var(--panel) 70%); }
.kill .icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line-2); flex: none; }
.kill.on .icon { background: var(--danger); border-color: var(--danger); color: #fff; }
.kill .txt { flex: 1; min-width: 0; }
.kill .txt b { font: 700 18px var(--display); text-transform: uppercase; letter-spacing: .03em; }

/* switch */
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line-2); transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--lime); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--lime-ink); }
.switch.danger input:checked + span { background: var(--danger); }
.switch.danger input:checked + span::after { background: #fff; }

/* ---------- chart ---------- */
.chart svg { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--lime); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .axis { fill: var(--dim); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.hbar { display: grid; grid-template-columns: 120px 1fr 50px; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.hbar .fill { height: 100%; background: var(--lime); border-radius: 4px; }

/* ---------- modal + toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 7, 13, .72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 18px; animation: pop .15s; }
.modal.wide { max-width: 820px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; max-width: 380px; animation: pop .15s; }
.toast.ok { border-color: rgba(182, 242, 58, .5); }
.toast.ok::before { content: "✓ "; color: var(--lime); }
.toast.err { border-color: rgba(255, 93, 99, .6); }
.toast.err::before { content: "! "; color: var(--danger); }

.codes { font-family: var(--mono); font-size: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; max-height: 280px; overflow-y: auto; white-space: pre; user-select: all; }
pre.stack { font-family: var(--mono); font-size: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; overflow: auto; max-height: 420px; white-space: pre-wrap; margin: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--dim); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end;
  background:
    radial-gradient(800px 420px at 20% 10%, rgba(182, 242, 58, .18), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 26px),
    linear-gradient(160deg, #101a2c, #070b13);
  border-right: 1px solid var(--line);
}
.login .art h1 { font-size: 64px; line-height: .95; max-width: 520px; }
.login .art h1 b { color: var(--lime); }
.login .art p { color: var(--muted); max-width: 440px; font-size: 16px; }
.login .pane { display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .g4, .form.cols { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login .art { display: none; }
  .kv { grid-template-columns: 1fr; }
}
