:root {
  --color-primary: #240952;
  --color-on-primary: #FFFFFF;
  --color-primary-container: #131b2e;
  --color-on-primary-container: #7c839b;
  --color-secondary: #171717;
  --color-on-secondary: #FFFFFF;
  --color-secondary-container: #d5e3fd;
  --color-on-secondary-container: #57657b;
  --color-tertiary: #000000;
  --color-on-tertiary: #FFFFFF;
  --color-tertiary-container: #271901;
  --color-on-tertiary-container: #98805d;
  --color-error: #ba1a1a;
  --color-on-error: #FFFFFF;
  --color-error-container: #ffdad6;
  --color-on-error-container: #93000a;
  --color-background: #ffffff;
  --color-on-background: #171717;
  --color-surface: #fafafa;
  --color-on-surface: #171717;
  --color-surface-variant: #f5f5f5;
  --color-on-surface-variant: #525252;
  --color-surface-bright: #ffffff;
  --color-surface-dim: #eeeeee;
  --color-surface-container: #f5f5f5;
  --color-surface-container-low: #fafafa;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-high: #eeeeee;
  --color-surface-container-highest: #e5e5e5;
  --color-outline: #d4d4d4;
  --color-outline-variant: #e5e5e5;
  --color-inverse-surface: #303032;
  --color-inverse-on-surface: #f3f0f2;
  --color-inverse-primary: #bec6e0;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --space-unit: 4px;
  --space-gutter: 16px;
  --space-container-padding: 24px;
  --space-stack-xs: 4px;
  --space-stack-sm: 8px;
  --space-stack-md: 16px;
  --space-stack-lg: 32px;
  --space-stack-xl: 48px;
  --radius-sm: 0.125rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.16);
}

html.dark {
  --color-primary: #bec6e0;
  --color-on-primary: #2a3042;
  --color-primary-container: #383f54;
  --color-on-primary-container: #bec6e0;
  --color-secondary: #b6c7e0;
  --color-on-secondary: #213146;
  --color-secondary-container: #39485e;
  --color-on-secondary-container: #d5e3fd;
  --color-tertiary: #c6b8a0;
  --color-on-tertiary: #2e2312;
  --color-tertiary-container: #46391e;
  --color-on-tertiary-container: #e3d3b8;
  --color-error: #ffb4ab;
  --color-on-error: #690005;
  --color-error-container: #93000a;
  --color-on-error-container: #ffdad6;
  --color-background: #131316;
  --color-on-background: #e4e2e4;
  --color-surface: #131316;
  --color-on-surface: #e4e2e4;
  --color-surface-variant: #45464d;
  --color-on-surface-variant: #c6c6cd;
  --color-surface-bright: #39393b;
  --color-surface-dim: #131316;
  --color-surface-container: #1f1f22;
  --color-surface-container-low: #1b1b1e;
  --color-surface-container-lowest: #0e0e11;
  --color-surface-container-high: #29292c;
  --color-surface-container-highest: #343437;
  --color-outline: #909097;
  --color-outline-variant: #45464d;
  --color-inverse-surface: #e4e2e4;
  --color-inverse-on-surface: #303032;
  --color-inverse-primary: #000000;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.6);
}

* {
  transition: background-color 0.3s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container);
  color: var(--color-on-surface);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--color-surface-container-high);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Dark mode overrides for dashboard shell ─────────────────── */
html.dark body {
  background: #131316;
  color: #e4e2e4;
}

html.dark .topbar {
  background: rgba(19,19,22,0.92);
  border-bottom-color: #29292c;
}

html.dark .sidebar-panel {
  background: #1b1b1e;
  border-right-color: #29292c;
}

html.dark .kpi-card {
  background: #1f1f22;
  border-color: #29292c;
}
html.dark .kpi-card:hover {
  border-color: #bec6e0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

html.dark .nav-item:hover {
  background: #29292c;
}
html.dark .nav-active {
  background: linear-gradient(90deg, rgba(190,198,224,0.1), transparent);
  border-left-color: #bec6e0;
  color: #bec6e0;
}

html.dark .insight-card {
  background: #1f1f22;
  border-color: #29292c;
}
html.dark .insight-card:hover {
  border-color: #bec6e0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

html.dark .activity-item {
  border-bottom-color: #29292c;
}
html.dark .activity-item:hover {
  background: rgba(190,198,224,0.05);
}

html.dark .quick-action {
  background: #1f1f22;
  border-color: #29292c;
}
html.dark .quick-action:hover {
  border-color: #bec6e0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

html.dark .coverage-card {
  background: #1f1f22;
  border-color: #29292c;
}

html.dark .market-chip {
  background: #29292c;
  border-color: #45464d;
}
html.dark .market-chip:hover {
  background: #bec6e0;
  color: #131316;
  border-color: #bec6e0;
}

html.dark .search-input {
  background: #29292c;
  border-color: #45464d;
  color: #e4e2e4;
}
html.dark .search-input:focus {
  background: #1f1f22;
  border-color: #bec6e0;
  box-shadow: 0 0 0 3px rgba(190,198,224,0.15);
}

html.dark .btn-primary {
  background: #bec6e0;
  color: #2a3042;
}
html.dark .btn-primary:hover {
  background: #d0d7eb;
  box-shadow: 0 4px 16px rgba(190,198,224,0.2);
}

html.dark .avatar-ring {
  background: #bec6e0;
  color: #2a3042;
}

html.dark .metric-pill {
  background: #1f1f22;
  border-color: #29292c;
}

html.dark .alert-feed-item {
  border-bottom-color: #29292c;
}
html.dark .alert-feed-item:hover {
  background: rgba(190,198,224,0.05);
}

html.dark table {
  color: #e4e2e4;
}
html.dark thead {
  background: #1f1f22;
}
html.dark tbody tr {
  border-bottom-color: #29292c;
}
html.dark tbody tr:hover {
  background: rgba(190,198,224,0.05);
}
html.dark td, html.dark th {
  border-bottom-color: #29292c;
}

html.dark .bg-white { background: #1f1f22; }
html.dark .bg-\[\#fafafa\] { background: #1b1b1e; }
html.dark .bg-\[\#f5f5f5\] { background: #29292c; }
html.dark .bg-surface { background: #131316; }
html.dark .bg-surface-card { background: #1f1f22; }
html.dark .bg-surface-container { background: #29292c; }

html.dark .text-on-surface { color: #e4e2e4; }
html.dark .text-text-primary { color: #e4e2e4; }
html.dark .text-text-secondary { color: #c6c6cd; }
html.dark .text-text-muted { color: #909097; }

html.dark .border-outline { border-color: #909097; }
html.dark .border-outline-variant { border-color: #45464d; }
html.dark .border-\[\#e5e5e5\] { border-color: #45464d; }
html.dark .border-\[\#d4d4d4\] { border-color: #909097; }
html.dark .divide-y > * + * { border-color: #29292c; }

html.dark input, html.dark select, html.dark textarea {
  background: #29292c;
  border-color: #45464d;
  color: #e4e2e4;
}
html.dark input:focus, html.dark select:focus, html.dark textarea:focus {
  border-color: #bec6e0;
  box-shadow: 0 0 0 3px rgba(190,198,224,0.15);
}

html.dark .shadow-sm { box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
html.dark .shadow { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
html.dark .shadow-md { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
html.dark .shadow-lg { box-shadow: 0 4px 16px rgba(0,0,0,0.5); }

html.dark .placeholder-gray-400::placeholder { color: #909097; }
html.dark .placeholder-gray-500::placeholder { color: #909097; }

/* Sidebar dark toggle button */
.theme-toggle-sidebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}
.theme-toggle-sidebar:hover {
  background: rgba(36,9,82,0.05);
  border-color: #e5e5e5;
}
html.dark .theme-toggle-sidebar:hover {
  background: rgba(190,198,224,0.08);
  border-color: #45464d;
}
.theme-toggle-sidebar .material-symbols-outlined {
  font-size: 18px;
  opacity: 0.7;
}
