/* ============================================
   WORDY ADMIN V2 — Design System & Styles
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:wght@700&display=swap');

/* --- Design Tokens --- */
:root {
  /* Backgrounds */
  --bg: #F7F5F2;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F9F8F6;
  --bg-muted: #F0EDE8;
  /* Sidebar */
  --sidebar-bg: #1A1A1A;
  --sidebar-hover: #2A2A2A;
  --sidebar-active: #333333;
  --sidebar-text: #A3A3A3;
  --sidebar-text-active: #FFFFFF;
  /* Text */
  --text-primary: #111111;
  --text-secondary: #6B6B6B;
  --text-muted: #9CA3AF;
  --text-inverse: #FFFFFF;
  /* Brand */
  --primary: #6C5CE7;
  --primary-light: #EDE9FF;
  --primary-text: #FFFFFF;
  /* Semantic */
  --success: #22C55E;
  --success-light: #DCFCE7;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  /* Borders */
  --border: #E5E2DD;
  --border-light: #EEEAE5;
  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 100px;
  /* Chart palette */
  --chart-1: #6C5CE7;
  --chart-2: #00B894;
  --chart-3: #FDCB6E;
  --chart-4: #E17055;
  --chart-5: #74B9FF;
  /* Typography */
  --font-display: 'Lora', serif;
  --font-body: 'Inter', sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

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

/* --- Sidebar --- */
.sidebar {
  width: 256px;
  min-width: 256px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 4px;
  overflow-y: auto;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  margin-bottom: 28px;
}
.sidebar-logo-icon {
  width: 32px;
  height: 32px;
}
.sidebar-logo-text {
  font-weight: 600;
  font-size: 16px;
  color: var(--sidebar-text-active);
}
.sidebar-spacer { flex: 1; }
.sidebar-footer {
  font-size: 12px;
  color: var(--sidebar-text);
  line-height: 1.6;
  padding: 0 12px;
}
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,59,48,0.08); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}
.nav-item i { width: 20px; height: 20px; flex-shrink: 0; font-size: 18px; line-height: 20px; text-align: center; }

.nav-section-label {
  display: flex;
  align-items: flex-end;
  height: 32px;
  padding: 12px 12px 4px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  margin-top: 8px;
}

/* --- Right Panel (Header + Content) --- */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* --- Header --- */
.page-header {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.page-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  width: 240px;
}
.header-search input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  color: var(--text-primary);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search i { color: var(--text-muted); width: 16px; height: 16px; }

/* --- Env Badge --- */
.env-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}
.env-badge--production {
  background: var(--success-light);
  color: var(--success);
}
.env-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Avatar --- */
.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Grid Layouts --- */
.grid-row {
  display: grid;
  gap: 20px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Metric Card --- */
.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.metric-card__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.metric-card__value-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.metric-card__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.metric-card__change {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.4;
}
.metric-card__change--up {
  color: var(--success);
  background: var(--success-light);
}
.metric-card__change--down {
  color: var(--error);
  background: var(--error-light);
}
.metric-card__change--neutral {
  color: var(--text-secondary);
  background: var(--bg-muted);
}

/* Alert metric cards (colored backgrounds) */
.metric-card--error {
  background: var(--error-light);
  border-color: transparent;
}
.metric-card--error .metric-card__value { color: var(--error); }
.metric-card--error .metric-card__label { color: var(--error); }

.metric-card--warning {
  background: var(--warning-light);
  border-color: transparent;
}
.metric-card--warning .metric-card__value { color: var(--warning); }
.metric-card--warning .metric-card__label { color: var(--warning); }

.metric-card--info {
  background: var(--info-light);
  border-color: transparent;
}
.metric-card--info .metric-card__value { color: var(--info); }
.metric-card--info .metric-card__label { color: var(--info); }

.metric-card--neutral {
  background: var(--bg-muted);
  border-color: transparent;
}

/* --- Chart Card --- */
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
}
.chart-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.chart-card__subtitle {
  font-size: 12px;
  color: var(--text-muted);
}
.chart-card__body {
  padding: 0 24px 24px 24px;
  flex: 1;
  min-height: 200px;
  position: relative;
}
.chart-card__body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--success { background: var(--success-light); color: var(--success); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--error { background: var(--error-light); color: var(--error); }
.badge--info { background: var(--info-light); color: var(--info); }
.badge--primary { background: var(--primary-light); color: var(--primary); }
.badge--neutral { background: var(--bg-muted); color: var(--text-secondary); }
.badge--super-admin {
  background: var(--error-light);
  color: var(--error);
  font-size: 11px;
}

/* --- Table --- */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.table-toolbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  flex: 1;
  max-width: 320px;
  background: var(--bg);
}
.table-toolbar__search input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
}
.table-toolbar__search i { color: var(--text-muted); }
.table-toolbar__count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: auto;
}

table thead th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-muted);
  height: 44px;
  padding: 0 20px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table tbody td {
  padding: 0 20px;
  height: 52px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: var(--bg-surface-hover); }
table tbody tr.row--suspicious { background: #FEE2E210; }

.table-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.table-user-cell__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}
.table-user-cell__info { display: flex; flex-direction: column; }
.table-user-cell__name { font-weight: 500; font-size: 14px; }
.table-user-cell__email { font-size: 12px; color: var(--text-muted); }

/* Pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-secondary);
}
.table-pagination__pages {
  display: flex;
  gap: 4px;
}
.table-pagination__btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.table-pagination__btn:hover { background: var(--bg-muted); }
.table-pagination__btn.active {
  background: var(--primary);
  color: #fff;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: #fff; }
.btn--success { background: var(--success); color: #fff; }
.btn--error { background: var(--error); color: #fff; }
.btn--warning { background: var(--warning); color: #fff; }
.btn--outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn--outline:hover { background: var(--bg-muted); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-muted); color: var(--text-primary); }
.btn--sm { padding: 4px 10px; font-size: 12px; }
.btn--danger-outline {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
}

/* --- Filter Chips --- */
.filter-chips {
  display: flex;
  gap: 8px;
  align-items: center;
}
.filter-chip {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip:hover { background: var(--bg-muted); }
.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* --- Card (generic) --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.card__subtitle {
  font-size: 12px;
  color: var(--text-muted);
}
.card__body { padding: 24px; }
.card__body--flush { padding: 0; }

/* --- Section Header --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Form Controls --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-input,
.form-select,
.form-textarea {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
}
.form-textarea {
  height: auto;
  min-height: 100px;
  padding: 12px;
  resize: vertical;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* --- Toggle --- */
.toggle {
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: #D1D5DB;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.active { background: var(--success); }
.toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle.active::after { transform: translateX(24px); }

/* --- Leaderboard --- */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 44px;
}
.leaderboard-item__rank {
  width: 20px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}
.leaderboard-item__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  flex-shrink: 0;
}
.leaderboard-item__name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}
.leaderboard-item__stat {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Health Indicator --- */
.health-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot--green { background: var(--success); }
.health-dot--yellow { background: var(--warning); }
.health-dot--red { background: var(--error); }
.health-indicator__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.health-indicator__value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Heatmap --- */
.heatmap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.heatmap-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.heatmap-label {
  width: 32px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}
.heatmap-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
  min-width: 12px;
  max-width: 28px;
}
.heatmap-header {
  display: flex;
  gap: 4px;
  margin-left: 36px;
}
.heatmap-header span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  min-width: 12px;
  max-width: 28px;
}

/* --- Platform Health Card --- */
.platform-health {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

/* --- User Detail Drawer --- */
.user-drawer {
  border-top: 2px solid var(--primary);
  padding: 24px;
}
.user-drawer__header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.user-drawer__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.user-drawer__name {
  font-size: 18px;
  font-weight: 700;
}
.user-drawer__email {
  font-size: 13px;
  color: var(--text-muted);
}
.user-drawer__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.user-drawer__stat-card {
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 16px;
}
.user-drawer__stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.user-drawer__stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

/* --- Ad Placement Card --- */
.ad-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.ad-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.ad-card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}
.ad-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.ad-card__section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.ad-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}
.ad-card__row-label { color: var(--text-secondary); }
.ad-card__row-value {
  font-weight: 600;
  color: var(--text-primary);
}
.ad-card.disabled { opacity: 0.6; }

/* Rollout bar */
.rollout-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.rollout-bar__fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}

/* --- SQL Editor --- */
.sql-editor {
  background: var(--sidebar-bg);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 120px;
}
.sql-editor textarea {
  width: 100%;
  min-height: 100px;
  background: transparent;
  border: none;
  outline: none;
  color: #A8E6CF;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.sql-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--warning);
  background: var(--warning-light);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

/* --- Retention Cohort Table --- */
.cohort-cell {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* --- Notification Form --- */
.notif-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.notif-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.notif-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* --- Reconciliation Card --- */
.recon-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.recon-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  text-align: center;
}
.recon-card__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.recon-card__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}
.recon-card--default { background: var(--bg-muted); }
.recon-card--error {
  background: var(--error-light);
}
.recon-card--error .recon-card__label { color: var(--error); }
.recon-card--error .recon-card__value { color: var(--error); }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease-out;
  min-width: 280px;
}
.toast--success { background: var(--success); }
.toast--error { background: var(--error); }
.toast--info { background: var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Loading --- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* --- Diagnostics Row --- */
.diag-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.diag-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.diag-card__value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}
.diag-card__sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Edge Function / Cron List --- */
.func-list { list-style: none; }
.func-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.func-item:last-child { border-bottom: none; }
.func-item__name { font-weight: 500; }
.func-item__status {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Input inline --- */
.input-inline {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  width: 100%;
  background: var(--bg);
}
.input-inline:focus { border-color: var(--primary); }

/* --- Utility --- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.ml-auto { margin-left: auto; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- Login Overlay --- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.login-box__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.login-box__logo .sidebar-logo-text {
  color: var(--text-primary);
}
.login-box__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
}
.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { width: 100%; height: 44px; }
.login-box__error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
  display: none;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.modal__title { font-size: 16px; font-weight: 600; }
.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.modal__close:hover { background: var(--bg-muted); }
.modal__body { padding: 24px; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}
