/* ===============================================
   Greek Floods Web Map - Minimalist Design System
   =============================================== */

/* CSS Variables for Consistent Theming */
:root {
    /* Ultra Minimalist Color Palette */
    --primary-color: #000000;
    --primary-light: #333333;
    --accent-color: #666666;
    --accent-blue: #0066ff;
    --accent-green: #00aa44;

    /* Clean Neutral Colors */
    --background-primary: #ffffff;
    --background-secondary: #ffffff;
    --background-tertiary: #fafafa;
    --border-color: #333333;
    --border-light: #666666;

    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-inverse: #ffffff;

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

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

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Typography tokens (liaskos.eu palette) */
    --font-serif: 'EB Garamond', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

/* Search tab */
.search-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}

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

/* Hide placeholder "hint" text while focused to reduce visual noise */
.search-input:focus::placeholder {
    color: transparent;
}

/* Hide the hint text while the user is interacting with the input */
.search-panel:focus-within .search-hint {
    display: none;
}

/* Selected search values (badges) */
.search-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-selected.hidden {
    display: none;
}

.search-results {
    border: 1px solid var(--border-color);
    background: var(--background-primary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
}

.search-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.search-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
}

.search-section-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.search-result {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-light);
    background: var(--background-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.search-result:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border-color);
}

.search-hint {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Collapsible sidebar (desktop) */
body.sidebar-collapsed .main-content {
    grid-template-columns: 56px 1fr;
}

body.sidebar-collapsed .sidebar {
    background: #000;
    border-color: #000;
}

body.sidebar-collapsed .tab-content {
    display: none !important;
}

/* Sidebar internal layout: tab rail + content panel */
.sidebar-layout {
    display: flex;
    height: 100%;
    gap: 0;
}

.sidebar-rail {
    width: 56px;
    flex: 0 0 56px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-panel {
    flex: 1;
    min-width: 0;
    padding-left: 0.75rem;
}

body.sidebar-collapsed .sidebar-panel {
    display: none;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv11";
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Editorial serif for display headings (LAGOONS title, modal titles, fig captions) */
.header h1,
.modal-content > .modal-header h3,
.welcome-text,
.stats-figcaption .stats-figure-title,
.stats-fig-label {
    font-family: var(--font-serif);
    font-feature-settings: "lnum" 1, "kern" 1;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.875rem; }
h6 { font-size: 0.75rem; }

/* Main App Container */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Header Styles - Ultra Minimal */
.header {
    background: var(--background-primary);
    border-bottom: none;
    /* Asymmetric padding compensates for Italianno's tall ascender
       overshoot — the visible title content sits optically higher than
       its line-box, so we add more top padding and less below. */
    padding: 1.05rem 0 0.4rem;
    flex-shrink: 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Title block: hairline · serif title · hairline (magazine masthead) */
.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.header-rule {
    flex: 0 0 auto;
    width: clamp(40px, 12vw, 110px);
    height: 1px;
    background: var(--text-primary);
    opacity: 0.45;
}

.header h1 {
    color: var(--text-primary);
    /* Whole title now in Italianno calligraphic script — same family on
       both spans, only the colour differs for the italic continuation. */
    font-family: 'Italianno', cursive;
    font-weight: 400;
    font-style: normal;
    font-size: clamp(2.6rem, 5vw, 3.4rem);
    line-height: 0.9;
    letter-spacing: 0.01em;
    text-transform: none;
    text-indent: 0;
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: baseline;
    gap: 0.18em;
}
.header h1 em {
    /* Inherits font-family, size, and weight from the h1; only the colour
       changes so 'of Earth' reads as a quieter continuation. */
    font-family: inherit;
    font-style: normal;
    font-weight: inherit;
    color: var(--text-secondary);
    font-size: 1em;
    line-height: inherit;
    letter-spacing: inherit;
}

.subtitle {
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0;
    line-height: 1.5;
    max-width: 36rem;
    margin: 0 auto;
}

/* Mobile header/layout tuning */
@media (max-width: 768px) {
    .header {
        /* Reduce vertical whitespace on mobile */
        padding: 0.75rem 0 0.25rem 0;
    }

    .header-content {
        padding: 0 1rem;
    }

    .header-title {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
    }

    .header h1 {
        /* Italianno calligraphic title, scaled for phones */
        font-size: 2.1rem;
        margin: 0;
        letter-spacing: 0.01em;
        text-indent: 0;
        line-height: 0.9;
    }
    .header-title { gap: 0.7rem; }
    .header-rule  { width: clamp(20px, 8vw, 50px); }

    .subtitle {
        display: block !important;
        font-size: 0.85rem;
        line-height: 1.45;
        letter-spacing: 0;
        opacity: 1;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0 0.5rem;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .mobile-controls {
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .mobile-toggle-btn {
        padding: 0.6rem 1rem;
    }

    /* On mobile, the top tab rail inside the sidebar is redundant
       because Filters/Search is controlled via the mobile buttons. */
    .sidebar.active .tab-nav {
        display: none;
    }

    /* With tab-nav hidden, reduce top padding so content starts higher */
    .sidebar.active .sidebar-content {
        padding-top: 1.25rem;
    }
}

/* Navigation Bar - Positioned absolutely on the left */
.header-nav {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Actions - Positioned absolutely on the right */
.header-actions {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

/* Navigation Link Styling - Base Class */
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    min-height: 44px;
    background: var(--background-primary);
    border: 1px solid var(--primary-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: 0;
    outline: none;
    text-decoration: none;
    white-space: nowrap;
    gap: 0.5rem;
}

.nav-icon {
    width: 28px;
    height: 28px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
    transition: all 0.2s ease;
}

.nav-link:hover .nav-icon {
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
    transform: translateY(-1px);
}

.nav-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: 0;
    outline: none;
    text-decoration: none;
}

.nav-link-icon:hover {
    background: transparent;
    transform: translateY(-2px);
}

.nav-link-icon:hover .nav-icon {
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3));
}

.nav-link:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.nav-link.active {
    background: var(--primary-color);
    color: var(--text-inverse);
    font-weight: 600;
}

.nav-link.active:hover {
    background: var(--primary-light);
    color: var(--text-inverse);
}

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

.nav-link svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* Mobile Controls - Hidden by default on desktop */
.mobile-controls {
    display: none;
    padding: 0.875rem 1rem;
    background: var(--background-primary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
    gap: 0.75rem;
}

.mobile-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    min-width: 44px;
    background: var(--background-primary);
    border: 1px solid var(--primary-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: 0;
    outline: none;
    /* Prevent horizontal overflow on narrow screens when the label becomes long */
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-decoration: none;
    position: relative;
}

.mobile-toggle-btn:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.mobile-toggle-btn.active {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.mobile-toggle-btn.active:hover {
    background: var(--background-primary);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}


/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    margin: 0;
    padding: 1rem;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

/* Sidebar Styles - Minimal */
.sidebar {
    background: var(--background-primary);
    border-radius: 0;
    box-shadow: none;
    border: 1px solid var(--border-color);
    height: 100%;
    overflow-y: hidden;
    overflow-x: visible;
    position: relative;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--background-tertiary);
    border-radius: var(--radius-sm);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

.sidebar-content {
    /* Responsive padding so the filter panel stays compact on short viewports */
    padding: clamp(0.75rem, 2vh, var(--spacing-xl));
    position: relative;
}

/* Mobile Sidebar Close Button */
.mobile-sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: var(--background-primary);
    border: 1px solid var(--primary-color);
    color: var(--text-primary);
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
}

.mobile-sidebar-close:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.mobile-sidebar-close svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* Section Headers */
.section-header {
    margin-bottom: var(--spacing-lg);
}

.section-header h3,
.section-header h4 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.section-divider {
    display: block;
    height: 1px;
    background: var(--border-color);
    border-radius: 0;
}

/* Filter Styles */
.filter-group {
    margin-bottom: clamp(0.5rem, 1.6vh, var(--spacing-lg));
    position: relative;
}

.filter-group label {
    display: block;
    color: var(--text-secondary);
    font-size: clamp(0.65rem, 1.4vh, 0.8rem);
    font-weight: 500;
    margin-bottom: clamp(0.25rem, 1vh, var(--spacing-sm));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--background-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 16px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
    min-height: 44px;
}

.filter-group select:hover {
    border-bottom-color: var(--text-primary);
    background-color: rgba(0, 0, 0, 0.02);
}

.filter-group select:focus {
    border-bottom-color: var(--primary-color);
    background-color: var(--background-primary);
    box-shadow: 0 2px 0 0 var(--primary-color);
}

.filter-group select:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.filter-group select option {
    padding: 0.5rem 1rem;
}

.filter-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--background-secondary);
}

/* Active filter indicator */
.filter-group select.has-value,
.filter-group input.has-value {
    border-bottom: 2px solid var(--primary-color);
    border-left: 3px solid var(--primary-color);
    background-color: rgba(51, 122, 183, 0.05);
    padding-left: calc(1rem - 3px);
}

.filter-group select.has-value:hover,
.filter-group input.has-value:hover {
    background-color: rgba(51, 122, 183, 0.08);
}

/*
 * Z-INDEX HIERARCHY
 * =================
 * This application uses a structured z-index system to ensure proper layering of UI elements.
 * Always reference this hierarchy when adding new elements to prevent stacking conflicts.
 *
 * Tier 0 (z-index: 1-10): Base interactive elements
 *   - Dropdown containers (z-index: 0)
 *   - Dropdown toggles (z-index: 1)
 *   - Tab buttons (z-index: 1)
 *   - Active tab buttons (z-index: 2)
 *   - Filter loading overlays (z-index: 10)
 *
 * Tier 1 (z-index: 100-200): Structural elements
 *   - Mobile controls (z-index: 100)
 *   - Mobile sidebar close button (z-index: 100)
 *   - Header elements (z-index: 100-200)
 *
 * Tier 2 (z-index: 1000): Tooltips and info popups
 *   - Map loading indicator (z-index: 1000)
 *   - Measurement info tooltip (z-index: 1000)
 *
 * Tier 3 (z-index: 1050): Secondary dropdowns
 *   - User menu dropdown (z-index: 1050)
 *
 * Tier 4 (z-index: 1100): Primary dropdowns
 *   - Filter dropdowns (z-index: 1100)
 *   - Uses standard absolute positioning with overflow: hidden
 *   - No special containment or isolation properties needed
 *
 * Tier 5 (z-index: 10000+): Critical overlays
 *   - Modals (z-index: 10000)
 *   - Error banners (z-index: 10000)
 *   - Success banners (z-index: 10000)
 */

/* Native Select Styling for Filters */
.filter-select,
select[id$="-filter"] {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    background-color: var(--background-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
}

.filter-select:focus,
select[id$="-filter"]:focus {
    border-bottom-color: var(--primary-color);
    box-shadow: 0 3px 0 0 var(--primary-color);
    background-color: rgba(51, 122, 183, 0.02);
    outline: none;
}

.filter-select:hover,
select[id$="-filter"]:hover {
    border-bottom-color: var(--text-primary);
    background-color: rgba(0, 0, 0, 0.02);
}

.filter-select.has-value,
select[id$="-filter"].has-value {
    border-bottom: 2px solid var(--primary-color);
    border-left: 3px solid var(--primary-color);
    background-color: rgba(51, 122, 183, 0.05);
    padding-left: calc(1rem - 3px);
}

.filter-select:disabled,
select[id$="-filter"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.05);
}

select[id$="-filter"] option {
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Active Filters Summary Panel */
.active-filters-summary {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: rgba(51, 122, 183, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.active-filters-summary.hidden {
    display: none;
}

.active-filters-summary h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* Filter Badge Styling */
.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.5rem 0.875rem;
    min-height: 32px;
    background-color: var(--background-primary);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-primary);
    /* Avoid horizontal overflow: allow badge contents to wrap/break */
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    flex-wrap: wrap;
}

.filter-badge-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-badge-value {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.filter-badge-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 24px;
    min-height: 24px;
    margin-left: 0.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: all var(--transition-fast);
}

.filter-badge-remove:hover {
    color: var(--error-color);
    transform: scale(1.1);
}

/* SQL Filter Badge - distinct styling */
.filter-badge-sql {
    background: rgba(49, 130, 206, 0.1);
    border-color: var(--primary-color);
}

.filter-badge-sql .filter-badge-value {
    color: var(--primary-color);
}

/* Filter dropdowns use native select behavior for accessibility and performance */


/* Button Styles */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: clamp(0.5rem, 1.4vh, 0.75rem) 1rem;
    min-height: clamp(34px, 6vh, 44px);
    border-radius: var(--radius-md);
    font-size: clamp(0.8rem, 1.7vh, 16px);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    outline: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-inverse);
    border: 1px solid var(--primary-color);
    box-shadow: none;
    border-radius: 0;
}

.btn-primary:hover {
    background: var(--background-primary);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    transform: none;
    box-shadow: none;
}

.btn-primary:active {
    transform: none;
}

.btn-secondary {
    background: var(--background-primary);
    color: var(--text-primary);
    border: 1px solid var(--primary-color);
    border-radius: 0;
}

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

/* Sidebar top tabs (Filters / Search) */
.tab-nav {
    display: flex;
    flex-direction: row;
    gap: 0;
    margin-bottom: 1rem;
}

.tab-nav .tab-button {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.55rem 0.4rem;
    margin-bottom: 0;
}

.tab-nav .tab-button + .tab-button {
    margin-left: -1px;
}

.tab-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
}

.tab-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* (kept) tab icon + label */

.rail-btn:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

body.sidebar-collapsed .rail-btn {
    background: #000;
    color: #fff;
    border-color: #fff;
}

body.sidebar-collapsed .rail-btn:hover {
    background: #fff;
    color: #000;
}

.tab-button {
    width: 100%;
    flex: 0 0 auto;
    padding: 0.75rem 0.75rem;
    min-height: 44px;
    background: var(--background-primary);
    border: 1px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    border-radius: 0;
    margin-right: 0;
    margin-bottom: -1px;
}

.tab-button:last-child {
    margin-bottom: 0;
}

.tab-button:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
    z-index: 1;
}

.tab-button.active {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
    z-index: 2;
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: hidden;
}

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

#stats-content,
.stats-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-item {
    background: var(--background-primary);
    border: none;
    border-left: 2px solid var(--border-color);
    border-radius: 0;
    padding: 1rem;
    transition: border-color var(--transition-fast);
}

.stat-item:hover {
    transform: none;
    border-left-color: var(--primary-color);
    box-shadow: none;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    display: block;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Map Container - Clean */
.map-container {
    background: var(--background-primary);
    border-radius: 0;
    box-shadow: none;
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* ===== MAP STATUS BAR ===== */
.map-status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    color: #1e1e1e;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 0.75rem 0.5rem;
    z-index: 1000;
    pointer-events: none;
}

.map-status-bar > * {
    pointer-events: auto;
}

.status-bar-left-col {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}

.status-bar-left {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 4px;
    padding: 0.5rem 0.75rem 0.6rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.status-bar-left .status-scale {
    margin: 0 auto;
    justify-content: center;
}

.status-bar-legend {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: #ffffff;
    border-radius: 4px;
    padding: 0.6rem 0.85rem 0.7rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.legend-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 0.55rem;
    padding: 0.1rem 0;
}

.legend-count {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-align: right;
    min-width: 1.6em;
}

.legend-row .legend-count:empty::before { content: '—'; color: var(--text-muted); }

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.legend-dot.high   { background: #b91c1c; }
.legend-dot.medium { background: #ea580c; }
.legend-dot.low    { background: #0d9488; }

.legend-text {
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.2;
}

.status-bar-right {
    display: flex;
    align-items: baseline;
    gap: 0.85rem;
    background: #ffffff;
    border-radius: 4px;
    padding: 0.55rem 0.95rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.status-bar-right > .status-scale::before {
    content: '·';
    color: var(--text-muted);
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1;
    margin-right: 0.55rem;
    font-weight: 400;
}

/* Live mouse coordinates */
.status-coords {
    display: flex;
    align-items: baseline;
    gap: 0.85rem;
    font-family: var(--font-serif);
    line-height: 1.2;
}

.coord-pair {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
}

.coord-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0;
}

.coord-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: 0;
    min-width: 5.5em;
    text-align: right;
}

/* Representative fraction (1 : N), no eyebrow — editorial mono.
   Sits inline with the coords; a tiny serif middle-dot separates them (rendered via ::before above). */
.status-scale {
    display: flex;
    align-items: baseline;
}

.carto-scale-fraction {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: 0;
}

.carto-scale-colon {
    color: var(--text-muted);
    font-weight: 400;
    padding: 0 0.05rem;
}

/* Leaflet Controls - Consistent Width */
.leaflet-bar a {
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
}

.leaflet-control-layers-toggle {
    width: 34px !important;
    height: 34px !important;
    background-size: 20px 20px;
    cursor: pointer;
}

/* ===== MOBILE BASEMAP PICKER (touch-friendly) ===== */
.basemap-picker {
    background: #fff;
    border: 1px solid var(--border-color);
    position: relative;
}

.basemap-picker.basemap-picker-open {
    z-index: 1200;
}

.basemap-picker-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    background: #fff;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.basemap-picker-btn:hover {
    background: rgba(0,0,0,0.05);
}

.basemap-picker-btn:active {
    background: rgba(0,0,0,0.08);
}

.basemap-picker-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.basemap-picker-panel {
    position: absolute;
    top: 0;
    left: 38px;
    background: #fff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    z-index: 1200;
    min-width: 220px;
    max-height: 60vh;
    overflow: auto;
}

.basemap-picker-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 12px;
    min-height: 44px;
    background: #fff;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    font-family: inherit;
    font-size: 14px;
}

.basemap-picker-item:last-child {
    border-bottom: none;
}

.basemap-picker-item:active {
    background: rgba(0,0,0,0.06);
}

/* ═══════════════════════════════════════════════════════════════════
   Boundary Layer Control  (topright floating panel)
   ═══════════════════════════════════════════════════════════════════ */

.boundary-layer-control {
    position: relative;
    font-family: inherit;
}

/* The map-button that opens the panel */
.boundary-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: #ffffff;
    border: none;
    border-radius: 0;
    color: #333333;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.boundary-ctrl-btn:hover,
.boundary-ctrl-btn.active {
    background: #000000;
    color: #ffffff;
}

/* Dropdown panel */
.boundary-ctrl-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 38px;
    min-width: 210px;
    background: #ffffff;
    border: 1px solid #333333;
    box-shadow: var(--shadow-md);
    z-index: 800;
}

.boundary-ctrl-panel.open {
    display: block;
}

.boundary-panel-header {
    padding: 0.55rem 0.85rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
}

/* Each toggle row */
.boundary-panel-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.boundary-panel-row:hover {
    background: #f5f5f5;
}

.boundary-panel-row:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

.boundary-panel-checkbox {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    accent-color: #000000;
    cursor: pointer;
    margin: 0;
}

.boundary-panel-swatch {
    flex-shrink: 0;
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    background: transparent;
}

.boundary-panel-label {
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.boundary-tooltip {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #cccccc;
    border-radius: 0;
    color: #111111;
    font-size: 0.78rem;
    font-family: inherit;
    padding: 3px 7px;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.boundary-tooltip::before {
    display: none;
}

@media (max-width: 480px) {
    .boundary-ctrl-panel {
        left: 0;
        top: 38px;
        min-width: 190px;
    }
}

/* Cartographic scale — representative fraction (1 : N) */

/* ===== Mobile status bar — full rebuild =====
   Below 720px the bar leaves the map (no more absolute overlay) and becomes
   an in-flow strip beneath it. .map-container turns into a flex column, #map
   flexes to fill, the bar takes its own row. The legend stops being a stacked
   pill and becomes a single horizontal row of chips: [● count] [● count]
   [● count]  ·  scale. This layout has no vertical clipping mode and renders
   identically on every phone. */
@media (max-width: 720px) {
    .map-container {
        display: flex;
        flex-direction: column;
    }
    .map-container > .leaflet-container,
    .map-container > #map {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
    }

    .map-status-bar {
        position: static;
        flex: 0 0 auto;
        width: 100%;
        padding: 0.5rem 0.75rem;
        gap: 0.75rem;
        background: var(--background-primary);
        border-top: 1px solid var(--border-color);
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
        pointer-events: auto;
        box-sizing: border-box;
    }

    /* Left column collapses — legend goes inline. */
    .status-bar-left-col {
        flex: 1 1 auto;
        min-width: 0;
        gap: 0;
    }

    /* Horizontal chip layout for the legend. */
    .status-bar-legend {
        display: flex;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.55rem;
        padding: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Hide the verbose "Inundation by 2100" title on mobile — colored dots
       are self-explanatory and the title eats horizontal real estate. */
    .status-bar-legend .legend-title { display: none; }

    /* Each row becomes a compact dot + count chip. Labels hidden on mobile. */
    .legend-row {
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0;
        grid-template-columns: none;       /* drop grid */
        column-gap: 0;
        min-width: 0;
    }
    .legend-row .legend-text { display: none; }
    .legend-dot {
        width: 10px;
        height: 10px;
        flex-shrink: 0;
    }
    .legend-count {
        font-family: var(--font-mono);
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--text-primary);
        min-width: 0;
        text-align: left;
    }

    /* Right column: scale only on touch devices (mousemove coords are useless). */
    .status-bar-right {
        flex: 0 0 auto;
        padding: 0;
        gap: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        max-width: none;
        width: auto;
        box-sizing: border-box;
        white-space: nowrap;
    }
    .status-coords { display: none; }
    .status-bar-right > .status-scale::before { content: none; }
    .status-scale,
    .carto-scale-fraction { font-size: 0.72rem; white-space: nowrap; }
    .status-label { display: none; }
}

/* Tighten padding on very narrow phones; layout is otherwise identical. */
@media (max-width: 380px) {
    .map-status-bar { padding: 0.45rem 0.55rem; gap: 0.5rem; }
    .status-bar-legend { gap: 0.4rem; }
    .legend-count, .status-scale, .carto-scale-fraction { font-size: 0.66rem; }
    .legend-dot { width: 9px; height: 9px; }
}

/* Loading Indicator - Minimal */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    background: white;
    padding: 2rem;
    border: 1px solid #000;
    box-shadow: none;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 1rem;
    border: 2px solid #f0f0f0;
    border-top: 2px solid #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 0.8rem;
    margin: 0;
}
/* ===============================================
   Error Display Styles
   =============================================== */

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Error Banner Styles */
.error-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #FFF3CD;
    border-bottom: 2px solid #FFB800;
    padding: 1rem;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.error-banner-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.error-banner-message {
    flex: 1;
    color: #856404;
}

.error-banner-message strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.error-banner-message p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.error-banner-instructions {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0.25rem;
    font-size: 0.8125rem;
}

.error-banner-instructions p {
    margin: 0.5rem 0;
}

.error-banner-instructions code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875em;
}

.error-banner-instructions a {
    color: #0066cc;
    text-decoration: underline;
}

.error-banner-instructions a:hover {
    color: #0052a3;
}

.error-banner-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #856404;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.error-banner-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
}

/* Filter Error Message Styles */
.filter-error {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #FFE5E5;
    border-left: 3px solid #DC3545;
    border-radius: 0.25rem;
    color: #721c24;
    font-size: 0.875rem;
    line-height: 1.5;
}

.filter-error::before {
    content: "⚠️ ";
    font-size: 1rem;
    margin-right: 0.5rem;
}

/* Filter Loading Overlay */
.filter-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 10;
    border-radius: 0.5rem;
}

.filter-loading span {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Small Spinner for Inline Loading */
.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top: 2px solid #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Filter Dropdown Error State */
.filter-error-state {
    border-color: #DC3545 !important;
    background: #FFF5F5 !important;
}

.filter-error-state:focus {
    outline: none;
    border-color: #DC3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

.filter-error-state:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Filter Controls Container */
#filter-controls {
    position: relative;
}


/* Flood Details Container */
#flood-details {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Flood Details - Minimal */
.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
    min-height: 2.5rem;
}

.detail-item:last-of-type {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #000;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-value {
    color: #666;
    font-size: 0.8rem;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Highlighted Event ID */
.detail-item-highlighted {
    background: #f0f8ff;
    /* Keep the highlighted row inside the modal body padding to avoid horizontal clipping */
    margin: 0;
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--primary-color) !important;
}

.detail-item-highlighted .detail-label {
    color: var(--primary-color);
    font-weight: 600;
}

.detail-item-highlighted .detail-value {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Detail sections for grouped information */
.detail-section {
  margin-bottom: 1.5rem;
}

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

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* Community Actions Section */
.community-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Report Issue Button */
.btn-report {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    background: var(--background-primary);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 0;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    width: auto;
    min-width: 200px;
}

.btn-report:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-report:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-report svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Admin action buttons in table */
.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.admin-actions .action-button {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  font-size: 0.7rem;
  min-width: auto;
}

.action-approve {
  color: var(--accent-green, #28a745);
  border-color: var(--accent-green, #28a745);
}

.action-approve:hover {
  background: var(--accent-green, #28a745);
  color: white;
}

.action-reject {
  color: #dc3545;
  border-color: #dc3545;
}

.action-reject:hover {
  background: #dc3545;
  color: white;
}

/* Verification Status Badges */
.status-verified {
    color: var(--accent-green);
    font-weight: 500;
    padding: 2px 8px;
    border: 1px solid var(--accent-green);
    border-radius: 3px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.status-unverified {
    color: var(--text-muted);
    padding: 2px 8px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.status-disputed {
    color: #ff6b6b;
    font-weight: 500;
    padding: 2px 8px;
    border: 1px solid #ff6b6b;
    border-radius: 3px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Leaflet Popup Customization - Minimal */
.leaflet-popup-content-wrapper,
.minimal-popup .leaflet-popup-content-wrapper {
    background: white;
    border-radius: 2px; /* Slight rounding for softer look */
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    border: 1px solid #000;
}

/* Popup animations */
.leaflet-popup {
    animation: popupAppear 200ms ease-out;
}

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

.leaflet-popup-tip {
    background: white;
    border: 1px solid #000;
    box-shadow: none;
    margin-top: -1px; /* Fix tip alignment */
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
    min-width: 150px;
}

.leaflet-popup-close-button {
    display: none;
}

/* Minimal cluster styles */
.minimal-cluster {
    background: transparent !important;
}

/* Minimal tooltip styles */
.minimal-tooltip {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border: none;
    border-radius: 2px;
    padding: 4px 8px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.minimal-tooltip::before {
    display: none;
}

.leaflet-tooltip::before,
.leaflet-tooltip::after {
    display: none;
}

/* Remove Leaflet default popup completely */
.leaflet-popup {
    display: none !important;
}

/* SVG Marker Optimization for crisp rendering */
.leaflet-overlay-pane svg {
    shape-rendering: geometricPrecision;
    will-change: transform;
}

.leaflet-overlay-pane svg path {
    shape-rendering: geometricPrecision;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

/* Hover effect for markers */
.leaflet-interactive {
    cursor: pointer;
    transition: stroke-width 150ms ease, fill-opacity 150ms ease;
}

.leaflet-interactive:hover {
    stroke-width: 3 !important;
    fill-opacity: 0.9 !important;
}

/* Ensure crisp rendering on high DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .leaflet-overlay-pane svg path {
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}

/* Cluster improvements */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: none;
}

.leaflet-popup-content {
    margin: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.popup-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
    font-size: 0.95rem;
}

.popup-info {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    font-size: 0.8rem;
}

.popup-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: var(--text-inverse);
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    margin-top: var(--spacing-sm);
    transition: all var(--transition-base);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.popup-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ===========================================================
   App footer — editorial masthead bar
   Single line: signature on the left, italic-serif action menu
   on the right with thin dot separators, GitHub mark at the end.
   =========================================================== */
.footer {
    background: var(--background-primary);
    border-top: 1px solid var(--border-light);
    padding: 0.7rem 0;
    flex-shrink: 0;
    color: var(--text-primary);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0 1.5rem;
    flex-wrap: nowrap;
    min-width: 0;
}

/* Left: signature credit (already styled in .footer-credit / .footer-signature) */
.footer-credit { flex: 0 0 auto; }

/* Right: editorial nav */
.footer-nav {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.footer-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.92rem;
    line-height: 1.2;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: color var(--transition-fast);
    letter-spacing: 0;
    white-space: nowrap;
}
.footer-link:hover { color: var(--primary-color); }
.footer-link:focus-visible {
    outline: none;
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.footer-dot {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    user-select: none;
}

.footer-github {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}
.footer-github:hover { color: var(--primary-color); }

/* Mobile: stack credit above nav, both centered */
@media (max-width: 720px) {
    .footer-content {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 0 1rem;
    }
    .footer-nav { justify-content: center; gap: 0.45rem; }
    .footer-link { font-size: 0.86rem; }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-in;
    -webkit-overflow-scrolling: touch;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--background-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-overflow-scrolling: touch;
    will-change: transform, opacity;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.modal-close {
    background: none;
    border: none;
    outline: none;
    box-shadow: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-close:focus {
    outline: none;
    box-shadow: none;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== QUERY BUILDER MODAL =====
   Editorial layout matching the FBC sidebar: serif eyebrow + italic title,
   hairline dividers, no nested boxed cards. */
.sql-filter-modal .modal-content {
    max-width: 720px;
    background: var(--background-primary);
}

.sql-filter-modal .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 1rem;
    background: var(--background-primary);
    border-bottom: 1px solid var(--text-primary);
}

.sql-filter-modal .modal-header::before {
    content: 'filter by';
    position: absolute;
    margin-top: -0.65rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0;
}

.sql-filter-modal .modal-header h3 {
    margin-top: 0.85rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 1.45rem;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--text-primary);
    text-transform: none;
}

.sql-filter-modal .modal-close {
    color: var(--text-muted);
    background: none;
    opacity: 1;
    margin-top: 0.25rem;
    transition: color var(--transition-fast);
}

.sql-filter-modal .modal-close:hover {
    color: var(--primary-color);
    background: none;
}

.sql-filter-modal .modal-body {
    padding: 1.25rem 1.5rem 1.5rem;
    background: var(--background-primary);
}

/* Query Conditions Container — no outer card, just rhythm */
.query-conditions {
    margin-bottom: 1.25rem;
    padding: 0;
    background: transparent;
    border: none;
    min-height: 64px;
}

.query-conditions:empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-light);
}

.query-conditions:empty::before {
    content: 'No conditions yet — add one below to begin.';
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Condition Row — editorial row with hairline divider */
.query-condition-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    margin: 0;
    transition: background var(--transition-fast);
}

.query-condition-row:hover {
    background: rgba(0, 0, 0, 0.025);
}

.query-condition-row.grouped {
    margin-left: 0;
    border-left: none;
}

/* Condition Inputs - Unified Style */
.condition-logic,
.condition-field,
.condition-operator,
.condition-value {
    flex-shrink: 0;
}

.condition-logic {
    width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.condition-field {
    width: 140px;
}

.condition-operator {
    width: 140px;
}

.condition-value {
    flex: 1;
    min-width: 150px;
}

/* ── Editorial select trigger (replaces native <select>) ──────────────── */
.eds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    height: 38px;
    padding: 0 0.15rem;
    margin: 0;
    border: none;
    border-bottom: 1px solid var(--text-primary);
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.eds-btn .eds-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.eds-btn .eds-chev {
    flex-shrink: 0;
    color: var(--text-primary);
    transition: transform var(--transition-fast);
}

.eds-btn:hover {
    background-color: rgba(0, 0, 0, 0.025);
}

.eds-btn:focus-visible,
.eds-btn.is-open {
    outline: none;
    background-color: rgba(0, 0, 0, 0.04);
    border-bottom-color: var(--primary-color);
    box-shadow: inset 0 -2px 0 0 var(--primary-color);
}

.eds-btn.is-open .eds-chev { transform: rotate(180deg); }

.eds-btn .eds-value.is-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Field & value variants keep the editorial serif italic voice */
.eds-btn--field .eds-value,
.eds-btn--value .eds-value {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1rem;
}

.eds-btn--logic {
    border-bottom-color: var(--border-light);
}
.eds-btn--logic .eds-value {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
}

.eds-btn--operator .eds-value {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Numeric / free-text value input matches the editorial select look */
.eds-input {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    padding: 0 0.15rem;
    margin: 0;
    border: none;
    border-bottom: 1px solid var(--text-primary);
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1rem;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.eds-input::-webkit-outer-spin-button,
.eds-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.eds-input:hover { background-color: rgba(0, 0, 0, 0.025); }

.eds-input:focus {
    outline: none;
    background-color: rgba(0, 0, 0, 0.04);
    border-bottom-color: var(--primary-color);
    box-shadow: inset 0 -2px 0 0 var(--primary-color);
}

.eds-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
    opacity: 1;
}

/* ── Editorial popover (custom dropdown panel) ────────────────────────── */
.eds-popover {
    position: fixed;
    z-index: 11000;
    min-width: 200px;
    max-width: 360px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    background: var(--background-primary);
    border: 1px solid var(--text-primary);
    box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.22),
                0 4px 8px -4px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    animation: edsPopIn 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.eds-search-wrap {
    padding: 0.55rem 0.85rem 0.45rem;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.eds-search {
    width: 100%;
    padding: 0.25rem 0;
    border: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.eds-search:focus { border-bottom-color: var(--primary-color); }
.eds-search::placeholder { color: var(--text-muted); }

.eds-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.eds-group {
    padding: 0.6rem 0.95rem 0.25rem;
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.eds-option {
    display: block;
    width: 100%;
    padding: 0.45rem 0.95rem;
    border: none;
    background: transparent;
    text-align: left;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.eds-popover--operator .eds-option,
.eds-popover--logic .eds-option {
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

.eds-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.eds-option.is-active {
    background: var(--primary-color);
    color: var(--text-inverse);
    font-weight: 500;
}

.eds-empty {
    padding: 0.85rem 0.95rem;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.condition-where {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 38px;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
}

/* Remove Button — editorial × */
.condition-remove {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.condition-remove:hover {
    color: var(--primary-color);
    background: transparent;
}

.condition-remove svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* Query Group — editorial subgrouping with hairline frame */
.query-group {
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    margin: 0.5rem 0;
    padding: 0;
}

.query-group:first-child {
    border-top: none;
}

.query-group:last-child {
    margin-bottom: 0;
}

.query-group-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0 0.4rem;
    background: transparent;
    border: none;
}

.query-group-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0;
    text-transform: none;
}

.query-group-header .condition-logic {
    width: auto;
}

.query-group-header .condition-logic select {
    height: 26px !important;
    font-size: 0.65rem !important;
    padding: 0 1.2rem 0 0 !important;
}

.query-group-actions {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
}

.query-group-actions .btn-add-condition {
    height: auto;
    padding: 0;
    font-size: 0.8rem;
    border: none;
    background: transparent;
}

.query-group-conditions {
    padding: 0 0 0.4rem 0.85rem;
    border-left: 1px solid var(--border-light);
    margin-left: 0.1rem;
}

.query-group-conditions .query-condition-row {
    background: transparent;
}

/* Add Buttons — editorial italic links matching .fbc-link */
.query-builder-controls {
    display: flex;
    gap: 1.25rem;
    margin: 1rem 0 1.25rem;
}

.btn-add-condition,
.btn-add-group {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    height: auto;
    padding: 0.25rem 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-add-condition::after,
.btn-add-group::after {
    content: '+';
    font-family: var(--font-sans);
    font-style: normal;
    font-size: 0.95rem;
    color: inherit;
    transition: transform var(--transition-fast);
}

.btn-add-condition:hover,
.btn-add-group:hover {
    color: var(--primary-color);
    background: none;
}

.btn-add-condition:hover::after,
.btn-add-group:hover::after {
    transform: translateY(-1px);
}

/* Hide the original SVG icons — replaced by the css ::after symbol */
.btn-add-condition svg,
.btn-add-group svg {
    display: none;
}

/* Query Preview — editorial monospace block, no card chrome */
.query-preview {
    margin: 0 0 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.query-preview label {
    display: block;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    text-transform: none;
    letter-spacing: 0;
}

.query-preview-text {
    background: transparent;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-primary);
    min-height: auto;
    word-break: break-word;
}

.query-preview-text em {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.query-preview-text .query-field {
    color: var(--text-primary);
    font-weight: 600;
}

.query-preview-text .query-operator {
    color: var(--text-secondary);
}

.query-preview-text .query-value {
    color: var(--text-primary);
}

.query-preview-text .query-logic {
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Error Message — editorial inline note */
.sql-filter-error {
    background: transparent;
    border: none;
    border-top: 1px solid var(--text-primary);
    color: var(--text-primary);
    padding: 0.65rem 0 0;
    margin: 0 0 1rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.92rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.sql-filter-error::before {
    content: '—';
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

/* Action Buttons — primary stays solid black, secondary is editorial link */
.sql-filter-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.sql-filter-actions .btn-primary {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 0.65rem 1.5rem;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
}

.sql-filter-actions .btn-secondary {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 0.25rem 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    text-transform: none;
    letter-spacing: 0;
    border-radius: 0;
}

.sql-filter-actions .btn-secondary:hover {
    background: none;
    color: var(--primary-color);
    border: none;
}

/* Active Filter Indicator — editorial summary line */
.sql-filter-active {
    margin-top: 1.25rem;
    padding: 0.85rem 0 0;
    background: transparent;
    border: none;
    border-top: 1px solid var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
}

.sql-active-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

.sql-filter-active code,
.sql-filter-active #sql-active-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.5;
    padding-right: 1.75rem;
}

.btn-clear-sql {
    position: absolute;
    top: 0.6rem;
    right: 0;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.btn-clear-sql:hover {
    color: var(--primary-color);
    background: transparent;
    border: none;
}

/* ===== RESPONSIVE QUERY BUILDER ===== */
@media (max-width: 700px) {
    .sql-filter-modal .modal-content {
        max-width: 100%;
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .query-condition-row {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .condition-logic {
        width: 100%;
        order: -1;
    }

    .condition-field,
    .condition-operator {
        width: calc(50% - 0.25rem);
    }

    .condition-value {
        width: 100%;
    }

    .condition-remove {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }

    .query-condition-row {
        position: relative;
        padding-right: 2.5rem;
    }

    .query-builder-controls {
        flex-direction: column;
    }

    .btn-add-condition,
    .btn-add-group {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sql-filter-modal .modal-body {
        padding: 1rem;
    }

    .condition-field,
    .condition-operator {
        width: 100%;
    }

    .query-group-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

.reference-item {
    margin-bottom: 1.5rem;
}

.reference-item:last-child {
    margin-bottom: 0;
}

.reference-item strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.reference-item .citation-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 0.5px;
}

.reference-item p {
    margin: 0;
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.reference-item p:not(.citation-label) {
    color: var(--text-primary);
}

.reference-item a {
    color: var(--accent-blue);
    text-decoration: none;
    word-break: break-all;
}

.reference-item a:hover {
    text-decoration: underline;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

/* Welcome Modal Specific Styles */
.welcome-modal .modal-content {
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
}

.welcome-intro {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.welcome-intro p {
    margin: 0;
}

.welcome-logo-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.welcome-logo {
    height: 52px;
    width: auto;
    flex-shrink: 0;
    object-fit: contain;
}

.welcome-research {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.welcome-research p {
    margin: 0;
}

.welcome-research .welcome-logo-row {
    align-items: center;
}

.welcome-research .welcome-logo-row p + p {
    margin-top: 0.15rem;
    font-size: 0.85rem;
}

.welcome-citation {
    background: #f8f9fa;
    padding: 1.25rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 1.5rem;
}

.citation-primary,
.citation-secondary {
    margin-bottom: 1rem;
}

.citation-secondary {
    margin-bottom: 0;
}

.citation-label {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.welcome-citation p:not(.citation-label) {
    font-size: 0.85rem;
    line-height: 1.7;
    margin: 0;
    color: var(--text-primary);
}

.welcome-citation a {
    color: var(--text-primary);
    text-decoration: underline;
    word-break: break-word;
}

.welcome-citation a:hover {
    text-decoration: none;
}

.welcome-footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-welcome-enter {
    padding: 0.875rem 2rem;
    min-height: 44px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-welcome-enter:hover {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-welcome-enter:active {
    transform: translateY(0);
}

/* Welcome Modal Animation */
@keyframes welcomeSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.welcome-modal.active .modal-content {
    animation: welcomeSlideIn 0.4s ease-out;
}

/* Success banner */
.success-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: #d4edda;
  border-bottom: 2px solid #28a745;
  padding: 1rem;
  display: none;
  animation: slideDown 0.3s ease-out;
}

.success-banner.active {
  display: block;
}

.success-banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.success-banner-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.success-banner-message {
  flex: 1;
  color: #155724;
  font-size: 0.875rem;
}

.success-banner-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #155724;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.success-banner-close:hover {
  opacity: 0.7;
}

/* Individual lagoon centroid marker */
.lagoon-marker {
    width: 14px;
    height: 14px;
    border: 2.5px solid;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lagoon-marker:hover {
    transform: scale(1.35);
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

/* Cluster icons */
.minimal-cluster {
    background: transparent !important;
}

.cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #000;
    border: 2px solid #aaa;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    position: relative;
}

.cluster-badge {
    position: absolute;
    bottom: -6px;
    color: #fff;
    border: 1.5px solid #fff;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: 600;
    line-height: 13px;
    text-align: center;
    padding: 0 3px;
    font-family: 'Inter', sans-serif;
}

.badge-high   { background: #dc2626; right: -8px; bottom: 0px; }
.badge-medium { background: #f97316; left: 50%; bottom: -7px; transform: translateX(-50%); }
.badge-low    { background: #0d9488; left: -8px; bottom: 0px; }

/* Marker Cluster Customization */
.marker-cluster {
    background: transparent;
    border: none;
    box-shadow: none;
}

.marker-cluster div {
    background: var(--background-secondary);
    color: #111;
    font-weight: 600;
}

/* Custom Scrollbar for Body */
body::-webkit-scrollbar {
    width: 10px;
}

body::-webkit-scrollbar-track {
    background: var(--background-tertiary);
}

body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Body scroll lock when modal/sidebar is open */
body.modal-open,
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Login Page Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--spacing-lg);
}

.login-card {
    max-width: 400px;
    width: 100%;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-lg);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--spacing-md);
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-input {
    width: 100%;
    padding: 0.875rem 1rem;
    min-height: 44px;
    background: var(--background-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 16px;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
    outline: none;
}

.login-input:focus {
    border-bottom-color: var(--primary-color);
}

.password-input-container {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    min-width: 32px;
    min-height: 32px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.login-button {
    width: 100%;
    padding: 0.875rem 1rem;
    min-height: 44px;
    background: var(--background-primary);
    color: var(--text-primary);
    border: 1px solid var(--primary-color);
    border-radius: 0;
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    position: relative;
}

.login-button:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.login-button.loading {
    opacity: 0.6;
    pointer-events: none;
}

.login-error {
    padding: 0.75rem;
    background: #FFE5E5;
    border-left: 3px solid #DC3545;
    border-radius: 0.25rem;
    color: #721c24;
    font-size: 0.875rem;
    line-height: 1.5;
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    font-weight: 600;
    color: var(--primary-color);
}

.auth-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--accent-green);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-sm) 0;
    min-width: 150px;
    z-index: 1050;
}

.user-menu-item {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background var(--transition-fast);
}

.user-menu-item:hover {
    background: var(--background-secondary);
}

.forgot-password-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.875rem;
    text-align: center;
    margin-top: var(--spacing-sm);
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.login-footer {
    text-align: center;
    margin-top: var(--spacing-md);
}

/* User menu in header */
.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  flex-wrap: nowrap;
}

.user-email {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: lowercase;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logout-btn {
  padding: 0.625rem 1.25rem;
  min-height: 44px;
  font-size: 0.75rem;
  background: var(--background-primary);
  border: 1px solid var(--primary-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  border-radius: 0;
  outline: none;
}

#logout-btn:hover {
  background: var(--primary-color);
  color: var(--text-inverse);
}

/* Confirmation modal specific styling */
#confirm-modal .modal-content {
  max-width: 400px;
}

#confirm-modal .modal-body {
  padding: 2rem 1.5rem;
}

#confirm-modal .modal-body p {
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 280px 1fr;
        gap: 0.75rem;
    }

    .header-nav {
        left: 1rem;
    }

    .header-actions {
        right: 1rem;
    }

    .nav-link {
        padding: 0.35rem 0.8rem;
        font-size: 0.65rem;
    }
}

@media (max-width: 768px) {
    /* Header adjustments */
    .header {
        padding: 0.75rem 0;
    }

    .header-content {
        padding: 0 1rem;
        display: flex;
        align-items: center;
        min-height: 50px;
    }

    /* Active filters adjustments for mobile */
    .active-filters-summary {
        padding: var(--spacing-sm);
    }

    .active-filters-list {
        gap: 0.4rem;
    }

    .filter-badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    .filter-badge-remove {
        width: 1rem;
        height: 1rem;
        font-size: 1rem;
    }

    /* Mobile filter toggle button - accommodate longer text */
    .mobile-toggle-btn {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 220px;
    }
}

@media (max-width: 480px) {
    /* Very narrow screens - show count only in filter toggle */
    .mobile-toggle-btn {
        max-width: 150px;
    }
}

@media (max-width: 768px) {
    /* Keep navigation on left, title centered on mobile */
    .header-nav {
        position: relative;
        left: 0;
        transform: none;
    }

    .header-title {
        flex: 1;
        text-align: center;
        padding: 0 0.5rem;
    }

    .header-actions {
        position: relative;
        right: 0;
        transform: none;
    }

    .header h1 {
        /* Italianno is calligraphic — needs visible size to read at all.
           Scale with viewport so it never collapses on narrow phones. */
        font-size: clamp(2rem, 8vw, 2.6rem);
        line-height: 0.9;
        margin: 0;
    }

    .nav-icon {
        width: 24px;
        height: 24px;
    }

    .subtitle {
        display: block;
        font-size: 0.65rem;
        line-height: 1.2;
        letter-spacing: 0.04em;
        margin-top: 0.1rem;
        /* Avoid awkward overflow if the header gets very tight */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-link {
        padding: 0.3rem 0.6rem;
        font-size: 0.6rem;
        min-width: auto;
    }

    /* Mobile controls visible — compact, not towering */
    .mobile-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0.4rem 0.75rem;
        gap: 0.4rem;
    }
    .mobile-toggle-btn {
        padding: 0.4rem 0.75rem;
        min-height: 32px;
        min-width: 0;
        font-size: 0.65rem;
        letter-spacing: 0.04em;
        flex: 0 1 auto;
    }

    /* Remove padding from main content on mobile */
    .main-content {
        grid-template-columns: 1fr;
        padding: 0;
        margin: 0;
        gap: 0;
    }

    /* Sidebar becomes full-height panel */
    .sidebar {
        background: var(--background-primary);
        border: none;
        border-bottom: 1px solid var(--border-color);
        margin: 0;
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.active {
        display: block;
        transform: translateX(0);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    /* Hide map when sidebar is active on mobile */
    .sidebar.active ~ .map-container {
        display: none;
    }

    .sidebar-content {
        padding: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* Show close button on mobile */
    .mobile-sidebar-close {
        display: block;
    }

    /* Show tab navigation on mobile too (vertical list) */
    .tab-nav {
        display: flex;
        flex-direction: column;
        margin-bottom: 0.75rem;
    }

    .tab-content {
        padding: 1rem;
        padding-top: 3rem; /* Space for close button */
        flex: 1;
        overflow-y: auto;
    }

    .filter-group {
        margin-bottom: 1rem;
    }

    .filter-group label {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }

    .filter-group select {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }

    /* Custom Dropdown Mobile Adjustments */
    .custom-dropdown input[type="text"] {
        padding: 0.6rem 2.5rem 0.6rem 0.8rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .custom-dropdown input[type="text"].has-value {
        padding-left: calc(0.8rem - 3px);
    }

    .dropdown-toggle {
        width: 2.5rem;
    }

    .dropdown-menu {
        max-height: min(300px, 40vh);
        border-radius: 0;
        z-index: 1100;
        contain: layout style;
        isolation: isolate;
        will-change: transform, opacity;
        transform: translateZ(0);
    }

    .dropdown-option {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    #stats-content .stat-item {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    /* Make map fill all available space.
       Use dvh so the visible map (and the status bar pinned to its bottom)
       never get pushed under the mobile URL bar / system UI. vh fallback
       for older browsers. */
    .map-container {
        flex: 1;
        position: relative;
        width: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: none;
        border-radius: 0;
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
    }

    #map {
        height: 100%;
        width: 100%;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(85vh - 60px);
    }

    /* Responsive button styling */
    .community-actions {
        margin-top: 1rem;
        padding-top: 1rem;
    }

    .btn-report {
        width: 100%;
        min-width: unset;
        font-size: 0.7rem;
        padding: 0.75rem 1rem;
    }

    .btn-report svg {
        width: 12px;
        height: 12px;
    }

    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.625rem 0;
    }

    .detail-value {
        text-align: left;
        max-width: 100%;
    }

    .footer-content {
        padding: 0 1rem;
        font-size: 0.7rem;
    }

    .footer {
        padding: 0.75rem 0;
    }

    .references-btn {
        font-size: 0.7rem;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body {
        padding: 1rem;
    }

    /* Welcome Modal Mobile Adjustments */
    .welcome-modal .modal-content {
        max-width: 95%;
        padding: 0;
    }

    .welcome-intro {
        font-size: 0.85rem;
    }

    .welcome-logo {
        height: 40px;
    }

    .welcome-intro,
    .welcome-research {
        font-size: 0.85rem;
    }

    .welcome-citation {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .welcome-citation p:not(.citation-label) {
        font-size: 0.8rem;
    }

    .welcome-footer {
        padding-top: 1rem;
    }

    .btn-welcome-enter {
        width: 100%;
        padding: 0.75rem 1.5rem;
        font-size: 0.8rem;
    }

    .reference-item {
        font-size: 0.85rem;
    }

    .year-range-inputs {
        flex-direction: column;
    }

    .year-range-select {
        flex: 1 1 100%;
    }

    /* Login page responsive */
    .login-container {
        padding: var(--spacing-md);
    }

    .login-card {
        padding: var(--spacing-lg);
        max-width: 100%;
    }

    .login-header {
        font-size: 1.25rem;
    }

    .login-input {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }

    .login-button {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .login-error {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    .user-menu {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-end;
    }

    .user-email {
        font-size: 0.65rem;
    }

    .admin-actions {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .admin-actions .action-button {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin-right: 0;
    }
}

/* New intermediate breakpoint for smoother transitions */
@media (max-width: 640px) {
    .header h1 {
        font-size: 1rem;
    }

    .nav-link {
        padding: 0.35rem 0.75rem;
        font-size: 0.65rem;
    }

    .mobile-toggle-btn {
        padding: 0.5rem 1rem;
        font-size: 0.65rem;
    }

    .footer-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        font-size: 0.7rem;
    }

    .footer-divider {
        display: none;
    }

    .stat-item {
        padding: 0.875rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .filter-badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .modal-content {
        width: 95%;
        max-width: 500px;
    }
}

@media (max-width: 480px) {
    .error-banner {
        padding: 0.75rem;
    }

    .error-banner-content {
        gap: 0.75rem;
    }

    .error-banner-icon {
        font-size: 1.25rem;
    }

    .error-banner-message strong {
        font-size: 0.9rem;
    }

    .error-banner-message p {
        font-size: 0.8125rem;
    }

    .error-banner-instructions {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .error-banner-close {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 1.25rem;
    }

    .filter-error {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    .header {
        padding: 0.5rem 0;
    }

    .header h1 {
        font-size: 0.95rem;
        letter-spacing: 0.05em;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }

    .subtitle {
        display: none;
    }

    .header-content {
        padding: 0 0.5rem;
        min-height: 45px;
    }

    .header-nav {
        gap: 0.25rem;
    }

    .nav-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.55rem;
        min-width: 50px;
    }

    .mobile-toggle-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.55rem;
    }

    .header-actions .btn-primary {
        padding: 0.25rem 0.5rem;
        font-size: 0.55rem;
    }

    .mobile-toggle-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.6rem;
    }

    .mobile-toggle-btn svg {
        width: 14px;
        height: 14px;
    }

    .map-container {
        height: calc(100vh - 110px);
        height: calc(100dvh - 110px);
        border: none;
    }

    .sidebar-content {
        padding: var(--spacing-lg);
    }

    .main-content {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    /* Login page responsive */
    .login-container {
        padding: var(--spacing-sm);
    }

    .login-card {
        padding: var(--spacing-md);
    }

    .login-header {
        font-size: 1.125rem;
        margin-bottom: var(--spacing-md);
    }

    .login-input {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .login-button {
        padding: 0.625rem;
        font-size: 0.75rem;
    }

    .login-error {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .auth-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    .user-menu {
        min-width: 120px;
    }

    .user-menu-item {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.8125rem;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .footer {
        display: none;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .header {
        border-bottom: 2px solid #000;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn var(--transition-base);
}

.slide-up {
    animation: slideUp var(--transition-slow);
}

/* Accessibility */
.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;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .dropdown-menu {
        border-width: 3px;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }

    .dropdown-option {
        border-bottom: 2px solid rgba(0, 0, 0, 0.2);
    }

    .dropdown-option:hover {
        background-color: rgba(51, 122, 183, 0.2);
        border-left-width: 3px;
    }

    .dropdown-option.selected {
        background-color: rgba(51, 122, 183, 0.25);
        border-left-width: 4px;
    }

    .dropdown-option:focus-visible {
        outline-width: 3px;
    }

    .dropdown-options::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.6);
    }
}

/* Measurement Tool Styles */
.measurement-control {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.measurement-control.leaflet-bar {
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    box-shadow: none;
    background-clip: padding-box;
}

.measurement-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    max-width: 34px;
    max-height: 34px;
    background: white;
    border: none;
    border-bottom: 1px solid #ccc;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 200ms ease;
    color: #333;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.measurement-btn:first-child {
    border-radius: 4px 4px 0 0;
}

.measurement-btn:last-child {
    border-radius: 0 0 4px 4px;
    border-bottom: none;
}

.measurement-btn:hover {
    background: #f5f5f5;
}

.measurement-btn.active {
    background: #0066ff;
    color: white;
}

.measurement-clear-btn {
    font-size: 16px;
}

.measurement-info {
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0;
    min-width: 200px;
    z-index: 1000;
}

.measurement-info-content {
    padding: 12px 16px;
    font-size: 13px;
    color: #333;
}

.measurement-title {
    font-weight: 600;
    color: #0066ff;
    margin-bottom: 8px;
    font-size: 14px;
}

.measurement-stat {
    padding: 4px 0;
    color: #555;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.measurement-hint {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .measurement-info {
        min-width: 180px;
    }

    .measurement-info-content {
        padding: 12px 14px;
        font-size: 12px;
    }

    .measurement-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .measurement-title {
        font-size: 13px;
    }

    .measurement-stat {
        font-size: 11px;
    }

    .measurement-hint {
        font-size: 10px;
    }
}


/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Performance Optimization */
.sidebar,
.map-container {
    will-change: auto; /* Only use will-change when actually animating */
}

.modal-content {
    contain: layout style;
}

/* Optimize Leaflet markers for canvas rendering */
.leaflet-overlay-pane canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Hardware acceleration for smooth animations */
.leaflet-popup-content-wrapper {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reduce paint areas */
.detail-item {
    contain: layout;
}

/* Optimize scrolling performance */
.sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
}

/* ===== SUBMIT DATA MODAL ===== */
.submit-data-modal .modal-content {
    max-width: 800px;
}

.submit-data-intro {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.submit-data-intro p {
    margin: 0;
}

.submit-data-section {
    margin-bottom: 1.5rem;
}

.submit-data-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.format-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1.5rem;
}

.format-list li {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.notes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notes-list li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.notes-list li:last-child {
    border-bottom: none;
}

/* Template Table */
.template-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.template-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.template-table th,
.template-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.template-table th {
    background: var(--background-tertiary);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.template-table td {
    color: var(--text-primary);
}

.template-table code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    color: var(--primary-color);
}

.template-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* Submit Data Actions */
.submit-data-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.submit-data-actions .btn-primary {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Welcome modal contribute link */
.welcome-contribute {
    margin-bottom: 1.5rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    text-align: center;
}

.welcome-contribute p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.welcome-contribute a {
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
}

.welcome-contribute a:hover {
    text-decoration: none;
}

/* Responsive Submit Data Modal */
@media (max-width: 768px) {
    .submit-data-modal .modal-content {
        max-width: 95%;
    }

    .submit-data-actions {
        flex-direction: column;
    }

    .format-list {
        flex-direction: column;
        gap: 0.5rem;
    }

    .template-table {
        font-size: 0.7rem;
    }

    .template-table th,
    .template-table td {
        padding: 0.5rem;
    }

    .template-table code {
        font-size: 0.65rem;
    }
}

/* ===== FILTER SELECTOR BUTTONS ===== */
.filter-selector {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: clamp(0.5rem, 1.6vh, 0.875rem) 1rem;
    min-height: clamp(34px, 6vh, 44px);
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: 0;
    font-size: clamp(0.8rem, 1.8vh, 0.875rem);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    font-family: inherit;
}

.filter-selector:hover {
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.02);
}

.filter-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.filter-selector.has-value {
    border-color: var(--primary-color);
    border-left-width: 3px;
    background: rgba(0, 0, 0, 0.02);
}

.filter-selector-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-selector.has-value .filter-selector-value {
    font-weight: 500;
    color: var(--primary-color);
}

.filter-selector-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    font-size: clamp(0.6rem, 1.3vh, 0.7rem);
    font-weight: 600;
    border-radius: 10px;
    white-space: nowrap;
}

.filter-selector-badge:empty {
    display: none;
}

.filter-selector-badge.badge-full {
    background: var(--primary-color);
    color: white;
}

.filter-selector-badge.badge-filtered {
    background: rgba(0, 0, 0, 0.45);
    color: white;
}

.filter-selector-arrow {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.filter-selector:hover .filter-selector-arrow {
    color: var(--primary-color);
}

/* ===== FILTER SELECTION MODAL ===== */
.filter-selection-modal .modal-content {
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.filter-selection-modal .modal-header {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-bottom: none;
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}

.filter-selection-modal .modal-header h3 {
    color: var(--text-inverse);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.filter-selection-modal .modal-close {
    color: var(--text-inverse);
    opacity: 0.8;
}

.filter-selection-modal .modal-close:hover {
    opacity: 1;
}

.filter-selection-modal .modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    /* Allow the modal body to scroll instead of the list box itself */
    overflow-y: auto;
    flex: 1;
}

.filter-modal-search {
    position: relative;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.filter-modal-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.filter-modal-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-modal-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.filter-modal-actions-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.btn-filter-modal-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
    font-family: inherit;
}

.btn-filter-modal-clear:hover {
    color: var(--primary-color);
}

.filter-modal-list {
    flex: 0 0 auto;
    overflow: visible;
    border: 1px solid var(--border-color);
    max-height: none;
}

.filter-modal-option {
    display: flex;
    align-items: center;
    padding: clamp(0.45rem, 1.4vh, 0.75rem) 1rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: clamp(0.8rem, 1.8vh, 0.875rem);
    /* Prevent long values from overflowing horizontally */
    overflow-wrap: anywhere;
    word-break: break-word;
}

.filter-modal-option:last-child {
    border-bottom: none;
}

.filter-modal-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.filter-modal-option.selected {
    background: rgba(0, 0, 0, 0.08);
    font-weight: 500;
}

.filter-modal-option.selected::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.filter-modal-no-results {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: clamp(0.8rem, 1.8vh, 0.875rem);
}

/* Currently selected option in modal */
.filter-modal-option.selected-current {
    background: rgba(0, 0, 0, 0.08);
    font-weight: 600;
    color: var(--primary-color);
    cursor: default;
    border-left: 3px solid var(--primary-color);
    padding-left: calc(1rem - 3px);
}

.filter-modal-option.selected-current:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Unavailable options section */
.filter-modal-unavailable-section {
    margin-top: 0.75rem;
    flex-shrink: 0;
}

.filter-modal-unavailable-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.filter-modal-unavailable-list {
    max-height: none;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-top: none;
    background: var(--background-tertiary);
}

.filter-modal-option.unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    background: transparent;
    color: var(--text-muted);
}

.filter-modal-option.unavailable:hover {
    background: transparent;
}

.filter-modal-unavailable-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.filter-modal-footer {
    flex-shrink: 0;
    padding-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
}

/* Responsive filter modal */
@media (max-width: 480px) {
    .filter-selection-modal .modal-content {
        max-width: 95%;
        max-height: 80vh;
    }

    .filter-modal-list {
        max-height: none;
    }
}

/* Extra-tight vertical layouts (short viewports): shrink spacing a bit more so the filter panel stays scroll-free */
@media (max-height: 650px) {
    .sidebar-content {
        padding: 0.75rem;
    }

    .filter-group {
        margin-bottom: 0.6rem;
    }

    #sql-filter-btn,
    #clear-filters {
        margin-top: 0.5rem !important;
    }
}

/* ===== LAGOON HOVER CARD ===== */
.leaflet-tooltip.custom-tooltip {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
    padding: 0;
    pointer-events: auto;
    overflow: hidden;
    opacity: 1 !important;
}

.leaflet-tooltip.custom-tooltip .leaflet-tooltip-content {
    margin: 0;
    padding: 0;
}

.lagoon-hover-card {
    width: min(290px, calc(100vw - 40px));
    background: #ffffff;
    overflow: hidden;
    font-family: var(--font-sans);
}

.lagoon-hover-preview {
    width: 100%;
    height: 130px;
    border-bottom: 1px solid var(--border-light);
    background: #f3f4f6;
    overflow: hidden;
}

.lagoon-preview-map {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
}

.lagoon-hover-body {
    padding: 0.7rem 0.85rem 0.75rem;
}

/* Eyebrow */
.lagoon-hover-eyebrow {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

/* Name line: serif EN + thin slash + italic GR */
.lagoon-hover-name {
    margin: 0 0 0.35rem;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--primary-color);
    letter-spacing: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
}

.lagoon-hover-name-en { color: var(--primary-color); }

.lagoon-hover-name-sep {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 0.85em;
    color: var(--text-muted);
    user-select: none;
}

.lagoon-hover-name-gr {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.78em;
    color: var(--text-secondary);
}

/* Locality */
.lagoon-hover-locality {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-serif);
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0 0 0.55rem;
}

.lagoon-hover-pin {
    width: 0.85em;
    height: 0.85em;
    flex: 0 0 auto;
    color: var(--text-secondary);
    opacity: 0.6;
}

.lagoon-hover-loc-main {
    font-style: italic;
    font-weight: 500;
    color: var(--text-primary);
}

.lagoon-hover-loc-dot {
    color: var(--text-muted);
    font-weight: 700;
}

.lagoon-hover-loc-island {
    font-style: italic;
    color: var(--text-secondary);
}

/* Stats grid */
.lagoon-hover-stats {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px dashed var(--border-light);
    padding-top: 0.4rem;
}

.lagoon-hover-stat {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 1.55rem;
    padding: 0.2rem 0;
    line-height: 1.2;
}

.lagoon-hover-stat-label {
    flex: 0 0 auto;
}

.lagoon-hover-stat .lagoon-hover-basis-tag {
    flex: 0 0 auto;
}

.lagoon-hover-stat-value {
    flex: 0 0 auto;
    margin-left: auto;
    text-align: right;
}

.lagoon-hover-basis-tag.is-empty {
    visibility: hidden;
    width: 2.4rem;
}

.lagoon-hover-stat + .lagoon-hover-stat {
    border-top: 1px dashed var(--border-light);
}

.lagoon-hover-stat-label {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
}

.lagoon-hover-stat-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.2;
}

.lagoon-hover-stat .inundation-badge {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.12rem 0.42rem;
    line-height: 1.2;
}

/* Provenance tag — minimal italic serif footnote (no box, no caps shouting) */
.lagoon-hover-basis-tag {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.7rem;
    text-transform: lowercase;
    letter-spacing: 0;
    padding: 0;
    border: none;
    background: none;
    line-height: 1.2;
    color: var(--text-muted);
}

.lagoon-hover-basis-tag.is-VLM { color: var(--text-secondary); }
.lagoon-hover-basis-tag.is-geo { color: var(--text-muted); }

/* ===== LAGOON MODAL PREVIEW ===== */
.lagoon-modal-preview-panel {
    margin-bottom: 1.1rem;
}

.lagoon-modal-preview-map {
    width: 100%;
    height: 230px;
    border: 1px solid #0f172a;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.lagoon-modal-details-grid .detail-item:first-child {
    border-top: 1px solid #f0f0f0;
}

@media (max-width: 768px) {
    .lagoon-hover-card {
        width: min(260px, calc(100vw - 36px));
    }

    .lagoon-hover-preview {
        height: 122px;
    }

    .lagoon-modal-preview-map {
        height: 185px;
    }
}

/* ===============================================
   Statistics Panel — journal-grade descriptive stats
   =============================================== */

.statistics-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-feature-settings: "tnum" 1, "lnum" 1;
}

.stats-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.stats-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stats-sample {
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: 0.04em;
}

/* Variable button reuses .filter-selector — only group spacing + badge here */
.stats-field-group {
    margin: 0;
}

.stats-field-group .filter-selector {
    align-items: center;
    gap: 0.5rem;
}

.stats-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.5rem;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: var(--text-inverse);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto;
    margin-right: 0.4rem;
    line-height: 1;
}

.stats-type-badge.is-categorical {
    background: var(--background-primary);
    color: var(--primary-color);
}

/* Variable selection modal options */
.stats-variable-modal .filter-modal-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* ==========================================================================
   Variable picker modal — editorial table of contents
   Sections appear as sideheads with hairline rules. Options are clean lines:
   serif label … italic type marker, no bordered rows, no badges.
   ========================================================================== */

/* Drop the boxy outer border around the list */
.stats-variable-modal .filter-modal-list {
    border: none;
    padding: 0 0.25rem 0.5rem;
}

/* Section heading: italic serif + extending hairline */
.stats-variable-modal .stats-variable-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    padding: 1.5rem 0.75rem 0.45rem;
    border: none;
    background: transparent;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.92rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-primary);
}
.stats-variable-modal .stats-variable-group:first-child {
    padding-top: 0.4rem;
}
.stats-variable-modal .stats-variable-group::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: var(--border-light);
}

/* Options — clean rows, no borders, with a left gutter for the selected dot */
.stats-variable-modal .filter-modal-option {
    border: none;
    padding: 0.5rem 0.75rem 0.5rem 1.65rem;
    cursor: pointer;
    display: flex !important;
    align-items: baseline;
    gap: 0.6rem;
    position: relative;
    transition: background var(--transition-fast);
    overflow-wrap: anywhere;
}
.stats-variable-modal .filter-modal-option:hover {
    background: rgba(0, 0, 0, 0.03);
}
.stats-variable-modal .filter-modal-option:last-child { border: none; }

/* Selected-current bullet */
.stats-variable-modal .filter-modal-option.selected-current::before {
    content: '';
    position: absolute;
    left: 0.7rem;
    top: 50%;
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    transform: translateY(-50%);
}
.stats-variable-modal .filter-modal-option.selected-current {
    background: transparent;
}

/* Variable label — serif, slim weight, hover underline */
.stats-variable-modal .stats-variable-main {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-serif);
    font-size: 0.98rem;
    font-weight: 400;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stats-variable-modal .filter-modal-option:hover .stats-variable-main {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--border-color);
}
.stats-variable-modal .filter-modal-option.selected-current .stats-variable-main {
    color: var(--primary-color);
    font-weight: 500;
}

/* Type marker — quiet italic suffix, NO badge */
.stats-variable-modal .stats-variable-type {
    flex: 0 0 auto;
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.78rem;
    line-height: 1.2;
    text-transform: lowercase;
    letter-spacing: 0;
    color: var(--text-muted);
    border: none;
    background: transparent;
    padding: 0;
    border-radius: 0;
}
.stats-variable-modal .stats-variable-type.is-numeric,
.stats-variable-modal .filter-modal-option.selected-current .stats-variable-type.is-numeric {
    color: var(--text-muted);
    border: none;
    background: transparent;
}

/* Search input above the list — make it editorial too */
.stats-variable-modal .filter-modal-search {
    padding: 0.4rem 0.75rem 0.6rem;
    border-bottom: 1px solid var(--border-light);
}
.stats-variable-modal .filter-modal-search-input {
    width: 100%;
    padding: 0.35rem 0.05rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.stats-variable-modal .filter-modal-search-input:focus { border-bottom-color: var(--primary-color); }
.stats-variable-modal .filter-modal-search-input::placeholder { color: var(--text-muted); }

/* "No matching variables" empty state */
.stats-variable-modal .filter-modal-no-results {
    padding: 2rem 0.75rem;
    text-align: center;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
}

/* Figure */
.stats-figure {
    margin: 0;
    border: 1px solid var(--primary-color);
    background: var(--background-primary);
    padding: 0.75rem 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stats-figcaption {
    display: flex;
    gap: 0.45rem;
    align-items: baseline;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.4;
    color: var(--text-secondary);
    border-bottom: 1px dashed var(--border-light);
    padding-bottom: 0.55rem;
    letter-spacing: 0.005em;
}

.stats-fig-num {
    font-family: var(--font-sans);
    font-weight: 700;
    font-style: normal;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.62rem;
    flex: 0 0 auto;
}

.stats-chart-wrap {
    width: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.stats-axis-label {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    padding-top: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stats-axis-scale-tag {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 0.12rem 0.4rem;
    background: var(--primary-color);
    color: var(--text-inverse);
    line-height: 1;
}

/* SVG primitives */
.stats-axis-line,
.stats-tick {
    stroke: var(--primary-color);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.stats-gridline {
    stroke: #e6e6e6;
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.stats-tick-label {
    font-size: 9px;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, monospace;
    fill: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.stats-bar {
    fill: var(--primary-color);
    transition: fill var(--transition-fast);
    cursor: pointer;
}

.stats-bar-numeric {
    stroke: var(--background-primary);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.stats-bar:hover {
    fill: var(--accent-blue);
}

.stats-bar-cat.is-other {
    fill: var(--text-muted);
}

.stats-bar-track {
    stroke: #ececec;
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.stats-cat-label {
    font-size: 10px;
    fill: var(--text-primary);
    font-weight: 500;
}

.stats-cat-label.is-other {
    fill: var(--text-muted);
    font-style: italic;
}

.stats-bar-value {
    font-size: 10px;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    fill: var(--primary-color);
    font-weight: 600;
}

.stats-refline {
    stroke-width: 1;
    stroke-dasharray: 3 3;
    shape-rendering: crispEdges;
    pointer-events: none;
}

.stats-refline.is-median {
    stroke: var(--accent-blue);
}

.stats-refline.is-mean {
    stroke: var(--accent-green);
}

.stats-reflabel {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.stats-reflabel.is-median { fill: var(--accent-blue); }
.stats-reflabel.is-mean   { fill: var(--accent-green); }

/* Summary rows: LABEL …………… VALUE (dotted leader, journal style) */
.stats-summary {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--primary-color);
}

.stats-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.78rem;
    border-bottom: 1px dashed var(--border-light);
}

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

.stats-row:nth-child(odd) {
    background: var(--background-tertiary);
}

.stats-row-label {
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    font-weight: 600;
    flex: 0 0 auto;
}

.stats-row-leader {
    flex: 1 1 auto;
    height: 1px;
    align-self: end;
    margin-bottom: 0.35em;
    background-image: radial-gradient(circle, var(--text-muted) 0.6px, transparent 0.6px);
    background-size: 4px 1px;
    background-position: bottom;
    background-repeat: repeat-x;
    opacity: 0.5;
}

.stats-row-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, monospace;
    font-size: 0.78rem;
    text-align: right;
    flex: 0 0 auto;
    white-space: nowrap;
}

.stats-empty {
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    border: 1px dashed var(--border-light);
    width: 100%;
}

.stats-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0;
    border-left: 2px solid var(--primary-color);
    padding-left: 0.6rem;
}

/* Tooltip */
.stats-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: var(--primary-color);
    color: var(--text-inverse);
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--primary-color);
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* The statistics tab content needs to scroll if summary is tall */
#statistics-tab.tab-content.active {
    overflow-y: auto;
}

/* Statistics: bin/category drill-down modal rows */
.stats-bin-modal .stats-bin-summary {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--primary-color);
    margin-bottom: 0.75rem;
    background: var(--background-tertiary);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stats-bin-summary-count {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: 0.04em;
}

/* Inherit base list-row look from .filter-modal-option; only add layout */
.stats-bin-option {
    width: 100%;
    gap: 0.75rem;
    text-align: left;
    background: var(--background-primary);
    color: var(--text-primary);
    font-family: inherit;
    border: none;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
}

.stats-bin-option:last-child {
    border-bottom: none;
}

.stats-bin-option:hover .stats-bin-sub,
.stats-bin-option:hover .stats-bin-value {
    color: inherit;
}

.stats-bin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.stats-bin-name {
    font-weight: 600;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-bin-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-bin-value {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

/* Statistics: variable label row + glossary trigger */
.stats-field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
}

.stats-field-row .search-label {
    margin: 0;
}

.stats-glossary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: 1px dashed var(--border-light);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.stats-glossary-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-style: solid;
}

.stats-glossary-btn svg {
    flex: 0 0 14px;
    stroke: currentColor;
}

/* Categorical "Other" overflow cap (diagonal stripe end) */
.stats-bar-overflow-cap {
    fill: var(--text-inverse);
    fill-opacity: 0.92;
    pointer-events: none;
    /* Stripes via SVG would need a pattern; keep a solid white cap as a clear "truncation marker" */
}

.stats-bar-cat.is-overflow {
    /* Subtle hatched feel via stroke-dash on right edge */
    stroke: var(--background-primary);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

/* Glossary modal */
.stats-glossary-modal .modal-content {
    max-width: 720px;
    width: 92%;
    background: var(--background-primary);
    border: 1px solid var(--primary-color);
}

.stats-glossary-modal .modal-header h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.25rem;
    letter-spacing: 0.005em;
}

.stats-glossary-lead {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
    margin: 0 0 1rem;
    border-left: 2px solid var(--primary-color);
    padding-left: 0.75rem;
}

.stats-glossary-section {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--primary-color);
    margin: 1.1rem 0 0.45rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--primary-color);
}

.stats-glossary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
}

.stats-glossary-table thead th {
    text-align: left;
    font-family: var(--font-sans);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--primary-color);
    background: var(--background-tertiary);
}

.stats-glossary-table tbody td {
    padding: 0.5rem 0.5rem;
    vertical-align: top;
    border-bottom: 1px dashed var(--border-light);
}

.stats-glossary-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-glossary-table tbody td:first-child {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--primary-color);
    white-space: nowrap;
    width: 1%;
}

.stats-glossary-table tbody td:nth-child(2) {
    font-weight: 600;
    white-space: nowrap;
    width: 1%;
}

.stats-glossary-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.stats-glossary-list li {
    margin-bottom: 0.35rem;
}

.stats-glossary-list .is-mean   { color: var(--accent-green); font-weight: 700; }
.stats-glossary-list .is-median { color: var(--accent-blue);  font-weight: 700; }

/* Summary table head bar (eyebrow + glossary trigger) */
.stats-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin: 0 0 0.4rem;
    min-height: 2rem;
}

.stats-summary-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.25;
}

/* Inline italic note inside glossary table cells */
.stats-glossary-note {
    display: inline-block;
    margin-top: 0.15rem;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* ================================================
   Lagoon detail modal — grouped sections + scenarios
   ================================================ */

.lagoon-modal-section {
    margin-bottom: 1.25rem;
}

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

.lagoon-modal-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--primary-color);
}

.lagoon-modal-section-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin: 0;
}

/* Scenario blocks */
.lagoon-modal-scenarios {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.lagoon-scenario {
    border: 1px solid var(--border-light);
    background: var(--background-primary);
    padding: 0.85rem 1rem 0.75rem;
}

.lagoon-scenario-head {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
}

.lagoon-scenario-name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--primary-color);
    letter-spacing: 0;
    line-height: 1.1;
}

.lagoon-scenario-sub {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
}

.lagoon-scenario-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.lagoon-scenario-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 0.75rem;
    align-items: baseline;
    font-size: 0.85rem;
    padding: 0.45rem 0;
    border-top: 1px dashed var(--border-light);
}

.lagoon-scenario-row:first-child { border-top: none; padding-top: 0; }

.lagoon-scenario-label {
    text-transform: uppercase;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
}

.lagoon-scenario-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
    letter-spacing: -0.005em;
}

.provenance-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border-light);
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
    white-space: nowrap;
}

.provenance-tag.is-vlm {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

.provenance-tag.is-geo {
    background: var(--background-primary);
    color: var(--text-secondary);
    border-style: dashed;
}

.inundation-badge.badge-empty {
    background: var(--background-primary);
    color: var(--text-muted);
    border: 1px dashed var(--border-light);
}

/* Compare reveal (native <details>) */
.lagoon-scenario-compare {
    margin-top: 0.55rem;
    border-top: 1px dashed var(--border-light);
    padding-top: 0.4rem;
}

.lagoon-scenario-compare > summary {
    cursor: pointer;
    list-style: none;
    font-family: var(--font-sans);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.15rem 0;
    user-select: none;
}

.lagoon-scenario-compare > summary::-webkit-details-marker { display: none; }

.lagoon-scenario-compare > summary::before {
    content: '+ ';
    font-weight: 700;
    color: var(--primary-color);
}

.lagoon-scenario-compare[open] > summary::before {
    content: '− ';
}

.lagoon-scenario-compare > summary:hover { color: var(--primary-color); }

.lagoon-scenario-compare-rows {
    margin-top: 0.45rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-light);
}

.lagoon-scenario-row.is-compare .lagoon-scenario-value {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Inline tag in filter labels indicating "resolved" (VLM-or-geocentric) */
.filter-resolved-tag {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.05rem 0.35rem;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    background: var(--background-tertiary);
    border: 1px solid var(--border-light);
    line-height: 1.4;
    vertical-align: middle;
}

/* Inline "What is SSP / VLM?" link inside hint paragraphs */
.about-data-link {
    display: inline-block;
    margin-left: 0.4rem;
    background: none;
    border: 1px dashed var(--border-light);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
    line-height: 1.3;
    transition: color var(--transition-fast), border-color var(--transition-fast), border-style var(--transition-fast);
}

.about-data-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-style: solid;
}

/* About-the-data: wider modal, proper text wrapping */
.about-data-modal .modal-content {
    max-width: 820px;
    width: min(96%, 820px);
}

.about-data-body {
    overflow-wrap: anywhere;
    word-break: normal;
}

.about-data-body .stats-glossary-table {
    table-layout: fixed;
    width: 100%;
}

.about-data-body .stats-glossary-table tbody td {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.about-data-body .stats-glossary-table tbody td:first-child {
    width: 7em;
    white-space: nowrap;
}

.about-data-body .stats-glossary-table tbody td:nth-child(2) {
    width: auto;
    white-space: normal;
}

/* When 3 columns, give headers proportional widths */
.about-data-body .stats-glossary-table thead th:nth-child(3) ~ * { width: auto; }

/* Status-bar legend title — eyebrow + italic suffix */
.legend-title {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0 0 0.4rem;
    margin-bottom: 0.45rem;
    border-bottom: 1px solid var(--primary-color);
    line-height: 1.2;
}

.legend-title-main {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--primary-color);
}

.legend-title-sub {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0;
}

/* Lagoon scenario: "no local VLM" footnote */
.lagoon-scenario-note {
    margin-top: 0.55rem;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--background-tertiary);
    border-left: 2px solid var(--border-light);
    line-height: 1.4;
}

/* Top hints — breathing room above the first field; no dividing line */
.stats-hint.stats-hint-top {
    margin: 0 0 1.1rem;
    padding: 0;
    border: none;
}

#filters-tab > .stats-hint.stats-hint-top,
#search-tab  > .stats-hint.stats-hint-top {
    margin-top: 0;
}

/* ===========================================================
   Lagoon detail modal — redesigned title block + locators + scenarios table
   =========================================================== */

.lagoon-modal-titleblock {
    margin: 0;
    padding: 0 0 0 1rem;
    border: none;
    border-left: 3px solid var(--primary-color);
    min-width: 0;
}

/* Eyebrow: small uppercase tag above the name */
.lagoon-eyebrow {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

/* Combined name line: EN bold serif + thin slash + GR italic */
.lagoon-name {
    margin: 0 0 0.4rem;
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary-color);
    letter-spacing: -0.005em;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.55rem;
    font-feature-settings: "lnum" 1, "kern" 1, "liga" 1;
}

.lagoon-name-en { color: var(--primary-color); }

.lagoon-name-sep {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 0.85em;
    color: var(--text-muted);
    transform: translateY(-0.05em);
    user-select: none;
}

.lagoon-name-gr {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.7em;
    color: var(--text-secondary);
    letter-spacing: 0;
}

/* Locality: pin icon + prefecture · island */
.lagoon-locality {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.2;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.lagoon-locality-pin {
    width: 0.95em;
    height: 0.95em;
    flex: 0 0 auto;
    color: var(--text-secondary);
    opacity: 0.7;
}

.lagoon-locality-main {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0;
}

.lagoon-locality-dot {
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1;
}

/* Locator row: polygon detail + Greece + World */
.lagoon-modal-locators {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.lagoon-modal-locators .locator {
    margin: 0;
    border: 1px solid var(--border-light);
    background: var(--background-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lagoon-modal-locators .lagoon-preview-map {
    width: 100%;
    height: 175px;
    background: #f3f4f6;
}

.lagoon-modal-locators figcaption {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0.35rem 0.55rem;
    border-top: 1px solid var(--border-light);
    background: var(--background-tertiary);
    text-align: center;
}

@media (max-width: 720px) {
    .lagoon-modal-locators {
        grid-template-columns: 1fr 1fr;
    }
    .lagoon-modal-locators .locator-detail {
        grid-column: 1 / -1;
    }
}

/* Scenarios as a comparative table */
.lagoon-scenarios-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--primary-color);
    font-family: var(--font-sans);
    background: var(--background-primary);
}

.lagoon-scenarios-table thead {
    background: var(--background-tertiary);
}

/* Close the upper-left corner: matching background, proper borders */
.lagoon-scenarios-table .row-label-head {
    background: var(--background-tertiary);
    border-right: 1px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    padding: 0;
}

.lagoon-scenarios-table .ssp-header-row .ssp-head {
    padding: 0.55rem 0.6rem 0.4rem;
    border-bottom: 1px solid var(--border-light);
    font-weight: 400;
    text-align: center;
    line-height: 1.15;
}

.lagoon-scenarios-table .ssp-head + .ssp-head {
    border-left: 1px solid var(--primary-color);
}

.ssp-name {
    display: block;
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--primary-color);
    letter-spacing: 0;
}

.ssp-sub {
    display: block;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.lagoon-scenarios-table .basis-header-row .basis-head {
    padding: 0.35rem 0.5rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--primary-color);
    text-align: center;
    border-left: 1px dashed var(--border-light);
}

.lagoon-scenarios-table .basis-header-row .basis-head:nth-child(1),
.lagoon-scenarios-table .basis-header-row .basis-head:nth-child(3) {
    border-left: none;
}

.lagoon-scenarios-table tbody tr + tr td,
.lagoon-scenarios-table tbody tr + tr .row-label {
    border-top: 1px dashed var(--border-light);
}

.lagoon-scenarios-table .row-label {
    text-align: left;
    padding: 0.55rem 0.75rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-right: 1px solid var(--primary-color);
    background: var(--background-tertiary);
    width: 1%;
    white-space: nowrap;
}

.lagoon-scenarios-table .scenario-num,
.lagoon-scenarios-table .scenario-cat {
    padding: 0.55rem 0.75rem;
    text-align: center;
    border-left: 1px dashed var(--border-light);
}

.lagoon-scenarios-table .col-ssp85.col-geo,
.lagoon-scenarios-table tbody td:nth-child(4) {
    border-left: 1px solid var(--primary-color);
}

.lagoon-scenarios-table .scenario-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.92rem;
}

.lagoon-scenarios-note {
    margin: 0.6rem 0 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: 0.7rem;
    border-left: 2px solid var(--border-light);
    line-height: 1.4;
}

/* ===========================================================
   Filter sections (grouped headings)
   =========================================================== */
.filter-section {
    margin: 0 0 1.4rem;
    padding: 0;
}

.filter-section + .filter-section {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.filter-section-title {
    margin: 0 0 0.65rem;
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--primary-color);
}

#numeric-range-filters:empty::before,
#numeric-range-filters:not(:has(.range-row))::before {
    content: attr(data-empty-text);
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ===========================================================
   Lagoon modal header — title block now lives in the sticky header
   =========================================================== */
.lagoon-modal-header {
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.25rem 0.85rem;
    border-bottom: none;
}

.lagoon-modal-header .lagoon-modal-titleblock {
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
}

.lagoon-modal-header .lagoon-name { overflow-wrap: anywhere; }

.lagoon-locality-main {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0;
}

.lagoon-locality-island {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 0;
}

.lagoon-modal-header .modal-close {
    flex: 0 0 auto;
    align-self: flex-start;
}

/* ===========================================================
   Numeric range filter sliders (dual-thumb)
   =========================================================== */

/* Range filter accordions — minimal, no outer box */
.range-group {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.range-group + .range-group {
    margin-top: 0.65rem;
}

.range-group-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.45rem 0;
    font-family: inherit;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.range-group-summary::-webkit-details-marker { display: none; }

.range-group-summary::before {
    content: '+';
    width: 0.85rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    text-align: center;
}

.range-group[open] > .range-group-summary::before {
    content: '−';
    color: var(--primary-color);
}

.range-group-heading {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-primary);
}

.range-group-summary:hover .range-group-heading,
.range-group[open] > .range-group-summary .range-group-heading {
    color: var(--primary-color);
}

.range-group-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3em;
    padding: 0.05rem 0.35rem;
    background: var(--primary-color);
    color: var(--text-inverse);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.3;
    margin-left: auto;
}

.range-group-rows {
    padding: 0.35rem 0 0.5rem 0.85rem;
    margin-left: 0.4rem;
    border-left: 1px solid var(--border-light);
}

.range-row {
    padding: 0.55rem 0 0.65rem;
    border-bottom: 1px dashed var(--border-light);
}

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

.range-label-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.range-label {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    text-transform: none;
}

.range-reset {
    border: 1px solid var(--border-light);
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.range-reset:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Slider widget */
.range-slider {
    margin: 0.25rem 0;
}

.range-track-wrap {
    position: relative;
    height: 24px;
    margin: 0 8px;
}

.range-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border-light);
    transform: translateY(-50%);
    pointer-events: none;
}

.range-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--primary-color);
}

.range-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    position: absolute;
    top: 0;
    left: -8px;
    right: -8px;
    width: calc(100% + 16px);
    height: 24px;
    background: transparent;
    pointer-events: none;
    margin: 0;
    padding: 0;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    height: 16px;
    width: 16px;
    border: 2px solid var(--primary-color);
    background: #ffffff;
    cursor: grab;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    margin-top: 0;
}

.range-input::-webkit-slider-thumb:active {
    cursor: grabbing;
    background: var(--primary-color);
}

.range-input::-moz-range-thumb {
    pointer-events: auto;
    height: 16px;
    width: 16px;
    border: 2px solid var(--primary-color);
    background: #ffffff;
    cursor: grab;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.range-input::-moz-range-thumb:active { background: var(--primary-color); }

.range-input::-webkit-slider-runnable-track {
    background: transparent;
    height: 24px;
}

.range-input::-moz-range-track { background: transparent; height: 24px; }

.range-readout {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.4rem;
    margin-top: 0.3rem;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    color: var(--primary-color);
    font-weight: 600;
}

.range-readout-sep {
    color: var(--text-muted);
    font-weight: 400;
    font-family: var(--font-sans);
}

/* Tighter, journal-grade key/value rows inside the lagoon modal */
.lagoon-modal-section .lagoon-modal-details-grid {
    border-top: 1px solid var(--border-light);
}

.lagoon-modal-section .detail-item {
    min-height: 0;
    padding: 0.55rem 0.4rem;
    border-bottom: 1px dashed var(--border-light);
    align-items: baseline;
}

.lagoon-modal-section .detail-item:last-child {
    border-bottom: none;
}

.lagoon-modal-section .detail-item:nth-child(odd) {
    background: var(--background-tertiary);
}

.lagoon-modal-section .detail-label {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
}

.lagoon-modal-section .detail-value {
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
    font-weight: 600;
    max-width: none;
    word-break: normal;
    text-align: right;
}

/* Section heading: refined eyebrow with hairline rule under */
.lagoon-modal-section-head {
    margin-bottom: 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--primary-color);
}

.lagoon-modal-section-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin: 0;
}

/* ===========================================================
   Filters tab — unified panel
   Two interaction patterns:
     • numeric  → dual-thumb range slider
     • anything else → searchable list of options with mini count-bars
   Layout is locked to the panel's height; only the rows-list scrolls.
   Active filter pills + footer actions are pinned at the bottom.
   =========================================================== */

#filters-tab { padding: 0; }

body[data-active-tab="filters"] .sidebar       { overflow: hidden; }
body[data-active-tab="filters"] .sidebar-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#filters-tab.tab-content.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.fbc-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.25rem 0 0;
    overflow: hidden;
}

/* ----- 1. Picker — editorial title block ----- */
.fbc-picker-btn {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.05rem;
    padding: 0.15rem 0 0.65rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}
.fbc-picker-btn:hover { border-bottom-color: var(--primary-color); }
.fbc-picker-btn:focus-visible { outline: none; box-shadow: 0 1px 0 0 var(--primary-color); }

.fbc-picker-eyebrow {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    line-height: 1.2;
    color: var(--text-muted);
    letter-spacing: 0;
}

.fbc-picker-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.fbc-picker-value {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    font-style: italic;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fbc-picker-chev {
    flex: 0 0 auto;
    color: var(--text-muted);
    transition: color var(--transition-fast), transform var(--transition-fast);
}
.fbc-picker-btn:hover .fbc-picker-value { color: var(--primary-color); }
.fbc-picker-btn:hover .fbc-picker-chev  { color: var(--primary-color); transform: translateY(1px); }

/* ----- 2. Content area: slider OR list ----- */
.fbc-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fbc-empty {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    padding: 1.2rem 0;
    text-align: center;
}

/* ----- Numeric: dual-thumb slider ----- */
.fbc-slider {
    width: 100%;
    padding: 1.2rem 0.5rem 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.fbc-slider-track-wrap { position: relative; height: 22px; }
.fbc-slider-track {
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.12);
    transform: translateY(-50%);
    pointer-events: none;
}
.fbc-slider-fill {
    position: absolute;
    top: -1px;
    bottom: -1px;
    background: var(--primary-color);
}
.fbc-slider-input {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    position: absolute;
    top: 0; left: -8px; right: -8px;
    width: calc(100% + 16px);
    height: 22px;
    background: transparent;
    pointer-events: none;
    margin: 0; padding: 0; outline: none;
}
.fbc-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; pointer-events: auto;
    height: 16px; width: 16px;
    border: 2px solid var(--primary-color);
    background: #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.fbc-slider-input::-webkit-slider-thumb:active { cursor: grabbing; background: var(--primary-color); }
.fbc-slider-input::-moz-range-thumb {
    pointer-events: auto;
    height: 16px; width: 16px;
    border: 2px solid var(--primary-color);
    background: #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.fbc-slider-input::-moz-range-thumb:active { cursor: grabbing; background: var(--primary-color); }
.fbc-slider-input::-webkit-slider-runnable-track,
.fbc-slider-input::-moz-range-track {
    background: transparent; border: none; height: 22px;
}
.fbc-slider-ends {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    font-family: var(--font-serif);
    font-variant-numeric: tabular-nums;
}
.fbc-slider-end {
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--primary-color);
}
.fbc-slider-end-hi { text-align: right; }

/* ----- Categorical / binary / name: unified searchable list ----- */
.fbc-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.fbc-list-search {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.4rem 0.05rem 0.45rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.fbc-list-search:focus { border-bottom-color: var(--primary-color); }
.fbc-list-search::placeholder { color: var(--text-muted); }

.fbc-list-rows {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.fbc-list-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 14px;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.42rem 0.2rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background var(--transition-fast);
}
.fbc-list-row:hover { background: rgba(0, 0, 0, 0.025); }
.fbc-list-row.is-active { background: rgba(0, 0, 0, 0.045); }
.fbc-list-row.is-active .fbc-list-label { color: var(--primary-color); font-weight: 500; }

.fbc-list-label {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.fbc-list-sub {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-left: 0.4rem;
}

.fbc-list-count {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    text-align: right;
}
.fbc-list-row.is-active .fbc-list-count { color: var(--primary-color); }

.fbc-list-tick {
    text-align: center;
    color: var(--primary-color);
    font-family: var(--font-sans);
    font-size: 12px;
    line-height: 1;
}

.fbc-list-empty {
    padding: 1rem 0.4rem;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    text-align: center;
}

/* ----- 3. Active filters register — pills + overflow popover ----- */
.fbc-active-section {
    flex: 0 0 auto;
    border-top: 1px solid var(--border-light);
    padding-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.fbc-active-section.hidden { display: none; }

.fbc-active-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    max-height: calc(2 * (1.7rem + 0.35rem));
    overflow: hidden;
}

.fbc-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.18rem 0.45rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.3;
    max-width: 100%;
    transition: border-color var(--transition-fast);
}
.fbc-chip:hover { border-color: var(--text-primary); }

.fbc-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 24ch;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    cursor: pointer;
}
.fbc-chip-text:hover {
    color: var(--primary-color);
}

.fbc-chip-x {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-style: normal;
    font-size: 13px;
    line-height: 1;
    padding: 0 0.05rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.fbc-chip-x:hover { color: var(--primary-color); }

.fbc-chip-more {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.25;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.fbc-chip-more:hover { color: var(--primary-color); border-color: var(--primary-color); }

.fbc-active-popover {
    position: fixed;
    z-index: 11000;
    min-width: 240px;
    max-width: 360px;
    max-height: min(60vh, 420px);
    display: flex;
    flex-direction: column;
    background: var(--background-primary);
    border: 1px solid var(--text-primary);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
    font-family: inherit;
}
.fbc-popover-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}
.fbc-popover-title {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.fbc-popover-close {
    background: transparent; border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 16px; line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}
.fbc-popover-close:hover { color: var(--primary-color); }

.fbc-popover-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.25rem 0.25rem;
}
.fbc-popover-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
}
.fbc-popover-row:last-child { border-bottom: none; }
.fbc-popover-main {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 0.6rem;
    background: transparent; border: none; padding: 0;
    text-align: left; cursor: pointer;
    color: inherit; font: inherit;
}
.fbc-popover-label {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.fbc-popover-value {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
    text-align: right;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fbc-popover-main:hover .fbc-popover-value { text-decoration: underline; text-underline-offset: 3px; }
.fbc-popover-x {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px; line-height: 1;
    transition: color var(--transition-fast), background var(--transition-fast),
                border-color var(--transition-fast);
}
.fbc-popover-x:hover {
    color: var(--text-inverse);
    background: var(--primary-color);
    border-color: var(--primary-color);
}
.fbc-popover-foot {
    border-top: 1px solid var(--border-light);
    padding: 0.45rem 0.75rem;
    text-align: right;
}
.fbc-popover-clearall {
    background: none; border: none;
    padding: 0.2rem 0.25rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}
.fbc-popover-clearall:hover { color: var(--primary-color); }

/* ----- 4. Footer actions — pinned at the bottom ----- */
.fbc-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}
.fbc-link {
    background: none; border: none;
    padding: 0.25rem 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
}
.fbc-link:hover { color: var(--primary-color); }
.fbc-link-arrow {
    font-style: normal;
    font-family: var(--font-sans);
    transition: transform var(--transition-fast);
}
.fbc-link:hover .fbc-link-arrow { transform: translateX(2px); }

@media (max-width: 480px) {
    .fbc-panel { gap: 0.75rem; }
    .fbc-picker-value { font-size: 1.2rem; }
    .fbc-list-row { grid-template-columns: minmax(0, 1fr) auto 14px; }
}

/* ===========================================================
   Welcome modal — editorial poster
   Replaces the legacy .welcome-* layout with a magazine-cover-like
   composition: masthead title, hero schematic figure, capabilities
   grid (4 cards), and a credit / CTA footer.
   =========================================================== */

.wm .wm-content {
    max-width: 920px;
    width: calc(100vw - 2rem);
    max-height: min(94vh, 980px);
    padding: 0;
    overflow: hidden;
    background: var(--background-primary);
    border: 1px solid var(--text-primary);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.08);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Single internal scroll on the poster article — header bar removed */
.wm-poster {
    overflow-y: auto;
    padding: 1.6rem 2.2rem 1.4rem;
    color: var(--text-primary);
}

/* Close button — small, top-right, no chrome */
.wm-close {
    position: absolute;
    top: 0.85rem;
    right: 0.95rem;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}
.wm-close:hover { color: var(--primary-color); }

/* ----- Masthead ----- */
.wm-masthead {
    text-align: center;
    padding-bottom: 0.4rem;
    margin-bottom: 1.6rem;
}

.wm-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.55rem;
}

.wm-title {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(1.9rem, 4vw, 2.7rem);
    line-height: 1.02;
    letter-spacing: -0.012em;
    color: var(--text-primary);
    margin: 0 0 0.6rem;
}
.wm-title-italic {
    font-style: italic;
    font-weight: 400;
    color: var(--text-secondary);
}

.wm-deck {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 36rem;
    margin: 0 auto 0.85rem;
}

/* Read more inline link inside the deck */
.wm-readmore {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    margin-left: 0.4rem;
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: inherit;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--border-color);
    transition: text-decoration-color var(--transition-fast);
}
.wm-readmore:hover { text-decoration-color: var(--primary-color); }
.wm-readmore-arrow {
    font-style: normal;
    font-family: var(--font-sans);
    transition: transform var(--transition-fast);
}
.wm-readmore:hover .wm-readmore-arrow { transform: translateX(2px); }

/* Coverage stat blocks */
.wm-coverage {
    display: inline-flex;
    align-items: stretch;
    gap: 1.4rem;
    margin-top: 0.4rem;
    text-align: left;
}
.wm-cov-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    min-width: 0;
}
.wm-cov-label {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.wm-cov-value {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 1.4rem;
    line-height: 1.05;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.005em;
}
.wm-cov-value-text {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 1.2rem;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: 0;
}
.wm-cov-detail {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}
.wm-cov-divider {
    width: 1px;
    background: var(--border-light);
    align-self: stretch;
}

/* ===========================================================
   Asymmetric poster grid (4 tiles)
     row 1 — Map (i.) spans both columns
     row 2 — Attribute table (ii.) tall on left,
              Statistics (iii.) + Filters (iv.) stacked on right
   Frames hug their images at natural size — no gutters, no letterbox.
   =========================================================== */

/* ===========================================================
   Stage — single editorial scene of real UI specimens.
   Composition (no enumeration, no list-of-features feel):

     ┌───────────── tagline ─────────────┐  ┌── cluster cloud ──┐
     │                                   │  │                   │
     ├──── support stack ────┬───────────┤  │                   │
     │ filter mini           │           │  │                   │
     │ distribution mini     │  hero     │  └───────────────────┘
     │ active chips          │  dossier  │
     │                       │  card     │
     ├──────────────  closing italic note ─────────────────────┤
   =========================================================== */

.wm-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas:
        "tagline cloud"
        "support card"
        "note    note";
    gap: 1.4rem 1.8rem;
    margin-bottom: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--border-light);
    align-items: start;
}

.wm-stage-tagline {
    grid-area: tagline;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 24rem;
    margin: 0;
    align-self: end;
}
.wm-stage-tagline em {
    font-style: italic;
    font-size: 1.7rem;
    font-weight: 500;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    margin-right: 0.1rem;
}

/* Cluster cloud — clusters & loose markers floating in their cell */
.wm-stage-cloud {
    grid-area: cloud;
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 3;
    background:
        repeating-linear-gradient(0deg,  transparent 0 21px, rgba(0,0,0,0.04) 21px 22px),
        repeating-linear-gradient(90deg, transparent 0 21px, rgba(0,0,0,0.04) 21px 22px);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

/* Featured dossier card — the focal point */
.wm-stage-card {
    grid-area: card;
    width: 100%;
}
.wm-stage-card .wm-spec-attr { padding: 1rem 1.15rem 0.95rem; }

.wm-spec-attr-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-light);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.wm-spec-attr-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

/* Support column — stack of small UI specimens beside the card */
.wm-stage-support {
    grid-area: support;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}
.wm-stage-support .wm-spec-filters {
    padding: 0.7rem 0.85rem 0.5rem;
}
.wm-stage-support .wm-prev-fb-eyebrow { font-size: 0.65rem; }
.wm-stage-support .wm-prev-fb-value   { font-size: 0.95rem; }
.wm-stage-support .wm-prev-fb-row {
    padding: 0.25rem 0.05rem;
    font-size: 0.78rem;
}

/* Mini histogram with pointer to where the dossier lagoon falls */
.wm-stage-mini-stats {
    background: var(--background-primary);
    border: 1px solid var(--border-light);
    padding: 0.6rem 0.75rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.wm-stage-mini-stats .wm-spec-stats-cap {
    border-bottom: none;
    padding-bottom: 0;
    font-size: 0.78rem;
}
.wm-stage-mini-svg {
    width: 100%;
    height: auto;
    color: var(--text-primary);
}
.wm-stage-mini-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 9px;
    fill: var(--primary-color);
}

/* Active filter chips at the bottom of the support stack */
.wm-stage-mini-chips {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Closing italic note */
.wm-stage-note {
    grid-area: note;
    font-family: var(--font-serif);
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-light);
}
.wm-stage-note em {
    font-style: italic;
    color: var(--text-primary);
}

/* Mobile — the stage collapses to a single column */
@media (max-width: 720px) {
    .wm-stage {
        grid-template-columns: 1fr;
        grid-template-areas:
            "tagline"
            "cloud"
            "card"
            "support"
            "note";
        gap: 1rem;
    }
    .wm-stage-tagline { max-width: none; align-self: auto; }
    .wm-stage-cloud { aspect-ratio: 16 / 7; }
}

/* Legend (colored dots matching real map sub-badges) */
.wm-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    font-family: var(--font-serif);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.wm-legend li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    line-height: 1.2;
}
.wm-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.wm-legend-low  { background: #0d9488; }
.wm-legend-mid  { background: #f97316; }
.wm-legend-high { background: #dc2626; }

/* ===========================================================
   Real-UI specimens — each tile renders a fragment of the
   actual application using its own classes (cluster markers,
   attribute rows, histogram SVG, fbc filter list).
   =========================================================== */

/* ----- I. Map scene: clusters on a faint graticule ----- */
.wm-scene {
    position: relative;
    width: 100%;
    background: rgba(0, 0, 0, 0.012);
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.wm-scene-map {
    height: 220px;
    background:
        repeating-linear-gradient(0deg,  transparent 0 23px, rgba(0,0,0,0.04) 23px 24px),
        repeating-linear-gradient(90deg, transparent 0 23px, rgba(0,0,0,0.04) 23px 24px);
}
.wm-scene-label {
    position: absolute;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.wm-scene-label-aegean { right: 6%;  top: 14%; }
.wm-scene-label-ionian { left: 5%;   top: 14%; }

.wm-scene-legend {
    position: absolute;
    left: 0.9rem;
    bottom: 0.7rem;
    list-style: none;
    margin: 0;
    padding: 0.55rem 0.7rem;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    font-family: var(--font-serif);
    font-size: 0.74rem;
    color: var(--text-secondary);
    backdrop-filter: blur(2px);
}
.wm-scene-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.2;
}

.wm-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.wm-legend-low  { background: #0d9488; }
.wm-legend-mid  { background: #f97316; }
.wm-legend-high { background: #dc2626; }

/* Real cluster markers (matches the app's .cluster-icon vocabulary) */
.wm-prev-marker {
    position: absolute;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #000;
    border: 1.5px solid #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transform: translate(-50%, -50%);
}
.wm-prev-cluster {
    position: absolute;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #000;
    border: 2px solid #aaa;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.wm-prev-cluster-lg {
    width: 50px; height: 50px;
    border-width: 2.5px;
}
.wm-prev-cluster-num {
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
}
.wm-prev-cluster-lg .wm-prev-cluster-num { font-size: 15px; }
.wm-prev-sub {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 1.5px solid #fff;
}
.wm-prev-sub-low  { background: #0d9488; left: -4px;  bottom: 1px; }
.wm-prev-sub-mid  { background: #f97316; left: 50%;   bottom: -5px; transform: translateX(-50%); }
.wm-prev-sub-high { background: #dc2626; right: -4px; bottom: 1px; }

/* ----- II. Attribute table specimen ----- */
.wm-spec {
    width: 100%;
    background: var(--background-primary);
    border: 1px solid var(--border-light);
    padding: 0.85rem 1rem 0.75rem;
    box-sizing: border-box;
}

.wm-spec-attr-titleblock {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.55rem;
}
.wm-spec-attr-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.wm-spec-attr-name {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.25rem;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}
.wm-spec-attr-name em {
    font-style: italic;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.15rem;
}
.wm-spec-attr-loc {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.wm-spec-attr-section-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.52rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0.55rem 0 0.3rem;
}

.wm-spec-attr-rows {
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.05rem 0.5rem;
    align-items: baseline;
    border-top: 1px solid var(--border-light);
}
.wm-spec-attr-rows dt,
.wm-spec-attr-rows dd {
    margin: 0;
    padding: 0.28rem 0;
    border-bottom: 1px solid var(--border-light);
}
.wm-spec-attr-rows dt {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.wm-spec-attr-rows dt em {
    font-style: italic;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 0.25rem;
}
.wm-spec-attr-rows dd {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--primary-color);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ----- III. Statistics specimen ----- */
.wm-spec-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.wm-spec-stats-cap {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.3;
    padding-bottom: 0.45rem;
    border-bottom: 1px dashed var(--border-light);
}
.wm-spec-stats-cap em { color: var(--text-primary); }
.wm-spec-stats-fignum {
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 600;
    font-size: 0.55rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.wm-spec-stats-svg {
    width: 100%;
    height: auto;
    color: var(--text-primary);
}
.wm-spec-stats-ytick,
.wm-spec-stats-xtick {
    font-family: var(--font-sans);
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    fill: var(--text-secondary);
}
.wm-spec-stats-ref {
    font-family: var(--font-sans);
    font-size: 9px;
    font-weight: 600;
}
.wm-spec-stats-summary {
    display: flex;
    align-items: baseline;
    gap: 1.2rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border-light);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.wm-spec-stats-summary strong {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-right: 0.15rem;
}

/* ----- IV. Filters specimen ----- */
.wm-spec-filters { padding: 0.85rem 1rem 0.75rem; }
.wm-spec-filters .wm-prev-filters {
    padding: 0;
    background: transparent;
    gap: 0.5rem;
}
.wm-spec-filters .wm-prev-fb-pickerblock {
    padding-bottom: 0.45rem;
}
.wm-spec-filters .wm-prev-fb-eyebrow { font-size: 0.7rem; }
.wm-spec-filters .wm-prev-fb-value   { font-size: 1.1rem; }

.wm-spec-filters-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.4rem;
}
.wm-spec-filters .wm-prev-fb-row {
    padding: 0.32rem 0.05rem;
    font-size: 0.85rem;
}
.wm-spec-filters .wm-prev-fb-count { font-size: 0.7rem; }

.wm-spec-filters-active {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    padding-top: 0.55rem;
    margin-top: 0.35rem;
    border-top: 1px solid var(--border-light);
}
.wm-spec-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.18rem 0.45rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}
.wm-spec-chip-x {
    font-style: normal;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-muted);
}
.wm-fig-num {
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 600;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 0.4rem;
}


/* ===== Filters preview — real picker + list rows ===== */
.wm-prev-filters {
    padding: 0.7rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    background: var(--background-primary);
}

.wm-prev-fb-pickerblock {
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--text-primary);
}
.wm-prev-fb-eyebrow {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.2;
}
.wm-prev-fb-value {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.15;
    color: var(--text-primary);
}
.wm-prev-fb-rows {
    display: flex;
    flex-direction: column;
}
.wm-prev-fb-row {
    display: grid;
    grid-template-columns: 1fr auto 12px;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 0.05rem;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-serif);
    font-size: 0.82rem;
    color: var(--text-primary);
}
.wm-prev-fb-row:last-child { border-bottom: none; }
.wm-prev-fb-row.is-active {
    background: rgba(0, 0, 0, 0.045);
    font-weight: 500;
}
.wm-prev-fb-row.is-active .wm-prev-fb-label,
.wm-prev-fb-row.is-active .wm-prev-fb-count,
.wm-prev-fb-row.is-active .wm-prev-fb-tick {
    color: var(--primary-color);
}
.wm-prev-fb-count {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.wm-prev-fb-tick {
    text-align: center;
    color: var(--primary-color);
    font-family: var(--font-sans);
    font-size: 10px;
    line-height: 1;
}

/* ----- Footer (credit + CTA) ----- */
.wm-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding-top: 0.4rem;
}

.wm-cred {
    display: flex;
    align-items: center;
    gap: 1.15rem;
    min-width: 0;
}

.wm-cred-logo {
    height: 64px;
    width: auto;
    flex-shrink: 0;
    object-fit: contain;
    opacity: 0.95;
}

.wm-cred-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.wm-cred-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.05rem;
}

.wm-cred-univ {
    font-family: var(--font-serif);
    font-size: 0.7rem;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
    color: var(--text-secondary);
    margin: 0;
    max-width: 26rem;
}
.wm-cred-univ em {
    font-style: italic;
    font-weight: 400;
    color: var(--text-primary);
}
.wm-cred-univ sup {
    font-size: 0.7em;
    vertical-align: 0.3em;
}
.wm-cred-univ a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    text-decoration-color: var(--border-color);
    transition: text-decoration-color var(--transition-fast);
    word-break: break-word;
    overflow-wrap: anywhere;
}
.wm-cred-univ a:hover { text-decoration-color: var(--primary-color); }
.wm-cred-author { display: none; }

/* ----- Signature: handwritten image + typeset name underneath -----
   Wrapper is a column so the printed name sits as a caption below the
   signature image. Both elements together carry the link. */
.wm-signature {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    line-height: 1;
    text-decoration: none;
    color: inherit;
    transition: opacity var(--transition-fast);
}
.wm-signature img {
    display: block;
    height: 64px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}
.wm-signature:hover { opacity: 0.7; }

.wm-signature-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
}

/* Smaller variant for the welcome modal footer */
.wm-signature-sm img { height: 44px; }
.wm-signature-sm .wm-signature-name { font-size: 0.78rem; }

.wm-sig-tag {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    line-height: 1;
    flex: 0 1 auto;
}
.wm-sig-tag-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1;
}

/* Main app footer: subtle script signature inline with the divider strip */
.footer-credit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.footer-credit-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.footer-signature {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1;
    text-decoration: none;
    color: inherit;
    transition: opacity var(--transition-fast);
}
.footer-signature img {
    display: block;
    height: 24px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    flex-shrink: 0;
}
.footer-signature:hover { opacity: 0.7; }

.footer-signature-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    line-height: 1;
    white-space: nowrap;
}
.wm-cred-author a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    text-decoration-color: var(--border-color);
    transition: text-decoration-color var(--transition-fast), color var(--transition-fast);
}
.wm-cred-author a:hover {
    color: var(--primary-color);
    text-decoration-color: var(--primary-color);
}

/* CTA — primary, prominent */
.wm-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.5rem;
    background: var(--primary-color);
    color: var(--text-inverse);
    border: 1px solid var(--primary-color);
    border-radius: 2px;
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.005em;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                transform var(--transition-fast);
    flex-shrink: 0;
}
.wm-cta:hover {
    background: var(--background-primary);
    color: var(--primary-color);
}
.wm-cta-arrow {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    line-height: 1;
    transition: transform var(--transition-fast);
}
.wm-cta:hover .wm-cta-arrow { transform: translateX(3px); }

/* ----- Animation: subtle fade-up ----- */
@keyframes wmFadeUp {
    from { transform: translateY(14px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.welcome-modal.active .wm-content {
    animation: wmFadeUp 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ----- Tablet ----- */
@media (max-width: 820px) {
    .wm .wm-content { width: calc(100vw - 1.5rem); }
    .wm-poster { padding: 2rem 1.6rem 1.6rem; }
    .wm-foot {
        flex-direction: column;
        align-items: stretch;
        gap: 1.1rem;
    }
    .wm-cta { width: 100%; justify-content: center; }
}

/* ----- Mobile ----- */
@media (max-width: 480px) {
    .wm .wm-content { width: calc(100vw - 1rem); max-height: 96vh; }
    .wm-poster { padding: 1.5rem 1.1rem 1.3rem; }
    .wm-title { font-size: 2rem; }
    .wm-title-italic { font-size: 1.4rem; }
    .wm-deck { font-size: 0.92rem; }

    /* Coverage block stacks on narrow screens */
    .wm-coverage {
        flex-direction: column;
        gap: 0.65rem;
        align-items: center;
    }
    .wm-cov-divider { display: none; }
    .wm-cov-block { align-items: center; text-align: center; }

    /* Footer 3-column collapses; signature centered between cred + CTA */
    .wm-foot { gap: 0.9rem; }
    .wm-cred { justify-content: center; text-align: center; }
    .wm-cred-text { align-items: center; }
    .wm-sig-tag { justify-content: center; }
    .wm-signature-sm img { height: 38px; }
}

/* ===========================================================
   Global mobile safeguards — prevent horizontal overflow,
   tighten the persistent app footer, and keep the FilterByChart
   panel from spilling out of narrow viewports.
   =========================================================== */

html, body { overflow-x: hidden; }
.wm-content,
.fbc-panel,
.footer-content,
.modal-content {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    /* App footer — keep signature compact */
    .footer-content { gap: 0.5rem; padding: 0 0.85rem; }
    .footer-credit  { flex-wrap: wrap; justify-content: center; gap: 0.3rem; }
    .footer-signature { gap: 0.4rem; }
    .footer-signature img { height: 20px; }
    .footer-signature-name { font-size: 0.74rem; }
    .footer-link { font-size: 0.82rem; }
    .footer-dot { font-size: 0.72rem; }
    .footer-nav { gap: 0.35rem; }

    /* FilterByChart — ensure long values truncate cleanly */
    #filters-tab .fbc-picker-value { font-size: 1.05rem; }
    #filters-tab .fbc-list-row { padding: 0.38rem 0.15rem; }
    .fbc-active-popover {
        left: 0.5rem !important;
        right: 0.5rem !important;
        width: auto !important;
        max-width: calc(100vw - 1rem) !important;
    }
    .fbc-chip-text { max-width: 14ch; }

    /* Lagoon detail modal margins */
    .lagoon-modal-content { width: calc(100vw - 1rem); max-height: 94vh; }

    /* Header subtitle wraps cleanly on phones */
    .subtitle { max-width: 100%; padding: 0 0.5rem; }
}

/* ===========================================================
   Editorial styling for the four secondary modals:
     Cite (#references-modal)
     Submit Data (.submit-data-modal)
     Report Issue (.report-bug-modal)
     Suggest Feature (.submit-suggestion-modal)
   Same vocabulary as the welcome modal — serif italic title,
   hairline frame, refined CTA, generous padding.
   =========================================================== */

#references-modal .modal-content,
.submit-data-modal .modal-content,
.report-bug-modal .modal-content,
.submit-suggestion-modal .modal-content {
    border-radius: 0;
    border: 1px solid var(--text-primary);
    max-width: 540px;
    background: var(--background-primary);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Header — italic-serif title, no border-bottom, tighter top spacing */
#references-modal .modal-header,
.submit-data-modal .modal-header,
.report-bug-modal .modal-header,
.submit-suggestion-modal .modal-header {
    align-items: flex-start;
    padding: 1.4rem 1.75rem 0.7rem;
    border-bottom: none;
    background: transparent;
}

#references-modal .modal-header h3,
.submit-data-modal .modal-header h3,
.report-bug-modal .modal-header h3,
.submit-suggestion-modal .modal-header h3 {
    font-family: 'Cormorant Garamond', var(--font-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 1.7rem;
    line-height: 1.1;
    letter-spacing: -0.005em;
    color: var(--text-primary);
    text-transform: none;
}

/* Close button — quiet × in muted gray */
#references-modal .modal-close,
.submit-data-modal .modal-close,
.report-bug-modal .modal-close,
.submit-suggestion-modal .modal-close {
    min-width: auto;
    min-height: auto;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: transparent;
}
#references-modal .modal-close:hover,
.submit-data-modal .modal-close:hover,
.report-bug-modal .modal-close:hover,
.submit-suggestion-modal .modal-close:hover {
    color: var(--primary-color);
    background: transparent;
}

/* Body — generous editorial padding */
#references-modal .modal-body,
.submit-data-modal .modal-body,
.report-bug-modal .modal-body,
.submit-suggestion-modal .modal-body {
    padding: 0.5rem 1.75rem 1.75rem;
}

/* Citation modal */
#references-modal .citation-label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}
#references-modal .citation-label-second {
    margin-top: 1.4rem;
}
#references-modal .reference-item p:not(.citation-label) {
    font-family: var(--font-serif);
    font-style: normal;
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.55;
    color: var(--text-primary);
    margin: 0;
}
#references-modal .citation-paper em {
    font-style: italic;
    color: var(--text-primary);
}
#references-modal .citation-paper sup {
    font-size: 0.7em;
    vertical-align: 0.4em;
}
#references-modal .reference-item a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--border-color);
    transition: text-decoration-color var(--transition-fast);
    word-break: break-word;
    overflow-wrap: anywhere;
}
#references-modal .reference-item a:hover {
    text-decoration-color: var(--primary-color);
}

/* Intro prose for Submit / Report / Suggest */
.submit-data-modal .submit-data-intro p,
.report-bug-modal .submit-data-intro p,
.submit-suggestion-modal .submit-data-intro p {
    font-family: 'Cormorant Garamond', var(--font-serif);
    font-style: italic;
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 1.4rem;
}

/* Refined CTA matching the welcome modal */
.submit-data-modal .btn-primary,
.report-bug-modal .btn-primary,
.submit-suggestion-modal .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.4rem;
    background: var(--primary-color);
    color: var(--text-inverse);
    border: 1px solid var(--primary-color);
    border-radius: 2px;
    font-family: 'Cormorant Garamond', var(--font-serif);
    font-style: italic;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.submit-data-modal .btn-primary:hover,
.report-bug-modal .btn-primary:hover,
.submit-suggestion-modal .btn-primary:hover {
    background: var(--background-primary);
    color: var(--primary-color);
}
.submit-data-modal .btn-primary svg,
.report-bug-modal .btn-primary svg,
.submit-suggestion-modal .btn-primary svg {
    margin: 0;
}

.submit-data-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0;
}

/* Mobile */
@media (max-width: 480px) {
    #references-modal .modal-content,
    .submit-data-modal .modal-content,
    .report-bug-modal .modal-content,
    .submit-suggestion-modal .modal-content {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
    }
    #references-modal .modal-header,
    .submit-data-modal .modal-header,
    .report-bug-modal .modal-header,
    .submit-suggestion-modal .modal-header {
        padding: 1.1rem 1.2rem 0.5rem;
    }
    #references-modal .modal-header h3,
    .submit-data-modal .modal-header h3,
    .report-bug-modal .modal-header h3,
    .submit-suggestion-modal .modal-header h3 {
        font-size: 1.4rem;
    }
    #references-modal .modal-body,
    .submit-data-modal .modal-body,
    .report-bug-modal .modal-body,
    .submit-suggestion-modal .modal-body {
        padding: 0.4rem 1.2rem 1.3rem;
    }
}


