/* Welfare Compare - Clean Modern Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Colors */
    --bg: #0f1419;
    --bg-dark: #0a0d10;
    --surface: #1a1f26;
    --surface-hover: #22282f;
    --surface-elevated: #252b33;
    --border: #2d343d;
    --border-light: #363d47;
    --text: #e7e9ea;
    --text-secondary: #a8b3c0;
    --text-muted: #6e7a8a;
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-bg: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --map-bg: #000000;

    /* Border radius */
    --radius: 8px;
    --radius-sm: 4px;

    /* Shadows */
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

    /* Transitions */
    --transition: 0.15s ease;
    --transition-fast: 0.1s ease;
    --transition-slow: 0.3s ease;

    /* Z-index scale */
    --z-base: 1;
    --z-dropdown: 10;
    --z-map-controls: 50;
    --z-header: 100;
    --z-overlay: 500;
    --z-modal: 1000;
    --z-tooltip: 1000;
    --z-skip-link: 10000;

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;

    /* Font sizes */
    --text-xs: 10px;
    --text-sm: 11px;
    --text-base: 12px;
    --text-md: 13px;
    --text-lg: 14px;
    --text-xl: 15px;
    --text-2xl: 16px;
    --text-3xl: 18px;
    --text-4xl: 22px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: var(--space-sm) var(--space-lg);
    z-index: var(--z-skip-link);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* App Container */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: var(--z-header);
}

.header-left,
.header-right {
    flex: 1;
    display: flex;
}

.header-left {
    justify-content: flex-start;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    text-align: center;
}

.site-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.5px;
}

.site-title .accent {
    color: var(--primary);
}

.header-context {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
}

.context-program {
    color: var(--text-secondary);
    font-weight: 500;
}

.context-divider {
    color: var(--border);
    font-size: 8px;
}

.context-year {
    color: var(--primary);
    font-weight: 600;
}

.context-year.fallback-warning {
    color: var(--warning);
    font-size: 11px;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    color: var(--primary-light);
}

.header-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.header-btn.primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    padding: 12px;
    gap: 12px;
    overflow: hidden;
}

/* Sidebars */
.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Panels */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.panel-section {
    margin-bottom: 16px;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Select Input */
.select-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e7a8a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.select-input:hover {
    border-color: var(--primary);
    background: var(--surface-hover);
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.select-input.small {
    padding: 6px 8px;
    font-size: 12px;
}

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--bg-dark);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.toggle-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition);
}

.toggle-btn:hover {
    color: var(--text-secondary);
    background: var(--surface);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

/* 3-button toggle group */
.toggle-group-3 .toggle-btn {
    padding: 8px 8px;
    font-size: 11px;
}

.toggle-group-3 .toggle-btn svg {
    width: 12px;
    height: 12px;
}

/* Back Button for County View */
.btn-back {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
}

.btn-back:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-back svg {
    flex-shrink: 0;
}

.current-state-label {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--primary-bg);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    text-align: center;
}

/* County prompt overlay */
.county-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: var(--space-2xl) 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: var(--z-overlay);
    max-width: 280px;
}

.county-prompt h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.county-prompt p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Ratio Builder */
.ratio-builder-new {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ratio-dropdowns {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ratio-dropdowns .select-small {
    flex: 1;
    min-width: 0;
}

.ratio-divider-symbol {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 2px;
}

.select-small {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    padding: 6px 6px;
}

.btn-swap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-swap:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-swap svg {
    flex-shrink: 0;
}

/* Data/Ratio Section Styles */
.data-ratio-section {
    position: relative;
}

.panel-label-active {
    color: var(--primary);
}

.active-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.panel-label-active .active-indicator {
    opacity: 1;
}

/* Mode Toggle Button */
.mode-toggle-section {
    padding: 4px 0;
}

.btn-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mode-toggle:hover {
    background: var(--primary);
    color: white;
}

.btn-mode-toggle svg {
    flex-shrink: 0;
}

/* Color Scale Selector */
.color-scale-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.color-scale-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 22px;
    padding: 2px;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.color-option:hover {
    border-color: var(--text-muted);
}

.color-option.active {
    border-color: var(--primary);
}

.color-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 2px;
}

/* Ratio Builder */
.ratio-builder {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
}

.ratio-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.ratio-inputs .select-input {
    flex: 1;
}

.ratio-divider {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
}

.btn-small {
    width: 100%;
    padding: 8px 12px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-small:hover {
    background: var(--primary-light);
}

.btn-small:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* County Controls */
.county-controls {
    animation: fadeIn 0.2s ease;
}

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

/* County Info Badge */
.county-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    margin-left: 8px;
}

/* Loading State for County Data */
.loading-counties {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}

.loading-counties .loader {
    width: 24px;
    height: 24px;
    margin-bottom: 12px;
}

/* No Data State */
.no-data-message {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.select-input optgroup {
    font-weight: 600;
    color: var(--text-muted);
}

.select-input option {
    font-weight: 400;
    color: var(--text);
}

/* Search Box */
.search-box {
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    transition: all var(--transition);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* Legend */
.legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-color {
    width: 28px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: var(--bg);
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.stat-item.high .stat-value { color: var(--success); }
.stat-item.low .stat-value { color: var(--danger); }

/* Map Wrapper */
.map-wrapper {
    flex: 1;
    position: relative;
    background: var(--map-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.map-view {
    width: 100%;
    height: 100%;
    background: var(--map-bg);
}

/* Leaflet zoom control styling */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--surface-hover) !important;
    color: var(--text) !important;
}

.leaflet-control-zoom-in {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
}

.leaflet-control-zoom-out {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
}

/* Loading Overlay */
.map-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: var(--z-map-controls);
    transition: opacity var(--transition-slow);
    color: var(--text);
}

.map-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Info Panel */
.info-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.info-header {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.info-location {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.info-body {
    flex: 1;
    overflow-y: auto;
}

.hint-text {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.info-value-large {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.info-description {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.info-rank {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-bg);
    color: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* Funding Breakdown */
.funding-breakdown {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.funding-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.funding-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    margin-bottom: 8px;
}

.funding-federal {
    background: var(--primary);
    transition: width 0.3s ease;
}

.funding-state {
    background: var(--success);
    transition: width 0.3s ease;
}

.funding-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.funding-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.funding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.funding-dot.federal { background: var(--primary); }
.funding-dot.state { background: var(--success); }

/* Info Stats */
.info-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.info-stat {
    background: var(--bg);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.info-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.info-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.info-comparison {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-comparison strong {
    color: var(--text);
}

.info-comparison.warning {
    color: var(--danger);
}

.info-comparison.good {
    color: var(--success);
}

.info-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 16px;
    margin-bottom: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.info-section-title:first-of-type {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
}

.info-data-date {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.data-date-label {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* Custom Tooltip */
.custom-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: var(--z-tooltip);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity var(--transition);
    max-width: 280px;
}

.custom-tooltip.visible {
    opacity: 1;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.tooltip-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.tooltip-type {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 3px;
}

.tooltip-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.tooltip-detail {
    font-size: 12px;
    color: var(--text-muted);
}

/* Search Results */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: var(--z-header);
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.highlighted {
    background: var(--bg);
}

.search-result-item.highlighted {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.result-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.result-type {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Compare Modal */
.compare-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.compare-select-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vs-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

#compare-results {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.compare-row {
    display: grid;
    grid-template-columns: 1fr 100px 1fr;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
}

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

.compare-row.header {
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
}

.compare-program {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.compare-value {
    font-size: 14px;
    font-weight: 600;
}

.compare-value:first-child { text-align: left; }
.compare-value:last-child { text-align: right; }

.compare-value.higher { color: var(--success); }
.compare-value.lower { color: var(--danger); }

/* Sources Grid */
.sources-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.source-card {
    background: var(--bg);
    padding: 14px;
    border-radius: var(--radius-sm);
}

.source-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.source-card p {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.source-card a {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.source-card a:hover {
    text-decoration: underline;
}

.source-note {
    grid-column: 1 / -1;
    background: var(--surface-elevated);
    padding: 16px;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}

.source-note h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.source-note p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.source-note p:last-child {
    margin-bottom: 0;
}

.source-disclaimer {
    grid-column: 1 / -1;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* Hide mobile panel on desktop */
.mobile-panel {
    display: none;
}

/* Leaflet Overrides */
.leaflet-container {
    background: var(--map-bg) !important;
    font-family: 'Inter', sans-serif;
}

/* Hide default leaflet tooltips */
.leaflet-tooltip {
    display: none !important;
}

/* Responsive - Tablet */
@media (max-width: 1100px) {
    .sidebar {
        width: 220px;
    }

    .site-title {
        font-size: 18px;
    }

    .header-context {
        font-size: 11px;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .top-header {
        padding: 10px 12px;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .header-btn span {
        display: none;
    }

    .header-btn {
        padding: 10px 12px;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }

    .header-context {
        display: none;
    }

    .site-title {
        font-size: 18px;
    }

    .main-content {
        flex-direction: column;
        padding: 0;
        gap: 0;
        flex: 1;
    }

    /* Hide sidebars on mobile - use bottom sheet instead */
    .left-sidebar {
        display: none;
    }

    .right-sidebar {
        display: none;
    }

    /* Map takes full width */
    .map-wrapper {
        width: 100%;
        height: 50vh;
        min-height: 300px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        order: 1;
    }

    /* Mobile bottom panel - show on mobile */
    .mobile-panel {
        display: flex !important;
        flex-direction: column;
        background: var(--surface);
        border-top: 1px solid var(--border);
        order: 2;
        flex: 1;
        min-height: 40vh;
    }

    .mobile-tabs {
        display: flex;
        border-bottom: 1px solid var(--border);
        background: var(--bg);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .mobile-tab {
        flex: 1;
        padding: 12px 8px;
        background: none;
        border: none;
        font-size: 12px;
        font-weight: 500;
        color: var(--text-muted);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        transition: all var(--transition);
        min-height: 56px;
    }

    .mobile-tab svg {
        width: 20px;
        height: 20px;
    }

    .mobile-tab.active {
        color: var(--primary);
        background: var(--surface);
        box-shadow: inset 0 -2px 0 var(--primary);
    }

    .mobile-tab-content {
        display: none;
        padding: 16px;
        overflow-y: auto;
        flex: 1;
    }

    .mobile-tab-content.active {
        display: block;
    }

    /* Mobile-friendly form controls */
    .select-input {
        padding: 12px 14px;
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 48px;
    }

    .search-box input {
        padding: 12px 12px 12px 40px;
        font-size: 16px;
        min-height: 48px;
    }

    .panel-section {
        margin-bottom: 20px;
    }

    /* Stats grid on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-item {
        padding: 12px;
    }

    .stat-value {
        font-size: 16px;
    }

    /* Legend on mobile */
    .legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .legend-item {
        font-size: 11px;
    }

    /* Info panel mobile styles */
    .info-value-large {
        font-size: 24px;
    }

    .info-stats {
        grid-template-columns: 1fr 1fr;
    }

    /* Modal full screen on mobile */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }

    .modal-header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        background: var(--surface);
        z-index: 10;
    }

    .modal-body {
        padding: 16px;
    }

    .sources-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .compare-controls {
        flex-direction: column;
        gap: 12px;
    }

    .compare-select-group {
        width: 100%;
    }

    .vs-badge {
        align-self: center;
    }

    .compare-row {
        grid-template-columns: 1fr 80px 1fr;
        gap: 8px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .compare-program {
        font-size: 10px;
    }

    /* Tooltip adjustments */
    .custom-tooltip {
        max-width: 250px;
        padding: 10px 12px;
    }

    .tooltip-value {
        font-size: 18px;
    }

    /* Search results on mobile */
    .search-results {
        max-height: 180px;
    }

    .search-result-item {
        padding: 12px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .site-title {
        font-size: 16px;
    }

    .header-btn {
        padding: 8px;
    }

    .mobile-tab {
        padding: 10px 4px;
        font-size: 11px;
    }

    .mobile-tab svg {
        width: 18px;
        height: 18px;
    }

    .legend {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .compare-row {
        grid-template-columns: 1fr 60px 1fr;
        font-size: 12px;
    }
}

/* ===================================
   Screenshot Mode
   =================================== */

/* Screenshot title overlay - hidden by default */
.screenshot-title {
    display: none;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    z-index: 500;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* Screenshot exit button - hidden by default */
.screenshot-exit {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 500;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.screenshot-exit:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.screenshot-exit svg {
    flex-shrink: 0;
}

/* Screenshot mode active state */
.app-container.screenshot-mode .top-header,
.app-container.screenshot-mode .left-sidebar,
.app-container.screenshot-mode .right-sidebar,
.app-container.screenshot-mode .mobile-panel,
.app-container.screenshot-mode .custom-tooltip {
    display: none !important;
}

.app-container.screenshot-mode .main-content {
    padding: 0;
}

.app-container.screenshot-mode .map-wrapper {
    height: 100vh !important;
    width: 100vw !important;
}

.app-container.screenshot-mode .screenshot-title {
    display: block;
}

.app-container.screenshot-mode .screenshot-exit {
    display: flex;
}

/* Screenshot mode legend - repositioned to bottom left of map */
.legend.screenshot-legend {
    position: absolute;
    bottom: 70px;
    left: 20px;
    z-index: 500;
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.legend.screenshot-legend .legend-item {
    padding: 4px 0;
}

/* Hide screenshot elements in print - use browser's print directly */
@media print {
    .screenshot-title,
    .screenshot-exit {
        display: none !important;
    }
}

/* Print Styles */
@media print {
    .top-header,
    .left-sidebar,
    .modal,
    .custom-tooltip,
    .map-overlay,
    .skip-link {
        display: none !important;
    }

    .app-container {
        height: auto;
        display: block;
    }

    .main-content {
        display: block;
        padding: 0;
    }

    .map-wrapper {
        border: 1px solid #ccc;
        page-break-inside: avoid;
        height: 500px !important;
    }

    .right-sidebar {
        width: 100%;
        margin-top: 20px;
        page-break-before: avoid;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    body {
        font-size: 12pt;
        background: white;
    }

    a {
        text-decoration: none;
        color: inherit;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }
}
