@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sb-bg: #0a0f1e;
  --sb-surface: #111827;
  --sb-text: #6b7280;
  --sb-text-active: #ffffff;
  --sb-active-bg: rgba(99,102,241,.18);
  --sb-border: rgba(255,255,255,.06);

  /* Brand */
  --accent: #6366f1;
  --accent-hover: #5558e8;
  --accent-subtle: rgba(99,102,241,.12);
  --accent-text: #818cf8;

  /* Content */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-2: #cbd5e1;

  /* Text */
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --text-inverse: #ffffff;

  /* Status */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  /* Dimensions */
  --sidebar-w: 260px;
  --topbar-h: 60px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Motion */
  --ease: cubic-bezier(.4,0,.2,1);
  --fast: 120ms;
  --normal: 200ms;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; }

/* ── App Shell ─────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--sb-border);
  position: relative;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(99,102,241,.2);
}

.sidebar-logo-icon svg { color: white; }

.sidebar-logo-text { display: flex; flex-direction: column; line-height: 1.2; }

.sidebar-logo-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--sb-text-active);
  letter-spacing: -.01em;
}

.sidebar-logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-text);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--sb-text);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 14px 18px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: var(--r-sm);
  color: var(--sb-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
  text-decoration: none;
}

.nav-item:hover { color: var(--sb-text-active); background: rgba(255,255,255,.06); }

.nav-item.active {
  color: var(--sb-text-active);
  background: var(--sb-active-bg);
}

.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sb-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--fast) var(--ease);
}

.sidebar-user:hover { background: rgba(255,255,255,.06); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sb-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  color: var(--accent-text);
  font-weight: 500;
}

.logout-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--sb-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}

.logout-btn:hover { background: rgba(239,68,68,.15); color: var(--danger); }

/* ── Main ────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header-left {}
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ── Metric Cards ─────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.metric-icon.indigo { background: var(--accent-subtle); color: var(--accent); }
.metric-icon.green { background: var(--success-bg); color: var(--success); }
.metric-icon.amber { background: var(--warning-bg); color: var(--warning); }
.metric-icon.red { background: var(--danger-bg); color: var(--danger); }
.metric-icon.blue { background: var(--info-bg); color: var(--info); }

.metric-label { font-size: 12px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.metric-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.metric-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.card-body { padding: 20px; }

/* ── Data Table ──────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-amber { background: var(--warning-bg); color: var(--warning); }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-indigo { background: var(--accent-subtle); color: var(--accent); }
.badge-gray { background: var(--surface-2); color: var(--text-2); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--fast) var(--ease);
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--fast) var(--ease);
}

.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Loading ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 13px;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty-state-icon { margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; color: var(--text-3); }

/* ── Search ──────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 0 12px;
}

.search-bar input {
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.search-bar input:focus { outline: none; }

/* ── Login ───────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--sb-surface);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,.4);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 0 8px rgba(99,102,241,.15);
}

.login-logo-title {
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.login-logo-sub { font-size: 13px; color: #6b7280; }

.login-label { font-size: 12px; font-weight: 600; color: #9ca3af; margin-bottom: 6px; display: block; }

.login-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: white;
  transition: border-color var(--fast) var(--ease);
}

.login-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.login-input::placeholder { color: #4b5563; }

.login-input-wrapper { position: relative; }
.login-input--with-action { padding-right: 40px; }
.login-input-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; cursor: pointer;
  color: #6b7280; display: flex; align-items: center; line-height: 1;
}
.login-input-toggle:hover { color: white; }

.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--fast) var(--ease);
}

.login-btn:hover:not(:disabled) { background: var(--accent-hover); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 28px; height: 28px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-3);
  transition: all var(--fast) var(--ease);
}

.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -100%; top: 0; z-index: 100; transition: left var(--normal) var(--ease); }
  .sidebar.open { left: 0; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-3); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
