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

:root {
  --sidebar-w: 240px;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #ef4444;
  --success: #22c55e;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ── Auth pages ─────────────────────────────────────────── */
body.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.back-link {
  text-align: center;
  margin-top: 20px;
}
.back-link a { color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link a:hover { color: var(--accent); }

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.sidebar-site {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

.nav-item:hover, .nav-item.active {
  background: rgba(99,102,241,.15);
  color: #f1f5f9;
}

.nav-item.active { color: #a5b4fc; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.nav-logout { color: #6b7280; font-size: 13px; }
.nav-logout:hover { color: #fca5a5 !important; background: rgba(239,68,68,.1) !important; }

/* ── Main ───────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; }
.main-inner { max-width: 1100px; margin: 0 auto; padding: 32px 28px 60px; }

/* ── Page header ─────────────────────────────────────────── */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header .page-title { margin-bottom: 0; }
.page-actions { display: flex; gap: 10px; }

/* ── Stats ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-num   { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

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

.card-title { font-weight: 600; font-size: 14px; }
.card-link  { font-size: 13px; color: var(--accent); text-decoration: none; }
.card-link:hover { text-decoration: underline; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ── Tables ──────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

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

.table td {
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray  { background: #f1f5f9; color: #64748b; }
.badge-red   { background: #fee2e2; color: #b91c1c; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .87; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-danger    { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }
.btn-block     { width: 100%; justify-content: center; margin-top: 4px; }

.btn-sm {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  margin-right: 4px;
  transition: background .15s;
}
.btn-sm:hover    { background: #f1f5f9; }
.btn-sm.btn-danger { border-color: #fecaca; color: var(--danger); background: #fee2e2; }
.btn-sm.btn-danger:hover { background: #fecaca; }

/* ── Forms ───────────────────────────────────────────────── */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 6px;
  color: #374151;
}

.label-hint  { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 12px; }
.field-hint  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.test-row {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; }
.alert-warning a { color: var(--accent); }

/* ── Flash ───────────────────────────────────────────────── */
.flash.bg-green-100 { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding:12px 16px; border-radius:10px; margin-bottom:16px; font-size:13.5px; }
.flash.bg-red-100   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding:12px 16px; border-radius:10px; margin-bottom:16px; font-size:13.5px; }
.flash.bg-blue-100  { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; padding:12px 16px; border-radius:10px; margin-bottom:16px; font-size:13.5px; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { padding: 32px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-input  { flex: 1; min-width: 180px; }
.filter-select { width: 160px; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title   { font-size: 1.2rem; font-weight: 700; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-link {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-link.active, .tab-link:hover { color: var(--accent); border-color: var(--accent); }

/* ── Settings ────────────────────────────────────────────── */
.settings-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.settings-section:first-child { padding-top: 24px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 16px; }
.card .form-actions { padding: 20px 24px; }

.colour-row { display: flex; gap: 8px; align-items: center; }
.colour-row input[type="color"] { width: 40px; height: 38px; padding: 2px 4px; cursor: pointer; border-radius: 6px; flex-shrink: 0; }
.colour-row input[type="text"] { flex: 1; }

.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ── Notify page ─────────────────────────────────────────── */
.tag-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.tag-pill  { padding: 3px 10px; background: #eff6ff; color: #1d4ed8; border-radius: 999px; font-size: 12px; font-family: monospace; cursor: pointer; }

.history-list  { }
.history-item  { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }
.history-item:last-child { border-bottom: none; }
.history-subject { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.history-meta    { font-size: 12px; color: var(--muted); }
