/* ===============================================================
   CommuteLens Editorial Design System
   Single source of truth for global styling.
   Derived from the Analysis Dashboard look:
     - White surfaces, soft gray canvas (#f8f9fb)
     - Inter typography, deep editorial text (#1A242F)
     - Deep green accent (#2D6A4F), gold divider (#B59A5D)
     - 12px-radius cards, 1px hairline borders, subtle shadows
   =============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    /* ----- Single-source-of-truth colour channels -----
       Each colour is defined ONCE as an "R, G, B" triple. The
       solid hex-equivalent and any tinted rgba() variant both
       resolve from the same triple, so editing one token here
       instantly re-skins every solid + tinted usage app-wide. */

    /* Brand */
    --accent-primary-rgb: 45, 106, 79;     /* deep editorial green */
    --accent-primary-hover-rgb: 36, 90, 67;
    --accent-primary-strong-rgb: 4, 120, 87;
    --accent-secondary-rgb: 181, 154, 93;  /* gold divider */
    --accent-red-rgb: 239, 68, 68;

    --accent-primary: rgb(var(--accent-primary-rgb));
    --accent-primary-hover: rgb(var(--accent-primary-hover-rgb));
    --accent-primary-soft: #ecfdf5;        /* pre-tinted soft surface */
    --accent-primary-strong: rgb(var(--accent-primary-strong-rgb));
    --accent-secondary: rgb(var(--accent-secondary-rgb));
    --accent-amber: var(--accent-secondary);
    --accent-green: var(--accent-primary);
    --accent-red: rgb(var(--accent-red-rgb));

    /* Soft-shadow & modal-scrim channels */
    --shadow-color-rgb: 15, 23, 42;        /* slate-900 */
    --scrim-color-rgb: 0, 0, 0;

    /* Neutral channels (borders, empty-state tints, on-dark overlays) */
    --neutral-rgb: 107, 114, 128;          /* gray-500 */
    --slate-rgb: 148, 163, 184;            /* slate-400 */
    --on-accent-rgb: 255, 255, 255;        /* white tints on dark */

    /* Fixed-contrast text on dark / amber surfaces */
    --text-on-dark: #e2e8f0;
    --text-on-dark-muted: #cbd5e1;
    --text-on-amber: #000;

    /* ----- Semantic status palette -----
       Channel-first for every colour that ships both as a solid
       fill and as a tinted background. Editing one channel
       updates the badge + every rgba() overlay derived from it. */
    --status-success-strong-rgb: 34, 197, 94;
    --status-success-text-rgb: 4, 120, 87;
    --status-success-bg: #d1fae5;
    --status-success-text: rgb(var(--status-success-text-rgb));
    --status-success-strong: rgb(var(--status-success-strong-rgb));
    --status-success-deep: #065f46;

    --status-info-rgb: 59, 130, 246;
    --status-info-strong-hover-rgb: 37, 99, 235;
    --status-info-text-rgb: 30, 64, 175;
    --status-info-sky-rgb: 14, 165, 233;
    --status-info-sky-light-rgb: 56, 189, 248;
    --status-info-sky-deep-rgb: 2, 132, 199;
    --status-info-bg: #dbeafe;
    --status-info-text: rgb(var(--status-info-text-rgb));
    --status-info-strong: rgb(var(--status-info-rgb));
    --status-info-strong-hover: rgb(var(--status-info-strong-hover-rgb));
    --status-info-sky: rgb(var(--status-info-sky-light-rgb));

    --status-warning-text-strong-rgb: 180, 83, 9;
    --status-warning-bg: #fef3c7;
    --status-warning-text: #92400e;
    --status-warning-text-strong: rgb(var(--status-warning-text-strong-rgb));

    --status-danger-bg: #fee2e2;
    --status-danger-text: #991b1b;

    --status-purple-rgb: 168, 85, 247;
    --status-purple-text-strong-rgb: 109, 40, 217;
    --status-purple-bg: #ede9fe;
    --status-purple-text: #5b21b6;
    --status-purple-text-strong: rgb(var(--status-purple-text-strong-rgb));
    --status-purple-strong: rgb(var(--status-purple-rgb));

    /* Activity / chart dots (semantic, solid only) */
    --activity-completed: #2ecc71;
    --activity-failed: #e74c3c;
    --activity-running: #3498db;
    --activity-pending: #f1c40f;
    --accent-cyan: #2D6A4F;          /* legacy alias → brand */
    --traffic-green: #2D6A4F;
    --traffic-amber: #d97706;
    --traffic-red: #dc2626;

    /* Surfaces (canvas, cards, hover) */
    --bg-primary: #f8f9fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --surface-primary: #ffffff;
    --surface-secondary: #f8f9fb;
    --surface-card: #ffffff;
    --surface-muted: #f8f9fb;
    --surface-hover: #f8fafc;

    /* "Glass" tokens — flat editorial replacements */
    --glass-bg: #ffffff;
    --glass-border: #E5E7EB;
    --glass-hover: #f8fafc;

    /* Borders & dividers */
    --border-subtle: #E5E7EB;
    --border-row: #f1f5f9;
    --border-strong: #d1d5db;

    /* Text */
    --text-primary: #1A242F;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --text-strong: #1A242F;
    --text-on-accent: #ffffff;

    /* Gradients (flattened to solids; safe for background-clip:text) */
    --gradient-primary: linear-gradient(135deg, #2D6A4F 0%, #2D6A4F 100%);
    --gradient-traffic: linear-gradient(135deg, #2D6A4F 0%, #B59A5D 50%, #EF4444 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(45,106,79,0.06) 0%, rgba(181,154,93,0.06) 100%);
    --gradient-glow: linear-gradient(135deg, rgba(45,106,79,0.15) 0%, rgba(181,154,93,0.15) 100%);

    /* Shadows & glows (soft, editorial) */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 1px 6px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10);
    --glow-green: 0 1px 6px rgba(45, 106, 79, 0.18);
    --glow-amber: 0 1px 6px rgba(181, 154, 93, 0.18);
    --glow-red: 0 1px 6px rgba(239, 68, 68, 0.18);
    --glow-subtle: 0 1px 4px rgba(15, 23, 42, 0.06);

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Type */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* ----- Type scale -----
       Six paired size/weight steps from hero number down to metadata.
       Pages compose tier classes (.hero-answer, .context-strip, etc.)
       built from these — they should not hand-roll font-size literals. */
    --type-hero-size:           4rem;        /* 64px — page-hero number */
    --type-hero-weight:         700;
    --type-hero-tracking:       -0.03em;
    --type-hero-sentence-size:  1.375rem;    /* 22px — hero supporting line */
    --type-hero-sentence-weight:500;
    --type-page-title-size:     1.75rem;     /* 28px — h1 / page title */
    --type-page-title-weight:   600;
    --type-section-size:        1.125rem;    /* 18px — section heading */
    --type-section-weight:      600;
    --type-card-lead-size:      2rem;        /* 32px — card lead value */
    --type-card-lead-weight:    700;
    --type-body-size:           0.9375rem;   /* 15px — body */
    --type-body-weight:         400;
    --type-meta-size:           0.78rem;     /* ~12.5px — metadata strip */
    --type-meta-weight:         500;
    --type-eyebrow-size:        0.7rem;      /* ~11px — uppercase eyebrow */
    --type-eyebrow-weight:      600;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Legacy aliases — older pages still reference these names */
    --neon-cyan:    var(--accent-primary);
    --neon-green:   var(--accent-primary);
    --neon-magenta: var(--accent-secondary);
}

/* Dark theme intentionally neutralised — design is light editorial only */
[data-theme="dark"] { color-scheme: light; }

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

html { scroll-behavior: smooth; font-size: 16px; }

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

/* Kill the old animated radial-gradient background pseudo-element */
body::before { content: none !important; display: none !important; }

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-primary-hover); }

button { font-family: inherit; }

::selection { background: rgba(45,106,79,0.18); color: var(--text-primary); }

/* ---------- Theme toggle (legacy markup) ---------- */
.theme-toggle { display: none !important; }

/* ---------- Layout shells ---------- */
.app-container {
    position: relative;
    min-height: 100vh;
    display: flex;
}

/* Sidebar (used by index.html progress tracker) */
.sidebar {
    width: 240px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--surface-card);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-md) var(--space-md);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-base), padding var(--transition-base);
}

.sidebar-collapse-toggle {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: all var(--transition-fast);
    padding: 0;
    box-shadow: var(--shadow-sm);
}
.sidebar-collapse-toggle:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.sidebar.collapsed { width: 64px; padding: 24px 8px 16px 8px; }
.sidebar.collapsed .sidebar-greeting,
.sidebar.collapsed .step-content { display: none; }
.sidebar.collapsed .step-header { justify-content: center; }
.sidebar.collapsed .progress-step::before { left: 50%; transform: translateX(-50%); }
.sidebar.collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .main-content { margin-left: 64px; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
}
.sidebar-logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.01em;
    -webkit-text-fill-color: currentColor;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

/* Progress tracker */
.progress-tracker { flex: 1; }
.progress-step {
    position: relative;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.progress-step::before {
    content: "";
    position: absolute;
    left: 22px;
    top: calc(100% + 2px);
    width: 2px;
    height: calc(100% + 4px);
    background: var(--border-subtle);
}
.progress-step:last-child::before { display: none; }
.progress-step:hover { background: var(--surface-hover); }
.progress-step.active {
    background: var(--accent-primary-soft);
    border: 1px solid var(--accent-primary);
    box-shadow: var(--glow-green);
}
.progress-step.active::before { background: var(--accent-primary); }
.progress-step.completed { opacity: 0.85; }
.progress-step.completed .step-icon {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.step-header { display: flex; align-items: center; gap: 12px; }
.step-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface-muted);
    border: 1.5px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}
.step-content { flex: 1; }
.step-title { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); margin-bottom: 0.125rem; }
.step-description { font-size: 0.75rem; color: var(--text-tertiary); }

/* Main content area */
.main-content {
    margin-left: 240px;
    flex: 1;
    padding: var(--space-lg);
    position: relative;
    transition: margin-left var(--transition-base);
}

/* Glass header (used as fixed top bar) */
.glass-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
}
.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.01em;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: currentColor;
    background-clip: initial;
}
.header-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }

.content-container { margin-top: 88px; }

/* ---------- Cards / panels ---------- */
.glass-panel,
.data-card,
.kpi-card,
.executive-dashboard,
.layer-control-panel {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.glass-panel:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.panel-header {
    margin: calc(var(--space-lg) * -1) calc(var(--space-lg) * -1) var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}
.panel-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

/* KPI cards */
.kpi-card { padding: var(--space-md) var(--space-lg); }
.kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.02em;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: currentColor;
    background-clip: initial;
}
.kpi-trend { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-green,
.btn-amber,
.btn-red,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.btn-primary,
.btn-green {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border-color: var(--accent-primary);
}
.btn-primary:hover,
.btn-green:hover {
    background: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: var(--text-on-accent);
}

.btn-secondary {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.btn-amber { background: var(--accent-secondary); color: #fff; border-color: var(--accent-secondary); }
.btn-amber:hover { background: #9c834d; border-color: #9c834d; color: #fff; }

.btn-red { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.btn-red:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-hover); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: var(--space-md); }
.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-input,
.header-input,
.header-select,
.isochrone-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.header-input:focus,
.header-select:focus,
.isochrone-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.10);
}

/* ---------- Tables ---------- */
.data-table,
.data-table table {
    width: 100%;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
}
.data-table th {
    background: var(--surface-muted);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--border-row);
    color: var(--text-primary);
    font-size: 0.88rem;
}
.data-table tr:hover td { background: var(--surface-hover); }

/* ---------- Badges ---------- */
.commute-badge,
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.status-badge.completed,
.status-badge.transit { background: #d1fae5; color: #065f46; }
.status-badge.running,
.status-badge.analyst { background: #dbeafe; color: #1e40af; }
.status-badge.failed,
.status-badge.admin { background: #fee2e2; color: #991b1b; }
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.owner { background: #ede9fe; color: #5b21b6; }
.status-badge.viewer { background: #f1f5f9; color: #475569; }

/* ---------- Layout helpers ---------- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; }
.grid { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }
.hidden { display: none !important; }

/* ---------- Spinner & loading ---------- */
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: cl-spin 0.8s linear infinite;
}
@keyframes cl-spin { to { transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: cl-fade-in var(--transition-slow) ease-out; }
@keyframes cl-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Mapbox controls (consistent across pages) ---------- */
.mapboxgl-ctrl-attrib { font-size: 10px !important; }
.mapboxgl-ctrl-top-right .mapboxgl-ctrl-group,
.mapboxgl-ctrl-top-left .mapboxgl-ctrl-group {
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: none;
}
.mapboxgl-ctrl-group button { width: 36px; height: 36px; border: none; }
.mapboxgl-ctrl-group button:hover { background: #ffffff; }
.mapboxgl-popup-content {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    font-family: var(--font-sans);
    color: var(--text-primary);
    padding: 12px 14px;
}

/* ---------- Page-meta header bits (kept compatible) ---------- */
.dashboard-header {
    background: var(--surface-card);
    color: var(--text-strong);
}
.dashboard-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}
.dashboard-actions { display: flex; gap: 8px; align-items: center; }

.header-actions { display: flex; align-items: center; gap: 6px; }
.header-controls,
.header-controls-group,
.header-control-row { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.header-control-item { display: flex; flex-direction: column; gap: 4px; }
.header-control-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 8px;
}
.header-icon-btn,
.header-auth-btn,
.header-settings-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.95rem;
}
.header-icon-btn:hover,
.header-auth-btn:hover,
.header-settings-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

/* ---------- Misc legacy components used across pages ---------- */
.create-project-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.create-project-btn:hover { background: var(--accent-primary-hover); color: #fff; }

.banner-header,
.how-it-works-banner {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}
.banner-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 4px;
}
.banner-subtitle { font-size: 0.85rem; color: var(--text-secondary); }
.banner-dismiss-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.banner-dismiss-btn:hover { color: var(--text-primary); background: var(--surface-hover); }

.area-select-btn,
.clear-selection-btn,
.map-style-btn,
.layer-toggle {
    padding: 7px 12px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}
.area-select-btn:hover,
.clear-selection-btn:hover,
.map-style-btn:hover,
.layer-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}
.area-select-btn.active,
.map-style-btn.active,
.layer-toggle.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.mode-tabs {
    display: inline-flex;
    background: var(--surface-muted);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 0;
}
.mode-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.mode-tab.active {
    background: var(--surface-card);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.opacity-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.opacity-value {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

/* ---------- Mobile overlay used by sidebar ---------- */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 99;
    display: none;
}
.mobile-overlay.active { display: block; }
.menu-toggle {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ===============================================================
   Visual Hierarchy — four-tier system
   ---------------------------------------------------------------
     Tier 1 — .hero-answer       The single answer of this page.
     Tier 2 — .tier-substance    The data the user scrolls through.
     Tier 3 — .context-strip     Run/page metadata, no card chrome.
     Tier 4 — chrome             Header/sidebar (defined elsewhere).

   Pages compose these classes; never hand-roll a hero or eyebrow
   from local font-size literals. Documented in replit.md.
   =============================================================== */

/* ---- Tier 1: Hero answer ---- */
.hero-answer {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--accent-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hero-answer__eyebrow {
    font-size: var(--type-eyebrow-size);
    font-weight: var(--type-eyebrow-weight);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    margin-bottom: 4px;
}
.hero-answer__sentence {
    font-size: var(--type-hero-sentence-size);
    font-weight: var(--type-hero-sentence-weight);
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.35;
}
.hero-answer__number {
    font-size: var(--type-hero-size);
    font-weight: var(--type-hero-weight);
    color: var(--accent-primary);
    letter-spacing: var(--type-hero-tracking);
    line-height: 1;
    display: inline-block;
    vertical-align: -0.05em;
    margin-right: 0.15em;
}
.hero-answer__site {
    font-weight: 700;
    color: var(--text-primary);
}
.hero-answer__caption {
    font-size: var(--type-meta-size);
    font-weight: var(--type-meta-weight);
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---- Tier 2: Substance block (composes with .glass-panel where useful) ----
   Encodes the base block rhythm for the "second loudest" tier so a row in
   a comparison feels distinct from page padding even without a card.
   Pages add .glass-panel on top when they want full card chrome. */
.tier-substance {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.tier-substance:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.tier-substance__lead {
    font-size: var(--type-card-lead-size);
    font-weight: var(--type-card-lead-weight);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
}
.tier-substance__lead-accent { color: var(--accent-primary); }

/* ---- Tier 3: Context strip ---- */
.context-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 4px 0 var(--space-md);
    font-size: var(--type-meta-size);
    font-weight: var(--type-meta-weight);
    color: var(--text-secondary);
}
.context-strip__item { display: inline-flex; align-items: baseline; gap: 4px; }
.context-strip__item + .context-strip__item::before {
    content: "·";
    color: var(--text-tertiary);
    margin-right: 10px;
}
.context-strip__value { color: var(--text-primary); font-weight: 600; }

/* ---- Section eyebrow + title ---- */
.section-eyebrow {
    font-size: var(--type-eyebrow-size);
    font-weight: var(--type-eyebrow-weight);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    margin-bottom: 6px;
}
.section-title {
    font-size: var(--type-section-size);
    font-weight: var(--type-section-weight);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ---- Winner / active cue ----
   ONE cue only. Both classes apply a single subtle gold top-rule that
   mirrors the hero card's rule, so the eye finds the standout row
   without any pill, heavier surface, or coloured border stacked on top.
   If a page truly needs an explicit text label, use a separate badge
   element — never combine it with these classes. */
.is-winner,
.is-active {
    border-top: 3px solid var(--accent-secondary) !important;
    position: relative;
}

/* ---------- Print ---------- */
@media print {
    body { background: #ffffff; }
    .glass-header, .sidebar, .theme-toggle, .header-actions, .banner-dismiss-btn { display: none !important; }
    .glass-panel, .data-card, .kpi-card { box-shadow: none; break-inside: avoid; }
    .main-content { margin-left: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: var(--space-md); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
