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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
header {
    background: #0f172a;
    color: white;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header .logo {
    font-size: 1.4rem;
}

header h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

header p {
    font-size: 0.72rem;
    opacity: 0.55;
    margin-top: 2px;
}

/* ── Layout ── */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#map {
    flex: 1;
    min-height: 0;
}

/* ── Sidebar ── */
#sidebar {
    width: 380px;
    background: white;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e2e8f0;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-top {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-top .search-wrap {
    flex: 1;
}

#sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    color: #64748b;
}

#sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.search-wrap {
    position: relative;
}

.search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.search-wrap input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
    background: white;
}

.search-wrap input::placeholder {
    color: #94a3b8;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

/* ── Filters ── */
.filters-header {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
}

.filters-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filters-badge {
    background: #3b82f6;
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
}

.filters-chevron {
    width: 14px;
    height: 14px;
    color: #64748b;
    transition: transform 0.2s;
}

.filters-header.open .filters-chevron {
    transform: rotate(180deg);
}

.filters {
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filters[hidden] {
    display: none;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 99px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.72rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.pill.active {
    background: #1e293b;
    border-color: #1e293b;
    color: white;
}

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

/* ── Placeholder ── */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: #94a3b8;
    text-align: center;
    gap: 10px;
}

.placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

.placeholder p {
    font-size: 0.875rem;
}

/* ── Location Header ── */
.loc-header {
    margin-bottom: 16px;
}

.loc-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.loc-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 6px;
}

.loc-meta span {
    font-size: 0.78rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ── Inspection Card ── */
.inspection-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.card-date {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
}

.card-type {
    font-size: 0.78rem;
    color: #64748b;
    margin-bottom: 10px;
}

.badge {
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-clean {
    background: #dcfce7;
    color: #166534;
}

.badge-violations {
    background: #fee2e2;
    color: #991b1b;
}

.violation {
    font-size: 0.8rem;
    color: #dc2626;
    padding: 6px 10px;
    background: #fff5f5;
    border-left: 3px solid #fca5a5;
    border-radius: 0 5px 5px 0;
    margin: 4px 0;
    line-height: 1.4;
}

.no-violations {
    font-size: 0.8rem;
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.report-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.78rem;
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

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

/* ── Loader ── */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    color: #64748b;
    gap: 12px;
    font-size: 0.875rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-msg {
    font-size: 0.875rem;
    color: #dc2626;
    padding: 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    line-height: 1.5;
}

/* ── Leaflet tooltip overrides ── */
.leaflet-tooltip {
    border-radius: 8px !important;
    border: none !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
    padding: 8px 12px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 0.8rem !important;
    color: #1e293b !important;
}

/* ── Near Me button ── */
#near-me-btn {
    position: absolute;
    top: 80px;
    left: 10px;
    z-index: 1000;
    width: 34px;
    height: 34px;
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    box-shadow: none;
}

#near-me-btn:hover {
    background: #f4f4f4;
}

#near-me-btn svg {
    width: 18px;
    height: 18px;
}

#near-me-btn.loading svg {
    animation: spin 1s linear infinite;
    opacity: 0.5;
}

/* ── Legend ── */
.map-legend {
    position: absolute;
    bottom: 28px;
    left: 10px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 0.75rem;
    color: #1e293b;
    pointer-events: none;
}

.map-legend .legend-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 3px 0;
}

.map-legend .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    #map {
        height: 35dvh;
        flex: none;
    }

    .sidebar-collapsed #map {
        height: auto;
        flex: 1;
    }

    #sidebar {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }

    .search-wrap input {
        font-size: 16px;
    }

    #sidebar-toggle {
        display: flex;
    }

    #sidebar.collapsed {
        flex: none;
    }

    #sidebar.collapsed .sidebar-body {
        display: none;
    }

    #sidebar.collapsed #toggle-icon {
        transform: rotate(180deg);
    }
}
