/* =============================================================================
   EXE CATCHMENT MAP — Design System
   Adjust the CSS variables below to retheme the entire map.
============================================================================= */

:root {
    /* Brand colours */
    --navy-deep:    #0c1a2e;
    --navy:         #112240;
    --navy-mid:     #1a3153;
    --navy-light:   #233d63;
    --teal:         #14a085;
    --teal-light:   #1abc9c;
    --teal-dim:     rgba(20, 160, 133, 0.15);
    --gold:         #f5a623;
    --green:        #27ae60;
    --red:          #e74c3c;

    /* Text */
    --text-bright:  #e8edf5;
    --text-mid:     rgba(232, 237, 245, 0.75);
    --text-dim:     rgba(232, 237, 245, 0.4);

    /* Surfaces */
    --border:       rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --surface:      rgba(255, 255, 255, 0.04);
    --surface-hover:rgba(255, 255, 255, 0.08);

    /* Layout */
    --sidebar-w:    310px;
    --radius:       10px;
    --radius-sm:    6px;
    --transition:   0.2s ease;

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

/* =============================================================================
   RESET & BASE
============================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 14px;
    background: var(--navy-deep);
    color: var(--text-bright);
    -webkit-font-smoothing: antialiased;
}

button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }
a { color: var(--teal-light); }


/* =============================================================================
   WELCOME OVERLAY
============================================================================= */

#welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(11, 26, 46, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeIn 0.4s ease;
}

#welcome-card {
    background: linear-gradient(160deg, var(--navy-mid) 0%, var(--navy) 100%);
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(20,160,133,0.1);
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#welcome-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#welcome-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.welcome-subtitle {
    font-size: 13px;
    color: var(--teal);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.welcome-desc {
    font-size: 14px;
    color: var(--text-mid);
    line-height: 1.65;
    margin-bottom: 24px;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 28px;
    text-align: left;
}

.welcome-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-mid);
}

.feature-icon { font-size: 16px; }

#welcome-enter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--teal);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 20px rgba(20, 160, 133, 0.35);
    margin-bottom: 16px;
}

#welcome-enter:hover {
    background: var(--teal-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(20, 160, 133, 0.45);
}

.welcome-credit {
    font-size: 11px;
    color: var(--text-dim);
}


/* =============================================================================
   APP LAYOUT
============================================================================= */

#app {
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* =============================================================================
   MAP CONTAINER
============================================================================= */

#map-container {
    flex: 1;
    position: relative;
}

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

/* Sidebar toggle button (floating over map) */
#sidebar-toggle {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    width: 40px;
    height: 40px;
    background: var(--navy);
    color: var(--text-bright);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    transition: background var(--transition), border-color var(--transition);
}

#sidebar-toggle:hover {
    background: var(--navy-mid);
    border-color: rgba(255,255,255,0.2);
}

/* Map location badge */
#map-badge {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 26, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-mid);
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
    pointer-events: none;
    white-space: nowrap;
}

/* MapLibre control overrides */
.maplibregl-ctrl-group {
    border-radius: var(--radius-sm) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    border: 1px solid rgba(0,0,0,0.15) !important;
}

.maplibregl-ctrl-attrib {
    font-size: 10px !important;
}

.maplibregl-popup-content {
    border-radius: var(--radius) !important;
    padding: 12px 16px !important;
    font-family: var(--font) !important;
    font-size: 13px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2) !important;
    border: 1px solid #e0e0e0 !important;
}


/* =============================================================================
   SIDEBAR
============================================================================= */

#sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
    transition: width var(--transition), opacity var(--transition);
}

#sidebar.collapsed {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

/* Brand */
#sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#brand-mark {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--teal-dim);
    border: 1px solid rgba(20,160,133,0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#brand-text h1 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-bright);
    white-space: nowrap;
}

#brand-text p {
    font-size: 11px;
    color: var(--teal);
    font-weight: 500;
    white-space: nowrap;
}

/* Catchment selector */
#catchment-selector {
    padding: 10px 18px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#catchment-select {
    width: 100%;
    padding: 8px 28px 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-bright);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='rgba(255,255,255,0.35)'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition);
    margin-top: 4px;
}

#catchment-select:focus {
    outline: none;
    border-color: var(--teal);
}

#catchment-select option {
    background: var(--navy-mid);
    color: var(--text-bright);
}

/* Section labels */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    padding: 14px 18px 6px;
    flex-shrink: 0;
}

/* Layer container */
#layers-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

#layers-container::-webkit-scrollbar { width: 3px; }
#layers-container::-webkit-scrollbar-track { background: transparent; }
#layers-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Layer groups */
.layer-group {
    border-bottom: 1px solid var(--border);
}

.group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    background: none;
    border: none;
    color: var(--text-bright);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    transition: background var(--transition);
}

.group-header:hover { background: var(--surface-hover); }

.group-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }
.group-name { flex: 1; }

.chevron {
    color: var(--text-dim);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.layer-group.collapsed .chevron { transform: rotate(-90deg); }
.layer-group.collapsed .group-layers { display: none; }

.group-layers { padding: 2px 0 8px; }

/* Individual layer items */
.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 18px 7px 32px;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}

.layer-item:hover { background: var(--surface); }

.layer-dot {
    width: 10px;
    height: 10px;
    background: var(--color);
    border-radius: 2px;
    flex-shrink: 0;
}

.layer-dot.dot { border-radius: 50%; }

.layer-name {
    flex: 1;
    font-size: 12.5px;
    color: var(--text-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition);
}

/* Show layer name bright when toggle is on */
.layer-item:has(input:checked) .layer-name { color: var(--text-bright); }

/* Layer data badge */
.layer-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--teal-dim);
    color: var(--teal);
    border: 1px solid rgba(20,160,133,0.2);
    white-space: nowrap;
    display: none; /* shown via JS when data loads */
}

/* Custom toggle switch */
.toggle {
    position: relative;
    width: 30px;
    height: 17px;
    flex-shrink: 0;
}

.toggle input { display: none; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.12);
    border-radius: 9px;
    transition: background var(--transition);
    cursor: pointer;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 13px;
    height: 13px;
    background: var(--text-mid);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition), background var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle input:checked + .toggle-slider {
    background: var(--teal);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(13px);
    background: white;
}


/* =============================================================================
   QUERY TOOL
============================================================================= */

#query-section {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.query-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 18px;
    background: none;
    border: none;
    color: var(--text-bright);
    cursor: pointer;
    transition: background var(--transition);
}

.query-header:hover { background: var(--surface-hover); }

.query-header .chevron {
    transition: transform var(--transition);
}

#query-section.collapsed .query-header .chevron {
    transform: rotate(-90deg);
}

#query-body {
    padding: 0 18px 14px;
    overflow: hidden;
}

#query-section.collapsed #query-body {
    display: none;
}

.query-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.55;
    margin-bottom: 12px;
}

.query-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-bright);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    margin-bottom: 4px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='rgba(255,255,255,0.3)'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    transition: border-color var(--transition);
}

.query-select:focus {
    outline: none;
    border-color: var(--teal);
}

.query-select option {
    background: var(--navy-mid);
    color: var(--text-bright);
}

.query-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    margin: 4px 0;
}

.btn-query {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px;
    background: var(--teal-dim);
    color: var(--teal-light);
    border: 1px solid rgba(20,160,133,0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-top: 6px;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn-query:hover {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
}

.btn-query:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#query-results { margin-top: 10px; }

#query-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-mid);
    margin-bottom: 6px;
}

#query-result-count {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
    flex-shrink: 0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 0;
    transition: color var(--transition);
}

.btn-text:hover { color: var(--text-mid); }


/* =============================================================================
   SIDEBAR FOOTER
============================================================================= */

#sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 16px rgba(39, 174, 96, 0.3);
    margin-bottom: 8px;
}

.btn-submit:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.footer-note {
    font-size: 10.5px;
    color: var(--text-dim);
    text-align: center;
}


/* =============================================================================
   INFO PANEL
============================================================================= */

#info-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    background: white;
    box-shadow: -6px 0 30px rgba(0,0,0,0.2);
    z-index: 30;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#info-panel.hidden {
    transform: translateX(100%);
    display: flex !important; /* keep in DOM for transition */
}

#info-panel-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid #eff2f5;
    background: #f8fafc;
    flex-shrink: 0;
}

#info-layer-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 20px;
    margin-bottom: 8px;
    background: #e8f8f5;
    color: #0d7377;
}

#info-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a2744;
    padding-right: 28px;
    line-height: 1.3;
}

#close-info {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f0f2f5;
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: background var(--transition);
}

#close-info:hover { background: #e0e4ea; }

#info-description {
    font-size: 12.5px;
    color: #666;
    line-height: 1.55;
    padding: 12px 16px 0;
    flex-shrink: 0;
}

#info-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 16px;
}

.info-row {
    display: flex;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid #f5f7fa;
    font-size: 13px;
}

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

.info-key {
    font-weight: 600;
    color: #555;
    min-width: 110px;
    flex-shrink: 0;
    font-size: 12px;
}

.info-value { color: #222; word-break: break-word; font-size: 13px; }
.info-value a { color: #0d7377; text-decoration: none; }
.info-value a:hover { text-decoration: underline; }

.info-empty {
    color: #aaa;
    font-size: 13px;
    padding: 12px 0;
    font-style: italic;
}

.info-multi-section {
    border: 1px solid #eff2f5;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.info-multi-header {
    background: #f8fafc;
    padding: 10px 12px;
    border-bottom: 1px solid #eff2f5;
}

.info-multi-layer {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #0d7377;
    margin-bottom: 3px;
}

.info-multi-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a2744;
    line-height: 1.3;
}

.info-multi-section .info-row {
    padding: 7px 12px;
    margin: 0;
}


/* =============================================================================
   MODAL
============================================================================= */

#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 18, 32, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

#modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid #eff2f5;
    flex-shrink: 0;
}

#modal-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

#modal-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: #1a2744;
    margin-bottom: 2px;
}

#modal-header p {
    font-size: 12.5px;
    color: #888;
}

#close-modal {
    margin-left: auto;
    background: #f0f2f5;
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    flex-shrink: 0;
    transition: background var(--transition);
}

#close-modal:hover { background: #e0e4ea; }

#modal-body {
    overflow-y: auto;
    padding: 20px 22px 24px;
}

.modal-intro-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f0faf8;
    border: 1px solid #c8ede8;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12.5px;
    color: #2d6b5e;
    line-height: 1.55;
    margin-bottom: 18px;
}

.modal-intro-banner svg { flex-shrink: 0; margin-top: 1px; color: #14a085; }

/* Form elements */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.required { color: var(--teal); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: #222;
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(20,160,133,0.12);
}

.form-group textarea { resize: vertical; min-height: 90px; }

.form-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
    line-height: 1.4;
}

.location-unset {
    padding: 10px 13px;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #a0aec0;
}

.location-set {
    padding: 10px 13px;
    background: #f0faf8;
    border: 1.5px solid #c8ede8;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #2d6b5e;
    font-weight: 500;
}

.form-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    font-size: 13px;
    color: #c53030;
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.btn-submit-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: linear-gradient(135deg, #1a2744 0%, #243459 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
}

.btn-submit-form:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-set-location {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: transparent;
    color: var(--teal);
    border: 1.5px solid var(--teal);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-set-location:hover {
    background: var(--teal);
    color: white;
}


/* =============================================================================
   TOAST NOTIFICATIONS
============================================================================= */

#toast-container {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: rgba(17, 34, 64, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-bright);
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    border: 1px solid var(--border-hover);
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.toast.success { border-color: rgba(39,174,96,0.4); }
.toast.error   { border-color: rgba(231,76,60,0.4); }


/* =============================================================================
   PICKING MODE (crosshair cursor state)
============================================================================= */

body.picking-location #map { cursor: crosshair !important; }

.picking-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy);
    color: var(--teal);
    border: 1px solid rgba(20,160,133,0.3);
    border-radius: 50px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}


/* =============================================================================
   UTILITY
============================================================================= */

.hidden { display: none !important; }


/* =============================================================================
   ANIMATIONS
============================================================================= */

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

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

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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


/* =============================================================================
   RESPONSIVE — tablet (sidebar overlay)
============================================================================= */

@media (max-width: 768px) and (min-width: 641px) {
    #sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 40;
        box-shadow: 4px 0 32px rgba(0,0,0,0.5);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--sidebar-w) !important;
        transform: translateX(0);
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        opacity: 1;
    }

    #info-panel {
        width: 320px;
    }
}


/* =============================================================================
   MOBILE — bottom-sheet layout (≤ 640px)
============================================================================= */

@media (max-width: 640px) {

    /* ── App layout: map fills full screen, panels float over it ── */
    #app { display: block; }

    #map-container {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    /* ── Sidebar → full-width bottom sheet ── */
    #sidebar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        top: auto;
        width: 100% !important;
        height: 62vh;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 48px rgba(0,0,0,0.55);
        z-index: 40;
        transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1) !important;
        transform: translateY(0);
    }

    /* Drag handle pill */
    #sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border-hover);
        border-radius: 2px;
        margin: 10px auto 2px;
        flex-shrink: 0;
    }

    /* Collapsed = slides fully below viewport */
    #sidebar.collapsed {
        transform: translateY(100%) !important;
        width: 100% !important;
        opacity: 1 !important;
        pointer-events: none;
    }

    /* Tighten brand row to save vertical space */
    #sidebar-brand { padding: 8px 16px 10px; }
    #brand-text h1 { font-size: 13px; }

    /* ── Sidebar toggle → larger tap target, stays top-left ── */
    #sidebar-toggle {
        top: 14px;
        left: 14px;
        width: 44px;
        height: 44px;
        border-radius: var(--radius);
    }

    /* ── Layer groups: bigger tap targets ── */
    .group-header {
        min-height: 48px;
        padding: 12px 18px;
        font-size: 13.5px;
    }

    .layer-item {
        min-height: 44px;
        padding: 10px 16px 10px 28px;
    }

    .layer-name { font-size: 13px; }

    /* Slightly larger toggle switch for fingers */
    .toggle { width: 36px; height: 20px; }
    .toggle-slider { border-radius: 10px; }
    .toggle-slider::after { width: 16px; height: 16px; }
    .toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

    /* Query section inputs */
    .query-select { padding: 10px 32px 10px 10px; font-size: 13px; }
    .btn-query    { padding: 11px; font-size: 13.5px; }

    /* ── Info panel → bottom sheet, sits above sidebar ── */
    #info-panel {
        right: 0; left: 0;
        top: auto; bottom: 0;
        width: 100%;
        height: 58vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.3);
        transform: translateY(0);
        z-index: 50;
    }

    /* Drag handle for info panel */
    #info-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #d8dde6;
        border-radius: 2px;
        margin: 10px auto 0;
        flex-shrink: 0;
    }

    #info-panel.hidden { transform: translateY(100%); }

    #info-panel-header { padding: 12px 16px 12px; }
    #info-title { font-size: 14px; }

    /* ── Hide map badge on mobile (space is precious) ── */
    #map-badge { display: none; }

    /* ── Picking mode banner ── */
    .picking-banner { font-size: 12px; padding: 8px 16px; }

    /* ── Welcome overlay ── */
    #welcome-overlay { padding: 16px; align-items: flex-end; }

    #welcome-card {
        padding: 28px 20px 24px;
        border-radius: 20px 20px 16px 16px;
        max-width: 100%;
    }

    #welcome-card h1  { font-size: 24px; }
    .welcome-subtitle { font-size: 12px; }
    .welcome-desc     { font-size: 13px; }
    .welcome-features { gap: 8px; margin-bottom: 20px; }
    .welcome-feature  { padding: 8px 12px; font-size: 12.5px; }

    /* ── Modal → slides up from bottom ── */
    #modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    #modal {
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        max-width: 100%;
        animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    #modal-header { padding: 18px 18px 14px; }
    #modal-body   { padding: 16px 18px 32px; }

    /* Form adjustments */
    .form-row { grid-template-columns: 1fr; }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 11px 12px;
    }

    /* ── Toast: sits above any open bottom sheet ── */
    #toast-container { bottom: 80px; }

    /* ── MapLibre controls: keep away from toggle ── */
    .maplibregl-ctrl-top-left { margin-top: 70px !important; }
}
