:root {
  --bg: #09090b;
  --surface: #111116;
  --surface-2: #181820;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #8b8b99;
  --indigo: #6366f1;
  --violet: #8b5cf6;
  --mint: #34d399;
  --amber: #fbbf24;
  --danger: #f87171;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: radial-gradient(circle at 50% -10%, rgba(99, 102, 241, 0.14) 0%, var(--bg) 42%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 0.82em; }
.muted { color: var(--muted); font-size: 0.84rem; }
.hidden { display: none !important; }

/* Auth Gate */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.auth-card h1 { font-size: 1.35rem; letter-spacing: -0.02em; }

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.brand-icon.sm { width: 34px; height: 34px; border-radius: 9px; }

.error-text {
  color: var(--danger);
  font-size: 0.8rem;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  padding: 8px 10px;
  border-radius: 8px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 28px;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 1rem; margin-right: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.kpi-val {
  font-size: 1.65rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.kpi-val.mint { color: var(--mint); }
.kpi-val.indigo { color: #a5b4fc; }
.kpi-sub { font-size: 0.76rem; color: var(--muted); }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-head h2 { font-size: 1.05rem; letter-spacing: -0.01em; }

/* Forms & Inputs */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}

.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .span-2 { grid-column: span 1; } }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.input {
  font-family: var(--font);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  outline: none;
  width: 100%;
}

.input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.search-sm { max-width: 320px; }
.form-actions { display: flex; justify-content: flex-start; align-items: flex-end; }
.form-actions .btn { height: 40px; }

/* Buttons */
.btn {
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.14s ease, background 0.14s ease;
}

.btn-full { width: 100%; padding: 11px; }
.btn-sm { padding: 7px 12px; font-size: 0.78rem; border-radius: 8px; }
.btn-xs { padding: 5px 9px; font-size: 0.72rem; border-radius: 7px; }

.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover { opacity: 0.92; }

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.btn-ghost:hover { background: #22222d; color: var(--text); }

.btn-danger-ghost {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.btn-danger-ghost:hover { background: rgba(248, 113, 113, 0.18); }

/* Pills */
.pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-mint { background: rgba(52, 211, 153, 0.14); color: var(--mint); }
.pill-amber { background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.pill-indigo { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; }
.pill-danger { background: rgba(248, 113, 113, 0.14); color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.table th, .table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.table tr:hover td { background: rgba(255, 255, 255, 0.015); }
.act-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a24;
  border: 1px solid rgba(129, 140, 248, 0.45);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 0.84rem;
  z-index: 100;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.toast.error { border-color: rgba(248, 113, 113, 0.55); color: #fecaca; }
