/* ============================================================
   Nieuws Monitor — Design System
   Single shared stylesheet: tokens, shell, components, legacy compat.
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Surfaces */
  --bg-primary: #0a0c11;
  --bg-secondary: #0f1218;
  --bg-tertiary: #151924;
  --bg-card: #10141c;
  --bg-card-hover: #151a24;
  --bg-inset: #0c0f15;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.07);

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(10, 132, 255, 0.35);

  /* Text */
  --text-primary: #f2f4f8;
  --text-secondary: #a9b1c0;
  --text-tertiary: #687083;

  /* Accents (Apple dark palette) */
  --accent-blue: #0a84ff;
  --accent-blue-hover: #3899ff;
  --accent-blue-glow: rgba(10, 132, 255, 0.22);
  --accent-teal: #64d2ff;
  --accent-green: #30d158;
  --accent-orange: #ff9f0a;
  --accent-yellow: #ffd60a;
  --accent-red: #ff453a;
  --accent-purple: #bf5af2;
  --accent-pink: #ff375f;

  /* Soft accent backgrounds */
  --blue-soft: rgba(10, 132, 255, 0.13);
  --teal-soft: rgba(100, 210, 255, 0.13);
  --green-soft: rgba(48, 209, 88, 0.13);
  --orange-soft: rgba(255, 159, 10, 0.13);
  --yellow-soft: rgba(255, 214, 10, 0.13);
  --red-soft: rgba(255, 69, 58, 0.13);
  --purple-soft: rgba(191, 90, 242, 0.13);
  --gray-soft: rgba(255, 255, 255, 0.07);

  /* Gradients (legacy names kept) */
  --gradient-primary: linear-gradient(135deg, #0a84ff 0%, #64d2ff 100%);
  --gradient-secondary: linear-gradient(135deg, #151924 0%, #0a0c11 100%);
  --gradient-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 100%);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(10, 132, 255, 0.18);

  /* Motion */
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.35s ease;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* Shell */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1480px;
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, svg, canvas { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-blue-hover); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; color: var(--text-primary); }
strong { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-glass); padding: 2px 6px; border-radius: 5px; }

h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.3; }

::selection { background: rgba(10, 132, 255, 0.35); }

:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- 3. App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
}
.sidebar-brand .brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}
.sidebar-brand .brand-name { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-brand .brand-sub { font-size: 0.65rem; color: var(--text-tertiary); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }

.nav-section { margin-top: 14px; }
.nav-section-label {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-tertiary);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.845rem;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; color: var(--text-tertiary); transition: color var(--transition-fast); }
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item:hover svg { color: var(--text-secondary); }
.nav-item.active { background: var(--blue-soft); color: #fff; font-weight: 600; }
.nav-item.active svg { color: var(--accent-blue); }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--text-tertiary);
}

.sidebar-foot {
  border-top: 1px solid var(--border-color);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-foot .user-chip {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}
.sidebar-foot .user-chip:hover { background: var(--bg-glass); color: var(--text-primary); }
.sidebar-foot .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--accent-purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase;
}
.sidebar-foot .user-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .logout-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}
.sidebar-foot .logout-btn:hover { background: var(--red-soft); color: var(--accent-red); }
.sidebar-foot .logout-btn svg { width: 16px; height: 16px; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 890;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.sidebar-backdrop.open { opacity: 1; visibility: visible; }

.shell-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 800;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: rgba(10, 12, 17, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-color);
}
.topbar .menu-btn {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topbar .menu-btn:hover { background: var(--bg-glass); }
.topbar .menu-btn svg { width: 20px; height: 20px; }
.topbar-title { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.015em; }
.topbar-spacer { flex: 1; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: 999px;
}
.live-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(48, 209, 88, 0.7);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
.live-pill.delayed .dot { background: var(--accent-orange); box-shadow: 0 0 8px rgba(255, 159, 10, 0.7); }
.live-pill.disconnected .dot { background: var(--accent-red); box-shadow: 0 0 8px rgba(255, 69, 58, 0.7); animation: none; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 26px 28px 64px;
  flex: 1;
}

/* ---------- 4. Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -0.03em; }
.page-head .page-sub { color: var(--text-tertiary); font-size: 0.85rem; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-tertiary);
  margin: 26px 0 12px;
}

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent-blue); color: #fff; box-shadow: 0 2px 10px rgba(10, 132, 255, 0.3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-blue-hover); }
.btn-secondary { background: var(--bg-glass); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-glass-hover); border-color: var(--border-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-glass); color: var(--text-primary); }
.btn-danger { background: var(--red-soft); color: var(--accent-red); border-color: rgba(255, 69, 58, 0.25); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 69, 58, 0.22); }
.btn-success { background: var(--green-soft); color: var(--accent-green); border-color: rgba(48, 209, 88, 0.25); }
.btn-success:hover:not(:disabled) { background: rgba(48, 209, 88, 0.22); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 0.76rem; border-radius: var(--radius-sm); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 42px; padding: 0 22px; font-size: 0.9rem; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

/* ---------- 6. Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header, .card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-body { min-width: 0; }
.card-title {
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.card-title svg { width: 16px; height: 16px; color: var(--text-tertiary); }
.card-sub { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; align-items: center; }

.glass-card {
  background: var(--gradient-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* ---------- 7. KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  min-width: 0;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-soft);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-icon.blue { background: var(--blue-soft); color: var(--accent-blue); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--accent-teal); }
.kpi-icon.green { background: var(--green-soft); color: var(--accent-green); }
.kpi-icon.orange { background: var(--orange-soft); color: var(--accent-orange); }
.kpi-icon.red { background: var(--red-soft); color: var(--accent-red); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--accent-purple); }
.kpi-icon.yellow { background: var(--yellow-soft); color: var(--accent-yellow); }

.kpi-value {
  font-size: 1.65rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi-value small { font-size: 0.85rem; font-weight: 600; color: var(--text-tertiary); margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 0.72rem; color: var(--text-tertiary); flex-wrap: wrap; }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.delta svg { width: 11px; height: 11px; }
.delta.up { background: var(--green-soft); color: var(--accent-green); }
.delta.down { background: var(--red-soft); color: var(--accent-red); }
.delta.flat { background: var(--gray-soft); color: var(--text-tertiary); }
.delta.up.bad { background: var(--red-soft); color: var(--accent-red); }
.delta.down.good { background: var(--green-soft); color: var(--accent-green); }

/* ---------- 8. Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}
.card > .table-wrap { border: none; background: transparent; margin: 0 -20px -20px; width: calc(100% + 40px); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.table th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.015);
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-glass); }
.table tbody tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.strong, .table .td-strong { color: var(--text-primary); font-weight: 550; }

/* ---------- 9. Badges & tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-blue { background: var(--blue-soft); color: var(--accent-blue); }
.badge-teal { background: var(--teal-soft); color: var(--accent-teal); }
.badge-green { background: var(--green-soft); color: var(--accent-green); }
.badge-orange { background: var(--orange-soft); color: var(--accent-orange); }
.badge-yellow { background: var(--yellow-soft); color: var(--accent-yellow); }
.badge-red { background: var(--red-soft); color: var(--accent-red); }
.badge-purple { background: var(--purple-soft); color: var(--accent-purple); }
.badge-gray { background: var(--gray-soft); color: var(--text-secondary); }
/* Semantische aliassen (gebruikt door templates) */
.badge-success { background: var(--green-soft); color: var(--accent-green); }
.badge-danger { background: var(--red-soft); color: var(--accent-red); }
.badge-warning { background: var(--orange-soft); color: var(--accent-orange); }
.badge-info { background: var(--blue-soft); color: var(--accent-blue); }
.badge-neutral { background: var(--gray-soft); color: var(--text-secondary); }
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  margin: 0 6px 6px 0;
  transition: all var(--transition-fast);
}
.tag:hover { border-color: var(--border-light); color: var(--text-primary); }

/* Legacy badge names */
.country-badge { padding: 3px 9px; border-radius: 999px; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; display: inline-flex; align-items: center; }
.country-nl { background: var(--orange-soft); color: var(--accent-orange); }
.country-be { background: var(--yellow-soft); color: var(--accent-yellow); }
.country-eu { background: var(--blue-soft); color: var(--accent-blue); }
.country-mix { background: var(--purple-soft); color: var(--accent-purple); }

.urgency-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.68rem; font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.urgency-high { background: var(--red-soft); color: var(--accent-red); }
.urgency-medium { background: var(--orange-soft); color: var(--accent-orange); }
.urgency-low { background: var(--green-soft); color: var(--accent-green); }

.breaking-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--red-soft); color: var(--accent-red);
  border: 1px solid rgba(255, 69, 58, 0.3);
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.62rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
  animation: breaking-pulse 2s ease-in-out infinite;
}
@keyframes breaking-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }

.quality-badge { padding: 2px 8px; border-radius: 5px; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; }
.quality-badge.high { background: var(--green-soft); color: var(--accent-green); }
.quality-badge.medium { background: var(--orange-soft); color: var(--accent-orange); }
.quality-badge.low { background: var(--red-soft); color: var(--accent-red); }

/* ---------- 10. Forms ---------- */
.input, .select, .textarea,
.filter-bar select, .filter-bar input,
input[type="text"].form-input, input[type="number"].form-input, input[type="password"].form-input {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, .textarea:focus,
.filter-bar select:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}
.select, .filter-bar select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23687083' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field .help-text { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 5px; line-height: 1.5; }
.field .input, .field .select, .field .textarea { width: 100%; }

.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition-normal);
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 17px; height: 17px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-normal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch input:checked + .slider { background: var(--accent-green); }
.switch input:checked + .slider::before { transform: translateX(17px); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }

.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-tertiary); pointer-events: none;
}
.search-box .input { padding-left: 33px; }

.filter-chip {
  padding: 6px 13px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-chip:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.filter-chip.active { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }

/* ---------- 11. Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 15px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab svg { width: 14px; height: 14px; }
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent-blue); }

.seg {
  display: inline-flex;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.seg button:hover { color: var(--text-secondary); }
.seg button.active { background: var(--bg-glass-hover); color: var(--text-primary); }

/* ---------- 12. Modal / drawer / toast ---------- */
.modal-overlay, .side-panel-overlay, .filter-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.modal-overlay.open, .side-panel-overlay.open, .filter-drawer-overlay.open { opacity: 1; visibility: visible; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.97);
  width: min(560px, calc(100vw - 32px));
  max-height: min(82vh, 720px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 2001;
  display: flex;
  flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: all var(--transition-normal);
}
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 15px 22px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close, .side-panel-close, .drawer-close {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}
.modal-close:hover, .side-panel-close:hover, .drawer-close:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

.drawer, .side-panel, .filter-drawer {
  position: fixed;
  top: 0; right: 0;
  transform: translateX(105%);
  width: min(600px, 94vw);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 2001;
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.5);
}
.drawer.open, .side-panel.open, .filter-drawer.open { transform: translateX(0); }
.drawer-header, .side-panel-header, .filter-drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.drawer-title, .side-panel-title, .filter-drawer-title { font-size: 1rem; font-weight: 700; }
.drawer-body, .side-panel-content, .filter-drawer-content { flex: 1; overflow-y: auto; padding: 22px; }

.toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 15px;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s ease;
}
.toast svg { width: 16px; height: 16px; margin-top: 1px; }
.toast.success svg { color: var(--accent-green); }
.toast.error svg { color: var(--accent-red); }
.toast.info svg { color: var(--accent-blue); }
.toast.warning svg { color: var(--accent-orange); }
.toast.leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(6px); opacity: 0; } }

/* ---------- 13. States: skeleton / empty / error / loading ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
  border-radius: 8px;
}
.skeleton::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skeleton-line { height: 12px; margin-bottom: 10px; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-block { height: 120px; }

.state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-tertiary);
}
.state .state-icon {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
}
.state .state-icon svg { width: 20px; height: 20px; }
.state.error .state-icon { background: var(--red-soft); border-color: rgba(255, 69, 58, 0.25); color: var(--accent-red); }
.state .state-title { font-size: 0.92rem; font-weight: 650; color: var(--text-secondary); margin-bottom: 4px; }
.state .state-desc { font-size: 0.8rem; max-width: 380px; margin: 0 auto 14px; line-height: 1.55; }

.empty-state { text-align: center; padding: 52px 24px; color: var(--text-tertiary); font-size: 0.88rem; }

.loading { text-align: center; padding: 52px; color: var(--text-tertiary); font-size: 0.85rem; }
.loading::after {
  content: '';
  display: block;
  width: 26px; height: 26px;
  margin: 14px auto 0;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ---------- 14. Charts ---------- */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.h-180 { height: 180px; }
.chart-box.h-220 { height: 220px; }
.chart-box.h-300 { height: 300px; }
.chart-box.h-340 { height: 340px; }
.chart-legend-note { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 10px; }

/* ---------- 15. Funnel ---------- */
.funnel { display: flex; gap: 0; align-items: stretch; overflow-x: auto; padding-bottom: 6px; }
.funnel-stage { flex: 1; min-width: 118px; display: flex; align-items: stretch; }
.funnel-node {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 14px 11px;
  position: relative;
  min-width: 0;
  transition: border-color var(--transition-fast);
}
.funnel-node:hover { border-color: var(--border-light); }
.funnel-node .fn-label {
  font-size: 0.64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-tertiary);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.funnel-node .fn-label svg { width: 12px; height: 12px; flex-shrink: 0; }
.funnel-node .fn-value { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.1; }
.funnel-node .fn-sub { font-size: 0.68rem; color: var(--text-tertiary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-node .fn-bar { height: 4px; border-radius: 2px; background: var(--bg-glass-hover); margin-top: 9px; overflow: hidden; }
.funnel-node .fn-bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent-blue); }
.funnel-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 4px;
  min-width: 44px;
  flex-shrink: 0;
}
.funnel-link .fl-pct { font-size: 0.68rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.funnel-link svg { width: 13px; height: 13px; color: var(--text-tertiary); margin-top: 2px; }

/* ---------- 16. Meters & misc data viz ---------- */
.meter { height: 7px; background: rgba(255, 255, 255, 0.07); border-radius: 4px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent-blue); transition: width var(--transition-slow); }
.meter.green > i { background: var(--accent-green); }
.meter.orange > i { background: var(--accent-orange); }
.meter.red > i { background: var(--accent-red); }
.meter.purple > i { background: var(--accent-purple); }
.meter.teal > i { background: var(--accent-teal); }

.meter-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.meter-row .mr-label { flex: 0 0 148px; font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-row .meter { flex: 1; }
.meter-row .mr-value { flex: 0 0 auto; font-size: 0.78rem; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

.score-meter { margin-bottom: 16px; }
.score-meter-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.score-meter-name { font-size: 0.8rem; color: var(--text-secondary); }
.score-meter-value { font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-meter-bar { height: 7px; background: rgba(255, 255, 255, 0.07); border-radius: 4px; overflow: hidden; }
.score-meter-fill { height: 100%; border-radius: 4px; transition: width var(--transition-slow); background: var(--accent-blue); }
.score-meter-fill.high { background: var(--accent-red); }
.score-meter-fill.medium { background: var(--accent-orange); }
.score-meter-fill.low { background: var(--accent-green); }

/* ---------- 17. Legacy layout & list components ---------- */
.stats-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.stat-item { text-align: center; padding: 6px; }
.stat-value {
  font-size: 1.5rem; font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.64rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.cluster-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.cluster-item:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.cluster-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); line-height: 1.45; }
.cluster-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 0.74rem; color: var(--text-tertiary); flex-wrap: wrap; }

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  margin-bottom: 10px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.news-card:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.timeline-item {
  padding: 15px 20px;
  border-left: 2px solid var(--border-color);
  margin-left: 20px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute; left: -5.5px; top: 21px;
  width: 9px; height: 9px;
  background: var(--accent-blue);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--bg-primary);
}
.timeline-entry { padding: 14px 0 14px 20px; border-left: 2px solid var(--border-color); position: relative; }
.timeline-entry::before { content: ''; position: absolute; left: -5px; top: 18px; width: 8px; height: 8px; background: var(--accent-blue); border-radius: 50%; }
.timeline-entry.first::before { background: var(--accent-green); }
.timeline-entry.last::before { background: var(--accent-orange); }
.timeline-time { font-size: 0.72rem; color: var(--text-tertiary); margin-bottom: 3px; }
.timeline-text { font-size: 0.83rem; color: var(--text-secondary); }

.alert-item {
  padding: 13px 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border-left: 3px solid var(--accent-blue);
}
.alert-item.critical { border-left-color: var(--accent-red); background: rgba(255, 69, 58, 0.05); }
.alert-item.warn { border-left-color: var(--accent-orange); background: rgba(255, 159, 10, 0.05); }
.alert-item.info { border-left-color: var(--accent-green); background: rgba(48, 209, 88, 0.05); }

/* Old per-page AI subnav is fully replaced by the sidebar */
.ai-subnav, .ai-nav, #ai-mobile-nav { display: none !important; }

.entity-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.entity-tag {
  background: var(--blue-soft);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 550;
  border: 1px solid rgba(10, 132, 255, 0.2);
}

/* ---------- 18. Utilities ---------- */
.muted { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.mono, .num-mono { font-family: var(--font-mono); font-size: 0.92em; }
.tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 0.8rem; } .text-xs { font-size: 0.72rem; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-green { color: var(--accent-green); } .text-red { color: var(--accent-red); }
.text-orange { color: var(--accent-orange); } .text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); } .text-teal { color: var(--accent-teal); }
.hide-mobile-inline { display: inline; }

/* ---------- 19. Auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(10, 132, 255, 0.09), transparent 60%),
    radial-gradient(800px 400px at 10% 110%, rgba(191, 90, 242, 0.07), transparent 60%),
    var(--bg-primary);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.auth-brand .brand-mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 8px 28px rgba(10, 132, 255, 0.4);
}
.auth-brand h1 { font-size: 1.25rem; font-weight: 750; }
.auth-brand p { font-size: 0.8rem; color: var(--text-tertiary); }
.auth-error {
  background: var(--red-soft);
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: var(--accent-red);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.auth-error svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- 20. Responsive ---------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-104%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .shell-main { margin-left: 0; }
  .topbar .menu-btn { display: flex; }
  .container { padding: 18px 16px 56px; }
}

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 1.35rem; }
  .page-head h1 { font-size: 1.2rem; }
  .card { padding: 16px; }
  .card > .table-wrap { margin: 0 -16px -16px; width: calc(100% + 32px); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.25rem; }
  .filter-bar select, .filter-bar input { flex: 1 1 46%; }
  .btn { height: 38px; }
  .funnel { flex-direction: column; }
  .funnel-stage { min-width: 0; }
  .funnel-link { flex-direction: row; gap: 6px; padding: 6px 0; min-width: 0; justify-content: flex-start; padding-left: 14px; }
  .funnel-link svg { transform: rotate(90deg); margin-top: 0; }
  .meter-row .mr-label { flex-basis: 104px; font-size: 0.74rem; }
  .modal { width: calc(100vw - 20px); max-height: 88vh; }
  .toast-stack { left: 16px; right: 16px; bottom: 14px; max-width: none; }
  .hide-mobile { display: none !important; }
  .hide-mobile-inline { display: none !important; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}

/* ---------- 21. Shared page components (banners, mini-stats, lists) ---------- */
.mt-12 { margin-top: 12px; }
.fs-13 { font-size: 0.8rem; }
.flex-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.text-muted { color: var(--text-tertiary); }
.text-danger { color: var(--accent-red); }
.text-warning { color: var(--accent-orange); }
.text-success { color: var(--accent-green); }
.kpi-sub { color: var(--text-tertiary); }

.hint { display: flex; align-items: flex-start; gap: 7px; font-size: 0.75rem; color: var(--text-tertiary); line-height: 1.5; }
.hint svg { flex-shrink: 0; margin-top: 1px; }

.banner {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem; line-height: 1.5;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  margin-bottom: 18px;
}
.banner svg { flex-shrink: 0; margin-top: 2px; }
.banner strong { color: var(--text-primary); }
.banner-warning { background: var(--orange-soft); border-color: rgba(255, 159, 10, 0.25); }
.banner-warning svg { color: var(--accent-orange); }
.banner-danger { background: var(--red-soft); border-color: rgba(255, 69, 58, 0.25); }
.banner-danger svg { color: var(--accent-red); }
.banner-info { background: var(--blue-soft); border-color: rgba(10, 132, 255, 0.25); }
.banner-info svg { color: var(--accent-blue); }

.mini-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.mini-stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.mini-stat {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  min-width: 0;
}
.mini-stat-value { font-size: 1.05rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.mini-stat-label { font-size: 0.68rem; color: var(--text-tertiary); margin-top: 3px; line-height: 1.4; }
.mini-stat-sub { display: block; font-size: 0.66rem; color: var(--text-tertiary); opacity: 0.85; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.list-item:first-child { padding-top: 0; }
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--bg-glass); border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); flex-shrink: 0;
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-sub { font-size: 0.73rem; color: var(--text-tertiary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-sub.text-danger { color: var(--accent-red); }
.list-item .btn { flex-shrink: 0; }

.funnel-drains { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 22. Expandable run rows / trace ---------- */
.run-row { cursor: pointer; }
.run-row:hover td { background: rgba(255, 255, 255, 0.02); }
.run-row.open td { background: rgba(255, 255, 255, 0.025); }
.run-row .row-chevron svg { transition: transform var(--transition-fast); color: var(--text-tertiary); }
.run-row.open .row-chevron svg { transform: rotate(90deg); }
.trace-cell { background: var(--bg-inset) !important; padding: 16px 18px !important; }
.trace-cell .table th { background: transparent; }
.trace-cell .table-wrap { background: var(--bg-card); }
.score-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.score-tags .tag { font-variant-numeric: tabular-nums; }
