﻿html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background: #f3f6fb;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 56px);
    gap: 16px;
    padding: 16px;
    box-sizing: border-box;
}

.sidebar {
    width: 420px;
    min-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
}

.sidebar-header {
    padding: 8px 4px 0 4px;
}

    .sidebar-header h2 {
        margin: 0;
        font-size: 1.65rem;
        font-weight: 700;
        color: #1d2a3a;
        line-height: 1.15;
    }

.sidebar-subtitle {
    color: #6b7785;
    margin-top: 4px;
    font-size: 0.95rem;
}

.panel-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(31, 52, 84, 0.08);
    padding: 16px;
}

.grow-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

.search-stack {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

    .search-stack .form-control,
    .search-stack .btn {
        min-height: 44px;
    }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-box {
    border: 1px solid #edf2f7;
    border-radius: 14px;
    padding: 12px;
    background: #fbfdff;
    min-width: 0;
}

.stat-label {
    font-size: 0.78rem;
    color: #6b7785;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #1d2a3a;
    word-break: break-word;
}

.small-value {
    font-size: 0.9rem;
    font-weight: 600;
}

.results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.results-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.results-table-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.results-table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid #e8eef5;
    background: #fff;
    min-height: 320px;
    max-height: 420px;
    -webkit-overflow-scrolling: touch;
}

.results-table {
    margin-bottom: 0;
}

    .results-table thead th {
        position: sticky;
        top: 0;
        background: #f8fbff;
        z-index: 2;
        font-size: 0.84rem;
        border-bottom: 1px solid #dde7f0;
        white-space: nowrap;
    }

    .results-table tbody tr {
        cursor: pointer;
        transition: background 0.15s ease, transform 0.15s ease;
    }

        .results-table tbody tr:hover {
            background: #f3f8ff;
        }

    .results-table tbody td {
        vertical-align: middle;
        font-size: 0.9rem;
    }

.plz-cell {
    font-weight: 700;
    color: #1f3f74;
    white-space: nowrap;
}

.city-cell {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.distance-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.status-center {
    background: #dff4ea;
    color: #18794e;
}

.status-near {
    background: #e4efff;
    color: #1d4ed8;
}

.status-edge {
    background: #fff0d9;
    color: #b65f00;
}

.map-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.map-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-chip {
    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(31, 52, 84, 0.08);
    padding: 8px 14px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    max-width: 100%;
}

.chip-label {
    font-size: 0.8rem;
    color: #6b7785;
    white-space: nowrap;
}

.chip-value {
    font-size: 0.92rem;
    color: #1d2a3a;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#map {
    flex: 1;
    min-height: 700px;
    width: 100%;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 14px 35px rgba(31, 52, 84, 0.12);
    border: 1px solid #dfe7f1;
}

.loading-overlay {
    position: absolute;
    inset: 56px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 246, 251, 0.55);
    border-radius: 22px;
    z-index: 999;
    backdrop-filter: blur(2px);
}

.loading-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 14px 35px rgba(31, 52, 84, 0.16);
    padding: 24px 28px;
    min-width: 230px;
    text-align: center;
    color: #1d2a3a;
    font-weight: 600;
    max-width: calc(100vw - 40px);
}

.leaflet-popup-content-wrapper {
    border-radius: 14px;
}

.leaflet-popup-content {
    margin: 12px 14px;
    font-size: 0.92rem;
}

@media (max-width: 1280px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        max-height: none;
        overflow: visible;
    }

    #map {
        min-height: 60vh;
    }
}

@media (max-width: 768px) {
    .app-shell {
        padding: 10px;
        gap: 10px;
    }

    .panel-card {
        padding: 14px;
        border-radius: 16px;
    }

    .sidebar-header {
        padding: 2px 2px 0 2px;
    }

        .sidebar-header h2 {
            font-size: 1.35rem;
        }

    .sidebar-subtitle {
        font-size: 0.88rem;
    }

    .search-stack {
        flex-direction: column;
    }

        .search-stack .btn {
            width: 100%;
        }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .results-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .results-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

        .results-toolbar-actions .btn {
            width: 100%;
            min-height: 42px;
        }

    .results-table-wrapper {
        min-height: 260px;
        max-height: 320px;
    }

    .results-table thead th,
    .results-table tbody td {
        font-size: 0.82rem;
        padding: 0.55rem 0.45rem;
    }

    .city-cell {
        max-width: 110px;
    }

    .status-badge {
        min-width: 72px;
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .map-toolbar {
        gap: 8px;
    }

    .toolbar-chip {
        width: 100%;
        justify-content: space-between;
        border-radius: 14px;
        padding: 10px 12px;
    }

    #map {
        min-height: 48vh;
        border-radius: 18px;
    }

    .loading-overlay {
        inset: 48px 0 0 0;
        border-radius: 18px;
    }
}

@media (max-width: 480px) {
    .app-shell {
        padding: 8px;
        gap: 8px;
    }

    .panel-card {
        padding: 12px;
        border-radius: 14px;
    }

    .sidebar-header h2 {
        font-size: 1.2rem;
    }

    .sidebar-subtitle {
        font-size: 0.82rem;
    }

    .stat-box {
        padding: 10px;
        border-radius: 12px;
    }

    .stat-value {
        font-size: 0.94rem;
    }

    .small-value {
        font-size: 0.84rem;
    }

    .results-table-wrapper {
        min-height: 220px;
        max-height: 280px;
    }

    .results-table thead th,
    .results-table tbody td {
        font-size: 0.77rem;
        padding: 0.5rem 0.35rem;
    }

    .city-cell {
        max-width: 82px;
    }

    .distance-cell {
        font-size: 0.76rem;
    }

    .status-badge {
        min-width: 64px;
        font-size: 0.68rem;
        padding: 3px 7px;
    }

    #map {
        min-height: 42vh;
    }

    .loading-card {
        min-width: 0;
        width: calc(100vw - 32px);
        padding: 18px 16px;
    }
}
