/* Full viewport height layout */
html {
    height: 100%;
}

body {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* AI Report specific styles */
.ai-report-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    overflow: visible;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0px;
    /* padding: 5px 0; */
    padding-top: 0px;
    padding-bottom: 5px;
    flex-shrink: 0;
}

.profile-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-selector label {
    font-weight: 600;
    color: #333;
}

.profile-selector select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    min-width: 250px;
}

.profile-selector select:focus {
    outline: none;
    border-color: #007aff;
}

/* Profile Toggle Styles */
#profile-toggle-container {
    margin-right: 20px;
}

.profile-toggle {
    display: inline-block;
}

.toggle-checkbox {
    display: none;
}

.toggle-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 0;
}

.toggle-option {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: color 0.3s ease;
    padding: 0 10px;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: #e0e0e0;
    border-radius: 13px;
    transition: background-color 0.3s ease;
    margin: 0 5px;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* .toggle-checkbox:checked + .toggle-label .toggle-slider {
    background-color: #007aff;
} */

.toggle-checkbox:checked+.toggle-label .toggle-slider::after {
    transform: translateX(24px);
}

.toggle-checkbox:checked+.toggle-label .toggle-option[data-mode="org"] {
    color: #007aff;
    font-weight: 600;
}

.toggle-checkbox:not(:checked)+.toggle-label .toggle-option[data-mode="user"] {
    color: #007aff;
    font-weight: 600;
}

/* Tabs */
.tabs-container {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}

.tab:hover {
    color: #333;
}

.tab.active {
    color: #007aff;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #007aff;
}

/* Model Weights Panel */
.model-weights-panel {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.weights-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.weights-values {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.edit-weights-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #007aff;
    background-color: white;
    border: 1px solid #007aff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    margin-left: 10px;
}

.edit-weights-btn:hover {
    background-color: #f0f7ff;
}

/* Model weights display (view mode) */
.model-weights-view {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.weight-separator {
    color: #ddd;
    margin: 0 2px;
    font-weight: 300;
}

.weight-label {
    font-weight: 400;
    color: #666;
    font-size: 12px;
    white-space: nowrap;
}

.weight-value {
    font-weight: 600;
    color: #007aff;
    font-size: 13px;
    margin-right: 2px;
    white-space: nowrap;
}

/* Model weights edit mode */
.model-weights-edit {
    display: none;
    /* max-width: 800px; */
    width: 80%;
    margin: 0 auto;
}

.edit-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.edit-mode-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.close-edit-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.close-edit-btn:hover {
    background-color: #e9ecef;
    border-color: #ccc;
}

.model-weights-edit.active {
    display: block;
}

.slider-group {
    margin-bottom: 15px;
}

.slider-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px 10px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.slider-label {
    flex: 0 0 180px;
    font-weight: 500;
    color: #333;
    font-size: 13px;
    display: flex;
    align-items: center;
}

.slider-expand-icon {
    margin-left: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.slider-expand-icon.expanded {
    transform: rotate(90deg);
}

.slider-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider {
    flex: 1;
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
    appearance: none;
    outline: none;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    background: #007aff;
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #007aff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    color: #007aff;
}

.sub-sliders {
    margin-left: 200px;
    display: none;
}

.sub-sliders.expanded {
    display: block;
}

.sub-slider-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 5px 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.sub-slider-label {
    flex: 0 0 160px;
    font-size: 12px;
    color: #666;
}

.model-weights-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.model-weights-actions button {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-refresh,
.btn-reset {
    background-color: white;
    color: #007aff;
    border: 2px solid #007aff;
}

.btn-update {
    background: linear-gradient(135deg, #007aff 0%, #0066cc 100%);
    color: white;
    border: none;
}

.btn-refresh:hover,
.btn-reset:hover {
    background-color: #f0f7ff;
}

.btn-update:hover:not(:disabled) {
    background: linear-gradient(135deg, #0066cc 0%, #0055aa 100%);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Table */
.report-table-container {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    padding-top: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 400px);
}

/* Wrapper for scrollable table */
.table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 0 0 12px 12px;
    flex: 1;
    min-height: 0;
    /* Improve scrolling experience */
    -webkit-overflow-scrolling: touch;
    /* Show scrollbar on hover for better UX */
    scrollbar-width: thin;
    scrollbar-color: #007aff #f0f0f0;
}

/* Competition and complements tabs need reduced height due to site selector */
#competition-tab .report-table-container,
#complements-tab .report-table-container {
    height: calc(100vh - 380px);
    max-height: calc(100vh - 380px);
    flex: none;
    min-height: 0;
}

/* Ensure scroll wrapper respects parent height in competition/complements tabs */
#competition-tab .table-scroll-wrapper,
#complements-tab .table-scroll-wrapper {
    height: calc(100vh - 410px);
    max-height: calc(100vh - 410px);
    flex: none;
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #007aff;
    border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #0066cc;
}

.report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    /* Ensure table maintains minimum width for many columns */
    min-width: max-content;
    position: relative;
}

.report-table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #e0e0e0;
}

.report-table th {
    padding: 10px 12px;
    padding-top: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border: none;
    position: relative;
    overflow: visible;
    background-color: #f8f9fa;
    /* Prevent text wrapping in headers for better column width */
    white-space: nowrap;
    /* Minimum width for readability */
    min-width: 120px;
    font-size: 14px;
}

.metric-header {
    position: relative;
    display: block;
    padding-right: 20px;
}

/* Info icon - circled i */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border: 1px solid #999;
    border-radius: 50%;
    font-size: 8px;
    font-style: italic;
    font-weight: normal;
    color: #999;
    cursor: help;
    position: absolute;
    top: 0;
    right: 0;
}

/* Tooltip styles */
/* Hide inline tooltips inside info icons */
.info-icon .tooltip {
    display: none !important;
}

/* Dynamic tooltip attached to body */
body>.tooltip {
    position: fixed !important;
    background-color: #333 !important;
    color: white !important;
    padding: 10px 14px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: normal !important;
    font-style: normal !important;
    white-space: normal !important;
    /* Allow text wrapping */
    word-wrap: break-word !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out !important;
    max-width: 300px !important;
    /* Slightly wider for better readability */
    min-width: 100px !important;
    z-index: 2147483647 !important;
    /* Maximum z-index */
    pointer-events: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.4 !important;
    text-align: left !important;
}

body>.tooltip.visible {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Remove any arrows */
body>.tooltip::before,
body>.tooltip::after {
    display: none !important;
}

/* Ensure info icons are interactive */
.info-icon {
    user-select: none;
}

.report-table tbody tr {
    transition: background-color 0.2s;
}

.report-table tbody tr:hover {
    background-color: #f8f9fa;
}

.report-table td {
    padding: 8px 12px;
    /* Prevent excessive width expansion */
    white-space: nowrap;
    /* Allow site column to expand for address info */
    font-size: 13px;
    border: none;
}

/* Site column styling */
.report-table th:first-child,
.report-table td:first-child {
    width: 180px !important;
    min-width: 180px;
    max-width: 180px;
    white-space: normal;
}

/* Spending category columns - compact with text wrapping */
.report-table th:not(:first-child):not(:nth-child(2)) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    white-space: normal;
    text-align: center;
}

.report-table td:not(:first-child) {
    width: 120px;
    min-width: 120px;
    text-align: center;
}

/* Expandable column headers - removed as columns are no longer expandable
.expandable-header {
    cursor: pointer;
    user-select: none;
}

.expand-icon {
    display: inline-block;
    margin-left: 5px;
    transition: transform 0.3s;
    font-size: 12px;
}

.expand-icon.expanded {
    transform: rotate(90deg);
} */

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.sortable:hover {
    background-color: #f0f7ff;
}

.sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
    color: #999;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.sort-icon.active {
    color: #007aff;
    opacity: 1;
    font-weight: bold;
}

.sortable:hover .sort-icon {
    opacity: 1;
}

/* Sub-score styling */
.sub-scores {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
    line-height: 1.3;
}

.sub-score-item {
    display: block;
    margin: 1px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.sub-score-label {
    font-weight: 500;
}

/* Removed hover effects as columns are no longer clickable
.metric-value.has-sub-scores {
    cursor: pointer;
}

.metric-value.has-sub-scores:hover {
    background-color: #f0f7ff;
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
} */

.site-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.site-details {
    font-size: 11px;
    color: #666;
    font-style: italic;
    line-height: 1.3;
}

.metric-value {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.metric-score {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.score-high {
    background-color: #d4edda;
    color: #155724;
}

.score-medium {
    background-color: #fff3cd;
    color: #856404;
}

.score-low {
    background-color: #f8d7da;
    color: #721c24;
}

/* Tab content */
.tab-content {
    display: none;
    overflow: visible;
    position: relative;
    flex: 1;
    width: 100%;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Ensure proper stacking context and overflow */
#scores-tab {
    position: relative;
    z-index: 1;
    overflow: visible;
}

#scores-tab.active {
    display: flex;
    flex-direction: column;
}

/* Allow overflow on demos and spending tabs */
#demos-tab,
#spending-tab {
    overflow: visible;
    position: relative;
}

/* Competition and complements tabs need different overflow behavior */
#competition-tab,
#complements-tab {
    overflow: hidden;
    position: relative;
}

#demos-tab.active,
#spending-tab.active,
#competition-tab.active,
#complements-tab.active {
    display: flex;
    flex-direction: column;
}


/* Site selector styling for competition and complements tabs */
.site-selector {
    flex-shrink: 0;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 20px !important;
}

.site-selector label {
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.site-selector select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    min-width: 200px;
}

/* Main content overflow */
main {
    overflow: visible;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Responsive table heights */
@media (max-width: 1200px) {
    /* Tables now flex to fill available space */
}

@media (max-width: 768px) {
    /* Tables now flex to fill available space */

    .report-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    /* Model weights responsive styles */
    .model-weights-panel {
        padding: 10px 15px;
    }

    .model-weights-view {
        gap: 10px;
        font-size: 12px;
    }

    .weights-title {
        font-size: 13px;
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .weights-values {
        gap: 5px;
    }

    .weight-separator {
        display: none;
    }

    .weight-label,
    .weight-value {
        font-size: 12px;
    }

    /* Each weight pair on its own line on very small screens */
    @media (max-width: 480px) {

        .weights-values>span:nth-child(4n-3),
        .weights-values>span:nth-child(4n-2) {
            width: 100%;
            text-align: center;
        }

        .weights-values>span:nth-child(4n-2) {
            margin-bottom: 8px;
        }
    }

    /* Edit mode responsive */
    /* .model-weights-edit {
        max-width: 100%;
    } */

    .slider-label {
        flex: 0 0 120px;
        font-size: 12px;
    }

    .sub-sliders {
        margin-left: 0;
        margin-top: 10px;
    }

    .sub-slider-label {
        flex: 0 0 110px;
    }

    .profile-selector {
        width: 100%;
    }

    .profile-selector select {
        width: 100%;
    }

    .slider-label {
        flex: 0 0 120px;
    }

    .sub-sliders {
        margin-left: 20px;
    }

    .report-table {
        font-size: 12px;
    }

    .report-table th,
    .report-table td {
        padding: 6px 8px;
    }

    /* Mobile tooltip adjustments */
    body>.tooltip {
        max-width: 90vw !important;
        white-space: normal !important;
    }

    /* Better table scrolling on mobile */
    .table-scroll-wrapper {
        /* Add padding to indicate scrollable content */
        box-shadow: inset -10px 0 10px -10px rgba(0, 0, 0, 0.1);
    }

    /* Smaller minimum header width on mobile */
    .report-table th {
        min-width: 70px;
        font-size: 12px;
    }

    /* Adjust site column on mobile */
    .report-table th:first-child,
    .report-table td:first-child {
        width: 120px !important;
        min-width: 120px;
        max-width: 120px;
    }

    /* Smaller spending columns on mobile */
    .report-table th:not(:first-child):not(:nth-child(2)) {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
    }

    .report-table td:not(:first-child) {
        width: 70px;
        min-width: 70px;
    }
}

@media (max-width: 480px) {
    /* Tables now flex to fill available space */
}

/* Status Badge Styles */
.status-badge {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 10px;
    font-size: 8px;
    font-weight: 500;
    text-transform: capitalize;
    margin-left: 5px;
    vertical-align: middle;
}

.status-badge.status-prospect {
    background-color: #e3f2fd;
    color: #1976d2;
}

.status-badge.status-active {
    background-color: #e8f5e9;
    color: #388e3c;
}

/* Map tab specific layout */
#map-tab {
    display: none;
}

#map-tab.active {
    display: block;
    height: 100%;
}

/* Map Container Styles */
#map-container {
    height: calc(100vh - 350px);
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    box-sizing: border-box;
    margin-bottom: 15px;
}

/* Adjust for wider screens where legend stays in one row */
@media (min-width: 1300px) {
    #map-container {
        height: calc(100vh - 320px);
    }
}

/* Ensure Mapbox map fills its container */
#map-container .mapboxgl-map {
    height: 100% !important;
    width: 100% !important;
}

/* Mapbox Popup Styles */
.mapboxgl-popup-content {
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: auto;
    max-width: 200px;
}

.mapboxgl-popup-tip {
    width: 8px;
    height: 8px;
}

.map-popup-title {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-popup-address {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    line-height: 1.4;
}

.map-popup-status,
.map-popup-category,
.map-popup-rating {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.map-popup-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.map-popup-link {
    display: inline-block;
    padding: 6px 12px;
    background-color: #007aff;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: background-color 0.2s;
}

.map-popup-link:hover {
    background-color: #0066cc;
}

.map-popup-link.website {
    background-color: #666;
}

.map-popup-link.website:hover {
    background-color: #555;
}

/* Map Marker Styles */
.map-marker {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid;
    /* border: 2px solid white; */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;


    background-color: white;
    /* clean white fill */
    display: flex;
    align-items: center;
    /* vertical center */
    justify-content: center;
    /* horizontal center */
    text-align: center;
    /* makes sure inline text centers too */
}

.marker-score {
    display: inline-block;
    /* prevents the span from stretching */
    /* line-height: 1; */
    /* remove extra vertical spacing */
    font-size: 14px;
    /* font-weight: bold; */
    /* color: black; */
}

.map-marker.site-active {
    /* background-color: #4caf50; */
    border-color: #4caf50;
    color: #4caf50;
}

.map-marker.site-prospect {
    /* background-color: #2196f3; */
    border-color: #2196f3;
    color: #2196f3;
}

.map-marker.competition,
.map-marker.complements {
    width: 10px;
    height: 10px;
    border-width: 1px;
}

.map-marker.competition {
    background-color: #f44336;
}

.map-marker.complements {
    background-color: #9c27b0;
}

/* Complement marker sizes based on traffic_driver_score */
.map-marker.complements.traffic-score-1 {
    width: 8px;
    height: 8px;
}

.map-marker.complements.traffic-score-2 {
    width: 12px;
    height: 12px;
}

.map-marker.complements.traffic-score-3 {
    width: 16px;
    height: 16px;
}

/* Map Legend Styles */
.map-legend {
    flex-shrink: 0;
    padding: 15px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 14px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-item.clickable {
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.3s ease;
    user-select: none;
}

.legend-item.clickable:hover {
    background-color: #f8f9fa;
}

.legend-item.disabled {
    opacity: 0.4;
}

.legend-item.disabled .legend-dot {
    filter: grayscale(50%);
}

.legend-dot {
    flex-shrink: 0;
    /* Inherits all styling from existing map-marker classes */
}

.legend-label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

/* Responsive table height adjustments */
@media (min-width: 1300px) {
    .report-table-container {
        max-height: calc(100vh - 380px);
    }

    #competition-tab .report-table-container,
    #complements-tab .report-table-container {
        height: calc(100vh - 440px);
        max-height: calc(100vh - 440px);
        flex: none;
        min-height: 0;
    }

    #competition-tab .table-scroll-wrapper,
    #complements-tab .table-scroll-wrapper {
        height: calc(100vh - 470px);
        max-height: calc(100vh - 470px);
        flex: none;
    }
}

@media (max-width: 768px) {
    .report-table-container {
        max-height: calc(100vh - 420px);
    }

    #competition-tab .report-table-container,
    #complements-tab .report-table-container {
        height: calc(100vh - 480px);
        max-height: calc(100vh - 480px);
        flex: none;
        min-height: 0;
    }

    #competition-tab .table-scroll-wrapper,
    #complements-tab .table-scroll-wrapper {
        height: calc(100vh - 510px);
        max-height: calc(100vh - 510px);
        flex: none;
    }

    #map-container {
        height: calc(100vh - 360px);
        /* Account for mobile header differences and stacked legend */
    }

    .legend-items {
        flex-direction: column;
        gap: 8px;
    }

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

    .legend-label {
        font-size: 12px;
    }
}