/*
 * Rogue Origin Operations Hub — Dashboard
 * Design: Timber mill control room aesthetic
 * Typography: DM Serif Display (titles), JetBrains Mono (data), Outfit (UI)
 * Colors: Green #668971, Gold #e4aa4f, Blue #62758d
 * Grid: 8px spacing, 8px card radius, 6px input radius
 * Redesigned: February 2026
 */

/* ========================================
   Z-INDEX HIERARCHY (Standardized)
   ========================================
   Layer                          Value
   ----------------------------------------
   Background texture             -1
   Base content / widgets         1-10
   Widget drag states             50
   Sidebar                        50
   Sticky header                  60
   Dropdowns / tooltips           100
   Modals / overlays              300-350
   Settings panel                 400-410
   FAB (floating action button)   800
   Toast / notifications          950
   AI chat FAB                    1000
   AI chat panel                  1050
   Loading overlay                1100
   ======================================== */

/* ========================================
   CSS VARIABLES - HYBRID THEME SYSTEM
   ======================================== */
:root {
  /* ===== TYPOGRAPHY ===== */
  --font-display: 'DM Serif Display', serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-ui: 'Outfit', sans-serif;

  /* Type Scale */
  --text-hero: 96px;
  --text-hero-mobile: 64px;
  --text-display: 48px;
  --text-display-sm: 36px;
  --text-h1: 28px;
  --text-h2: 22px;
  --text-h3: 18px;
  --text-h4: 16px;
  --text-body: 14px;
  --text-sm: 13px;
  --text-xs: 11px;
  --text-xxs: 10px;
  --text-mono-lg: 18px;
  --text-mono-md: 14px;
  --text-mono-sm: 12px;

  /* Line Heights */
  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Letter Spacing */
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.05em;
  --tracking-wider: 0.08em;
  --tracking-widest: 0.1em;

  /* ===== COLORS ===== */
  /* Brand */
  --ro-green: #668971;
  --ro-gold: #e4aa4f;

  /* Green Family */
  --green-50: #f4f7f5;
  --green-100: #e8efe9;
  --green-200: #d1dfd4;
  --green-300: #a8c4ad;
  --green-400: #8ba896;
  --green-500: #668971;
  --green-600: #4a6b54;
  --green-700: #3d5243;
  --green-800: #2d3a32;
  --green-900: #1a1f16;

  /* Gold Family */
  --gold-50: #fef9f0;
  --gold-100: #fdf0d8;
  --gold-200: #f8ddb0;
  --gold-300: #f0cb60;
  --gold-400: #e4aa4f;
  --gold-500: #d4993f;
  --gold-600: #c08832;
  --gold-700: #a67428;
  --gold-800: #8c5f1f;
  --gold-warm: #e8b05d;

  /* Legacy aliases */
  --gold: #e4aa4f;
  --gold-light: #f0cb60;
  --gold-glow: #f0cb60;
  --gold-dim: rgba(228,170,79,0.15);
  --green: #668971;
  --green-dim: rgba(102,137,113,0.15);
  --green-dark: #4a6b54;
  --ro-green-dark: #3d5243;
  --ro-green-glow: rgba(102, 137, 113, 0.4);

  /* Semantic */
  --success: #668971;
  --success-light: rgba(102, 137, 113, 0.15);
  --warning: #e4aa4f;
  --warning-light: rgba(228, 170, 79, 0.15);
  --danger: #c45c4a;
  --danger-light: rgba(196, 92, 74, 0.15);
  --info: #62758d;
  --info-light: rgba(98, 117, 141, 0.15);

  /* Cultivation */
  --sungrown: #bf8e4e;
  --sungrown-dim: rgba(191,142,78,0.15);
  --sungrown-light: rgba(191,142,78,0.15);
  --greenhouse: #8f9263;
  --greenhouse-dim: rgba(143,146,99,0.15);
  --greenhouse-light: rgba(143,146,99,0.15);
  --indoor: #62758d;
  --indoor-dim: rgba(98,117,141,0.15);
  --indoor-light: rgba(98,117,141,0.15);

  /* Special */
  --hemp-fiber: #b8a88a;
  --parchment: #faf8f5;
  --candlelight: rgba(228, 170, 79, 0.08);

  /* Light Theme */
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-dark: #faf8f5;
  --sidebar-bg: #0f1210;
  --glass: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(102,137,113,0.15);
  --border: rgba(102,137,113,0.2);
  --border-light: rgba(102,137,113,0.1);
  --text: #2d3a32;
  --text-primary: #2d3a32;
  --text-secondary: #5a6b5f;
  --text-muted: #5a6b5f;
  --text-light: #8a9a8e;
  --text-emphasis: #2d3a32;

  /* ===== LAYOUT ===== */
  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  
  /* ===== SIDEBAR COLORS ===== */
  --sidebar-text: rgba(255, 255, 255, 0.5);
  --sidebar-text-muted: rgba(255, 255, 255, 0.4);
  --sidebar-text-active: rgba(255, 255, 255, 0.9);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* ===== SPACING ===== */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 40px;
  --space-xl: 64px;

  /* ===== BORDER RADIUS ===== */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  --radius-organic-sm: 8px 12px 10px 14px;
  --radius-organic-md: 12px 16px 14px 18px;
  --radius-organic-lg: 16px 20px 18px 22px;
  --radius-organic-xl: 20px 24px 22px 26px;

  /* ===== SHADOWS ===== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.12);
  --shadow-elevated:
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(102, 137, 113, 0.05);
  --shadow-dramatic: 0 2px 8px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-dramatic-hover: 0 4px 12px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.08);

  /* Glow Effects */
  --glow-gold-sm: 0 0 8px rgba(228, 170, 79, 0.3);
  --glow-gold-md: 0 0 16px rgba(228, 170, 79, 0.4);
  --glow-gold-lg: 0 0 32px rgba(228, 170, 79, 0.5);
  --glow-gold-xl: 0 0 48px rgba(228, 170, 79, 0.6);
  --glow-green-sm: 0 0 8px rgba(102, 137, 113, 0.3);
  --glow-green-md: 0 0 16px rgba(102, 137, 113, 0.4);
  --glow-green-lg: 0 0 32px rgba(102, 137, 113, 0.5);

  /* ===== ANIMATIONS ===== */
  --duration-instant: 0ms;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;
  --duration-slowest: 1200ms;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-expo: cubic-bezier(0.87, 0, 0.13, 1);
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 300ms var(--ease-spring);
  --transition-slow: 500ms var(--ease-spring);
  --transition-colors: 200ms ease;
  --transition-transform: 300ms var(--ease-spring);
  --transition-all: 300ms var(--ease-spring);

  /* Legacy */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ===== CHARTS ===== */
  --chart-grid: rgba(0,0,0,0.06);
  --chart-text: rgba(45,58,46,0.4);
}

/* ========================================
   DARK THEME - ORGANIC INDUSTRIAL
   ======================================== */
:root[data-theme="dark"] {
  /* Earth Tones */
  --earth-900: #0f110e;
  --earth-800: #12150f;
  --earth-700: #1a1f16;
  --earth-600: #252b22;
  --earth-500: #2d3a32;
  --earth-400: #4a5a4e;
  --earth-300: #6b7a6f;
  --earth-200: #8a9a8e;
  --earth-100: #b8c4ba;
  --earth-50: #f5f2ed;

  /* Legacy Earth Tones */
  --soil: #2d2419;
  --clay: #4a3f35;
  --hemp-fiber: #b8a88a;
  --leaf-green: #8ba896;
  --sage: #9ca89a;
  --mist: rgba(102, 137, 113, 0.08);

  /* Dark Backgrounds */
  --bg: #141816;
  --bg-dark: #0f1210;
  --bg-card: rgba(26, 30, 27, 0.85);
  --sidebar-bg: #0f1210;
  --sidebar-text: rgba(255, 255, 255, 0.5);
  --sidebar-text-muted: rgba(255, 255, 255, 0.4);
  --sidebar-text-active: rgba(255, 255, 255, 0.9);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(102, 137, 113, 0.15);
  --border: rgba(102, 137, 113, 0.15);
  --border-light: rgba(102, 137, 113, 0.1);

  /* Dark Text */
  --text: rgba(255, 255, 255, 0.88);
  --text-primary: rgba(255, 255, 255, 0.88);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-light: rgba(255, 255, 255, 0.3);
  --text-emphasis: #f0ece4;

  /* Adjusted Colors */
  --gold: #e8b05d;
  --gold-dim: rgba(232,176,93,0.2);
  --green-dim: rgba(102,137,113,0.2);
  --sungrown-dim: rgba(191,142,78,0.2);
  --sungrown-light: rgba(191,142,78,0.2);
  --greenhouse-dim: rgba(143,146,99,0.2);
  --greenhouse-light: rgba(143,146,99,0.2);
  --indoor-dim: rgba(98,117,141,0.2);
  --indoor-light: rgba(98,117,141,0.2);
  --success-light: rgba(102,137,113,0.2);
  --warning-light: rgba(232,176,93,0.2);
  --danger-light: rgba(196,92,74,0.2);
  --info-light: rgba(98,117,141,0.2);

  /* Charts Dark */
  --chart-grid: rgba(255,255,255,0.06);
  --chart-text: rgba(255,255,255,0.4);

  /* Dramatic Shadows (4-layer) */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-md:
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 8px 16px rgba(0, 0, 0, 0.15),
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 0 24px rgba(228, 170, 79, 0.05);
  --shadow-lg:
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 8px 16px rgba(0, 0, 0, 0.15),
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 32px 64px rgba(0, 0, 0, 0.25);
  --shadow-xl:
    0 4px 8px rgba(0, 0, 0, 0.1),
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 32px 64px rgba(0, 0, 0, 0.25),
    0 48px 96px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(102, 137, 113, 0.1);
  --shadow-gold:
    0 4px 8px rgba(0, 0, 0, 0.1),
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 0 32px rgba(228, 170, 79, 0.3);
  --shadow-dramatic:
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 8px 16px rgba(0, 0, 0, 0.15),
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 32px 64px rgba(0, 0, 0, 0.25);
  --shadow-dramatic-hover:
    0 4px 8px rgba(0, 0, 0, 0.1),
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 32px 64px rgba(0, 0, 0, 0.25),
    0 48px 96px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(102, 137, 113, 0.3);
}

/* ========================================
   DARK THEME — Pass 3: Comprehensive Coverage
   ======================================== */

/* Body background */
:root[data-theme="dark"] body {
  background: #141816;
}

/* KPI cards */
:root[data-theme="dark"] .kpi-card {
  background: rgba(26, 30, 27, 0.6);
  border-color: rgba(102, 137, 113, 0.12);
}
:root[data-theme="dark"] .kpi-value {
  color: rgba(255, 255, 255, 0.88);
}
:root[data-theme="dark"] .kpi-label {
  color: rgba(255, 255, 255, 0.4);
}

/* Widget/chart/integration cards */
:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .widget-card,
:root[data-theme="dark"] .integration-card {
  background: rgba(26, 30, 27, 0.85);
  border-color: rgba(102, 137, 113, 0.15);
}

/* Current production & progress hero */
:root[data-theme="dark"] .current-production,
:root[data-theme="dark"] .progress-hero {
  background: rgba(26, 30, 27, 0.85);
  border-color: rgba(102, 137, 113, 0.15);
}

/* Header */
:root[data-theme="dark"] .header {
  background: rgba(15, 18, 16, 0.9);
  border-color: rgba(102, 137, 113, 0.1);
  backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.88);
}

/* Sidebar */
:root[data-theme="dark"] .sidebar {
  background: var(--sidebar-bg);
  border-right-color: rgba(102, 137, 113, 0.1);
}

/* Settings panel */
:root[data-theme="dark"] .settings-panel {
  background: #181c19;
  border-color: rgba(102, 137, 113, 0.1);
}
:root[data-theme="dark"] .settings-header {
  background: #181c19;
  border-bottom-color: rgba(102, 137, 113, 0.1);
}
:root[data-theme="dark"] .settings-section {
  border-bottom-color: rgba(102, 137, 113, 0.08);
}
:root[data-theme="dark"] .settings-close {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.5);
}
:root[data-theme="dark"] .settings-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

/* AI chat panel */
:root[data-theme="dark"] .ai-chat-panel {
  background: rgba(26, 30, 27, 0.95);
  border-color: rgba(102, 137, 113, 0.15);
  backdrop-filter: blur(20px);
}

/* Date picker dropdown */
:root[data-theme="dark"] .date-picker-dropdown,
:root[data-theme="dark"] .compare-dropdown {
  background: #1a1e1b;
  border-color: rgba(102, 137, 113, 0.15);
}

:root[data-theme="dark"] .date-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(102, 137, 113, 0.12);
  color: rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .date-chip:hover {
  background: rgba(102, 137, 113, 0.15);
  color: var(--ro-green);
  border-color: var(--ro-green);
}

:root[data-theme="dark"] .date-chip.active {
  background: var(--ro-green);
  color: #fff;
  border-color: var(--ro-green);
}

:root[data-theme="dark"] input[type="date"] {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

/* All form inputs */
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

/* Widget toggle & perf table borders */
:root[data-theme="dark"] .widget-toggle,
:root[data-theme="dark"] .perf-table div {
  border-color: rgba(102, 137, 113, 0.08);
}
:root[data-theme="dark"] .widget-toggle {
  background: rgba(255, 255, 255, 0.04);
}

/* Strain items */
:root[data-theme="dark"] .strain-item {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(102, 137, 113, 0.06);
}

/* Perf rows */
:root[data-theme="dark"] .perf-row {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(102, 137, 113, 0.06);
}
:root[data-theme="dark"] .perf-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .perf-label {
  color: rgba(255, 255, 255, 0.4);
}

/* FAB items */
:root[data-theme="dark"] .fab-item-btn,
:root[data-theme="dark"] .fab-item-label {
  background: #1a1e1b;
  border-color: rgba(102, 137, 113, 0.15);
}

/* Loading overlay */
:root[data-theme="dark"] .logo-loader {
  background: #141816;
}

:root[data-theme="dark"] .logo-loader img {
  animation: logoPulseDark 1.6s ease-in-out infinite;
}

@keyframes logoPulseDark {
  0%, 100% { opacity: 0.4; filter: drop-shadow(0 0 0 transparent) brightness(1.1); transform: scale(0.98); }
  50% { opacity: 1; filter: drop-shadow(0 0 30px rgba(201, 166, 90, 0.6)) drop-shadow(0 0 60px rgba(201, 166, 90, 0.35)) brightness(1.2); transform: scale(1); }
}

:root[data-theme="dark"] .logo-loader-bar {
  animation: barPulseDark 1.6s ease-in-out infinite;
}

@keyframes barPulseDark {
  0%, 100% { width: 80px; opacity: 0.4; }
  50% { width: 130px; opacity: 0.85; }
}

/* Compare banner */
:root[data-theme="dark"] .compare-banner {
  background: rgba(102, 137, 113, 0.08);
  border-color: rgba(102, 137, 113, 0.15);
  color: rgba(255, 255, 255, 0.88);
}
:root[data-theme="dark"] .compare-badge {
  background: rgba(102, 137, 113, 0.15);
  color: var(--ro-green);
}
:root[data-theme="dark"] .compare-dot.previous {
  background: rgba(255, 255, 255, 0.3);
}
:root[data-theme="dark"] .compare-close {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(102, 137, 113, 0.1);
  color: rgba(255, 255, 255, 0.5);
}
:root[data-theme="dark"] .compare-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

/* Connection status bar */
:root[data-theme="dark"] .connection-retry-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(102, 137, 113, 0.15);
}
:root[data-theme="dark"] .connection-retry-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Date display toolbar */
:root[data-theme="dark"] .date-display {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.35);
}

/* Sparkline metric labels */
:root[data-theme="dark"] .sparkline-metric-label {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .sparkline-bars {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(102, 137, 113, 0.08);
}

/* Integration stat labels */
:root[data-theme="dark"] .integration-stat-label {
  color: rgba(255, 255, 255, 0.4);
}

/* Chart subtitle */
:root[data-theme="dark"] .chart-subtitle {
  color: rgba(255, 255, 255, 0.35);
}

/* Widget action buttons */
:root[data-theme="dark"] .widget-collapse,
:root[data-theme="dark"] .widget-hide,
:root[data-theme="dark"] .widget-help,
:root[data-theme="dark"] .widget-resize,
:root[data-theme="dark"] .widget-drag-handle {
  background: rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .widget-collapse:hover,
:root[data-theme="dark"] .widget-help:hover,
:root[data-theme="dark"] .widget-resize:hover,
:root[data-theme="dark"] .widget-drag-handle:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Current card dark mode text */
:root[data-theme="dark"] .current-time {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .current-stat-label {
  color: rgba(255, 255, 255, 0.35);
}

/* Welcome modal */
:root[data-theme="dark"] .welcome-modal {
  background: #1a1e1b;
  border-color: var(--ro-gold);
}
:root[data-theme="dark"] .welcome-modal-btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(102, 137, 113, 0.15);
}

/* Scrollbar — dark theme */
:root[data-theme="dark"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
:root[data-theme="dark"] ::-webkit-scrollbar-track {
  background: transparent;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Focus indicators dark mode — use gold for better visibility */
:root[data-theme="dark"] button:focus-visible,
:root[data-theme="dark"] [role="button"]:focus-visible,
:root[data-theme="dark"] [role="menuitem"]:focus-visible,
:root[data-theme="dark"] input:focus-visible,
:root[data-theme="dark"] a:focus-visible {
  outline-color: var(--ro-gold);
  box-shadow: 0 0 0 4px rgba(228, 170, 79, 0.25);
}

/* ========================================
   LIGHT THEME — Pass 3: Comprehensive Coverage
   ======================================== */

/* Body background */
:root[data-theme="light"] body {
  background: #faf8f5;
}

/* Sidebar */
:root[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .sidebar-toggle {
  color: rgba(45, 58, 46, 0.4);
}
:root[data-theme="light"] .sidebar-toggle:hover {
  color: rgba(45, 58, 46, 0.7);
}
:root[data-theme="light"] .brand {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] .brand h1 {
  color: #2d3a2e;
}
:root[data-theme="light"] .nav-item {
  color: rgba(45, 58, 46, 0.6);
}
:root[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #2d3a2e;
}
:root[data-theme="light"] .nav-item.active {
  background: rgba(102, 137, 113, 0.1);
  color: var(--ro-green);
}
:root[data-theme="light"] .nav-section {
  color: rgba(45, 58, 46, 0.35);
}
:root[data-theme="light"] .user-avatar {
  color: #2d3a2e;
}
:root[data-theme="light"] .user-details h4 {
  color: #2d3a2e;
}
:root[data-theme="light"] .user-details p {
  color: rgba(45, 58, 46, 0.5);
}
:root[data-theme="light"] .sidebar-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Header */
:root[data-theme="light"] .header {
  background: #ffffff;
  color: #2d3a2e;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: none;
}
:root[data-theme="light"] .header-time .time {
  color: #2d3a2e;
}
:root[data-theme="light"] .header-time .date {
  color: rgba(45, 58, 46, 0.5);
}
:root[data-theme="light"] .header-btn {
  background: rgba(0, 0, 0, 0.03);
  color: rgba(45, 58, 46, 0.7);
  border-color: rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .header-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #2d3a2e;
}
:root[data-theme="light"] .theme-toggle {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(45, 58, 46, 0.7);
}
:root[data-theme="light"] .theme-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Widget cards */
:root[data-theme="light"] .widget-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
}
:root[data-theme="light"] .widget-header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* KPI cards */
:root[data-theme="light"] .kpi-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
}
:root[data-theme="light"] .kpi-value {
  color: #2d3a2e;
}
:root[data-theme="light"] .kpi-label {
  color: rgba(45, 58, 46, 0.5);
}

/* Chart cards */
:root[data-theme="light"] .chart-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
}
:root[data-theme="light"] .chart-subtitle {
  color: rgba(45, 58, 46, 0.45);
}

/* Integration cards */
:root[data-theme="light"] .integration-stat-label {
  color: rgba(45, 58, 46, 0.5);
}

/* Sparkline & perf */
:root[data-theme="light"] .sparkline-bars {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] .sparkline-metric-label {
  color: rgba(45, 58, 46, 0.5);
}
:root[data-theme="light"] .strain-item {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.04);
}
:root[data-theme="light"] .perf-row {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.04);
}
:root[data-theme="light"] .perf-row:nth-child(even) {
  background: rgba(0, 0, 0, 0.03);
}
:root[data-theme="light"] .perf-label {
  color: rgba(45, 58, 46, 0.5);
}

/* Settings panel */
:root[data-theme="light"] .settings-panel {
  background: #ffffff;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .settings-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] .settings-section {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] .settings-close {
  background: rgba(0, 0, 0, 0.03);
  color: rgba(45, 58, 46, 0.6);
}
:root[data-theme="light"] .settings-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #2d3a2e;
}
:root[data-theme="light"] .widget-toggle {
  background: rgba(0, 0, 0, 0.02);
}

/* Compare banner */
:root[data-theme="light"] .compare-banner {
  background: rgba(102, 137, 113, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
  color: #2d3a2e;
}
:root[data-theme="light"] .compare-badge {
  background: rgba(102, 137, 113, 0.1);
  color: var(--ro-green);
}
:root[data-theme="light"] .compare-dot.previous {
  background: rgba(45, 58, 46, 0.3);
}
:root[data-theme="light"] .compare-close {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(45, 58, 46, 0.5);
}

/* Widget action buttons */
:root[data-theme="light"] .widget-collapse,
:root[data-theme="light"] .widget-hide,
:root[data-theme="light"] .widget-help,
:root[data-theme="light"] .widget-resize,
:root[data-theme="light"] .widget-drag-handle {
  background: rgba(0, 0, 0, 0.03);
}
:root[data-theme="light"] .widget-collapse:hover,
:root[data-theme="light"] .widget-help:hover,
:root[data-theme="light"] .widget-resize:hover,
:root[data-theme="light"] .widget-drag-handle:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Hero mini KPI */
:root[data-theme="light"] .hero-mini-kpi {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .hero-mini-kpi-value {
  color: #2d3a2e;
}
:root[data-theme="light"] .hero-mini-kpi-label,
:root[data-theme="light"] .hero-mini-kpi-sub {
  color: rgba(45, 58, 46, 0.5);
}

/* Light mode: hero label */
:root[data-theme="light"] .hero-label {
  color: rgba(45, 58, 46, 0.35);
}
/* Light mode: hero bottom border */
:root[data-theme="light"] .hero-section {
  border-bottom-color: rgba(102, 137, 113, 0.2);
}
/* Light mode: widget title ::before */
:root[data-theme="light"] .widget-title::before {
  color: rgba(45, 58, 46, 0.15);
}
/* Light mode: date display toolbar */
:root[data-theme="light"] .date-display {
  background: transparent;
  border: none;
  color: rgba(45, 58, 46, 0.35);
}
:root[data-theme="light"] .date-display strong {
  color: rgba(45, 58, 46, 0.5);
}
/* Light mode: integration card bottom borders */
:root[data-theme="light"] .widget-item[data-widget-id="widget-kanban"] .integration-card { border-bottom: 2px solid rgba(102, 137, 113, 0.2); }
:root[data-theme="light"] .widget-item[data-widget-id="widget-scoreboard"] .integration-card { border-bottom: 2px solid rgba(228, 170, 79, 0.2); }
:root[data-theme="light"] .widget-item[data-widget-id="widget-bags"] .integration-card { border-bottom: 2px solid rgba(98, 117, 141, 0.2); }
:root[data-theme="light"] .widget-item[data-widget-id="widget-sop"] .integration-card { border-bottom: 2px solid rgba(102, 137, 113, 0.2); }

/* Current card */
:root[data-theme="light"] .current-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  border-bottom: 2px solid rgba(102, 137, 113, 0.3);
}
:root[data-theme="light"] .current-stat-value { color: #2d3a2e; }
:root[data-theme="light"] .current-stat-value.highlight { color: var(--ro-green); }
:root[data-theme="light"] .current-stat-label { color: rgba(45, 58, 46, 0.5); }
:root[data-theme="light"] .current-strain { color: var(--ro-green); }
:root[data-theme="light"] .current-time { color: rgba(45, 58, 46, 0.4); }

/* Date picker */
:root[data-theme="light"] .date-picker-trigger {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(45, 58, 46, 0.7);
}
:root[data-theme="light"] .date-picker-trigger:hover {
  background: rgba(0, 0, 0, 0.06);
}
:root[data-theme="light"] .date-picker-dropdown {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .compare-dropdown {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

/* Loading overlay */
:root[data-theme="light"] .logo-loader {
  background: #faf8f5;
}

/* Mobile menu button */
:root[data-theme="light"] .mobile-menu-btn {
  color: #2d3a2e;
}

/* Date display toolbar */
:root[data-theme="light"] .date-display {
  background: transparent;
  border: none;
}

/* Scrollbar — light theme */
:root[data-theme="light"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
:root[data-theme="light"] ::-webkit-scrollbar-track {
  background: transparent;
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Light mode topo uses dark green strokes */
:root[data-theme="light"] body::after {
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'%3E%3Cg fill='none' stroke='%232d3a2e' stroke-width='1'%3E%3Cellipse cx='300' cy='300' rx='60' ry='40' transform='rotate(-15 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='110' ry='75' transform='rotate(-12 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='165' ry='115' transform='rotate(-8 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='225' ry='160' transform='rotate(-4 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='290' ry='210' transform='rotate(0 300 300)'/%3E%3Cellipse cx='140' cy='160' rx='45' ry='30' transform='rotate(20 140 160)'/%3E%3Cellipse cx='140' cy='160' rx='90' ry='60' transform='rotate(18 140 160)'/%3E%3Cellipse cx='140' cy='160' rx='140' ry='95' transform='rotate(14 140 160)'/%3E%3Cellipse cx='480' cy='420' rx='55' ry='35' transform='rotate(-25 480 420)'/%3E%3Cellipse cx='480' cy='420' rx='100' ry='65' transform='rotate(-22 480 420)'/%3E%3Cellipse cx='480' cy='420' rx='150' ry='100' transform='rotate(-18 480 420)'/%3E%3Cpath d='M0 200 Q150 180 300 220 Q450 260 600 230'/%3E%3Cpath d='M0 350 Q100 320 250 360 Q400 400 600 370'/%3E%3Cpath d='M0 500 Q200 470 350 510 Q500 550 600 520'/%3E%3C/g%3E%3C/svg%3E");
}

/* Topographic Contour Lines Background */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  pointer-events: none;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cellipse cx='300' cy='300' rx='60' ry='40' transform='rotate(-15 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='110' ry='75' transform='rotate(-12 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='165' ry='115' transform='rotate(-8 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='225' ry='160' transform='rotate(-4 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='290' ry='210' transform='rotate(0 300 300)'/%3E%3Cellipse cx='140' cy='160' rx='45' ry='30' transform='rotate(20 140 160)'/%3E%3Cellipse cx='140' cy='160' rx='90' ry='60' transform='rotate(18 140 160)'/%3E%3Cellipse cx='140' cy='160' rx='140' ry='95' transform='rotate(14 140 160)'/%3E%3Cellipse cx='480' cy='420' rx='55' ry='35' transform='rotate(-25 480 420)'/%3E%3Cellipse cx='480' cy='420' rx='100' ry='65' transform='rotate(-22 480 420)'/%3E%3Cellipse cx='480' cy='420' rx='150' ry='100' transform='rotate(-18 480 420)'/%3E%3Cpath d='M0 200 Q150 180 300 220 Q450 260 600 230'/%3E%3Cpath d='M0 350 Q100 320 250 360 Q400 400 600 370'/%3E%3Cpath d='M0 500 Q200 470 350 510 Q500 550 600 520'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 600px 600px;
}

/* Theme Toggle Button */
.theme-toggle {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

#themeIcon {
  display: flex;
  align-items: center;
  width: 16px;
  height: 16px;
}

#themeIcon svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.theme-toggle:active #themeIcon svg {
  transform: rotate(30deg);
}
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-width: 320px; /* Prevent layout collapse on very small screens */
  max-width: 100vw; /* Prevent horizontal expansion beyond viewport */
  overflow-x: hidden; /* Hide horizontal overflow */
  display: flex;
}
/* Old noise pattern removed — using topo contour lines via body::after */

main {
  flex: 1;
  min-width: 0; /* Allow flex item to shrink */
  max-width: 100%; /* Prevent expansion */
  overflow-x: hidden; /* Hide horizontal overflow */
}

/* ========================================
   BOTANICAL LUXURY ANIMATIONS
   ======================================== */

/* Page Load Sequence */
@keyframes backgroundFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes headerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sidebarSlideIn {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes heroReveal {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes heroNumberGlow {
  from {
    text-shadow: 0 0 0 rgba(228, 170, 79, 0);
  }
  to {
    text-shadow:
      0 0 40px rgba(228, 170, 79, 0.4),
      0 0 80px rgba(228, 170, 79, 0.2);
  }
}

@keyframes widgetPopIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fabBounceIn {
  0% {
    opacity: 0;
    transform: scale(0) translateY(20px);
  }
  60% {
    opacity: 1;
    transform: scale(1.15) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Number count-up animation */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Interaction Animations */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(228, 170, 79, 0);
  }
  50% {
    box-shadow: 0 0 24px 4px rgba(228, 170, 79, 0.4);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.animate-value { animation: countUp 0.4s ease-out forwards; }

/* ========================================
   PASS 6: MICRO-INTERACTIONS — Entrance Animations
   (fadeIn, fadeInUp, spin defined in shared-base.css)
   ======================================== */
@keyframes progressFill {
  from { width: 0; }
}

@keyframes productionNumberEntrance {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Staggered entrance: Welcome */
.welcome-section {
  animation: fadeIn 0.4s ease both;
}

/* Staggered entrance: Hero */
.hero-section {
  animation: fadeIn 0.5s ease 0.1s both;
}

/* Staggered entrance: KPI cards */
.kpi-grid-item:nth-child(1) .kpi-card { animation: fadeInUp 0.4s ease 0.15s both; }
.kpi-grid-item:nth-child(2) .kpi-card { animation: fadeInUp 0.4s ease 0.21s both; }
.kpi-grid-item:nth-child(3) .kpi-card { animation: fadeInUp 0.4s ease 0.27s both; }
.kpi-grid-item:nth-child(4) .kpi-card { animation: fadeInUp 0.4s ease 0.33s both; }
.kpi-grid-item:nth-child(5) .kpi-card { animation: fadeInUp 0.4s ease 0.39s both; }
.kpi-grid-item:nth-child(6) .kpi-card { animation: fadeInUp 0.4s ease 0.45s both; }
.kpi-grid-item:nth-child(7) .kpi-card { animation: fadeInUp 0.4s ease 0.51s both; }
.kpi-grid-item:nth-child(8) .kpi-card { animation: fadeInUp 0.4s ease 0.57s both; }

/* Staggered entrance: Widget cards */













/* Production number entrance */
.hero-production-number {
  animation: productionNumberEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

/* Progress bar fill animation */
.hero-progress-fill {
  animation: progressFill 1s ease-out 0.6s both;
}

/* Apply page load animations */
body { animation: backgroundFadeIn 800ms ease-out forwards; }
.header { animation: headerSlideDown 400ms var(--ease-spring) 200ms backwards; }
.sidebar { animation: sidebarSlideIn 500ms var(--ease-spring) 300ms backwards; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 50; /* Layout: sidebar */
  transition: width 0.3s ease;
  border-right: 1px solid rgba(102, 137, 113, 0.1);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand h1,
.sidebar.collapsed .nav-item span:not(.icon),
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-toggle-label { display: none; }
.sidebar.collapsed .brand { justify-content: center; padding: 16px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px; }
.sidebar.collapsed .nav-item .icon { margin: 0; width: auto; }
.sidebar.collapsed .user-info { justify-content: center; }
.sidebar.collapsed .sidebar-toggle { justify-content: center; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: color 0.15s ease;
  font-size: 13px;
}
.sidebar-toggle:hover { color: rgba(255, 255, 255, 0.7); }
.sidebar-toggle svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-toggle-label { font-size: 13px; font-weight: 400; white-space: nowrap; }

.brand { display: flex; align-items: center; gap: 12px; padding: 24px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); margin-bottom: 16px; }
.logo { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.brand h1 { font-size: 16px; font-weight: 600; color: rgba(255, 255, 255, 0.9); font-family: var(--font-ui); white-space: nowrap; }
.nav-section { margin-top: 16px; margin-bottom: 8px; padding: 0 16px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--sidebar-text-muted); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin: 2px 8px; border-radius: 6px; color: rgba(255, 255, 255, 0.5); text-decoration: none; transition: all 0.15s ease; font-size: 14px; font-weight: 400; cursor: pointer; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.8); }
.nav-item.active { background: rgba(102, 137, 113, 0.15); color: var(--ro-green); }
.nav-item .icon { width: 22px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; opacity: 0.5; transition: opacity 0.2s ease; }
.nav-item:hover .icon, .nav-item.active .icon { opacity: 1; }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }
.sidebar-footer { margin-top: auto; padding: 14px 8px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.user-info { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; color: var(--sidebar-bg); flex-shrink: 0; }
.user-details h4 { font-size: 13px; color: rgba(255, 255, 255, 0.9); font-weight: 500; }
.user-details p { font-size: 11px; color: rgba(255, 255, 255, 0.4); }

/* Main Content */
.main { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 0.3s ease; }
body.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed); }

/* Header */
.header {
  background: rgba(15, 18, 16, 0.9);
  color: rgba(255, 255, 255, 0.88);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(102, 137, 113, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 16px; font-weight: 600; color: rgba(255, 255, 255, 0.88); }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-time { text-align: right; margin-right: 6px; }
.header-time .time { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.88); }
.header-time .date { font-size: 10px; color: rgba(255, 255, 255, 0.4); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.header-btn {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: var(--font-ui);
}
.header-btn:hover { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.9); }
.header-btn.primary { background: var(--ro-green); color: white; border-color: transparent; font-weight: 600; }
.header-btn.primary:hover { background: var(--green-600); }
.header-btn.active { background: var(--ro-green); color: #fff; border-color: transparent; }
.header-btn svg { width: 14px; height: 14px; }

/* Pass 6: Refresh button spin on click */
.header-btn.primary:active svg {
  animation: spin 0.6s ease;
}

/* Header Logo */
.header-logo { height: 28px; width: auto; }

/* Connection Status Bar — Pass 5: Minimal thin bar */
.connection-status {
  position: sticky;
  top: 60px;
  z-index: 55;
  background: transparent;
  border-bottom: none;
  padding: 0;
  height: 2px;
  display: block;
  font-size: 0;
  line-height: 0;
  transition: all 0.3s ease;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.connection-status.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.connection-status.connecting {
  background: var(--ro-gold);
}

.connection-status.connected {
  background: var(--ro-green);
}

.connection-status.error {
  background: var(--danger);
}

.connection-status-icon {
  display: none;
}

.connection-status.connected .connection-status-icon { display: none; }
.connection-status.error .connection-status-icon { display: none; }

.connection-status-icon .ph-spin {
  animation: spin 1s linear infinite;
}

.connection-status-text {
  display: none;
}

.connection-retry-btn {
  display: none;
}

.connection-retry-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Welcome Greeting — Editorial (merged visually into hero) */
.welcome-section { margin-bottom: 0; }
.welcome-greeting {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 32px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.welcome-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== HERO SECTION — PASS 5: DRAMATIC CENTERPIECE ===== */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  min-height: auto;
  border-bottom: 2px solid rgba(102, 137, 113, 0.3);
  padding-bottom: 32px;
}

.hero-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

.hero-botanical-frame {
  position: relative;
  padding: 16px 48px 24px;
  text-align: center;
  animation: heroFrameReveal 800ms var(--ease-spring) 400ms backwards;
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 12px;
  font-weight: 500;
}
.hero-strain {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  font-weight: 400;
  color: var(--ro-green);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.hero-production-number {
  font-family: var(--font-mono);
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: text-shadow 0.3s ease;
}

/* Green glow when near/above target */
.hero-progress-fill.ahead ~ .hero-production-number,
.hero-section.near-target .hero-production-number {
  text-shadow: 0 0 32px rgba(102, 137, 113, 0.4), 0 0 64px rgba(102, 137, 113, 0.2);
}

.hero-production-unit {
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 300;
  color: var(--text-muted);
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.hero-subtitle {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.hero-progress-bar {
  margin-top: 24px;
  height: 10px;
  background: rgba(102, 137, 113, 0.15);
  border-radius: 5px;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.hero-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--ro-green);
  border-radius: 5px;
  transition: width 1s var(--ease-spring), background 0.3s ease;
}

.hero-progress-fill.ahead {
  background: var(--ro-green);
}

.hero-progress-fill.on-track {
  background: var(--ro-green);
}

.hero-progress-fill.behind {
  background: var(--danger);
}

.hero-progress-text {
  position: absolute;
  right: 0;
  top: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.hero-right {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-content: center;
  padding: 0;
  width: 100%;
  margin-top: 24px;
}

.hero-mini-kpi {
  background: rgba(26, 30, 27, 0.6);
  border: 1px solid rgba(102, 137, 113, 0.12);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
  animation: widgetPopIn 400ms var(--ease-spring) backwards;
}

.hero-mini-kpi:nth-child(1) { animation-delay: 600ms; }
.hero-mini-kpi:nth-child(2) { animation-delay: 700ms; }
.hero-mini-kpi:nth-child(3) { animation-delay: 800ms; }
.hero-mini-kpi:nth-child(4) { animation-delay: 900ms; }

.hero-mini-kpi:hover {
  border-color: rgba(102, 137, 113, 0.3);
  transform: translateY(-2px);
}

.hero-mini-kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-emphasis);
  line-height: 1;
}

.hero-mini-kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 8px;
}

.hero-mini-kpi-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

.hero-mini-kpi.gold .hero-mini-kpi-value {
  color: var(--ro-gold);
}

@keyframes heroFrameReveal {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 1200px) {
  .hero-section {
    /* Single column, no grid change needed */
  }
  .hero-production-number {
    font-size: 60px;
  }
  .hero-right {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .hero-section {
    min-height: auto;
  }
  .hero-botanical-frame {
    padding: 16px;
  }
  .hero-production-number {
    font-size: 48px;
  }
  .hero-production-unit {
    font-size: 16px;
  }
  .hero-right {
    grid-template-columns: 1fr 1fr;
    padding: 0;
  }
}

/* Last Updated Indicator */
.last-updated { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-light); }
.last-updated-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.last-updated.stale .last-updated-dot { background: var(--warning); }

/* Daily Progress Ring Hero */
.progress-hero { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; display: flex; align-items: center; gap: 24px; box-shadow: none; }
.progress-ring-container { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.progress-ring { transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.progress-ring-fill { fill: none; stroke: var(--gold); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.progress-ring-fill.complete { stroke: var(--success); }
.progress-percent { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: var(--text); }
.progress-info { flex: 1; }
.progress-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-light); margin-bottom: 6px; font-weight: 500; }
.progress-value { font-size: 32px; font-weight: 700; color: var(--text); line-height: 1.1; }
.progress-value span { font-size: 16px; font-weight: 500; color: var(--text-muted); }
.progress-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.progress-stats { display: flex; gap: 24px; margin-left: auto; }
.progress-stat { text-align: center; }
.progress-stat-value { font-size: 18px; font-weight: 600; color: var(--text); }
.progress-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); margin-top: 2px; }
@media (max-width: 768px) {
  .progress-hero { flex-direction: column; text-align: center; }
  .progress-stats { margin-left: 0; margin-top: 16px; }
}

/* Floating Action Button - Botanical Luxury */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 800; /* FAB: above dropdowns, below toasts */
}

.fab-main {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-400) 0%, var(--gold-300) 100%);
  border: none;
  color: var(--earth-900);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(228,170,79,0.4);
  transition: all 300ms var(--ease-spring);

  /* Bounce entrance animation */
  animation: fabBounceIn 500ms var(--ease-spring) 1200ms backwards;
}

.fab-main:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(228,170,79,0.5),
              var(--glow-gold-md);
}

.fab-main:active {
  transform: scale(0.95);
}

.fab-main.open {
  transform: rotate(45deg);
}

/* Settings FAB (secondary, slightly delayed) */
.fab-settings .fab-main {
  width: 48px;
  height: 48px;
  background: var(--green-500);
  box-shadow: 0 4px 16px rgba(102, 137, 113, 0.4);
  animation-delay: 1350ms;
}

.fab-settings .fab-main:hover {
  box-shadow: 0 6px 24px rgba(102, 137, 113, 0.5),
              var(--glow-green-md);
}

/* Mobile safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .fab {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
.fab-menu { position: absolute; bottom: 64px; right: 0; display: flex; flex-direction: column; gap: 10px; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s; }
.fab-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.fab-item { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.fab-item-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.1); transition: all 0.2s; }
.fab-item-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }
.fab-item-label { background: var(--bg-card); padding: 6px 10px; border-radius: 6px; font-size: 11px; font-weight: 500; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid var(--border-light); }

/* Empty State */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; color: var(--text-light); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state-text { font-size: 13px; }

/* Date Picker */
.date-picker-wrapper { position: relative; }
.date-picker-trigger { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.7); padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 6px; min-width: 130px; transition: all 0.15s ease; }
.date-picker-trigger:hover { background: rgba(255, 255, 255, 0.08); }
/* Light mode date picker trigger — see Light Theme section */
.date-picker-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-card); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); padding: 14px; min-width: 280px; max-width: calc(100vw - 32px); z-index: 100; /* Dropdown: dropdowns range */ display: none; border: 1px solid var(--border-light); }
.date-picker-dropdown.open { display: block; }
.date-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.date-chip { padding: 5px 10px; border-radius: 16px; font-size: 11px; font-weight: 500; background: var(--bg); border: 1px solid var(--border-light); color: var(--text-muted); cursor: pointer; transition: all 0.2s; }
.date-chip:hover { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.date-chip.active { background: var(--green); color: #fff; border-color: var(--green); }
.date-custom { border-top: 1px solid var(--border-light); padding-top: 12px; }
.date-custom-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); margin-bottom: 6px; font-weight: 500; }
.date-inputs { display: flex; gap: 6px; align-items: center; }
.date-input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; font-size: 12px; font-family: inherit; }
.date-input:focus { outline: none; border-color: var(--green); }
.date-apply-btn { padding: 8px 14px; background: var(--green); color: #fff; border: none; border-radius: 6px; font-weight: 600; font-size: 12px; cursor: pointer; margin-top: 10px; width: 100%; }

/* Compare Dropdown */
.compare-selector { position: relative; }
.compare-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-card); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); padding: 6px; min-width: 180px; max-width: calc(100vw - 32px); z-index: 100; /* Dropdown: dropdowns range */ display: none; border: 1px solid var(--border-light); }
.compare-dropdown.open { display: block; }
.compare-option { padding: 8px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text); }
.compare-option:hover { background: var(--bg); }

/* Dashboard Content */
.dashboard {
  padding: 16px 20px;
  flex: 1;
  min-width: 0; /* Allow flex item to shrink below content size */
  display: none;
  max-width: 100%; /* Prevent horizontal expansion */
  overflow-x: hidden; /* Clip horizontal overflow */
}
.dashboard.active { display: block; }

/* Compare Banner — Pass 2 */
.compare-banner { background: rgba(102, 137, 113, 0.08); border: 1px solid rgba(102, 137, 113, 0.15); border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; display: none; align-items: center; justify-content: space-between; color: var(--text); }
.compare-banner.active { display: flex; }
.compare-banner-left { display: flex; align-items: center; gap: 12px; }
.compare-badge { background: rgba(102, 137, 113, 0.15); padding: 3px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ro-green); }
.compare-periods { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.compare-dot { width: 6px; height: 6px; border-radius: 50%; }
.compare-dot.current { background: var(--ro-gold); }
.compare-dot.previous { background: rgba(255,255,255,0.3); }
.compare-close { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(102, 137, 113, 0.1); color: var(--text-muted); width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: all 0.15s ease; }
.compare-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-display { background: transparent; border: none; border-radius: 0; padding: 4px 0; font-family: var(--font-ui); font-size: 11px; color: rgba(255, 255, 255, 0.35); }
.date-display strong { color: rgba(255, 255, 255, 0.5); font-family: var(--font-mono); font-weight: 500; }
.toolbar-right { display: flex; gap: 6px; }
.tool-btn { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(102, 137, 113, 0.12); color: var(--text-muted); padding: 6px 10px; border-radius: 6px; font-size: 11px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 5px; transition: all 0.15s ease; }
.tool-btn:hover { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.tool-btn.active { background: var(--green); color: #fff; border-color: var(--green); }

/* ===== SECTION NUMBERING — Pass 5: Editorial ===== */
.section-number {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 0.06em;
  margin: 24px 24px 12px;
}

/* Light mode section numbering */
:root[data-theme="light"] .section-number {
  color: rgba(45, 58, 46, 0.25);
}

/* KPI Row */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; margin-bottom: 20px; }
/* Override grid when Muuri is active - Muuri uses absolute positioning */
.kpi-row.muuri { display: block; position: relative; }

/* KPI Grid Item - Muuri wrapper for positioning */
.kpi-grid-item {
  position: absolute; /* Required for Muuri to position items */
  width: 175px;
  min-width: 140px;
  max-width: 100%;
  padding: 3px; /* Half of gap for proper spacing */
}
.kpi-grid-item[data-hidden="true"] { display: none; }

.kpi-card {
  background: rgba(26, 30, 27, 0.6);
  border: 1px solid rgba(102, 137, 113, 0.12);
  border-radius: 8px;
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
}
.kpi-card:hover { box-shadow: none; border-color: rgba(102, 137, 113, 0.3); transform: translateY(-2px); }
.kpi-card:active { transform: scale(0.98); }
.kpi-card.muuri-item-dragging { transition: none !important; }
.kpi-card.muuri-item-releasing { transition: none !important; }
/* ===== KPI VISUAL HIERARCHY — Pass 5: Primary KPIs ===== */
.kpi-grid-item[data-kpi="totalTops"],
.kpi-grid-item[data-kpi="avgRate"] {
  width: 220px;
}

.kpi-grid-item[data-kpi="totalTops"] .kpi-card,
.kpi-grid-item[data-kpi="avgRate"] .kpi-card {
  border-left: 2px solid var(--ro-green);
}

.kpi-grid-item[data-kpi="totalTops"] .kpi-value,
.kpi-grid-item[data-kpi="avgRate"] .kpi-value {
  font-size: 32px;
}

/* No colored top-edge accents on KPI cards */
.kpi-card::before { display: none; }
.kpi-card.gold::before { display: none; }
.kpi-card.green::before { display: none; }
.kpi-card.sungrown::before { display: none; }
.kpi-card.greenhouse::before { display: none; }
.kpi-card.indoor::before { display: none; }
.kpi-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.kpi-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: opacity 0.2s ease; }
.kpi-card:hover .kpi-icon { opacity: 1; }
.kpi-card.gold .kpi-icon { color: var(--gold); }
.kpi-card.green .kpi-icon { color: var(--green); }
.kpi-card.sungrown .kpi-icon { color: var(--sungrown); }
.kpi-card.greenhouse .kpi-icon { color: var(--greenhouse); }
.kpi-card.indoor .kpi-icon { color: var(--indoor); }
.kpi-delta { padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; display: none; }
.kpi-delta.up { background: rgba(102,137,113,0.15); color: var(--green); }
.kpi-delta.down { background: rgba(196,92,74,0.15); color: var(--danger); }
.kpi-delta.neutral { background: rgba(255,255,255,0.04); color: var(--text-light); }
.compare-mode .kpi-delta { display: inline-block; }
.kpi-label { font-family: var(--font-ui); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.35); margin-bottom: 4px; font-weight: 500; }
.kpi-values { display: flex; align-items: baseline; gap: 6px; }
/* KPI Values — Mono data numbers */
.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-emphasis);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

/* Gold highlight for important KPIs */
.kpi-card.gold .kpi-value {
  color: var(--ro-gold);
}

/* Smaller KPI values */
.kpi-card.small .kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
}
.kpi-value-compare { font-size: 12px; font-weight: 500; color: var(--text-light); display: none; }
.compare-mode .kpi-value-compare { display: inline; }
.kpi-unit { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.kpi-sub { font-size: 11px; color: var(--text-light); margin-top: 6px; }

/* ========================================
   KPI CLICK-TO-EXPAND
   ======================================== */
.kpi-expanded-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-spring), opacity 0.3s;
  opacity: 0;
  margin-top: 0;
}
.kpi-card.expanded .kpi-expanded-content {
  max-height: 300px;
  opacity: 1;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.kpi-card.expanded {
  grid-column: span 2;
  cursor: pointer;
}
.kpi-expanded-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 12px;
}
.kpi-expanded-label {
  color: var(--text-light);
  font-weight: 500;
}
.kpi-expanded-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}
.kpi-expanded-sparkline {
  height: 40px;
  margin: 10px 0;
  position: relative;
}
.kpi-expanded-notes {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
  margin-top: 8px;
}
.kpi-expanded-notes:empty {
  display: none;
}

/* ========================================
   STATE-BASED VISUAL EMPHASIS
   ======================================== */
/* Ahead of target - Gold border glow */
.kpi-card.state-ahead {
  box-shadow: none;
  border-color: rgba(228, 170, 79, 0.4);
  animation: goldBorderGlow 2s ease-in-out infinite;
}
@keyframes goldBorderGlow {
  0%, 100% { border-color: rgba(228, 170, 79, 0.3); }
  50% { border-color: rgba(228, 170, 79, 0.6); }
}
/* Behind rolling average - Subtle desaturation */
.kpi-card.state-behind {
  filter: saturate(0.6);
  opacity: 0.85;
}
/* Ahead state overrides hover */
.kpi-card.state-ahead:hover {
  box-shadow: none;
  border-color: rgba(228, 170, 79, 0.6);
}

/* ========================================
   TUTORIAL/ONBOARDING SYSTEM
   ======================================== */
/* Tutorial overlay - blocks interaction except on highlighted elements */
body.tutorial-active::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 300; /* Modal: overlay layer */
  animation: tutorialFadeIn 0.4s ease;
  pointer-events: all; /* Block clicks on overlay */
}
@keyframes tutorialFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
/* Highlighted element - spotlight effect with dramatic pulsing */
.tutorial-highlight {
  position: relative;
  z-index: 310 !important; /* Modal: highlight layer */
  box-shadow: 0 0 0 4px var(--gold),
              0 0 40px rgba(228, 170, 79, 0.8),
              0 0 80px rgba(228, 170, 79, 0.4) !important;
  animation: tutorialPulse 1.2s ease-in-out infinite;
  border-radius: 12px;
  pointer-events: all !important; /* Allow clicks on highlighted elements */
  cursor: pointer !important;
}
/* Allow child elements of highlighted elements to be clickable */
.tutorial-highlight * {
  pointer-events: all !important;
}
@keyframes tutorialPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px var(--gold),
                0 0 40px rgba(228, 170, 79, 0.8),
                0 0 80px rgba(228, 170, 79, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px var(--gold),
                0 0 60px rgba(228, 170, 79, 1),
                0 0 120px rgba(228, 170, 79, 0.6);
    transform: scale(1.02);
  }
}
/* Tutorial tooltip */
.tutorial-tooltip {
  position: fixed;
  max-width: 360px;
  background: var(--bg-card);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 320; /* Modal: tooltip layer */
  animation: tutorialSlideIn 0.3s var(--ease-spring);
}
@keyframes tutorialSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.tutorial-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
/* Widget help icon (lightbulb) */
.widget-help {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  opacity: 0.6;
}
.widget-help:hover {
  opacity: 1;
  color: var(--gold);
  background: var(--gold-dim);
}
/* Welcome Modal */
.welcome-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 350; /* Modal: welcome overlay */
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
.welcome-modal-overlay.active {
  display: flex;
}
.welcome-modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.4s var(--ease-spring);
  border: 2px solid var(--gold);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.welcome-modal-icon {
  width: 64px;
  height: 64px;
  background: var(--gold-dim);
  color: var(--gold);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 20px;
  animation: iconBounce 0.6s var(--ease-spring) 0.2s;
}
@keyframes iconBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.welcome-modal-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 12px;
  font-family: var(--font-display);
}
.welcome-modal-content {
  font-size: 15px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 24px;
}
.welcome-modal-actions {
  display: flex;
  gap: 12px;
}
.welcome-modal-btn {
  flex: 1;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font-ui);
}
.welcome-modal-btn-primary {
  background: var(--gold);
  color: #1a1f16;
}
.welcome-modal-btn-primary:hover {
  background: var(--gold-400);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(228, 170, 79, 0.3);
}
.welcome-modal-btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.welcome-modal-btn-secondary:hover {
  background: var(--border-light);
}

/* ========================================
   MUURI WIDGET SYSTEM
   ======================================== */
/* Widget Item - Muuri Container */
.widget-item {
  position: absolute;
  width: calc(33.333% - 8px); /* 3-column default */
  margin: 4px;
  z-index: 1;
  transition: all var(--transition-normal);
  
}

/* Widget Size Classes - 12 Column Grid System (uses data-size attribute) */
.widget-item[data-size="small"] { width: calc(25% - 8px); }      /* 3 cols = 1/4 */
.widget-item[data-size="medium"] { width: calc(33.333% - 8px); } /* 4 cols = 1/3 */
.widget-item[data-size="large"] { width: calc(50% - 8px); }      /* 6 cols = 1/2 */
.widget-item[data-size="xl"] { width: calc(66.666% - 8px); }     /* 8 cols = 2/3 */
.widget-item[data-size="full"] { width: calc(100% - 8px); }      /* 12 cols = Full */

/* Responsive Widget Sizes */
@media (max-width: 1400px) {
  .widget-item[data-size="small"] { width: calc(33.333% - 8px); }  /* 4 cols */
  .widget-item[data-size="medium"] { width: calc(50% - 8px); }     /* 6 cols */
  .widget-item[data-size="large"] { width: calc(50% - 8px); }      /* 6 cols */
  .widget-item[data-size="xl"] { width: calc(100% - 8px); }        /* 12 cols */
}

@media (max-width: 1000px) {
  .widget-item[data-size="small"],
  .widget-item[data-size="medium"] { width: calc(50% - 8px); }     /* 6 cols */
  .widget-item[data-size="large"] { width: calc(50% - 8px); }      /* 6 cols */
  .widget-item[data-size="xl"],
  .widget-item[data-size="full"] { width: calc(100% - 8px); }      /* 12 cols */
}


/* Muuri Drag States */
.widget-item.muuri-item-dragging {
  z-index: 50; /* Widget drag: above base, below dropdowns */
  box-shadow: var(--shadow-dramatic-hover, 0 20px 60px rgba(0,0,0,0.3));
  transform: scale(1.05);
  cursor: grabbing;
  opacity: 0.9;
}

.widget-item.muuri-item-releasing {
  z-index: 50; /* Widget release: same as dragging */
}

.widget-item.muuri-item-hidden {
  z-index: 0;
  opacity: 0;
  pointer-events: none;
}

/* Dragging placeholder - shows where item will land */
.widget-item.muuri-item-placeholder {
  z-index: 2;
  opacity: 0;
}

/* Pop-in Animation */
@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive Widget Sizes */
@media (max-width: 1200px) {
  .widget-item[data-size="small"],
  .widget-item[data-size="medium"] { width: calc(50% - 8px); }
  .widget-item[data-size="large"] { width: calc(50% - 8px); }
  .widget-item[data-size="xl"] { width: calc(100% - 8px); }
}

@media (max-width: 768px) {
  .widget-item,
  .widget-item[data-size="small"],
  .widget-item[data-size="medium"],
  .widget-item[data-size="large"],
  .widget-item[data-size="xl"],
  .widget-item[data-size="full"] {
    width: calc(100% - 16px) !important;
    margin: 8px !important;
    min-width: unset !important;
  }
}

/* Widget Cards — Pass 2: Unified Treatment */
.widget-card {
  background: rgba(26, 30, 27, 0.85);
  border: 1px solid rgba(102, 137, 113, 0.15);
  border-radius: 8px;
  padding: 20px;
  box-shadow: none;
  margin-bottom: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.2s ease;
}

/* Widget Error State - Bottom Accent Strip */
.widget-item.error-state .widget-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--warning);
  animation: errorPulse 2s ease-in-out infinite;
  cursor: pointer;
}

@keyframes errorPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.widget-item.error-state .widget-card {
  cursor: pointer;
}

.widget-item.error-state .widget-card:hover::after {
  height: 4px;
  animation: none;
  opacity: 1;
}

/* Widget card texture removed — using topo background only */

:root[data-theme="dark"] .widget-card {
  background: rgba(26, 30, 27, 0.85);
  backdrop-filter: blur(8px);
  box-shadow: none;
}

.widget-card:hover {
  transform: translateY(-2px);
  box-shadow: none;
  border-color: rgba(102, 137, 113, 0.3);
}

.widget-card:active {
  transform: scale(0.98);
}

:root[data-theme="dark"] .widget-card:hover {
  box-shadow: none;
  border-color: rgba(102, 137, 113, 0.3);
}

.widget-card .widget-content {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.widget-card.collapsed .widget-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.widget-card[data-hidden="true"] { display: none; }

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(102, 137, 113, 0.1);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.widget-header:active,
.muuri-item-dragging .widget-header {
  cursor: grabbing;
}

.widget-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
}

.widget-title::before {
  content: '/ ';
  color: rgba(255, 255, 255, 0.15);
  font-style: normal;
}

.widget-subtitle { font-size: 10px; color: var(--text-light); margin-top: 2px; }

/* Widget Action Buttons */
.widget-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.widget-card:hover .widget-actions {
  opacity: 1;
}

.widget-collapse,
.widget-hide,
.widget-help,
.widget-resize,
.widget-drag-handle {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s ease;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.widget-collapse svg,
.widget-hide svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.widget-collapse:hover,
.widget-help:hover,
.widget-resize:hover,
.widget-drag-handle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  transform: none;
}

.widget-hide:hover {
  color: var(--danger);
  background: rgba(196, 92, 74, 0.12);
  transform: none;
}

/* Widget Corner Resize Handle */
.widget-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
}

.widget-card:hover .widget-resize-handle {
  opacity: 1;
}

.widget-resize-handle::before,
.widget-resize-handle::after {
  content: '';
  position: absolute;
  background: var(--text-muted);
  border-radius: 1px;
}

.widget-resize-handle::before {
  bottom: 8px;
  right: 2px;
  width: 2px;
  height: 8px;
  transform: rotate(45deg);
}

.widget-resize-handle::after {
  bottom: 2px;
  right: 8px;
  width: 8px;
  height: 2px;
  transform: rotate(45deg);
}

.widget-card {
  position: relative; /* Needed for absolute positioned resize handle */
}

.widget-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 9px; color: var(--text-muted); }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; }
.legend-line { width: 12px; height: 2px; border-radius: 2px; }

/* ========================================
   ANIMATED TIMELINE WIDGET
   ======================================== */
.timeline-dot {
  transition: all 0.3s var(--spring);
  cursor: pointer;
}

.timeline-dot.past {
  fill: var(--green);
  opacity: 0.9;
}

.timeline-dot.current {
  fill: var(--gold);
  animation: pulseDot 2s ease-in-out infinite;
}

.timeline-dot.future {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1;
  opacity: 0.5;
}

.timeline-dot:hover {
  transform: scale(1.3);
  opacity: 1;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* Current Production Card — Premium Data Display */
.current-card {
  background: rgba(26, 30, 27, 0.85);
  border: 1px solid rgba(102, 137, 113, 0.15);
  border-bottom: 2px solid rgba(102, 137, 113, 0.4);
  border-radius: 8px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  color: var(--text);
  box-shadow: none;
}
.current-card[data-hidden="true"] { display: none; }
.current-card::before { display: none; }
.current-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid rgba(102, 137, 113, 0.1); position: relative; }
.current-strain { font-family: var(--font-display); font-style: italic; font-size: 18px; font-weight: 400; color: var(--ro-green); }
.current-time { font-family: var(--font-mono); font-size: 11px; color: rgba(255, 255, 255, 0.35); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.status-badge { padding: 4px 10px; border-radius: 4px; font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.status-badge.in-progress { background: rgba(228, 170, 79, 0.15); color: var(--ro-gold); border: 1px solid rgba(228, 170, 79, 0.3); }
.status-badge.completed { background: rgba(102, 137, 113, 0.15); color: var(--ro-green); border: 1px solid rgba(102, 137, 113, 0.3); }
.status-badge.idle { background: rgba(255, 255, 255, 0.04); color: rgba(255, 255, 255, 0.5); border: 1px solid rgba(255, 255, 255, 0.08); }
.status-badge.historical { background: rgba(98, 117, 141, 0.15); color: var(--info); border: 1px solid rgba(98, 117, 141, 0.3); }
.current-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; position: relative; }
.current-stat { text-align: center; }
.current-stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--text); }
.current-stat-value.highlight { color: var(--ro-green); }
.current-stat-label { font-family: var(--font-ui); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.35); margin-top: 4px; }

/* Light mode: current-card — see Light Theme section */

/* Charts — Clean Containers */
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 14px; box-shadow: none; }
.chart-card[data-hidden="true"] { display: none; }
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.chart-title { font-family: var(--font-display); font-style: italic; font-size: 18px; font-weight: 400; color: var(--text); letter-spacing: -0.01em; }
.chart-subtitle { font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chart-container { position: relative; height: 180px; }
.chart-container canvas { background: transparent; }

/* Widgets Container (main sortable grid) */
/* Muuri Grid Container - Structured Grid Layout */
.widgets-container {
  position: relative;
  width: 100%; /* Constrain to viewport width */
  max-width: 100%; /* Prevent expansion beyond parent */
  overflow: hidden; /* Clip overflow content */
  margin-top: 16px;
  min-height: 400px;
  padding: 4px;
}

/* Fallback: Flexbox layout when Muuri is not active */
/* Body gets .muuri-active class when Muuri initializes successfully */
body:not(.muuri-active) .widgets-container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

body:not(.muuri-active) .widget-item {
  position: relative; /* Override absolute positioning */
  flex: 0 0 calc(33.333% - 8px);
  max-width: calc(33.333% - 8px);
}

body:not(.muuri-active) .widget-item[data-size="small"] { flex-basis: calc(25% - 8px); max-width: calc(25% - 8px); }
body:not(.muuri-active) .widget-item[data-size="medium"] { flex-basis: calc(33.333% - 8px); max-width: calc(33.333% - 8px); }
body:not(.muuri-active) .widget-item[data-size="large"] { flex-basis: calc(50% - 8px); max-width: calc(50% - 8px); }
body:not(.muuri-active) .widget-item[data-size="xl"] { flex-basis: calc(66.666% - 8px); max-width: calc(66.666% - 8px); }
body:not(.muuri-active) .widget-item[data-size="full"] { flex-basis: calc(100% - 8px); max-width: calc(100% - 8px); }

@media (max-width: 768px) {
  body:not(.muuri-active) .widget-item,
  body:not(.muuri-active) .widget-item[data-size="small"],
  body:not(.muuri-active) .widget-item[data-size="medium"],
  body:not(.muuri-active) .widget-item[data-size="large"],
  body:not(.muuri-active) .widget-item[data-size="xl"],
  body:not(.muuri-active) .widget-item[data-size="full"] {
    flex-basis: 100%;
    max-width: 100%;
  }
}

/* Sparkline Widgets — Pass 2 */
.sparkline-metrics { display: flex; gap: 20px; margin-bottom: 12px; }
.sparkline-metric { text-align: center; }
.sparkline-metric-value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }
.sparkline-metric-value.current { color: var(--green); }
.sparkline-metric-value.best { color: var(--gold); }
.sparkline-metric-value.avg { color: var(--indoor); }
.sparkline-metric-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 4px; }
.sparkline-bars { display: flex; align-items: flex-end; gap: 2px; height: 60px; padding: 6px; background: transparent; border: 1px solid rgba(102, 137, 113, 0.08); border-radius: 8px; }
.spark-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 3px; transition: all 0.3s; background: var(--ro-green); }
.spark-bar.good { background: var(--ro-green); }
.spark-bar.avg { background: var(--ro-green); opacity: 0.6; }
.spark-bar.below { background: var(--danger); opacity: 0.7; }
.spark-bar.best { background: var(--ro-green); filter: brightness(1.2); box-shadow: none; }
.strain-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.strain-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(102, 137, 113, 0.06); border-radius: 6px; }
.strain-name { font-family: var(--font-ui); font-size: 12px; font-weight: 500; max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strain-stats { display: flex; gap: 8px; }
.strain-tops { font-family: var(--font-mono); font-size: 12px; color: var(--ro-green); font-weight: 600; }
.strain-smalls { font-family: var(--font-mono); font-size: 12px; color: var(--sungrown); font-weight: 600; }

/* Performance Tables — Pass 2 */
.perf-table { display: flex; flex-direction: column; gap: 4px; }
.perf-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(102, 137, 113, 0.06); border-radius: 6px; }
.perf-row:nth-child(even) { background: rgba(255, 255, 255, 0.04); }
.perf-label { font-family: var(--font-ui); font-size: 11px; color: rgba(255, 255, 255, 0.4); }
.perf-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text); }
.perf-compare { display: flex; align-items: center; gap: 5px; }
.perf-prev { font-family: var(--font-mono); font-size: 10px; color: var(--text-light); display: none; }
.compare-mode .perf-prev { display: inline; }

/* Integration Cards — Pass 2 */
.integration-card[data-hidden="true"] { display: none; }
.integration-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.integration-icon { width: 36px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.integration-icon.kanban { background: rgba(102, 137, 113, 0.12); color: var(--ro-green); }
.integration-icon.scoreboard { background: rgba(228, 170, 79, 0.12); color: var(--ro-gold); }
.integration-icon.sop { background: rgba(102, 137, 113, 0.12); color: var(--ro-green); }
.integration-icon.bags { background: rgba(98, 117, 141, 0.12); color: var(--info); }
.integration-icon.pool-inventory { background: rgba(102, 137, 113, 0.12); color: var(--ro-green); }
.integration-title { font-family: var(--font-display); font-style: italic; font-size: 16px; font-weight: 400; color: var(--text); letter-spacing: -0.01em; }
.integration-stats { display: flex; flex-direction: column; gap: 6px; }
.integration-stat { display: flex; justify-content: space-between; align-items: center; }
.integration-stat-label { font-family: var(--font-ui); font-size: 11px; color: rgba(255, 255, 255, 0.4); }
.integration-stat-value { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--text); }
.integration-stat-value.alert { color: var(--danger); }
.integration-stat-value.good { color: var(--green); }

/* Integration Card — Pass 5: Bottom-border accents & icon hover */
.integration-card { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease; }
.integration-card:active { transform: scale(0.98); }
.integration-card .integration-icon.kanban ~ .integration-title,
.widget-item[data-widget-id="widget-kanban"] .integration-card { border-bottom: 2px solid rgba(102, 137, 113, 0.3); }
.widget-item[data-widget-id="widget-scoreboard"] .integration-card { border-bottom: 2px solid rgba(228, 170, 79, 0.3); }
.widget-item[data-widget-id="widget-bags"] .integration-card { border-bottom: 2px solid rgba(98, 117, 141, 0.3); }
.widget-item[data-widget-id="widget-sop"] .integration-card { border-bottom: 2px solid rgba(102, 137, 113, 0.3); }
.integration-icon {
  transition: transform 0.2s var(--ease-spring);
}
.integration-card:hover .integration-icon {
  transform: scale(1.1);
}

/* Settings Panel — Pass 2 */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 400; display: none; }
.settings-overlay.open { display: block; }
.settings-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 320px; max-width: 100vw; background: #181c19; border-left: 1px solid rgba(102, 137, 113, 0.1); box-shadow: none; z-index: 410; transform: translateX(100%); transition: transform 0.3s ease; overflow-y: auto; }
.settings-panel.open { transform: translateX(0); }
.settings-header { padding: 16px; border-bottom: 1px solid rgba(102, 137, 113, 0.1); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #181c19; z-index: 1; }
.settings-title { font-family: var(--font-display); font-style: italic; font-size: 18px; font-weight: 400; color: var(--text); }
.settings-close {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transform: none;
}
.settings-section { padding: 16px; border-bottom: 1px solid rgba(102, 137, 113, 0.08); }
.settings-section-title { font-family: var(--font-display); font-style: italic; font-size: 14px; letter-spacing: 0; color: var(--text); margin-bottom: 10px; font-weight: 400; text-transform: none; }
.widget-toggle { display: flex; align-items: center; justify-content: space-between; padding: 8px; background: rgba(255, 255, 255, 0.04); border-radius: 6px; margin-bottom: 5px; }
.widget-toggle-info { display: flex; align-items: center; gap: 8px; }
.widget-toggle-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.widget-toggle-icon.gold { background: var(--gold-dim); color: var(--gold); }
.widget-toggle-icon.green { background: var(--green-dim); color: var(--green); }
.widget-toggle-icon.sungrown { background: var(--sungrown-dim); color: var(--sungrown); }
.widget-toggle-icon.greenhouse { background: var(--greenhouse-dim); color: var(--greenhouse); }
.widget-toggle-icon.indoor { background: var(--indoor-dim); color: var(--indoor); }
.widget-toggle-name { font-size: 12px; font-weight: 500; }
.toggle-switch { position: relative; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: rgba(255, 255, 255, 0.1); border-radius: 20px; transition: 0.3s; }
.toggle-slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--ro-green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }

/* Settings panel utility styles */
.settings-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.settings-desc-lg { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.settings-input-row { display: flex; align-items: center; gap: 8px; }
.settings-input-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--bg); color: var(--text); }
.settings-input-unit { color: var(--text-muted); font-size: 12px; }
.settings-btn-full { width: 100%; justify-content: center; }
.settings-btn-full.save { margin-bottom: 8px; background: var(--ro-green); color: white; }
.settings-btn-full.tour { background: var(--gold); color: var(--green-900); }
.icon-mr { margin-right: 6px; }

/* Widget header layout helpers */
.widget-header-left { display: flex; align-items: center; gap: 8px; }

/* Compare banner helpers */
.compare-period { display: flex; align-items: center; gap: 4px; }
.compare-vs { opacity: 0.5; }

/* Date inputs arrow separator */
.date-arrow { color: var(--text-light); }

/* Clickable integration cards */
.integration-card[onclick] { cursor: pointer; }

/* Strain list empty state */
.strain-list-empty { color: var(--text-light); text-align: center; padding: 16px; }

/* Skeleton grid layouts */
.skeleton-grid-3col { padding: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.skeleton-productivity { padding: 16px; }
.skeleton-productivity-row { display: flex; gap: 24px; margin-bottom: 16px; }
.skeleton-productivity-row .skeleton-number { width: 80px; }
.skeleton-chart-sm { height: 60px; }

/* ========================================
   FLOATING ACTION BUTTONS (FABs)
   ======================================== */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(102, 137, 113, 0.4);
  transition: all 0.2s var(--ease-spring);
  z-index: 1000; /* AI chat FAB */
  background: var(--ro-green);
  color: white;
  animation: bounceFAB 1.2s ease-out 1.5s;
}

.ai-chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(102, 137, 113, 0.5);
}

@keyframes bounceFAB {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ========================================
   AI CHAT PANEL
   ======================================== */
.ai-chat-panel {
  position: fixed;
  top: 0; /* Full height from top */
  right: -400px;
  bottom: 0; /* Full height to bottom */
  width: 400px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 1050; /* AI chat panel */
  display: flex;
  flex-direction: column;
  transition: right var(--transition-slow);
  max-height: 100vh; /* Constrain to viewport height */
}

.ai-chat-panel.open {
  right: 0;
}

.ai-chat-header {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0; /* Prevent header from shrinking */
  background: var(--bg-card); /* Ensure it's visible */
}

.ai-chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-glow));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ai-chat-header-text h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-display);
  margin: 0;
}

.ai-chat-header-text span {
  font-size: 13px;
  color: var(--text);
  opacity: 0.7;
  font-weight: 500;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.ai-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.ai-message.user {
  align-self: flex-end;
  background: var(--green);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message.assistant {
  align-self: flex-start;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.ai-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-sm);
}

.ai-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: aiBounce 1.4s infinite ease-in-out;
}

.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.ai-chat-input-area {
  padding: var(--space-sm);
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  flex-shrink: 0; /* Prevent input area from shrinking */
  background: var(--bg-card); /* Ensure it's visible */
}

.ai-chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.2s;
}

.ai-chat-input:focus {
  border-color: var(--gold);
}

.ai-chat-input::placeholder {
  color: var(--text-muted);
}

.ai-chat-send {
  width: 40px;
  height: 40px;
  background: var(--gold);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-send:hover {
  background: var(--gold-light);
  transform: scale(1.05);
}

.ai-chat-send:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 768px) {
  .ai-chat-panel {
    width: 100%;
    right: -100%;
  }

}

/* Iframe App View */
.app-view {
  display: none;
  flex-direction: column;
  height: var(--app-height);
  max-height: 100dvh; /* Dynamic viewport height (modern browsers) */
}

.app-view.active { display: flex; }

.app-iframe-container {
  flex: 1;
  position: relative;
  height: calc(var(--app-height) - var(--header-height));
  max-height: calc(100dvh - var(--header-height));
}

/* Fallback for browsers without dvh support */
@supports not (height: 100dvh) {
  .app-view { height: 100vh; }
  .app-iframe-container { height: calc(100vh - 52px); }
}
.app-iframe { width: 100%; height: 100%; border: none; }
.app-expand-btn { position: absolute; top: 6px; right: 6px; background: rgba(45,58,46,0.7); color: #fff; border: none; width: 28px; height: 28px; border-radius: 6px; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity 0.2s, background 0.2s; z-index: 10; display: flex; align-items: center; justify-content: center; }
.app-expand-btn:hover { background: var(--gold); }
.app-iframe-container:hover .app-expand-btn { opacity: 0.7; }
.app-iframe-container .app-expand-btn:hover { opacity: 1; }

/* Loading — Pass 2: Match topo background */
.logo-loader { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1100; gap: 20px; }
.logo-loader.hidden { opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
.logo-loader img { width: 320px; height: auto; animation: logoPulse 1.6s ease-in-out infinite; }
@keyframes logoPulse { 0%, 100% { opacity: 0.35; filter: drop-shadow(0 0 0 transparent); transform: scale(0.98); } 50% { opacity: 1; filter: drop-shadow(0 0 25px rgba(201, 166, 90, 0.5)) drop-shadow(0 0 50px rgba(201, 166, 90, 0.25)); transform: scale(1); } }
.logo-loader-bar { width: 80px; height: 2px; background: var(--ro-green); border-radius: 2px; opacity: 0.3; animation: barPulse 1.6s ease-in-out infinite; }
@keyframes barPulse { 0%, 100% { width: 80px; opacity: 0.3; } 50% { width: 130px; opacity: 0.7; } }
.spinning { animation: spin 1s linear infinite; }

/* ========================================
   SKELETON LOADING SYSTEM — Pass 9
   ======================================== */
.skeleton {
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%);
  animation: skeletonShimmer 1.5s ease infinite;
}
@keyframes skeletonShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-number { height: 32px; width: 120px; margin-bottom: 4px; }
.skeleton-chart { height: 200px; width: 100%; }
.skeleton-bar { height: 8px; border-radius: 4px; }
.skeleton-stat { height: 48px; border-radius: 8px; }
.skeleton-icon { width: 32px; height: 32px; border-radius: 8px; }

/* Light mode skeletons */
[data-theme='light'] .skeleton { background: rgba(0,0,0,0.04); }
[data-theme='light'] .skeleton::after { background: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.03) 50%, transparent 100%); }

/* KPI card loading state */
.kpi-card.loading .kpi-value, .kpi-card.loading .kpi-label, .kpi-card.loading .kpi-sub,
.kpi-card.loading .kpi-delta, .kpi-card.loading .kpi-value-compare { display: none; }
.kpi-card.loading .skeleton-content { display: block; }
.kpi-card .skeleton-content { display: none; }

/* Widget card loading state */
.widget-card .skeleton-placeholder { display: none; }
.widget-item.loading .skeleton-placeholder { display: block; }
.widget-item.loading .widget-content { display: none; }
.widget-item.loading .widget-header { opacity: 0.5; }

/* Loaded transition */
.widget-item .widget-content { transition: opacity 0.3s ease; }
.widget-item.loaded .widget-content { opacity: 1; }
.widget-item.loaded .skeleton-placeholder { display: none; }

/* Responsive — Sidebar drawer at 768px (handled in Pass 8 section below) */
@media (max-width: 900px) {
  .current-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .header { flex-wrap: wrap; gap: 8px; }
  .settings-panel { width: 100%; }
  .header-btn { padding: 10px 14px; font-size: 12px; min-height: 44px; }
  .header-btn svg { width: 16px; height: 16px; }
  .nav-item { padding: 14px 16px; min-height: 48px; }
  .date-chip { padding: 8px 14px; min-height: 40px; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar-btn { padding: 10px 14px; min-height: 44px; }

  /* Disable Muuri positioning on mobile - use fixed CSS grid instead */
  .kpi-card {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* Reduce text sizes slightly to fit better */
  .kpi-value { font-size: 40px; }
  .kpi-card.small .kpi-value { font-size: 24px; }
  .kpi-label { font-size: 10px; }
  .kpi-unit { font-size: 13px; }

  /* Current stats responsive - 2 columns on mobile */
  .current-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
@media (max-width: 400px) {
  .kpi-row { grid-template-columns: 1fr; }
  .header-right { width: 100%; justify-content: flex-end; }
  .welcome { font-size: 18px; }
}

.mobile-menu-btn { display: none; background: none; border: none; color: rgba(255, 255, 255, 0.7); cursor: pointer; padding: 8px; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
/* Light mode mobile-menu-btn — see Light Theme section */

/* Edit/Rearrange Mode */
.edit-mode .draggable-widget,
.edit-mode .kpi-card { cursor: grab; animation: wiggle 0.3s ease-in-out infinite; outline: 2px dashed var(--gold); outline-offset: 2px; }
.edit-mode .draggable-widget:active,
.edit-mode .kpi-card:active { cursor: grabbing; animation: none; }
.edit-mode [data-hidden="true"] { display: none !important; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 8px 25px rgba(228,170,79,0.4); transform: scale(1.02); z-index: 50; /* Sortable: above base, below dropdowns */ animation: none !important; }
.sortable-drag { opacity: 0.9; }
@keyframes wiggle { 0%, 100% { transform: rotate(-0.3deg); } 50% { transform: rotate(0.3deg); } }

/* Draggable widget wrapper */
.draggable-widget { transition: box-shadow 0.2s, transform 0.2s; }


/* Toast notifications */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 950; /* Toast/notification range */ display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-weight: 500; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: toastSlideIn 0.3s ease; max-width: 360px; display: flex; align-items: center; gap: 10px; }
.toast.error { background: var(--danger, #c45c4a); }
.toast.success { background: var(--success, #668971); }
.toast.warning { background: var(--warning, #e4aa4f); color: #1a1f16; }
.toast.info { background: var(--green, #668971); }
.toast.hiding { animation: toastSlideOut 0.3s ease forwards; }
@keyframes toastSlideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastSlideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }


/* ===== MOBILE ENHANCEMENTS ===== */
/* Ensure 44px minimum touch targets per MOBILE_DESIGN.md specifications */

@media (max-width: 768px) {
  /* Widget action buttons - increase touch target size */
  .widget-resize,
  .widget-collapse,
  .widget-hide {
    padding: 12px;
    font-size: 16px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* FAB menu items */
  .fab-item-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  /* Compare close button */
  .compare-close {
    width: 44px;
    height: 44px;
    font-size: 14px;
  }

  /* Tool buttons */
  .tool-btn {
    padding: 12px 14px;
    min-height: 44px;
    font-size: 12px;
  }

  /* Date apply button */
  .date-apply-btn {
    padding: 12px 16px;
    min-height: 44px;
    font-size: 13px;
  }

  /* Responsive typography scaling */
  :root {
    --text-hero: 64px;
    --text-display: 40px;
    --text-display-sm: 32px;
    --text-h1: 28px;
    --text-h2: 24px;
    --text-h3: 20px;
  }

  /* Increased tap spacing for mobile */
  .widget-actions {
    gap: 8px;
  }

  .toolbar-right {
    gap: 10px;
  }

  /* Ensure adequate spacing between interactive elements */
  .kpi-row {
    gap: 16px;
  }

  .widget-grid {
    gap: 16px;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  /* Further scale down hero text */
  :root {
    --text-hero: 48px;
    --text-display: 32px;
  }

  /* Full-width panels on very small screens */
  .ai-chat-panel,
  .settings-panel {
    width: 100%;
  }
}

/* ========================================
   RESPONSIVE FIXES - STRAIN LIST & MOBILE
   ======================================== */

/* 768px breakpoint - tablets */
@media (max-width: 768px) {
  /* KPI grid items responsive for tablets */
  .kpi-row.muuri .kpi-grid-item {
    width: calc(50% - 6px);
    min-width: 140px;
  }

  /* Strain list - tablet size */
  .strain-list {
    max-height: 180px;
  }
}

/* 600px breakpoint - mobile: KPI cards in Muuri grid stack to single column */
@media (max-width: 600px) {
  .kpi-row.muuri .kpi-grid-item {
    width: calc(100% - 6px) !important;
    min-width: unset !important;
  }
}

/* 600px breakpoint - medium mobile */
@media (max-width: 600px) {
  /* Strain list - medium mobile */
  .strain-list {
    max-height: 200px;
  }

  /* Settings panel responsive padding */
  .settings-section {
    padding: 12px;
  }
}

/* 480px breakpoint - small mobile additions */
@media (max-width: 480px) {
  /* Sidebar adjustments */
  .sidebar {
    width: 100%;
  }

  /* Hero section - compact for small phones */
  .hero-section {
    padding: 8px;
    gap: 8px;
  }

  .hero-botanical-frame {
    padding: 16px 12px;
  }

  .hero-production-number {
    font-size: 40px;
  }

  .hero-production-unit {
    font-size: 14px;
  }

  /* KPI cards - ensure single column */
  /* KPI grid items - static positioning on very small screens */
  .kpi-grid-item {
    position: static !important;
    width: 100% !important;
    margin-bottom: 12px !important;
  }

  /* KPI grid items responsive width on very small screens */
  .kpi-row.muuri .kpi-grid-item {
    width: calc(100% - 6px) !important;
    min-width: unset !important;
  }

  /* Current production stats - single column on tiny screens */
  .current-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* FAB positioning for small screens */
  .fab {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  /* Responsive strain list - more space on mobile */
  .strain-list {
    max-height: 240px;
  }

  /* Dropdown positioning fixes for small screens */
  .date-picker-dropdown,
  .compare-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Progress hero - even more compact */
  .progress-ring-container {
    width: 80px;
    height: 80px;
  }

  .progress-value {
    font-size: 24px;
  }
}

/* ========================================
   LANDSCAPE ORIENTATION OPTIMIZATIONS
   ======================================== */
@media (max-height: 600px) and (orientation: landscape) {
  /* Sidebar collapses in landscape on small heights */
  .sidebar {
    transform: translateX(-100%);
  }

  .main {
    margin-left: 0;
  }

  /* KPI cards use horizontal layout */
  .kpi-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  /* Compact hero section */
  .hero-section {
    padding: 12px 20px;
  }

  /* Smaller progress ring */
  .progress-ring-container {
    width: 100px;
    height: 100px;
  }
}

/* ========================================
   PWA INSTALL PROMPT
   ======================================== */
.install-prompt {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: 24px;
  background: var(--ro-gold);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(228, 170, 79, 0.3);
  cursor: pointer;
  z-index: 999;
  display: none;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  animation: slideInRight 0.5s ease-out;
}

.install-prompt.show {
  display: flex;
}

.install-prompt:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(228, 170, 79, 0.4);
}

.install-prompt:active {
  transform: translateY(0);
}

.install-prompt.ios {
  flex-direction: row-reverse;
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Install modal (iOS instructions) */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.install-modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-elevated);
  animation: fadeInUp 0.3s ease-out;
}

.install-modal-content h2 {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.install-modal-content p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  font-size: 15px;
}

.install-modal-content ol {
  margin-left: 20px;
  margin-bottom: var(--space-lg);
  color: var(--text);
}

.install-modal-content li {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.6;
}

.install-modal-content button {
  width: 100%;
  padding: 14px;
  background: var(--ro-green);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.install-modal-content button:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Install success message */
.install-success {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-elevated);
  z-index: 10001;
  text-align: center;
  animation: fadeInUp 0.3s ease-out;
}

.install-success.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

.install-success-content h3 {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text);
  margin: 12px 0 8px;
}

.install-success-content p {
  color: var(--text-secondary);
  font-size: 14px;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .install-prompt {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: 20px;
    font-size: 13px;
    padding: 12px 20px;
  }
}

@media (max-width: 480px) {
  .install-prompt {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    justify-content: center;
  }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS (WCAG AA)
   Phase 5.1 - Added comprehensive accessibility features
   ======================================== */

/* Skip link for keyboard users (visually hidden until focused) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ro-green, #668971);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--gold, #e4aa4f);
  outline-offset: 2px;
}

/* Comprehensive focus indicators for keyboard navigation */
.nav-item:focus,
.tool-btn:focus,
.date-chip:focus,
.compare-option:focus,
.header-btn:focus,
.theme-toggle:focus,
.mobile-menu-btn:focus,
.sidebar-toggle:focus,
.date-picker-trigger:focus,
.date-apply-btn:focus,
.widget-help:focus,
.widget-collapse:focus,
.widget-hide:focus,
.widget-resize:focus,
.widget-drag-handle:focus,
.settings-close:focus,
.fab:focus,
.kpi-card:focus,
.modal-close:focus,
.install-prompt button:focus,
.install-modal-content button:focus {
  outline: 2px solid var(--ro-green, #668971);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(102, 137, 113, 0.2);
}

/* Focus-visible for modern browsers (no outline for mouse clicks) */
button:focus-visible,
[role="button"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="tab"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ro-green, #668971);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(102, 137, 113, 0.2);
}

/* Enhanced focus for form inputs */
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  border-color: var(--ro-green, #668971);
  outline: 2px solid var(--ro-green, #668971);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(102, 137, 113, 0.15);
}

/* Dark mode focus — handled in Dark Theme section */

/* High contrast mode support */
@media (prefers-contrast: high) {
  .nav-item:focus,
  button:focus,
  a:focus,
  input:focus {
    outline: 3px solid currentColor;
    outline-offset: 3px;
  }

  .skip-link:focus {
    outline: 4px solid yellow;
  }
}

/* Keyboard navigation visual feedback */
[role="button"][tabindex="0"]:focus,
[onclick][tabindex="0"]:focus {
  outline: 2px solid var(--ro-green, #668971);
  outline-offset: 2px;
  background-color: rgba(102, 137, 113, 0.08);
}

/* Remove focus outline when using mouse (prevents double outline) */
button:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* Ensure disabled elements are clearly marked */
[disabled],
[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.5;
  filter: grayscale(0.4);
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Enhanced color contrast for text (WCAG AA compliance) */
/* Ensure minimum 4.5:1 contrast ratio for normal text */
.text-muted,
.text-light {
  /* Dark mode inherits better contrast from shared-base.css */
  color: var(--text-muted);
  /* Minimum contrast enforced by CSS variable values */
}

/* Improve contrast for small text */
.text-xs,
.text-sm,
small {
  /* Enforce darker color for better readability of small text */
  color: var(--text-secondary);
  font-weight: 400;
}

/* Enhanced link contrast */
a {
  color: var(--ro-green, #668971);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--green-dark, #4a6b54);
  text-decoration-thickness: 2px;
}

:root[data-theme="dark"] a {
  color: var(--green-light, #7a9d86);
}

:root[data-theme="dark"] a:hover {
  color: var(--ro-green, #668971);
}

/* Ensure sufficient contrast for interactive elements */
.header-btn,
.tool-btn {
  /* Background and border contrast checked in design */
  min-height: 36px; /* Ensure touch target size */
  position: relative;
}

/* Focus trap for modals (accessibility) */
.modal-content:focus,
.settings-panel:focus {
  outline: none; /* Modal itself doesn't need outline, content inside does */
}

/* Improve table accessibility */
table {
  border-collapse: collapse;
}

th {
  font-weight: 600;
  text-align: left;
  background: var(--bg-warm);
}

/* Accessible tooltips with proper timing */
[title] {
  cursor: help;
}

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

  .skip-link {
    transition: none;
  }
}

/* Print accessibility */
@media print {
  .skip-link,
  .sidebar,
  .header-btn,
  .fab {
    display: none;
  }

  body {
    background: white;
    color: black;
  }
}

/* ========================================
   END ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* ========================================
   COMMAND PALETTE — Pass 7
   ======================================== */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}
.command-palette-overlay.open {
  display: flex;
}
.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.command-palette-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid rgba(102, 137, 113, 0.2);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: commandPaletteIn 0.15s ease-out;
}
@keyframes commandPaletteIn {
  from { opacity: 0; transform: scale(0.98) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.command-palette-input {
  width: 100%;
  height: 52px;
  padding: 0 20px;
  border: none;
  border-bottom: 1px solid rgba(102, 137, 113, 0.1);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.command-palette-input::placeholder {
  color: var(--text-light);
}
.command-palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}
.command-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s ease;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 14px;
}
.command-palette-item:hover,
.command-palette-item.active {
  background: rgba(102, 137, 113, 0.1);
  color: var(--text);
}
.command-palette-item .cp-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  flex-shrink: 0;
}
.command-palette-item.active .cp-icon,
.command-palette-item:hover .cp-icon {
  opacity: 0.8;
}
.command-palette-item .cp-label {
  flex: 1;
}
.command-palette-item .cp-shortcut {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-light);
  opacity: 0.5;
}
.command-palette-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid rgba(102, 137, 113, 0.1);
  background: rgba(102, 137, 113, 0.03);
}
.command-palette-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-light);
}
.command-palette-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  border: 1px solid rgba(102, 137, 113, 0.15);
  border-radius: 3px;
  background: rgba(102, 137, 113, 0.05);
  margin-right: 2px;
  font-family: var(--font-mono);
}

/* Command Palette — Light theme */
:root[data-theme="light"] .command-palette-box {
  background: #ffffff;
  border-color: rgba(102, 137, 113, 0.15);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}
:root[data-theme="light"] .command-palette-backdrop {
  background: rgba(0, 0, 0, 0.4);
}
:root[data-theme="light"] .command-palette-input {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .command-palette-item:hover,
:root[data-theme="light"] .command-palette-item.active {
  background: rgba(102, 137, 113, 0.08);
}

/* Focus trap indicator */
.settings-panel.open:focus-within {
  outline: none;
}

/* Focus visible — verify/enhance from pass 3 */
.command-palette-input:focus-visible {
  outline: none;
}

/* Mobile: Command palette full width */
@media (max-width: 768px) {
  .command-palette-overlay {
    padding: 12px;
    padding-top: 10vh;
  }
  .command-palette-box {
    max-width: 100%;
  }
}

/* ========================================
   PASS 9: EMPTY STATES
   ======================================== */
.empty-state-production {
  text-align: center;
  padding: 32px 16px;
}
.empty-state-production .empty-state-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.empty-state-production .empty-state-sub {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-light);
}

/* ========================================
   PASS 9: LOADING OVERLAY IMPROVEMENTS
   ======================================== */
.logo-loader {
  background: var(--bg, #141816);
}

/* Topo background on loader */
.logo-loader::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.025;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cellipse cx='300' cy='300' rx='60' ry='40' transform='rotate(-15 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='110' ry='75' transform='rotate(-12 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='165' ry='115' transform='rotate(-8 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='225' ry='160' transform='rotate(-4 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='290' ry='210' transform='rotate(0 300 300)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 600px 600px;
}
[data-theme='light'] .logo-loader::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'%3E%3Cg fill='none' stroke='%232d3a2e' stroke-width='1'%3E%3Cellipse cx='300' cy='300' rx='60' ry='40' transform='rotate(-15 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='110' ry='75' transform='rotate(-12 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='165' ry='115' transform='rotate(-8 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='225' ry='160' transform='rotate(-4 300 300)'/%3E%3Cellipse cx='300' cy='300' rx='290' ry='210' transform='rotate(0 300 300)'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.035;
}

/* Logo pulse: subtle 1→1.02 */
.logo-loader img {
  animation: logoPulseSubtle 1s ease-in-out infinite;
}
@keyframes logoPulseSubtle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Smooth progress bar */
.logo-loader-bar::after {
  transition: width 0.3s ease;
  animation: loaderSlideSmooth 1.5s ease-in-out infinite;
}
@keyframes loaderSlideSmooth {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ========================================
   PASS 9: ERROR TOAST REFINEMENT
   ======================================== */
.toast-error {
  background: rgba(20, 24, 22, 0.95) !important;
  border: 1px solid rgba(196,92,74,0.3);
  backdrop-filter: blur(8px);
}
.toast-error .toast-title { color: var(--danger); }

/* Toast with title+message structure */
.toast-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}
.toast-message {
  font-weight: 400;
  font-size: 12px;
  opacity: 0.8;
}
[data-theme='light'] .toast-error {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #2d3a2e;
}

/* ========================================
   PASS 9: PERFORMANCE — CSS HINTS
   ======================================== */
.kpi-card,
.widget-card,
.integration-card {
  will-change: transform;
  contain: layout style paint;
}

/* Remove will-change after animations settle (reduced motion) */
@media (prefers-reduced-motion: reduce) {
  .kpi-card,
  .widget-card,
  .integration-card {
    will-change: auto;
  }
}

/* ========================================
   PASS 9: SMOOTH DATA UPDATE TRANSITIONS
   ======================================== */
.stat-value, .kpi-value, .hero-production-number, .hero-mini-kpi-value,
.current-stat-value, .integration-stat-value {
  transition: opacity 0.2s ease;
}
.stat-value.updating, .kpi-value.updating, .hero-production-number.updating,
.hero-mini-kpi-value.updating, .current-stat-value.updating, .integration-stat-value.updating {
  opacity: 0.5;
}

/* ========================================
   PASS 8: MOBILE RESPONSIVE
   ========================================
   Breakpoints:
   - Desktop:  > 1200px (current layout)
   - Tablet:   768px — 1200px
   - Mobile:   < 768px
   ======================================== */

/* --- Sidebar backdrop --- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.3s ease;
}
body.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* ===== TABLET: 768px — 1200px ===== */
@media (max-width: 1200px) and (min-width: 769px) {
  /* Hero */
  .hero-production-number {
    font-size: 56px;
  }
  .hero-right {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  /* KPI: 3 columns */
  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .kpi-grid-item {
    width: calc(33.333% - 6px) !important;
  }

  /* Widgets: 2 columns */
  .widget-item[data-size="small"],
  .widget-item[data-size="medium"] {
    width: calc(50% - 8px);
  }
  .widget-item[data-size="large"] {
    width: calc(50% - 8px);
  }
  .widget-item[data-size="xl"],
  .widget-item[data-size="full"] {
    width: calc(100% - 8px);
  }

  body:not(.muuri-active) .widget-item[data-size="small"],
  body:not(.muuri-active) .widget-item[data-size="medium"] {
    flex-basis: calc(50% - 8px);
    max-width: calc(50% - 8px);
  }
}

/* ===== MOBILE: < 768px ===== */
@media (max-width: 768px) {

  /* --- 1. Sidebar: slide-out drawer --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.collapsed {
    width: 260px; /* Don't collapse on mobile */
  }
  .sidebar.collapsed .brand h1,
  .sidebar.collapsed .nav-item span:not(.icon),
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .user-details,
  .sidebar.collapsed .sidebar-toggle-label {
    display: block; /* Override collapsed hide on mobile */
  }
  .sidebar.collapsed .brand { justify-content: flex-start; padding: 24px 16px; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 16px; }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Sidebar toggle (collapse/expand) hidden on mobile */
  .sidebar-toggle {
    display: none;
  }

  /* Main: no sidebar margin */
  .main {
    margin-left: 0 !important;
  }
  body.sidebar-collapsed .main {
    margin-left: 0 !important;
  }

  /* Hamburger */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
  }

  /* --- 2. Header: Mobile layout --- */
  .header {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .header-left {
    gap: 8px;
  }
  .header-logo {
    height: 28px;
  }

  /* Hide clock on mobile */
  .header-time {
    display: none;
  }

  /* Date picker & compare hidden in header on mobile */
  .date-picker-wrapper,
  .compare-selector {
    display: none;
  }

  /* Header right: only theme, settings, refresh */
  .header-right {
    gap: 6px;
  }
  .header-btn {
    padding: 8px 10px;
    font-size: 12px;
    min-height: 44px;
    min-width: 44px;
  }
  /* Hide label text on refresh btn on mobile */
  #refreshBtn {
    font-size: 0;
    padding: 8px;
  }
  #refreshBtn svg {
    width: 16px;
    height: 16px;
  }
  /* Theme toggle: icon only */
  .theme-toggle {
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
  }
  #themeLabel {
    display: none;
  }

  /* Toolbar */
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* --- 3. Welcome / Hero: Stack vertically --- */
  .welcome-greeting {
    font-size: 24px;
  }

  .hero-section {
    padding-bottom: 24px;
    margin-bottom: 24px;
  }
  .hero-botanical-frame {
    padding: 12px 16px 20px;
  }
  .hero-production-number {
    font-size: 48px;
  }
  .hero-production-unit {
    font-size: 16px;
  }
  .hero-right {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 16px;
  }
  .hero-mini-kpi {
    padding: 12px;
  }
  .hero-mini-kpi-value {
    font-size: 20px;
  }

  /* --- 4. KPI Cards: 2 columns --- */
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi-grid-item {
    width: calc(50% - 6px) !important;
    min-width: unset !important;
  }
  .kpi-card {
    padding: 12px;
    min-height: 100px;
  }
  .kpi-value {
    font-size: 24px;
  }
  .kpi-card.small .kpi-value {
    font-size: 20px;
  }
  /* Primary KPIs same width as others on mobile */
  .kpi-grid-item[data-kpi="totalTops"],
  .kpi-grid-item[data-kpi="avgRate"] {
    width: calc(50% - 6px) !important;
  }
  .kpi-grid-item[data-kpi="totalTops"] .kpi-value,
  .kpi-grid-item[data-kpi="avgRate"] .kpi-value {
    font-size: 24px;
  }

  /* --- 5. Widget Grid: single column --- */
  .widget-item,
  .widget-item[data-size="small"],
  .widget-item[data-size="medium"],
  .widget-item[data-size="large"],
  .widget-item[data-size="xl"],
  .widget-item[data-size="full"] {
    width: calc(100% - 16px) !important;
    margin: 8px !important;
  }

  /* Hide drag handles on mobile */
  .widget-drag-handle {
    display: none;
  }
  .widget-resize-handle {
    display: none;
  }
  /* Widget header: no grab cursor on mobile */
  .widget-header {
    cursor: default;
  }

  .widget-card {
    padding: 14px;
  }

  .chart-container {
    height: 160px;
  }

  /* --- 6. Integration Cards: horizontal layout --- */
  .integration-stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .integration-stat {
    flex: 1;
    min-width: 80px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
  }

  /* --- 7. Settings Panel: full screen --- */
  .settings-panel {
    width: 100%;
    max-width: 100vw;
  }
  .settings-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 24px;
  }

  /* --- 8. Command Palette: full width, touch friendly --- */
  .command-palette-overlay {
    padding: 8px;
    padding-top: 8vh;
  }
  .command-palette-box {
    max-width: 100%;
    border-radius: 12px;
  }
  .command-palette-input {
    height: 56px;
    font-size: 16px; /* Prevents iOS zoom on input focus */
    padding: 0 16px;
  }
  .command-palette-item {
    padding: 12px;
    min-height: 48px;
  }

  /* --- 9. Toast: bottom of screen, full width --- */
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
    align-items: stretch;
  }
  .toast {
    max-width: 100%;
    animation: toastSlideUp 0.3s ease;
  }


  /* --- 10. Touch Targets: 44px minimum --- */
  .nav-item {
    padding: 12px 16px;
    min-height: 44px;
  }
  .date-chip {
    padding: 8px 14px;
    min-height: 44px;
  }
  .compare-close {
    width: 44px;
    height: 44px;
  }
  .tool-btn {
    padding: 10px 14px;
    min-height: 44px;
  }
  .widget-collapse,
  .widget-hide,
  .widget-help,
  .widget-resize {
    min-width: 44px;
    min-height: 44px;
  }

  /* AI chat FAB */
  .ai-chat-fab {
    width: 52px;
    height: 52px;
    bottom: 16px;
    right: 16px;
  }

  /* AI chat panel: full width */
  .ai-chat-panel {
    width: 100%;
    right: -100%;
  }

  /* Section numbers */
  .section-number {
    margin: 16px 12px 8px;
  }

  /* Dashboard padding */
  .dashboard {
    padding: 12px;
  }

  /* Compare banner */
  .compare-banner {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }

  /* Current production stats */
  .current-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Sparkline metrics */
  .sparkline-metrics {
    gap: 12px;
    justify-content: space-between;
  }
}

/* Mobile toast slide-up animation */
@keyframes toastSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== EXTRA SMALL: < 480px ===== */
@media (max-width: 480px) {
  /* Hero: even smaller */
  .hero-production-number {
    font-size: 40px;
  }
  .hero-production-unit {
    font-size: 14px;
  }
  .welcome-greeting {
    font-size: 20px;
  }

  /* KPI: still 2 columns but tighter */
  .kpi-card {
    padding: 10px;
  }
  .kpi-value {
    font-size: 22px;
  }

  /* Current stats: 2 col */
  .current-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Full-width panels */
  .ai-chat-panel,
  .settings-panel {
    width: 100%;
  }

  /* Sidebar: full width on very small screens */
  .sidebar {
    width: 100%;
  }
  body.sidebar-open .sidebar {
    width: 100%;
  }
}

/* ===== SAFE AREA INSETS (notched phones) ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .toast-container {
      bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .ai-chat-fab {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
    .ai-chat-input-area {
      padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}

/* ========================================
   END PASS 8: MOBILE RESPONSIVE
   ======================================== */

/* Widget entrance — opacity only (transform conflicts with Muuri positioning) */
.widget-item {
  animation: widgetFadeIn 0.3s ease both;
}
@keyframes widgetFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
