:root {
  --bg: #020617;
  --card: #0E1223;
  --card2: #141931;
  --border: #1E2745;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --accent: #22C55E;
  --accent-dim: rgba(34, 197, 94, .12);
  --danger: #EF4444;
  --warn: #F59E0B;
  --mono: 'GeistMono', ui-monospace, monospace;
  --sans: 'Geist', system-ui, sans-serif;
}
@font-face { font-family: 'Geist'; src: url('/fonts/Geist.woff2') format('woff2'); font-weight: 100 900; }
@font-face { font-family: 'GeistMono'; src: url('/fonts/GeistMono.woff2') format('woff2'); font-weight: 100 900; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#root { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 18px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13px; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(2, 6, 23, .85); backdrop-filter: blur(10px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); font-size: 13px;
}
.brand-sub { color: var(--muted); font-weight: 400; font-size: 13px; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

.wrap { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 220px; flex-shrink: 0; border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--muted); font: inherit; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.sidebar button:hover { background: var(--card); color: var(--text); }
.sidebar button.on { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.main { flex: 1; padding: 28px; overflow-y: auto; min-width: 0; }
.section { max-width: 860px; margin: 0 auto; animation: fadeUp .3s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stack > * + * { margin-top: 20px; }

/* ---------- cards / stats ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px;
}
.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .grid.c4, .grid.c2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 600; font-family: var(--mono); margin-top: 2px; }
.bar { height: 5px; border-radius: 3px; background: var(--card2); overflow: hidden; margin-top: 10px; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .4s ease; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--danger); }

/* ---------- forms / buttons ---------- */
input, select, textarea {
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit; padding: 9px 12px; width: 100%; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #052E14; border: none; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 500; cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.mono { font-size: 12px; }
.tbl-scroll { overflow-x: auto; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500;
  background: var(--card2); color: var(--muted);
}
.badge.ok { background: var(--accent-dim); color: var(--accent); }
.badge.bad { background: rgba(239, 68, 68, .12); color: var(--danger); }
.badge.warn { background: rgba(245, 158, 11, .12); color: var(--warn); }

/* ---------- key display ---------- */
.keybox {
  display: flex; align-items: center; gap: 10px; background: var(--card2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-family: var(--mono); font-size: 13px; word-break: break-all;
}
.keybox .grow { flex: 1; }
.snippet {
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-family: var(--mono); font-size: 12px; overflow-x: auto;
  white-space: pre; color: #C9D4E8; position: relative;
}
.snippet-copy { position: absolute; top: 8px; right: 8px; }

/* ---------- login ---------- */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; animation: fadeUp .35s ease both; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 24px; font-size: 17px; font-weight: 600; }
.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ---------- skeleton loaders ---------- */
.skel {
  border-radius: 8px; background: linear-gradient(90deg, var(--card2) 25%, #1B2240 50%, var(--card2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; height: 14px;
}
.skel.card-skel { height: 84px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50;
  display: grid; place-items: center; animation: fade .15s ease both; padding: 20px;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 420px; animation: fadeUp .2s ease both;
}
.modal h3 { margin-bottom: 14px; }

/* ---------- toast ---------- */
#toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; animation: fadeUp .2s ease both; max-width: 320px;
}
.toast.err { border-left-color: var(--danger); }

/* ---------- tabs ---------- */
.tabrow { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabrow button {
  background: none; border: none; color: var(--muted); font: inherit; padding: 8px 12px;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tabrow button.on { color: var(--accent); border-bottom-color: var(--accent); }
