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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #0f172a;
    color: #e2e8f0;
    position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────── */

/* ── Sidebar toggle button ────────────────────────────────── */

.sidebar-toggle-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 15;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.sidebar-toggle-btn:hover { background: #334155; }

.sidebar-toggle-btn.visible { display: flex; }

#sidebar {
    width: 280px;
    min-width: 280px;
    height: 100vh;
    overflow-y: auto;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: margin-left 0.25s ease;
}

#sidebar.sidebar-closed {
    margin-left: -280px;
}

/* ── Branding ────────────────────────────────────────────── */

.sidebar-branding {
    padding: 14px 16px 8px;
    border-bottom: 1px solid #334155;
    text-align: center;
    background: #1e293b;
}

.sidebar-logo {
    width: 180px;
    height: auto;
}

.branding-credit {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
}

.subtitle {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.sidebar-section {
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 10px;
}

/* ── Layer toggles ───────────────────────────────────────── */

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    color: #cbd5e1;
}

.layer-toggle:hover { color: #f1f5f9; }

.layer-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.well-type-toggles,
.subbasin-toggles,
.subbasin-gsas {
    margin-left: 22px;
    border-left: 2px solid #334155;
    padding-left: 12px;
    margin-top: 4px;
}

.subbasin-gsas {
    display: none;
    margin-bottom: 4px;
}

.subbasin-gsas.expanded {
    display: block;
}

.subbasin-header {
    cursor: pointer;
}

.sub-toggle { font-size: 12px; }

.count {
    margin-left: auto;
    font-size: 11px;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

/* ── Filters ─────────────────────────────────────────────── */

.filter-group { margin-bottom: 12px; }

.filter-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 4px;
}

.filter-control {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    outline: none;
}

.filter-control:focus { border-color: #3b82f6; }

.filter-control--half { width: calc(50% - 10px); }

.range-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.range-sep { color: #64748b; font-size: 13px; }

.btn-clear {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-clear:hover {
    color: #f1f5f9;
    border-color: #475569;
    background: #1e293b;
}

/* ── Stats ───────────────────────────────────────────────── */

.sidebar-stats {
    font-size: 13px;
    color: #94a3b8;
    border-bottom: none;
}

.sidebar-stats #well-count {
    font-weight: 700;
    color: #f8fafc;
    font-variant-numeric: tabular-nums;
}

/* ── Disclaimer ──────────────────────────────────────────── */

.sidebar-disclaimer {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.6;
    border-bottom: none;
}

.sidebar-disclaimer p {
    margin-bottom: 6px;
}

.sidebar-disclaimer ul {
    list-style: none;
    padding: 0;
    margin: 0 0 8px 0;
}

.sidebar-disclaimer li {
    padding: 2px 0;
}

.sidebar-disclaimer li::before {
    content: "\2022";
    color: #475569;
    margin-right: 6px;
}

.sidebar-disclaimer a {
    color: #60a5fa;
    text-decoration: none;
}

.sidebar-disclaimer a:hover {
    text-decoration: underline;
}

.disclaimer-text {
    font-size: 10px;
    color: #64748b;
    font-style: italic;
}

/* ── Map ─────────────────────────────────────────────────── */

#map {
    flex: 1;
    height: 100vh;
}

/* ── Fullscreen button ────────────────────────────────────── */

.fullscreen-btn {
    position: absolute;
    top: 126px;
    right: 10px;
    z-index: 15;
    width: 36px;
    height: 36px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: background 0.15s;
}

.fullscreen-btn:hover { background: #334155; }

/* ── Basemap selector ─────────────────────────────────────── */

.basemap-selector {
    position: absolute;
    top: 170px;
    right: 10px;
    z-index: 15;
}

.basemap-btn {
    width: 36px;
    height: 36px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: background 0.15s;
}

.basemap-btn:hover { background: #334155; }

.basemap-menu {
    position: absolute;
    top: 0;
    right: 44px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.basemap-menu.hidden { display: none; }

.basemap-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    font-size: 11px;
    color: #94a3b8;
}

.basemap-option:hover { border-color: #475569; }
.basemap-option.active { border-color: #3b82f6; color: #e2e8f0; }

.basemap-thumb {
    width: 56px;
    height: 40px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
}

.hybrid-thumb    { background: linear-gradient(135deg, #1a3a1a 40%, #555 60%); }
.satellite-thumb { background: linear-gradient(135deg, #1a3a1a, #2a4a2a); }
.usgs-thumb      { background: linear-gradient(135deg, #e8dcc8, #d4c4a8); }
.streets-thumb   { background: linear-gradient(135deg, #f0ede6, #d5d0c4); }

/* ── Popup ────────────────────────────────────────────────── */

.map-popup {
    position: absolute;
    z-index: 20;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    color: #e2e8f0;
    max-width: 300px;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    line-height: 1.5;
}

.map-popup.hidden { display: none; }

.popup-title {
    font-weight: 700;
    font-size: 13px;
    color: #f8fafc;
    margin-bottom: 6px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.popup-label { color: #94a3b8; }
.popup-value { color: #f1f5f9; font-weight: 500; text-align: right; }

.popup-link {
    display: inline-block;
    margin-top: 6px;
    color: #60a5fa;
    text-decoration: none;
    pointer-events: auto;
}

.popup-link:hover { text-decoration: underline; }

/* ── Detail panel (right side, all wells at location) ───── */

.detail-panel {
    position: absolute;
    right: 16px;
    top: 16px;
    bottom: 16px;
    width: 340px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
}

.detail-panel.hidden { display: none; }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
    flex-shrink: 0;
}

.detail-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.detail-close-btn:hover { color: #f1f5f9; }

.detail-list {
    overflow-y: auto;
    padding: 8px 12px;
    flex: 1;
}

.detail-well {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.detail-well-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #f8fafc;
}

.detail-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    padding: 2px 0;
}

.detail-label { color: #94a3b8; }
.detail-value { color: #e2e8f0; font-weight: 500; text-align: right; }

.detail-report-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.15s;
}

.detail-report-link:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #93bbfc;
}

.detail-no-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}

.popup-hint {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
    .sidebar-toggle-btn { display: flex; }
    #sidebar.sidebar-closed { margin-left: -280px; }
}
