/* =============================================================================
   styles.css — ALL styling for The Analyst Dashboard
   Sections:
   1.  Design Tokens (CSS Custom Properties)
   2.  Reset & Base
   3.  Typography
   4.  Layout
   5.  Skip Link (Accessibility)
   6.  Header
   7.  Stale Data Banner
   8.  Date Range Picker
   9.  KPI Cards Grid
   10. Chart Cards
   11. Promo Analysis
   12. Top Clients Table
   13. Actions Bar
   14. Settings Panel
   15. States (Loading / Error / Empty)
   16. Skeleton Screens
   17. Toast Notifications
   18. Buttons
   19. Data Quality
   20. Dark Theme
   21. Responsive Breakpoints
   22. Animations & Transitions
   23. Reduced Motion Override
   24. Accessibility Utilities
============================================================================= */

/* =============================================================================
   1. DESIGN TOKENS
============================================================================= */
:root {
  /* Background */
  --bg-primary:   #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary:  #f1f5f9;

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-tertiary:  #94a3b8;

  /* Border */
  --border: #e2e8f0;

  /* Brand */
  --primary:       #6366f1;
  --primary-hover: #4f46e5;

  /* Semantic */
  --success:    #22c55e;
  --success-bg: #f0fdf4;
  --warning:    #eab308;
  --warning-bg: #fefce8;
  --danger:     #ef4444;
  --danger-bg:  #fef2f2;
  --info:       #3b82f6;

  /* Chart Colors */
  --chart-1: #6366f1;
  --chart-2: #8b5cf6;
  --chart-3: #06b6d4;
  --chart-4: #f59e0b;
  --chart-5: #10b981;
  --chart-6: #f43f5e;
  --chart-7: #64748b;
  --chart-8: #d946ef;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-full: 9999px;
}

/* =============================================================================
   2. RESET & BASE
============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 300ms ease, color 300ms ease;
}

/* Prevent flash of transition on initial theme load */
[data-no-transition] *,
[data-no-transition] *::before,
[data-no-transition] *::after {
  transition: none !important;
}

img {
  max-width: 100%;
  display: block;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* =============================================================================
   3. TYPOGRAPHY
============================================================================= */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.numeric {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* =============================================================================
   4. LAYOUT
============================================================================= */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.hidden {
  display: none !important;
}

/* =============================================================================
   5. SKIP LINK
============================================================================= */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: top 200ms ease;
}

.skip-link:focus {
  top: var(--space-2);
}

/* =============================================================================
   6. HEADER
============================================================================= */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 300ms ease, border-color 300ms ease;
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 44px;
}

.header__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.header__logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.header__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.header__last-updated {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* =============================================================================
   7. STALE DATA BANNER
============================================================================= */
.stale-banner {
  background: var(--warning-bg);
  border-bottom: 1px solid rgba(234, 179, 8, 0.3);
  border-left: 4px solid var(--warning);
  padding: var(--space-3) 0;
  transition: background-color 300ms ease;
}

.stale-banner__content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.stale-banner__icon {
  color: var(--warning);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.stale-banner__text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 200px;
}

/* =============================================================================
   8. DATE RANGE PICKER
============================================================================= */
.date-range-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: background-color 300ms ease, border-color 300ms ease;
}

.date-range__inputs {
  display: flex;
  gap: var(--space-4);
  align-items: flex-end;
  flex-wrap: wrap;
}

.date-range__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.date-range__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.date-input {
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  min-width: 160px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.date-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.date-range__presets {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.preset-btn {
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.preset-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.preset-btn--active,
.preset-btn:focus-visible.preset-btn--active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.preset-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.preset-btn:active {
  transform: scale(0.97);
}

/* =============================================================================
   9. KPI CARDS GRID
============================================================================= */
.kpi-section {
  margin-bottom: var(--space-8);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  cursor: default;
  transition:
    transform 200ms ease-out,
    box-shadow 200ms ease-out,
    background-color 300ms ease,
    border-color 200ms ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Smart KPI coloring: left border + background tint */
.kpi-card--success {
  border-left: 4px solid var(--success);
  background-color: var(--success-bg);
}

.kpi-card--warning {
  border-left: 4px solid var(--warning);
  background-color: var(--warning-bg);
}

.kpi-card--danger {
  border-left: 4px solid var(--danger);
  background-color: var(--danger-bg);
}

.kpi-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-card__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}

.kpi-card__icon {
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.kpi-card__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.kpi-change--up   { color: var(--success); }
.kpi-change--down { color: var(--danger); }
.kpi-change--neutral { color: var(--text-tertiary); }

/* =============================================================================
   10. CHART CARDS
============================================================================= */
.charts-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  transition:
    transform 200ms ease-out,
    box-shadow 200ms ease-out,
    background-color 300ms ease,
    border-color 200ms ease;
}

.chart-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.chart-card--full {
  width: 100%;
}

.chart-card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  line-height: 1.4;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

.chart-container--square canvas {
  max-height: 280px;
}

.chart-container--tall canvas {
  min-height: 200px;
}

.charts-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

/* =============================================================================
   11. PROMO ANALYSIS
============================================================================= */
.promo-analysis {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.promo-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.promo-stat-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  transition: background-color 300ms ease;
}

.promo-stat__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.promo-stat__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.promo-stat__sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.promo-chart-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: calc(var(--space-2) * -1);
}

/* =============================================================================
   12. TOP CLIENTS TABLE
============================================================================= */
.top-clients {
  overflow-x: auto;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.data-table {
  min-width: 480px;
  font-size: 14px;
}

.table-th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-th--right { text-align: right; }

.table-row:nth-child(even) {
  background: var(--bg-tertiary);
}

.table-row:hover {
  background: var(--bg-tertiary);
}

.table-td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.table-td--right { text-align: right; }

.table-rank {
  font-weight: 700;
  color: var(--primary);
  width: 48px;
}

.empty-section-msg {
  color: var(--text-tertiary);
  font-size: 14px;
  text-align: center;
  padding: var(--space-8);
}

/* =============================================================================
   13. ACTIONS BAR
============================================================================= */
.actions-bar {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-6) 0 var(--space-12);
  flex-wrap: wrap;
}

/* =============================================================================
   14. SETTINGS PANEL
============================================================================= */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  backdrop-filter: blur(2px);
  animation: fade-in 250ms ease-out forwards;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  animation: slide-in-right 250ms ease-out forwards;
  transition: background-color 300ms ease;
  overflow-y: auto;
}

.settings-panel.hidden {
  display: none;
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.settings-panel__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-panel__title svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.settings-panel__body {
  padding: var(--space-6);
  flex: 1;
}

.settings-group {
  border: none;
  padding: 0;
}

.settings-group__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
  display: block;
}

.settings-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  flex-shrink: 0;
}

/* Theme radio group */
.theme-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  transition: background-color 150ms ease;
}

.theme-option:hover {
  background: var(--bg-tertiary);
}

.theme-option svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.theme-radio {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.theme-radio:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: flex;
  align-items: center;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
  position: relative;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-tertiary);
  border-radius: var(--radius-full);
  transition: transform 200ms ease, background-color 200ms ease;
}

.toggle-input:checked + .toggle-track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background: #ffffff;
}

.toggle-input:focus-visible + .toggle-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* =============================================================================
   15. STATES — Loading / Error / Empty
============================================================================= */
.state-fullscreen {
  min-height: 100vh;
  background: var(--bg-primary);
  transition: background-color 300ms ease;
}

/* Centered error/empty content */
.state-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-4);
  min-height: 70vh;
  gap: var(--space-4);
  max-width: 480px;
  margin: 0 auto;
}

.state-icon {
  width: 48px;
  height: 48px;
}

.state-icon--error { color: var(--danger); }
.state-icon--empty { color: var(--text-tertiary); }

.state-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.state-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 400px;
}

/* =============================================================================
   16. SKELETON SCREENS
============================================================================= */
@keyframes shimmer {
  0%   { background-position: -800px 0; }
  100% { background-position: 800px 0; }
}

.skeleton-block {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--border) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.5s linear infinite;
}

/* Loading state top padding */
.state-fullscreen .container {
  padding-top: var(--space-4);
}

.skeleton-header-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  margin-bottom: var(--space-6);
}

.skeleton-logo        { width: 32px; height: 32px; border-radius: var(--radius-sm); flex-shrink: 0; }
.skeleton-title       { width: 160px; height: 24px; }
.skeleton-icon-btn    { width: 40px; height: 40px; border-radius: var(--radius-sm); margin-left: auto; }

.skeleton-date-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.skeleton-date-input  { width: 140px; height: 44px; }
.skeleton-preset-btn  { width: 90px;  height: 36px; border-radius: var(--radius-full); }

.skeleton-kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.skeleton-kpi-label   { height: 13px; width: 70%; }
.skeleton-kpi-value   { height: 32px; width: 55%; }
.skeleton-kpi-change  { height: 12px; width: 40%; }

.skeleton-chart-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.skeleton-chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.skeleton-chart-title { height: 20px; width: 50%; }
.skeleton-chart-body  { height: 200px; border-radius: var(--radius-sm); }

/* =============================================================================
   17. TOAST NOTIFICATIONS
============================================================================= */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 380px;
  width: calc(100vw - var(--space-12));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
  border-left: 4px solid var(--border);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--exiting {
  opacity: 0;
  transform: translateY(8px);
}

.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--info    { border-left-color: var(--info); }

.toast__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast--success .toast__icon { color: var(--success); }
.toast--error   .toast__icon { color: var(--danger); }
.toast--info    .toast__icon { color: var(--info); }

.toast__message {
  flex: 1;
  line-height: 1.4;
}

.toast__close {
  flex-shrink: 0;
}

/* =============================================================================
   18. BUTTONS
============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 100ms ease,
    opacity 150ms ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--primary);
  color: #ffffff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn--outline:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

.btn--warning-outline {
  background: transparent;
  border: 1px solid var(--warning);
  color: var(--warning);
  font-size: 13px;
}

.btn--warning-outline:hover:not(:disabled) {
  background: rgba(234, 179, 8, 0.1);
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.btn--icon:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn--icon svg {
  width: 18px;
  height: 18px;
}

.btn--sm {
  height: 36px;
  font-size: 13px;
  padding: 0 var(--space-3);
}

.btn--action {
  min-width: 160px;
}

.btn__icon {
  width: 16px;
  height: 16px;
}

/* =============================================================================
   19. DATA QUALITY
============================================================================= */
.data-quality-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  height: 32px;
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.data-quality-badge:hover {
  background: rgba(239, 68, 68, 0.15);
}

.data-quality-badge:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.data-quality-badge svg {
  width: 14px;
  height: 14px;
}

.data-quality-details {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  overflow-x: auto;
}

.data-quality-table {
  font-size: 13px;
  min-width: 400px;
}

.data-quality-table thead th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dq-cell {
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

/* =============================================================================
   20. DARK THEME
============================================================================= */
[data-theme="dark"] {
  --bg-primary:   #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary:  #334155;

  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary:  #64748b;

  --border: #334155;

  --primary:       #818cf8;
  --primary-hover: #a5b4fc;

  --success:    #4ade80;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning:    #fbbf24;
  --warning-bg: rgba(234, 179, 8, 0.1);
  --danger:     #f87171;
  --danger-bg:  rgba(239, 68, 68, 0.1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .date-input {
  color-scheme: dark;
}

[data-theme="dark"] .table-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .table-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* =============================================================================
   21. RESPONSIVE BREAKPOINTS
============================================================================= */

/* ── Tablet: 768px ── */
@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .date-range-section {
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .skeleton-chart-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .promo-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Desktop: 1024px ── */
@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-8);
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .charts-two-col {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-panel {
    width: 320px;
  }
}

/* ── Large Desktop: 1440px ── */
@media (min-width: 1440px) {
  .kpi-card__value {
    font-size: 32px;
  }
}

/* ── Mobile overrides ── */
@media (max-width: 767px) {
  .header__last-updated {
    display: none;
  }

  .kpi-card__value {
    font-size: 24px;
  }

  .actions-bar {
    flex-direction: column;
  }

  .btn--action {
    width: 100%;
    justify-content: center;
  }

  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
    width: auto;
  }

  .settings-panel {
    width: 100vw;
  }

  .promo-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================================================
   22. ANIMATIONS & TRANSITIONS
============================================================================= */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stale banner entrance */
.stale-banner:not(.hidden) {
  animation: fade-in-up 300ms ease-out forwards;
}

/* =============================================================================
   23. REDUCED MOTION
============================================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .skeleton-block {
    animation: none;
    background: var(--bg-tertiary);
  }
}

/* =============================================================================
   24. ACCESSIBILITY UTILITIES
============================================================================= */

/* Visually hidden but accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Visible focus indicator for all interactive elements */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove outline for mouse users (only show for keyboard) */
:focus:not(:focus-visible) {
  outline: none;
}

/* Main content landmark */
.main-content {
  padding: var(--space-6) 0;
}
