:root {
  --bg: #08080b;
  --bg-elev: #0e0e13;
  --bg-card: #121218;
  --bg-card-2: #171720;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #ffffff;
  --accent-ink: #09090b;
  --emerald: #34d399;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-bd: rgba(52, 211, 153, 0.28);
  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --amber-bd: rgba(251, 191, 36, 0.28);
  --red: #f87171;
  --red-bg: rgba(239, 68, 68, 0.12);
  --red-bd: rgba(248, 113, 113, 0.28);
  --violet: #a78bfa;
  --violet-bg: rgba(139, 92, 246, 0.14);
  --sky: #38bdf8;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.text-ok { color: var(--emerald); }
.text-warn { color: var(--amber); }
.text-bad { color: var(--red); }

/* Layout helpers */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg-card-2); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s ease; white-space: nowrap; }
.btn:hover { background: #20202b; border-color: rgba(255,255,255,0.26); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #e4e4e7; }
.btn.emerald { background: var(--emerald-bg); color: var(--emerald); border-color: var(--emerald-bd); }
.btn.emerald:hover { background: rgba(16,185,129,0.2); }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }
.btn.danger:hover { background: rgba(239,68,68,0.22); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 7px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 14px; border-radius: 10px; }

/* Cards & surfaces */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-elev { background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; margin-top: 6px; color: #fff; }
.kpi-sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--emerald-bg); color: var(--emerald); border-color: var(--emerald-bd); }
.badge.warn { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-bd); }
.badge.bad { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }
.badge.violet { background: var(--violet-bg); color: var(--violet); border-color: rgba(167,139,250,0.3); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 9px 12px; color: var(--text); outline: none; transition: border-color .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: rgba(255,255,255,0.45); }
textarea { resize: vertical; min-height: 82px; }
.codebox { display: flex; align-items: center; gap: 8px; background: #09090d; border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-family: var(--mono); font-size: 12.5px; color: #e4e4e7; overflow-x: auto; }
.codebox code, .codebox pre { margin: 0; flex: 1; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12.5px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); font-weight: 600; background: rgba(255,255,255,0.015); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255,255,255,0.018); }

/* Dashboard Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--bg-elev); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15.5px; letter-spacing: -0.02em; padding: 6px 10px 18px; color: #fff; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: linear-gradient(135deg, #fff, #94a3b8); color: #09090b; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; cursor: pointer; border: 1px solid transparent; background: transparent; width: 100%; text-align: left; transition: all .12s ease; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(255,255,255,0.08); color: #fff; border-color: var(--border); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.main { flex: 1; min-width: 0; padding: 28px 32px 64px; max-width: 1280px; }
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; align-items: center; padding: 12px; }
  .brand { padding: 0 10px 0 0; }
  .sidebar-foot { margin-top: 0; padding-top: 0; border-top: 0; margin-left: auto; }
  .main { padding: 20px 16px 48px; }
}

/* Tabs */
.tabs { display: inline-flex; gap: 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.tab { padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; border: 0; background: transparent; }
.tab.active { background: var(--bg-card-2); color: #fff; box-shadow: inset 0 0 0 1px var(--border-strong); }

/* Progress bars */
.bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: #fff; }
.bar > i.warn { background: var(--amber); }
.bar > i.hot { background: var(--red); }

/* Modals */
dialog.modal { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-card); color: var(--text); padding: 0; width: min(94vw, 640px); max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.75); }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: rgba(255,255,255,0.015); }

/* Toast */
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 999; background: #181820; color: #fff; border: 1px solid var(--border-strong); padding: 11px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 14px 36px rgba(0,0,0,0.6); opacity: 0; transform: translateY(10px); pointer-events: none; transition: all .2s ease; max-width: 420px; }
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.ok { border-color: var(--emerald-bd); }
.toast.bad { border-color: var(--red-bd); color: var(--red); }
.hidden { display: none !important; }

/* Landing glow */
.hero-glow { position: relative; overflow: hidden; }
.hero-glow::before { content: ""; position: absolute; top: -180px; left: 50%; transform: translateX(-50%); width: 820px; height: 420px; background: radial-gradient(ellipse at center, rgba(167,139,250,0.16), rgba(56,189,248,0.06) 45%, transparent 72%); pointer-events: none; }
.chart-svg { width: 100%; height: 210px; display: block; }
