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

body {
    font-family: system-ui, sans-serif;
    margin: 0;
    background: #f5f5f5;
    color: #222;
}

/* ── Map page layout ─────────────────────────────── */

.map-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #666;
}

.filter-group {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.filter-group:last-of-type {
    border-bottom: none;
    flex: 1;
}

.filter-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.filter-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.filter-group-header .filter-label {
    margin-bottom: 0;
}

.filter-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: #888;
    user-select: none;
}

.filter-toggle {
    accent-color: #1a56b8;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.toggle-text {
    min-width: 3em;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-slider {
    flex: 1;
    accent-color: #1a56b8;
    cursor: pointer;
}

.range-slider:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.range-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a56b8;
    min-width: 3em;
    text-align: right;
}

.filter-inactive .range-value {
    color: #bbb;
}

.dept-select:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.dept-select {
    width: 100%;
    height: 320px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.25rem;
    background: #fafafa;
    color: #222;
}

.dept-select option {
    padding: 0.3rem 0.4rem;
    border-radius: 3px;
}

.filter-hint {
    font-size: 0.72rem;
    color: #aaa;
    margin: 0.35rem 0 0;
}

.sidebar-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.apply-btn {
    width: 100%;
    padding: 0.65rem 1rem;
    background: #1a56b8;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.apply-btn:hover:not(:disabled) {
    background: #1448a0;
}

.apply-btn:disabled {
    background: #b0b8c4;
    cursor: not-allowed;
}

.apply-btn--secondary {
    background: #374151;
    margin-top: 0.5rem;
}

.apply-btn--secondary:hover:not(:disabled) {
    background: #1f2937;
}

.status-msg {
    font-size: 0.78rem;
    color: #666;
    margin: 0.5rem 0 0;
    min-height: 1.1em;
}

.map-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.rail-legend {
    position: absolute;
    bottom: 32px;
    left: 12px;
    z-index: 1000;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14);
    padding: 0.6rem 0.9rem;
}

.price-legend {
    position: absolute;
    bottom: 32px;
    left: 180px;
    z-index: 1000;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14);
    padding: 0.6rem 0.9rem;
}

.rail-legend-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #888;
    margin: 0 0 0.45rem;
}

.rail-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.rail-legend-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #333;
}

.rail-legend-swatch {
    display: inline-block;
    width: 20px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── City detail panel ───────────────────────────── */

.city-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 280px;
    max-height: calc(100vh - 24px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.city-panel-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    z-index: 1;
}

.city-panel-close:hover {
    color: #333;
    background: #f0f0f0;
}

.city-panel-body {
    padding: 1rem 1.1rem 1.1rem;
    overflow-y: auto;
    flex: 1;
}

.city-panel-hint {
    font-size: 0.82rem;
    color: #999;
    margin: 0.5rem 0;
    text-align: center;
}

.city-panel-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    padding-right: 1.2rem;
    color: #111;
}

.city-panel-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.6rem;
    font-size: 0.82rem;
    margin: 0 0 0.9rem;
}

.city-panel-dl dt {
    color: #888;
    font-weight: 500;
    white-space: nowrap;
}

.city-panel-dl dd {
    margin: 0;
    color: #222;
    font-weight: 600;
}

.city-panel-section {
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
    margin-top: 0.1rem;
}

.city-panel-section h4 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #888;
    margin: 0 0 0.55rem;
}

.season-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.season-card {
    background: #f7f9fc;
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
}

.season-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: #1a56b8;
    margin-bottom: 0.2rem;
}

.season-stat {
    font-size: 0.78rem;
    color: #333;
    line-height: 1.4;
}

.fiber-coverage {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.fiber-bar-wrap {
    flex: 1;
    height: 8px;
    background: #e8ecf0;
    border-radius: 4px;
    overflow: hidden;
}

.fiber-bar {
    height: 100%;
    background: #22c55e;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.fiber-pct {
    font-size: 0.82rem;
    font-weight: 700;
    color: #22c55e;
    min-width: 2.8em;
    text-align: right;
}

.fiber-year {
    font-size: 0.72rem;
    color: #aaa;
    margin: 0;
}

.city-panel-na {
    font-size: 0.8rem;
    color: #bbb;
    margin: 0;
}

.city-panel-meta {
    font-size: 0.72rem;
    color: #aaa;
    font-weight: 400;
}

.city-panel-loading {
    font-size: 0.78rem;
    color: #aaa;
    margin-top: 0.5rem;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

h1 {
    margin-bottom: 1.5rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

.filters input[type="search"],
.filters input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    min-width: 220px;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #555;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 160px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.8rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
