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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Landing Page */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    background: #16213e;
    padding: 3rem 1.5rem 2rem;
    text-align: center;
    border-bottom: 1px solid #0f3460;
}

.landing-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #4fc3f7;
    margin-bottom: 0.5rem;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: #90a4ae;
}

.landing-main {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.landing-search {
    text-align: center;
    margin-bottom: 2.5rem;
}

.landing-search label {
    display: block;
    font-size: 1rem;
    color: #b0bec5;
    margin-bottom: 0.75rem;
}

.landing-search-row {
    display: flex;
    justify-content: center;
    gap: 0;
    max-width: 400px;
    margin: 0 auto;
}

.landing-search-row input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 2px solid #0f3460;
    border-right: none;
    border-radius: 8px 0 0 8px;
    background: #1a1a2e;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.2s;
}

.landing-search-row input:focus {
    border-color: #4fc3f7;
}

.landing-search-row button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: #4fc3f7;
    color: #16213e;
    border: 2px solid #4fc3f7;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    transition: background 0.2s;
}

.landing-search-row button:hover {
    background: #29b6f6;
    border-color: #29b6f6;
}

.landing-hint {
    font-size: 0.8rem;
    color: #607d8b;
    margin-top: 0.5rem;
}

.landing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.landing-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 1.5rem;
    text-decoration: none;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.landing-card:hover {
    transform: translateY(-2px);
    border-color: #4fc3f7;
}

.landing-card--coming {
    opacity: 0.6;
    pointer-events: none;
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.landing-card h2 {
    font-size: 1.1rem;
    color: #4fc3f7;
    margin-bottom: 0.4rem;
}

.landing-card p {
    font-size: 0.85rem;
    color: #90a4ae;
    line-height: 1.4;
}

.card-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #0f3460;
    color: #607d8b;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 600px) {
    .landing-header h1 {
        font-size: 1.6rem;
    }
    .landing-cards {
        grid-template-columns: 1fr;
    }
}

/* Header */
.header {
    background: #16213e;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-back {
    color: #4fc3f7;
    text-decoration: none;
    font-size: 1.2rem;
    line-height: 1;
}

.header-back:hover {
    color: #29b6f6;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #4fc3f7;
}

.header .subtitle {
    font-size: 0.85rem;
    color: #90a4ae;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    background: #16213e;
    border-bottom: 2px solid #0f3460;
    padding: 0 1rem;
    overflow-x: auto;
}

.category-tabs .tab {
    padding: 0.6rem 1.2rem;
    border: none;
    background: none;
    color: #78909c;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.category-tabs .tab:hover {
    color: #b0bec5;
}

.category-tabs .tab.active {
    color: #4fc3f7;
    border-bottom-color: #4fc3f7;
}

/* Panel visibility */
.controls-panel.hidden {
    display: none;
}

/* Map Container */
.map-container {
    flex: 1;
    display: flex;
    position: relative;
    min-height: calc(100vh - 140px);
}

#map {
    flex: 1;
    z-index: 1;
}

/* Controls Panel */
.controls-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.25rem;
    width: 280px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    border: 1px solid #0f3460;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.controls-panel h2 {
    font-size: 1.1rem;
    color: #4fc3f7;
    margin-bottom: 0.25rem;
}

.controls-description {
    font-size: 0.8rem;
    color: #78909c;
    margin-bottom: 1rem;
}

.layer-group {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(79, 195, 247, 0.1);
}

.layer-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.layer-group h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #b0bec5;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    cursor: pointer;
    transition: opacity 0.2s;
}

.layer-toggle:hover {
    opacity: 0.85;
}

.layer-toggle input[type="checkbox"],
.layer-toggle input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #4fc3f7;
    cursor: pointer;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #cfd8dc;
}

.colour-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Legend Panel (status strip) */
.legend-panel {
    position: absolute;
    bottom: 1.5rem;
    right: 1rem;
    z-index: 1000;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    border: 1px solid #0f3460;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.legend-panel:empty,
.legend-panel:has(#legend-content:empty) {
    display: none;
}

.legend-panel h3 {
    display: none;
}

.legend-placeholder {
    font-size: 0.8rem;
    color: #78909c;
    font-style: italic;
    margin: 0;
}

.legend-status {
    font-size: 0.85rem;
    color: #cfd8dc;
    margin: 0;
}

.legend-status small {
    color: #78909c;
}

/* Footer */
.footer {
    background: #16213e;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #0f3460;
    text-align: center;
}

.footer p {
    font-size: 0.75rem;
    color: #78909c;
}

.footer a {
    color: #4fc3f7;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Scrollbar Styling */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(79, 195, 247, 0.3);
    border-radius: 3px;
}

/* Loading indicator */
.loading-indicator {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(22, 33, 62, 0.95);
    color: #4fc3f7;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid #0f3460;
    display: none;
}

.loading-indicator.visible {
    display: block;
}

/* Search Control */
.search-control {
    background: white !important;
    display: flex;
    border-radius: 4px !important;
    overflow: hidden;
}

.search-control input {
    border: none;
    padding: 8px 12px;
    width: 180px;
    font-size: 14px;
    outline: none;
}

.search-control button {
    border: none;
    background: #4fc3f7;
    color: #16213e;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-control button:hover {
    background: #29b6f6;
}

/* Risk Summary in Popup */
.risk-summary {
    margin: 0.5rem 0;
    padding: 0.5rem 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.risk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
}

.risk-label {
    font-size: 0.8rem;
    color: #333;
    font-weight: 500;
}

.risk-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* Popup Styling */
.flood-popup {
    font-size: 0.85rem;
    line-height: 1.4;
}

.flood-popup strong {
    display: block;
    margin-bottom: 0.25rem;
}

.severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0.25rem 0;
    color: white;
}

.severity-badge.severity-1 {
    background: #8B0000;
}

.severity-badge.severity-2 {
    background: #CC0000;
}

.severity-badge.severity-3 {
    background: #CC7700;
}

.severity-badge.severity-4 {
    background: #666666;
}

/* Controls hint text */
.controls-hint {
    font-size: 0.7rem;
    color: #607d8b;
    font-style: italic;
    margin-top: 0.25rem;
    padding-left: 1.5rem;
}

/* Demographics / IMD Styles */
.demographics-summary {
    margin: 0.5rem 0;
}

.imd-headline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.imd-decile {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.imd-label {
    font-size: 0.85rem;
    color: #444;
}

.imd-domains {
    margin: 0.5rem 0;
    padding: 0.5rem 0;
    border-top: 1px solid #eee;
}

.imd-domain-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 2px 0;
    font-size: 0.75rem;
}

.imd-domain-name {
    width: 100px;
    flex-shrink: 0;
    color: #555;
}

.imd-domain-bar {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.imd-domain-fill {
    height: 100%;
    background: #ef5350;
    border-radius: 4px;
}

.imd-domain-val {
    width: 16px;
    text-align: right;
    font-weight: 600;
    color: #333;
}

/* House Price Styles */
.hp-panel {
    padding: 0.5rem 0;
}

.hp-avg {
    font-size: 1.4rem;
    font-weight: 700;
    color: #4fc3f7;
    margin-bottom: 0.2rem;
}

.hp-meta {
    font-size: 0.8rem;
    color: #90a4ae;
    margin-bottom: 0.75rem;
}

.hp-range {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #b0bec5;
    padding: 0.4rem 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.hp-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.hp-type {
    font-size: 0.8rem;
    color: #cfd8dc;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.hp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.hp-recent {
    border-top: 1px solid rgba(79, 195, 247, 0.15);
    padding-top: 0.5rem;
}

.hp-recent-title {
    font-size: 0.75rem;
    color: #78909c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.hp-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.8rem;
}

.hp-price {
    color: #e0e0e0;
    font-weight: 500;
}

.hp-detail {
    color: #78909c;
}

.hp-link {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #4fc3f7;
    text-decoration: none;
}

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

/* House price popup (light background) */
.hp-popup {
    padding: 0.25rem 0;
}

.hp-popup-avg {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1565C0;
}

.hp-popup-avg span {
    font-size: 0.85rem;
    font-weight: 400;
    color: #666;
}

.hp-popup-meta {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.hp-popup-range {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
}

.hp-popup-range td {
    padding: 0.3rem 0.5rem;
    text-align: center;
}

.hp-popup-range tr:first-child td {
    color: #999;
    font-size: 0.7rem;
    padding-bottom: 0;
}

.hp-popup-range tr:last-child td {
    color: #333;
    font-weight: 500;
}

.hp-popup-recent {
    border-top: 1px solid #eee;
    padding-top: 0.4rem;
    margin: 0.4rem 0;
}

.hp-popup-row {
    font-size: 0.8rem;
    padding: 0.15rem 0;
}

.hp-popup-row strong {
    color: #333;
}

.hp-popup-row span {
    color: #888;
    margin-left: 0.3rem;
}

/* Legend inline dots */
.legend-inline {
    font-size: 0.8rem;
    color: #cfd8dc;
    line-height: 2;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 2px;
    margin-left: 8px;
}

.legend-dot:first-child {
    margin-left: 0;
}

/* Decile scale in panel */
.decile-scale {
    margin-top: 0.5rem;
}

.decile-bar {
    display: flex;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
}

.decile-bar span {
    flex: 1;
}

.decile-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.decile-labels small {
    font-size: 0.7rem;
    color: #78909c;
}

/* Crime Summary Styles */
.crime-summary {
    margin: 0.5rem 0;
}

/* Time Period Buttons */
.time-period-buttons {
    display: flex;
    gap: 0.25rem;
}

.period-btn {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #90a4ae;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.period-btn:hover {
    border-color: #4fc3f7;
    color: #cfd8dc;
}

.period-btn.active {
    background: #4fc3f7;
    color: #16213e;
    border-color: #4fc3f7;
    font-weight: 600;
}

.crime-total {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: #333;
}

.crime-total small {
    color: #888;
    font-weight: normal;
}

.crime-breakdown {
    margin: 0.4rem 0;
}

.crime-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 2px 0;
    font-size: 0.8rem;
}

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

.crime-cat-name {
    flex: 1;
    color: #444;
}

.crime-count {
    font-weight: 600;
    color: #333;
}

.crime-popup strong {
    display: block;
    margin-bottom: 0.2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem 1rem;
    }

    .header h1 {
        font-size: 1rem;
    }

    .category-tabs .tab {
        padding: 0.5rem 0.7rem;
        font-size: 0.75rem;
    }

    .map-container {
        min-height: calc(100vh - 100px);
    }

    .controls-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 40vh;
        overflow-y: auto;
        border-radius: 12px 12px 0 0;
        z-index: 1001;
        transform: translateY(calc(100% - 40px));
        transition: transform 0.3s ease;
    }

    .controls-panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: #4fc3f7;
        border-radius: 2px;
        margin: 0 auto 0.75rem;
        opacity: 0.6;
    }

    .controls-panel.open {
        transform: translateY(0);
    }

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

    .legend-panel {
        bottom: 50px;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }

    .search-control {
        max-width: 160px;
    }

    .search-control input {
        width: 110px !important;
        font-size: 12px !important;
    }

    .search-control button {
        padding: 8px 8px;
        font-size: 11px;
    }
}
