:root {
  --bg: #0b1120;
  --bg-card: #111827;
  --bg-elevated: #1f2937;
  --border: #283548;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-badge {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.brand-title { font-weight: 700; font-size: 0.98rem; color: #fff; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); }

.nav-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.75rem; border-radius: 8px;
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  margin-bottom: 0.25rem; text-decoration: none;
}
.nav-link:hover { background: var(--bg-elevated); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(59,130,246,0.16); color: #60a5fa; border: 1px solid rgba(59,130,246,0.35); }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--text-muted); }

.main-area { flex: 1; padding: 1.75rem 2rem; max-width: 1400px; width: 100%; overflow-x: auto; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { margin: 0; font-size: 1.45rem; font-weight: 700; }
.page-subtitle { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-title { margin: 0 0 0.75rem; font-size: 1.02rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.kpi-value { font-size: 1.75rem; font-weight: 700; margin: 0.25rem 0; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
}
.badge-ok { background: rgba(16,185,129,0.16); color: #34d399; border: 1px solid rgba(16,185,129,0.35); }
.badge-warn { background: rgba(245,158,11,0.16); color: #fbbf24; border: 1px solid rgba(245,158,11,0.35); }
.badge-err { background: rgba(239,68,68,0.16); color: #f87171; border: 1px solid rgba(239,68,68,0.35); }
.badge-neutral { background: rgba(156,163,175,0.16); color: #d1d5db; border: 1px solid rgba(156,163,175,0.3); }
.badge-info { background: rgba(56,189,248,0.16); color: #7dd3fc; border: 1px solid rgba(56,189,248,0.35); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.52rem 0.95rem; border-radius: 8px; border: 1px solid transparent;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #374151; }
.btn-danger { background: rgba(239,68,68,0.18); color: #fca5a5; border-color: rgba(239,68,68,0.45); }
.btn-danger:hover { background: rgba(239,68,68,0.32); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }

.form-group { margin-bottom: 0.95rem; }
.form-label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 0.35rem; color: #e5e7eb; }
.form-hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.25rem; }
.input, select, textarea {
  width: 100%; padding: 0.55rem 0.75rem; border-radius: 8px;
  background: #0f172a; border: 1px solid var(--border); color: var(--text);
  font-size: 0.9rem;
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

.alert { padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.88rem; }
.alert-ok { background: rgba(16,185,129,0.14); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7; }
.alert-warn { background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.4); color: #fcd34d; }
.alert-err { background: rgba(239,68,68,0.14); border: 1px solid rgba(239,68,68,0.45); color: #fca5a5; }
.alert-info { background: rgba(56,189,248,0.12); border: 1px solid rgba(56,189,248,0.35); color: #bae6fd; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.5rem; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto;
}

.step-list { list-style: none; padding: 0; margin: 0; }
.step-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; margin-top: 2px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.83rem; }
.flex-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab-btn { background: none; border: none; color: var(--text-muted); padding: 0.6rem 1rem; cursor: pointer; font-weight: 600; border-bottom: 2px solid transparent; }
.tab-btn.active { color: #60a5fa; border-bottom-color: #3b82f6; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .main-area { padding: 1.1rem; }
  .grid-2 { grid-template-columns: 1fr; }
}
