/* ============================================================
   MKX — Design System v2
   Dark-first control plane for AI traffic. Ink surfaces, a single
   volt-citron signal color reserved for "live/active", Space Grotesk
   display type, JetBrains Mono for anything that counts.
   ============================================================ */

@font-face {
  font-family: 'Space Grotesk';
  src: url('/assets/fonts/space-grotesk-500.woff2') format('woff2');
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/assets/fonts/space-grotesk-700.woff2') format('woff2');
  font-weight: 600 800;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/jetbrains-mono-400.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}

:root {
  /* ink surfaces */
  --bg0: #0b0e14;
  --bg1: #10141c;
  --bg2: #141a24;
  --bg3: #1a2230;
  --bg-hover: #1d2634;
  --border: #1e2733;
  --border-strong: #2c3848;
  /* text */
  --text: #e8edf5;
  --text2: #93a0b4;
  --text3: #5d6b80;
  /* signal */
  --volt: #d8f651;
  --volt-dim: rgba(216, 246, 81, 0.12);
  --volt-line: rgba(216, 246, 81, 0.38);
  --teal: #4fd6be;
  --teal-dim: rgba(79, 214, 190, 0.11);
  --red: #ff6b5e;
  --red-dim: rgba(255, 107, 94, 0.10);
  --amber: #ffc24b;
  --amber-dim: rgba(255, 194, 75, 0.11);
  --blue: #6fb7ff;
  --blue-dim: rgba(111, 183, 255, 0.10);
  --purple: #b48cff;
  /* legacy aliases (charts reference these) */
  --accent: var(--volt);
  --accent-hover: #e4ff70;
  --accent-dim: var(--volt-dim);
  --accent-text: var(--volt);
  --green: var(--teal);
  --green-dim: var(--teal-dim);

  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Space Grotesk', ui-sans-serif, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --sidebar-w: 240px;
}

[data-theme="light"] {
  --bg0: #f3f4f2;
  --bg1: #fcfcfa;
  --bg2: #eef0ec;
  --bg3: #e3e6df;
  --bg-hover: #e7eadf;
  --border: #dfe2da;
  --border-strong: #c6cabd;
  --text: #161a14;
  --text2: #4c5546;
  --text3: #7d8676;
  --volt: #5f7a00;
  --volt-dim: rgba(95, 122, 0, 0.10);
  --volt-line: rgba(95, 122, 0, 0.35);
  --teal: #0c7d6b; --teal-dim: rgba(12,125,107,.08);
  --red: #c73e30; --red-dim: rgba(199,62,48,.07);
  --amber: #9a6a00; --amber-dim: rgba(154,106,0,.09);
  --blue: #2563ae; --blue-dim: rgba(37,99,174,.08);
  --purple: #6d43c4;
  --shadow: 0 14px 34px rgba(40, 44, 36, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 480px at 78% -220px, rgba(216, 246, 81, 0.05), transparent 60%),
    var(--bg0);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--volt-dim); color: var(--text); }
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg0); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Boot splash ---------- */
.boot-splash { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--volt);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 16px;
}
.brand-mark { display: grid; place-items: center; flex-shrink: 0; }
.brand-mark svg { display: block; }
.brand-name {
  font-family: var(--font); font-weight: 700; font-size: 18px;
  letter-spacing: 0.06em; color: var(--text);
}
.brand-name em { font-style: normal; color: var(--volt); }
.brand-sub {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text3); margin-top: 1px;
}

.sidebar-section { padding: 12px 12px 2px; }
.sidebar-label {
  padding: 0 10px 7px; font-family: var(--mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--text3);
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7.5px 10px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text2); font-weight: 500; font-size: 13.5px;
  cursor: pointer; user-select: none;
  transition: background 0.12s, color 0.12s;
  animation: navIn 0.35s ease backwards;
}
.nav-item:nth-child(1) { animation-delay: 0.03s; }
.nav-item:nth-child(2) { animation-delay: 0.06s; }
.nav-item:nth-child(3) { animation-delay: 0.09s; }
.nav-item:nth-child(4) { animation-delay: 0.12s; }
.nav-item:nth-child(5) { animation-delay: 0.15s; }
@keyframes navIn { from { opacity: 0; transform: translateX(-7px); } }
.nav-item svg { width: 15.5px; height: 15.5px; opacity: 0.72; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--volt-dim); color: var(--volt); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 2.5px;
  border-radius: 2px; background: var(--volt);
  box-shadow: 0 0 12px var(--volt-line);
}

.sidebar-footer {
  margin-top: auto; padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 29px; height: 29px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border-strong);
  color: var(--volt);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; font-family: var(--mono);
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user .name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .email { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; padding: 28px 34px 64px; max-width: 1320px; animation: pageIn 0.3s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 3px; }
.page-sub { color: var(--text2); font-size: 13px; margin: 0; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.topbar-mobile { display: none; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0;
    transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-mobile {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg0) 88%, transparent);
    backdrop-filter: blur(8px);
    padding: 10px 16px; border-bottom: 1px solid var(--border);
  }
  .main { padding: 18px 16px 50px; }
}

/* ---------- Cards & stats ---------- */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-strong); }
.card + .card { margin-top: 16px; }
.card-title { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; color: var(--text); letter-spacing: 0.01em; }
.card-sub { font-size: 12px; color: var(--text3); margin: -8px 0 12px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  position: relative;
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px 12px;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--volt), transparent 70%);
  opacity: 0; transition: opacity 0.15s;
}
.stat:hover::after { opacity: 0.55; }
.stat .label {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text3);
}
.stat .value {
  font-family: var(--mono); font-size: 21px; font-weight: 600;
  margin-top: 6px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .delta { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.stat.good .value { color: var(--teal); }
.stat.bad .value { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-31 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1080px) { .grid-2, .grid-31 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto; max-height: 68vh;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg1);
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3);
  padding: 10px 14px; border-bottom: 1px solid var(--border-strong);
  background: var(--bg2);
  white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.08s; }
.tbl tbody tr:hover { background: var(--bg2); box-shadow: inset 2.5px 0 0 var(--volt-line); }
.tbl td.wrap { white-space: normal; word-break: break-all; }
.tbl .num { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; }
tr:hover .row-actions { opacity: 1; }

.table-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar .grow { flex: 1; }

.pagination { display: flex; align-items: center; gap: 10px; padding: 10px 2px 0; font-size: 12.5px; color: var(--text2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em; padding: 3px 9px;
  border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 5.5px; height: 5.5px; border-radius: 50%; background: currentColor; }
.badge.green { color: var(--teal); background: var(--teal-dim); border-color: rgba(79,214,190,0.25); }
.badge.red { color: var(--red); background: var(--red-dim); border-color: rgba(255,107,94,0.25); }
.badge.amber { color: var(--amber); background: var(--amber-dim); border-color: rgba(255,194,75,0.25); }
.badge.blue { color: var(--blue); background: var(--blue-dim); border-color: rgba(111,183,255,0.25); }
.badge.gray { color: var(--text2); background: var(--bg3); border-color: var(--border-strong); }
.badge.purple { color: var(--purple); background: rgba(180,140,255,0.10); border-color: rgba(180,140,255,0.25); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  letter-spacing: 0.01em;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg2); color: var(--text);
  cursor: pointer; transition: all 0.13s; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }
.btn.primary {
  background: var(--volt); border-color: transparent; color: #10130a;
}
.btn.primary:hover { background: var(--accent-hover); box-shadow: 0 4px 20px var(--volt-line); }
.btn.danger { color: var(--red); border-color: rgba(255,107,94,0.35); background: transparent; }
.btn.danger:hover { background: var(--red-dim); border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { padding: 4.5px 10px; font-size: 12.5px; }
.btn.icon-only { padding: 6px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; color: var(--text2); }
.input, select.input, textarea.input {
  width: 100%; font-family: var(--font); font-size: 13.5px;
  background: var(--bg0); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8.5px 11px; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus { border-color: var(--volt); box-shadow: 0 0 0 3px var(--volt-dim); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
.hint { font-size: 11.5px; color: var(--text3); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text3); }
.search-box .input { padding-left: 31px; width: 250px; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--bg3); border: 1px solid var(--border-strong); transition: 0.15s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: var(--text2); transition: 0.15s; }
.switch input:checked + .slider { background: var(--volt); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(14px); background: #10130a; }

.checkbox { width: 15px; height: 15px; accent-color: var(--volt); cursor: pointer; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 8px 14px; font-size: 13px; font-weight: 550; color: var(--text2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  user-select: none; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--volt); border-bottom-color: var(--volt); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 6, 10, 0.66); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 16px 16px; animation: fadeIn 0.14s ease;
}
.modal {
  background: var(--bg1); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 480px; max-height: 82vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.16s ease;
}
.modal.lg { max-width: 660px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-title { font-size: 15.5px; font-weight: 650; margin: 0; }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 4px 20px 18px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } }

.secret-reveal {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg0); border: 1px dashed var(--volt);
  border-radius: var(--radius-sm); padding: 11px 13px;
  word-break: break-all; user-select: all; color: var(--volt);
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--bg2); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--volt);
  border-radius: var(--radius-sm); padding: 11px 14px;
  box-shadow: var(--shadow); font-size: 13px;
  animation: toastIn 0.18s ease;
}
.toast.success { border-left-color: var(--teal); }
.toast.error { border-left-color: var(--red); }
.toast .msg { flex: 1; }
.toast .close { cursor: pointer; color: var(--text3); font-size: 15px; line-height: 1; padding: 0 2px; }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }

/* ---------- States ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text3); }
.empty .icon { font-size: 30px; margin-bottom: 10px; opacity: 0.6; }
.empty .title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.empty .sub { font-size: 12.5px; }
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg-hover) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  height: 14px; margin: 9px 0;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.error-banner {
  background: var(--red-dim); border: 1px solid rgba(255,107,94,0.3);
  color: var(--red); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--text3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 1.5px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

.progressbar { height: 6px; border-radius: 999px; background: var(--bg3); overflow: hidden; }
.progressbar > div { height: 100%; border-radius: 999px; background: var(--volt); transition: width 0.4s ease; }
.progressbar.warn > div { background: var(--amber); }
.progressbar.crit > div { background: var(--red); }

/* ---------- Charts ---------- */
.chart-box { position: relative; }
.chart-svg { width: 100%; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--text2); margin-top: 8px; flex-wrap: wrap; }
.chart-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--bg3); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 10px; font-size: 11.5px;
  box-shadow: var(--shadow); white-space: nowrap; display: none;
  font-family: var(--mono);
}
.donut-center { font-family: var(--mono); }

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -160px, rgba(216, 246, 81, 0.07), transparent 62%),
    radial-gradient(700px 380px at 82% 108%, rgba(79, 214, 190, 0.05), transparent 60%),
    var(--bg0);
  position: relative;
  overflow: hidden;
}
.auth-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(720px 420px at 50% 30%, rgba(0,0,0,0.5), transparent 78%);
  opacity: 0.5;
}
.auth-card { width: 100%; max-width: 392px; position: relative; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-logo h1 {
  font-size: 30px; font-weight: 700; letter-spacing: 0.08em; margin: 2px 0 0;
}
.auth-logo h1 em { font-style: normal; color: var(--volt); }
.auth-logo p { font-size: 12.5px; color: var(--text2); margin: 0; }
.auth-card .card { padding: 24px 22px; position: relative; overflow: hidden; }
.auth-card .card::before {
  content: ""; position: absolute; top: 0; left: 8%; right: 8%; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--volt-line), transparent);
  animation: trace 3.2s ease-in-out infinite alternate;
}
@keyframes trace { from { transform: translateX(-46%); } to { transform: translateX(46%); } }
.auth-foot { text-align: center; margin-top: 16px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); }

/* ---------- Misc ---------- */
.flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.text-dim { color: var(--text3); }
.text-small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.theme-toggle { background: none; border: none; color: var(--text3); cursor: pointer; padding: 6px; border-radius: 7px; display: grid; place-items: center; }
.theme-toggle:hover { background: var(--bg-hover); color: var(--volt); }
.theme-toggle svg { width: 16px; height: 16px; }
.copy-btn { cursor: pointer; color: var(--text3); background: none; border: none; padding: 3px; border-radius: 4px; display: inline-flex; }
.copy-btn:hover { color: var(--volt); background: var(--bg-hover); }
.copy-btn svg { width: 13px; height: 13px; }

/* ---------- v3: shell main column + desktop topbar ---------- */
.shell-main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-desktop {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 34px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg0) 72%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.topbar-search {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 12.5px; color: var(--text3);
  background: var(--bg1); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 6px 11px; cursor: pointer;
  min-width: 230px; transition: all 0.12s;
}
.topbar-search:hover { color: var(--text2); border-color: var(--text3); }
.topbar-search svg { width: 14px; height: 14px; }
.topbar-search kbd {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  color: var(--text3); background: var(--bg3); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 1.5px 5px;
}
@media (max-width: 900px) { .topbar-desktop { display: none; } }

/* ---------- v3: command palette ---------- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4, 6, 10, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 14vh 16px 16px; animation: fadeIn 0.12s ease;
}
.cmdk {
  width: 100%; max-width: 520px;
  background: var(--bg1); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; animation: slideUp 0.14s ease;
}
.cmdk-input {
  width: 100%; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: var(--font); font-size: 15px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 7px; }
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text2); font-size: 13.5px;
}
.cmdk-item.sel { background: var(--volt-dim); color: var(--volt); }
.cmdk-label { flex: 1; }
.cmdk-hint { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.65; }

/* ---------- v3: eyebrows + KPI stack ---------- */
.eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--volt); margin-bottom: 7px;
  display: flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ""; width: 18px; height: 1.5px; background: var(--volt-line); }

.kpi-stack { margin: 0; display: flex; flex-direction: column; }
.kpi-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 8.5px 0; border-bottom: 1px dashed var(--border);
}
.kpi-row:last-child { border-bottom: none; }
.kpi-row dt {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text3);
}
.kpi-row dd {
  margin: 0; font-family: var(--mono); font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.kpi-row dd.good { color: var(--teal); }
.kpi-row dd.bad { color: var(--red); }

/* live chart pulse */
.live-halo { animation: pulse 2s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 0% { opacity: 0.35; transform: scale(1); } 70% { opacity: 0; transform: scale(2.6); } 100% { opacity: 0; } }

/* hero layout for overview pages */
.hero-grid { display: grid; grid-template-columns: 1fr 280px; gap: 0; }
.hero-grid > .hero-chart-cell { padding-right: 22px; }
.hero-grid > .hero-kpi-cell {
  border-left: 1px solid var(--border); padding-left: 22px;
  display: flex; flex-direction: column;
}
.hero-grid > .hero-kpi-cell .card-title { margin-bottom: 4px; }
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-grid > .hero-chart-cell { padding-right: 0; padding-bottom: 16px; }
  .hero-grid > .hero-kpi-cell { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}

.mini-pool-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px;
}
.mini-pool-row:last-child { border-bottom: none; }
.mini-pool-row .name { flex: 1; color: var(--text2); }

/* ============================================================
   v4 — mission-control layer: depth, status band, orchestrated load
   ============================================================ */

/* card depth: hairline top-light on raised surfaces */
.card, .stat {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.028);
}
[data-theme="light"] .card, [data-theme="light"] .stat {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* orchestrated load: direct children of .main assemble in sequence */
.main > * { animation: riseIn 0.42s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
.main > :nth-child(1) { animation-delay: 0.02s; }
.main > :nth-child(2) { animation-delay: 0.07s; }
.main > :nth-child(3) { animation-delay: 0.12s; }
.main > :nth-child(4) { animation-delay: 0.17s; }
.main > :nth-child(5) { animation-delay: 0.22s; }
.main > :nth-child(6) { animation-delay: 0.27s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(9px); } }

/* ---------- live status band ---------- */
.status-band {
  display: flex; align-items: center; gap: 13px;
  padding: 7px 34px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg1) 78%, transparent);
  font-family: var(--mono); font-size: 11px; color: var(--text2);
  overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.status-band::-webkit-scrollbar { display: none; }
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2.5px 9px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--border-strong);
  color: var(--text3); flex-shrink: 0;
}
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-chip.ok { color: var(--teal); border-color: rgba(79, 214, 190, 0.28); }
.status-chip.warn { color: var(--amber); border-color: rgba(255, 194, 75, 0.28); }
.status-chip.bad { color: var(--red); border-color: rgba(255, 107, 94, 0.28); }
.status-chip.pulse::before { animation: chipPulse 1.7s ease-in-out infinite; }
@keyframes chipPulse { 50% { opacity: 0.3; } }
.status-band .num { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-band .lbl {
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text3); margin-right: -4px;
}
.band-sep { width: 1px; height: 15px; background: var(--border-strong); flex-shrink: 0; }
.band-right { margin-left: auto; display: flex; gap: 13px; align-items: center; flex-shrink: 0; }
@media (max-width: 900px) { .status-band { padding: 7px 16px; } .band-right .hide-sm { display: none; } }

/* ---------- login logomark draw-on ---------- */
.auth-logo svg .draw-path {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawStroke 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards 0.15s;
}
.auth-logo svg .draw-path:nth-of-type(2) { animation-delay: 0.4s; }
.auth-logo svg circle { opacity: 0; transform-origin: center; transform-box: fill-box; animation: nodePop 0.4s ease forwards; }
.auth-logo svg circle:nth-of-type(1) { animation-delay: 0.55s; }
.auth-logo svg circle:nth-of-type(2) { animation-delay: 0.95s; }
.auth-logo svg circle:nth-of-type(3) { animation-delay: 0.75s; }
.auth-logo svg circle:nth-of-type(4) { animation-delay: 1.15s; }
@keyframes drawStroke { to { stroke-dashoffset: 0; } }
@keyframes nodePop { 0% { opacity: 0; transform: scale(0.2); } 100% { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .auth-logo svg .draw-path { stroke-dashoffset: 0; animation: none; }
  .auth-logo svg circle { opacity: 1; animation: none; }
}

/* ============================================================
   v5 — LIQUID GLASS layer
   Glass lives ONLY on the navigation/chrome layer (skill law):
   topbar, status band, sidebar, palette, modals, toasts, login card.
   Content (cards, tables, stats) stays readable-solid.
   ============================================================ */

/* atmosphere behind the glass — without something to refract, glass reads as grey */
body::after {
  content: "";
  position: fixed; inset: -20%;
  z-index: -1;
  background:
    radial-gradient(560px 420px at 84% 6%, rgba(216, 246, 81, 0.055), transparent 62%),
    radial-gradient(680px 520px at 8% 88%, rgba(79, 214, 190, 0.05), transparent 60%),
    radial-gradient(420px 320px at 55% 45%, rgba(111, 183, 255, 0.032), transparent 65%);
  animation: orbDrift 70s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes orbDrift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.04); }
}

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 -1px 0 rgba(255, 255, 255, 0.02),
    0 12px 36px rgba(0, 0, 0, 0.38);
}

:root {
  --glass-bg: color-mix(in srgb, var(--bg1) 62%, transparent);
  --glass-filter: blur(22px) saturate(165%);
  --glass-edge: rgba(255, 255, 255, 0.07);
}
[data-theme="light"] {
  --glass-bg: color-mix(in srgb, #ffffff 58%, transparent);
  --glass-edge: rgba(22, 26, 20, 0.08);
}

/* floating island topbar */
.topbar-desktop {
  position: sticky; top: 10px;
  margin: 14px 28px 0;
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 14px 40px rgba(0, 0, 0, 0.35);
}
/* band floats directly beneath */
.status-band {
  position: sticky; top: 72px;
  margin: 9px 28px 0;
  border: 1px solid var(--glass-edge);
  border-radius: 11px;
  background: color-mix(in srgb, var(--bg1) 52%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 10px 28px rgba(0, 0, 0, 0.3);
}

/* sidebar becomes a glass rail */
.sidebar {
  background: color-mix(in srgb, var(--bg1) 55%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border-right: 1px solid var(--glass-edge);
}

/* modals, palette, toasts */
.modal, .cmdk {
  background: color-mix(in srgb, var(--bg1) 78%, transparent);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  border: 1px solid var(--glass-edge);
}
.toast {
  background: color-mix(in srgb, var(--bg2) 76%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}

/* login card floats on its grid + glow field */
.auth-wrap {
  background:
    radial-gradient(900px 420px at 50% -160px, rgba(216, 246, 81, 0.09), transparent 62%),
    radial-gradient(700px 380px at 82% 108%, rgba(79, 214, 190, 0.06), transparent 60%),
    var(--bg0);
}
.auth-card .card {
  background: color-mix(in srgb, var(--bg1) 58%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 22px 60px rgba(0, 0, 0, 0.42);
}

/* hero card earns glass; ordinary content cards stay near-solid for legibility */
.hero-grid { position: relative; }

/* --- accessibility & fallbacks (skill law) --- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar-desktop, .status-band, .sidebar, .modal, .cmdk, .toast,
  .auth-card .card {
    background: var(--bg1);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-bg: var(--bg1); }
  .topbar-desktop, .status-band, .sidebar, .modal, .cmdk, .toast,
  .auth-card .card {
    background: var(--bg1) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: var(--shadow);
  }
}

/* --- touch devices: row actions are hover-revealed on pointer devices; always show them --- */
@media (hover:none) {
  .row-actions { opacity: 1; }
}
