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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #0f1923;
    color: #c8d6e5;
}

/* ── Sidebar ── */
#sidebar {
    width: 270px;
    min-width: 270px;
    background: #141f2e;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid #1e2d40;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
    font-size: 15px;
    font-weight: 600;
    color: #e8f0fe;
    border-bottom: 1px solid #1e2d40;
}

.section {
    padding: 14px 16px 10px;
}

.section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #546e8a;
    margin-bottom: 10px;
}

.divider {
    height: 1px;
    background: #1e2d40;
    margin: 0 16px;
}

/* ── Buttons ── */
.btn-group {
    display: flex;
    gap: 4px;
}

.btn {
    padding: 6px 12px;
    border: 1px solid #2a3f58;
    border-radius: 4px;
    background: #1e2d40;
    color: #8fa8c0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.btn:hover { background: #253547; color: #c8d6e5; }
.btn.active { background: #1a6aa8; border-color: #2280c8; color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    width: 100%;
    padding: 9px;
    background: #1a6aa8;
    border-color: #2280c8;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: 5px;
    margin-top: 10px;
}
.btn-primary:hover:not(:disabled) { background: #2280c8; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
    width: 100%;
    padding: 7px;
    background: transparent;
    border: 1px solid #2a3f58;
    color: #8fa8c0;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.btn-secondary:hover { background: #1e2d40; color: #c8d6e5; }

/* ── Toggle switch ── */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.toggle-label input { display: none; }
.toggle-track {
    width: 34px; height: 18px;
    background: #2a3f58;
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #546e8a;
    transition: left 0.2s, background 0.2s;
}
.toggle-label input:checked + .toggle-track { background: #1a6aa8; }
.toggle-label input:checked + .toggle-track .toggle-thumb { left: 18px; background: #fff; }

/* ── Form elements ── */
.field { margin-bottom: 10px; }
.field label {
    display: block;
    font-size: 11px;
    color: #546e8a;
    margin-bottom: 5px;
}
select {
    width: 100%;
    padding: 7px 8px;
    background: #1e2d40;
    border: 1px solid #2a3f58;
    border-radius: 4px;
    color: #c8d6e5;
    font-size: 12px;
    appearance: none;
    cursor: pointer;
}
select:focus { outline: none; border-color: #2280c8; }

/* ── Results ── */
.count-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.count-badge {
    background: #1a6aa8;
    color: #fff;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.state-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.state-tag {
    background: #1e2d40;
    border: 1px solid #2a3f58;
    color: #8fa8c0;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
}

.warning-box {
    background: #3d2a00;
    border: 1px solid #7a5500;
    color: #f0a500;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 11px;
    margin-bottom: 8px;
}

.error-item {
    background: #2d1515;
    border: 1px solid #6b2d2d;
    color: #e07070;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 11px;
    margin-bottom: 6px;
}

/* ── Text styles ── */
.help-text { color: #546e8a; line-height: 1.5; }
.hint-text { font-size: 11px; color: #3d5570; margin-top: 6px; }
.info-text { font-size: 11px; color: #546e8a; margin-top: 6px; }
code {
    background: #1e2d40;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-box {
    background: #141f2e;
    border: 1px solid #2a3f58;
    border-radius: 6px;
    padding: 28px 36px;
    text-align: center;
    min-width: 260px;
}
.modal-box p {
    color: #e8f0fe;
    font-size: 14px;
    margin-bottom: 18px;
}

/* ── Footer ── */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid #1e2d40;
    font-size: 11px;
    color: #3d5570;
}

/* ── Map ── */
#map-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#map { flex: 1; }

/* ── Status bar ── */
#status-bar {
    height: 26px;
    background: #0f1923;
    border-top: 1px solid #1e2d40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    font-size: 12px;
    color: #546e8a;
    flex-shrink: 0;
}

.status-icon {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #2a3f58;
    flex-shrink: 0;
}
.status-icon.loading {
    background: #f0a500;
    animation: pulse 0.8s ease-in-out infinite alternate;
}
.status-icon.success { background: #27ae60; }
.status-icon.error   { background: #e74c3c; }
.status-icon.info    { background: #2280c8; }

@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }

#status-text { flex: 1; }
#coord-display { font-family: 'Courier New', monospace; font-size: 11px; color: #3d5570; }

/* ── Leaflet overrides ── */
.leaflet-bar a {
    background-color: #1e2d40 !important;
    color: #c8d6e5 !important;
    border-color: #2a3f58 !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 26px !important;
}
.leaflet-bar a:hover { background-color: #253547 !important; }
.leaflet-bar a.draw-active { color: #f0a500 !important; }

.parcel-tooltip {
    background: #141f2e;
    border: 1px solid #2a3f58;
    border-radius: 4px;
    color: #c8d6e5;
    font-size: 12px;
    padding: 4px 8px;
    white-space: nowrap;
}
