:root {
  --bg: #080b12;
  --bg-soft: #0d1220;
  --panel: #111827;
  --panel-2: #151d2e;
  --line: #1e293b;
  --line-soft: #17223a;
  --text: #e6edf7;
  --muted: #8fa0b8;
  --dim: #5c6b82;
  --violet: #7c5cff;
  --violet-soft: rgba(124, 92, 255, 0.14);
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 14px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(34, 211, 238, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.boot { height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot-mark {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--violet), #4f46e5); font-weight: 800; font-size: 26px; color: #fff;
  box-shadow: 0 0 40px rgba(124, 92, 255, 0.45); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(0.94); opacity: 0.7 } }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 254px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(13, 18, 32, 0.92), rgba(8, 11, 18, 0.86));
  backdrop-filter: blur(10px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(140deg, var(--violet), #4338ca); color: #fff; box-shadow: 0 0 26px rgba(124, 92, 255, 0.4);
}
.brand-name { font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.14em; }

.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-label { font-size: 10px; letter-spacing: 0.18em; color: var(--dim); padding: 16px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px;
  color: var(--muted); text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s; font-size: 13.5px;
}
.nav-item:hover { background: rgba(124, 92, 255, 0.09); color: var(--text); }
.nav-item.active { background: var(--violet-soft); border-color: rgba(124, 92, 255, 0.35); color: #fff; }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, 0.06);
  padding: 1px 7px; border-radius: 999px;
}
.icon { width: 17px; height: 17px; flex: none; }

.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--line-soft); }
.conn-mini { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, 0.7); }
.dot.bad { background: var(--red); box-shadow: 0 0 10px rgba(248, 113, 113, 0.6); }
.dot.warn { background: var(--amber); }

/* ----------------------------------------------------------------- main */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 11, 18, 0.82); backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--dim); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { padding: 24px 26px 60px; max-width: 1500px; width: 100%; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: linear-gradient(170deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 14px; margin: 0; font-weight: 600; letter-spacing: 0.01em; }
.card-head .eyebrow { margin-left: auto; font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.14em; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat-foot { font-size: 12px; color: var(--muted); }

.meter { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--cyan)); }
.meter.amber > span { background: linear-gradient(90deg, var(--amber), #f97316); }
.meter.row { display: flex; gap: 4px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow: auto; border: 1px solid var(--line-soft); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #0e1524; text-align: left; font-weight: 600; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(30, 41, 59, 0.55); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background 0.12s; }
tbody tr:hover { background: rgba(124, 92, 255, 0.07); }
tbody tr:last-child td { border-bottom: 0; }
td .primary { font-weight: 600; color: var(--text); }
td .secondary { color: var(--muted); font-size: 12px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { color: #6ee7b7; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.3); }
.badge.bad { color: #fca5a5; background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.3); }
.badge.warn { color: #fcd34d; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.3); }
.badge.muted { color: var(--muted); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.badge.violet { color: #c4b5fd; background: var(--violet-soft); border-color: rgba(124, 92, 255, 0.32); }

/* -------------------------------------------------------------- controls */
input, select, textarea {
  background: #0b1220; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font: inherit; outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16); }
input::placeholder { color: var(--dim); }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 13px;
  background: linear-gradient(140deg, var(--violet), #5b4bdd); color: #fff; border: 1px solid transparent;
  cursor: pointer; transition: transform 0.12s, filter 0.12s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--violet); }
.btn.danger { background: rgba(248, 113, 113, 0.14); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; cursor: pointer; background: transparent; font: inherit;
}
.chip.active { border-color: var(--violet); color: #fff; background: var(--violet-soft); }

/* --------------------------------------------------------------- states */
.skeleton { display: grid; gap: 10px; }
.sk-row { height: 42px; border-radius: 10px; background: linear-gradient(90deg, #0f1727 25%, #16203400 50%, #0f1727 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

.empty { display: grid; place-items: center; text-align: center; padding: 44px 18px; color: var(--muted); gap: 6px; }
.empty h3 { margin: 6px 0 0; font-size: 15px; color: var(--text); }
.empty p { margin: 0; font-size: 13px; max-width: 420px; }
.empty-orb {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--violet-soft); color: #c4b5fd; font-size: 20px; border: 1px solid rgba(124, 92, 255, 0.3);
}
.empty.error .empty-orb { background: rgba(248, 113, 113, 0.12); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); padding: 32px; border-radius: 20px;
  background: linear-gradient(170deg, #121a2b, #0a0f19); border: 1px solid var(--line);
  box-shadow: 0 40px 80px -40px #000;
}
.login-card h1 { margin: 18px 0 6px; font-size: 22px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-err { color: #fca5a5; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* --------------------------------------------------------------- drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(3px);
  z-index: 40; animation: fade 0.16s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(720px, 100%);
  background: linear-gradient(180deg, #0d1424, #080c14); border-left: 1px solid var(--line);
  z-index: 41; display: flex; flex-direction: column; animation: slide 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes slide { from { transform: translateX(30px); opacity: 0.4 } to { transform: none; opacity: 1 } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { margin: 0 0 4px; font-size: 17px; }
.drawer-head p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 540px; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; }
.drawer-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--dim); margin: 22px 0 10px; }
.drawer-body h3:first-child { margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; }
.tab { padding: 8px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit; }
.tab.active { color: #fff; border-bottom-color: var(--violet); }

/* --------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  padding: 11px 15px; border-radius: 10px; font-size: 13px; color: var(--text);
  background: #131c2e; border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: toastIn 0.2s ease-out; max-width: 360px;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.bad { border-color: rgba(248, 113, 113, 0.4); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ------------------------------------------------------------- responsive */
.menu-btn { display: none; }
@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 60px; }
  .topbar { padding: 12px 14px; }
  .drawer { width: 100%; }
}
