:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e7f0;
  --text: #14172b;
  --text-muted: #5b6478;
  --text-faint: #8a93a6;
  --accent: #2f6fed;
  --accent-soft: #e7edfe;
  --purple: #8a5cf6;
  --success-bg: #e4f8ee;
  --success-text: #0f8a52;
  --warning-bg: #fdf0d5;
  --warning-text: #8a5a00;
  --danger: #e4483f;
  --danger-soft: #fdeceb;
  --radius: 12px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
}
a { color: inherit; text-decoration: none; }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 12px 32px rgba(20, 23, 43, 0.06);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.auth-logo .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
}
.auth-logo span { font-weight: 800; font-size: 18px; }
.auth-card h1 { font-size: 20px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fafbfe;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; padding: 11px; }
.btn-primary:hover { background: #2559c9; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #f9d9d6; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f4f6fb; }
.btn-success { background: var(--success-bg); color: var(--success-text); }
.error-banner {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── App shell ──────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
}
.sidebar .brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  flex-shrink: 0;
}
.sidebar .brand span { font-weight: 800; font-size: 15px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}
.sidebar-footer .email { color: var(--text-muted); font-weight: 600; margin-bottom: 8px; word-break: break-all; }

.main { flex: 1; padding: 28px 36px; min-width: 0; }
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-header h1 { font-size: 21px; margin: 0; }
.page-header .sub { color: var(--text-muted); font-size: 13px; }

/* ── Stat cards ─────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ── Tables/cards ───────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel h2 { font-size: 14px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}
.pill-success { background: var(--success-bg); color: var(--success-text); }
.pill-warning { background: var(--warning-bg); color: var(--warning-text); }
.pill-muted { background: var(--bg); color: var(--text-muted); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.empty-state { padding: 40px 18px; text-align: center; color: var(--text-muted); }

form.inline { display: inline; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar-footer { display: none; }
  .main { padding: 18px; }
}
