/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    color: #e2e8f0;
    overflow: hidden;
}

/* ── Header ── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    z-index: 100;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
header h1 {
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.02em;
}
.subtitle {
    font-size: 13px;
    color: #94a3b8;
    padding: 2px 10px;
    background: #334155;
    border-radius: 12px;
    font-weight: 500;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.house-count {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}
.btn-icon {
    background: none;
    border: 1px solid #475569;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.btn-icon:hover { background: #334155; color: #e2e8f0; }

/* ── Map ── */
#map { flex: 1; width: 100%; }

/* ── Admin Panel ── */
.admin-panel {
    position: absolute;
    top: 60px;
    right: 16px;
    width: 360px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    z-index: 200;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    overflow: hidden;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
}
.admin-header h3 { font-size: 14px; font-weight: 600; }
.btn-icon-sm {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.btn-icon-sm:hover { color: #e2e8f0; }
.admin-auth {
    display: flex;
    gap: 8px;
    padding: 16px;
}
.admin-auth input {
    flex: 1;
    padding: 8px 12px;
    background: #0f172a;
    border: 1px solid #475569;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
}
.admin-auth input:focus { border-color: #3b82f6; }
.btn-primary-sm {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary-sm:hover { background: #2563eb; }
.admin-upload { padding: 16px; }
.upload-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
    line-height: 1.5;
}
.upload-hint code {
    background: #334155;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}
.upload-hint.warning { color: #f59e0b; }
.upload-area {
    border: 2px dashed #475569;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #3b82f6;
    background: rgba(59,130,246,0.05);
}
.upload-area p {
    margin-top: 8px;
    font-size: 13px;
    color: #94a3b8;
}
.upload-link {
    color: #3b82f6;
    cursor: pointer;
    text-decoration: underline;
}
.upload-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
}
.upload-status.success { background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }
.upload-status.error { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.upload-status.loading { background: rgba(59,130,246,0.1); color: #3b82f6; border: 1px solid rgba(59,130,246,0.2); }

/* ── Filter Panel ── */
.filter-panel {
    position: absolute;
    top: 60px;
    left: 0;
    width: 260px;
    background: #1e293b;
    border-right: 1px solid #334155;
    z-index: 150;
    height: calc(100vh - 57px);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
}
.filter-panel.collapsed { transform: translateX(-100%); }
.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
}
.filter-header h3 { font-size: 14px; font-weight: 600; }
.filter-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.zone-group { margin-bottom: 16px; }
.zone-district {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.zone-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
}
.zone-toggle input { display: none; }
.zone-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.zone-toggle input:not(:checked) + .zone-color { opacity: 0.2; }
.filter-divider { border: none; border-top: 1px solid #334155; margin: 12px 0; }
.zone-actions { display: flex; gap: 12px; }
.btn-text {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    padding: 0;
}
.btn-text:hover { color: #60a5fa; }

/* ── Filter Expand Button ── */
.filter-expand {
    position: absolute;
    top: 70px;
    left: 10px;
    z-index: 140;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: background 0.15s;
}
.filter-expand:hover { background: #334155; }

/* ── Loading ── */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #334155;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { margin-top: 12px; font-size: 14px; color: #94a3b8; }

/* ── Info Window ── */
.info-window {
    font-family: 'Inter', sans-serif;
    min-width: 220px;
}
.info-window .iw-address {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    line-height: 1.3;
}
.info-window .iw-city {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}
.info-window .iw-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.info-window .iw-detail {
    font-size: 12px;
    color: #475569;
}
.info-window .iw-detail strong {
    display: block;
    font-size: 15px;
    color: #1e293b;
    font-weight: 600;
}
.info-window .iw-zone {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #64748b;
}
.info-window .iw-zone strong {
    color: #475569;
    font-weight: 600;
}

/* ── Stars ── */
.stars-inline {
    display: inline-flex;
    gap: 1px;
    margin-right: 2px;
    flex-shrink: 0;
}
.star { font-size: 12px; line-height: 1; }
.star.filled { color: #fbbf24; }
.star.empty { color: #475569; }
.iw-stars { display: inline-flex; gap: 1px; }
.iw-stars .star { font-size: 16px; }
.iw-stars .star.filled { color: #fbbf24; }
.iw-stars .star.empty { color: #d1d5db; }

/* ── School Report Info Window ── */
.school-report {
    font-family: 'Inter', sans-serif;
    min-width: 300px;
    max-width: 380px;
}
.school-report .sr-header {
    margin-bottom: 10px;
}
.school-report .sr-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}
.school-report .sr-district {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}
.school-report .sr-stars-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.school-report .sr-badges {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.school-report .sr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.school-report .sr-badge.gs {
    background: #dbeafe;
    color: #1d4ed8;
}
.school-report .sr-badge.tea {
    background: #dcfce7;
    color: #15803d;
}
.school-report .sr-badge.tea-c {
    background: #fef9c3;
    color: #a16207;
}
.school-report .sr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0;
}
.school-report .sr-stat {
    font-size: 11px;
    color: #64748b;
}
.school-report .sr-stat strong {
    display: block;
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
}
.school-report .sr-bar-label {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 3px;
}
.school-report .sr-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.school-report .sr-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.school-report .sr-highlights {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #475569;
    line-height: 1.5;
}
.school-report .sr-highlights strong {
    color: #1e293b;
    font-weight: 600;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Mobile ── */
@media (max-width: 640px) {
    header { padding: 10px 14px; }
    header h1 { font-size: 15px; }
    .subtitle { font-size: 11px; }
    .admin-panel { width: calc(100vw - 20px); right: 10px; }
    .filter-panel { width: 220px; }
    .house-count { display: none; }
}
