/* ============================================================
   PM2.5 EWS — Dark Dashboard Theme
   Palette: zinc scale + blue accent + alert colors
   ============================================================ */

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #09090b;
    color: #fafafa;
    min-height: 100vh;
}

.app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* ---- Nav ---- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(9, 9, 11, 0.85);
    border-bottom: 1px solid #27272a;
    margin: 0 -20px;
    padding: 0 20px;
}

.nav-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-icon { font-size: 22px; line-height: 1; }

.nav-title {
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.03em;
    color: #fafafa;
}

/* Main tabs */
.nav-tabs {
    display: flex;
    gap: 2px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 3px;
}

.tab {
    all: unset;
    cursor: pointer;
    padding: 6px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #71717a;
    transition: all 0.15s;
}

.tab:hover { color: #a1a1aa; background: #27272a; }

.tab-active {
    color: #fafafa !important;
    background: #3b82f6 !important;
}

/* City pills */
.nav-pills {
    display: flex;
    gap: 4px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 3px;
}

.pill {
    all: unset;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #a1a1aa;
    transition: all 0.15s;
}

.pill:hover { color: #fafafa; background: #27272a; }

.pill-active { color: #fafafa; background: #27272a; box-shadow: 0 0 0 1px #3f3f46; }

/* ---- Tab Content ---- */
.tab-content { display: none; }
.tab-visible { display: block; }

/* ---- Banner ---- */
.banner-wrap { margin-top: 24px; }

.banner {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid #27272a;
    background: #18181b;
    padding: 32px;
    text-align: center;
    transition: border-color 0.4s;
}

.banner-glow {
    position: absolute;
    inset: 0;
    opacity: 0.12;
    background: radial-gradient(ellipse at 50% 0%, var(--banner-color, #3b82f6) 0%, transparent 70%);
    pointer-events: none;
    transition: background 0.4s;
}

.banner-content { position: relative; z-index: 1; }

.banner-city {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a1a1aa;
    margin-bottom: 8px;
}

.banner-status {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #fafafa;
    transition: color 0.3s;
}

.banner-health {
    font-size: 14px;
    color: #a1a1aa;
    margin-top: 8px;
    min-height: 20px;
}

/* ---- Actions ---- */
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.action-btn {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}

.action-primary { background: #3b82f6; color: white; }
.action-primary:hover { background: #2563eb; }
.action-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.action-ghost { background: #27272a; color: #fafafa; border: 1px solid #3f3f46; }
.action-ghost:hover { background: #3f3f46; }

.station-count {
    margin-left: auto;
    font-size: 13px;
    color: #71717a;
    font-weight: 500;
}

/* ---- Stats Row ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 16px 20px;
    text-align: center;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #71717a;
    margin-bottom: 4px;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: #fafafa;
    letter-spacing: -0.02em;
}

.stat-unit {
    font-size: 12px;
    color: #52525b;
    margin-top: 2px;
}

/* ---- Table ---- */
.table-card {
    margin-top: 16px;
    border: 1px solid #27272a;
    border-radius: 14px;
    overflow: hidden;
    background: #18181b;
}

.table-head {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #1c1c20;
    border-bottom: 1px solid #27272a;
}

.th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #71717a;
}

.table-body {
    max-height: calc(100vh - 440px);
    min-height: 200px;
    overflow-y: auto;
}

.table-body::-webkit-scrollbar { width: 6px; }
.table-body::-webkit-scrollbar-track { background: transparent; }
.table-body::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 3px; }

.th-station, .td-station { flex: 2; min-width: 160px; }
.th-dist,    .td-dist    { width: 80px; text-align: right; }
.th-dir,     .td-dir     { width: 50px; text-align: center; }
.th-tier,    .td-tier    { width: 50px; text-align: center; }
.th-pm,      .td-pm      { width: 70px; text-align: right; }
.th-pred,    .td-pred    { width: 80px; text-align: right; }
.th-level,   .td-level   { width: 105px; text-align: center; }
.th-lead,    .td-lead    { width: 95px; text-align: center; }

.tier-sep {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #3b82f6;
    border-top: 1px solid #27272a;
}

.tier-sep:first-child { border-top: none; }

.row {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(39, 39, 42, 0.5);
    transition: background 0.1s;
}

.row:last-child { border-bottom: none; }
.row:hover { background: rgba(59, 130, 246, 0.04); }
.row .td-station { font-weight: 600; color: #e4e4e7; }

.row .td-dist,
.row .td-dir,
.row .td-tier,
.row .td-lead {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #a1a1aa;
}

.row .td-pm,
.row .td-pred {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #d4d4d8;
}

.row.no-data .td-pm,
.row.no-data .td-pred { color: #3f3f46; }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.empty-state { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 14px; color: #52525b; line-height: 1.6; }
.empty-text strong { color: #a1a1aa; }

.footer { margin-top: 16px; }
.status { font-size: 12px; color: #52525b; font-weight: 500; }

/* ============================================================
   MAP TAB
   ============================================================ */
.map-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.map-container {
    margin-top: 16px;
    height: calc(100vh - 220px);
    min-height: 400px;
    border-radius: 14px;
    border: 1px solid #27272a;
    overflow: hidden;
    background: #18181b;
}

.map-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    padding: 10px 16px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 10px;
    flex-wrap: wrap;
}

.legend-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #71717a;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #a1a1aa;
}

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

.legend-dot-empty {
    background: transparent !important;
    border: 2px solid #52525b;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
    background: #18181b !important;
    color: #fafafa !important;
    border: 1px solid #3f3f46 !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip { background: #18181b !important; }

.leaflet-popup-content {
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    margin: 12px 16px !important;
}

.popup-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 0;
}

.popup-label { color: #a1a1aa; }

.popup-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

/* ============================================================
   RESEARCH TAB
   ============================================================ */
.research {
    margin-top: 24px;
}

.research-nav {
    display: flex;
    gap: 4px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 4px;
    flex-wrap: wrap;
}

.rnav {
    all: unset;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #71717a;
    transition: all 0.15s;
}

.rnav:hover { color: #a1a1aa; background: #27272a; }

.rnav-active {
    color: #fafafa !important;
    background: #27272a !important;
    box-shadow: 0 0 0 1px #3f3f46;
}

.research-section { display: none; margin-top: 20px; }
.research-visible { display: block; }

.research-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 14px;
    padding: 28px 32px;
    margin-bottom: 16px;
}

.research-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 4px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.research-h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: #fafafa;
    margin-bottom: 12px;
}

.research-authors {
    font-size: 15px;
    color: #a1a1aa;
    margin-bottom: 4px;
}

.research-period {
    font-size: 13px;
    color: #71717a;
    font-weight: 600;
}

.research-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fafafa;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.research-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: #e4e4e7;
    margin-bottom: 6px;
}

.research-card p {
    font-size: 14px;
    color: #a1a1aa;
    line-height: 1.7;
    margin-bottom: 12px;
}

.research-card p:last-child { margin-bottom: 0; }

.research-card strong { color: #e4e4e7; }

.research-quote {
    border-left: 3px solid #3b82f6;
    padding: 16px 20px;
    margin: 16px 0;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0 10px 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #d4d4d8;
    line-height: 1.5;
    font-style: italic;
}

.key-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.key-stat {
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.key-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    color: #3b82f6;
}

.key-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.method-item {
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 20px;
}

.method-list {
    list-style: none;
    padding: 0;
}

.method-list li {
    position: relative;
    padding: 8px 0 8px 20px;
    font-size: 14px;
    color: #a1a1aa;
    line-height: 1.6;
    border-bottom: 1px solid #27272a;
}

.method-list li:last-child { border-bottom: none; }

.method-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 16px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3b82f6;
}

.method-list li strong { color: #e4e4e7; }

.stat-highlight {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02));
    border: 1px solid rgba(59,130,246,0.15);
    border-radius: 12px;
}

.stat-highlight-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 48px;
    font-weight: 800;
    color: #3b82f6;
    letter-spacing: -0.03em;
}

.stat-highlight-label {
    font-size: 13px;
    font-weight: 600;
    color: #a1a1aa;
    margin-top: 4px;
}

.stat-highlight-desc {
    font-size: 12px;
    color: #71717a;
    margin-top: 2px;
}

.equation {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: #3b82f6;
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
    text-align: center;
}

/* Research subtitle */
.research-subtitle {
    font-size: 17px;
    font-weight: 600;
    color: #d4d4d8;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

/* Research tables */
.research-table-wrap {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 10px;
    border: 1px solid #27272a;
}

.research-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.research-table th {
    background: #1c1c20;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #71717a;
    border-bottom: 1px solid #27272a;
}

.research-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(39, 39, 42, 0.5);
    color: #d4d4d8;
}

.research-table tr:last-child td { border-bottom: none; }

.research-table .total-row td {
    background: rgba(59, 130, 246, 0.05);
    border-top: 1px solid #3f3f46;
}

.highlight-green {
    color: #A8D5A0;
    font-weight: 700;
}

.highlight-yellow {
    color: #D2CC9A;
    font-weight: 700;
}

/* Conclusion grid */
.conclusion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.conclusion-item {
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 20px;
}

.conclusion-item h3 {
    font-size: 14px;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 6px;
}

.conclusion-item p {
    font-size: 13px;
    margin-bottom: 0;
}

/* Reference list */
.ref-list li::before {
    display: none;
}

.ref-list li {
    padding-left: 0;
    font-size: 13px;
    color: #71717a;
}

/* Alert table */
.alert-table td:last-child {
    font-size: 12px;
    color: #a1a1aa;
    max-width: 400px;
}

/* ---- Progress Bar ---- */
.progress-wrap {
    margin-top: 20px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 16px 20px;
}

.progress-label {
    font-size: 12px;
    font-weight: 600;
    color: #a1a1aa;
    margin-bottom: 8px;
}

.progress-bar {
    height: 6px;
    background: #27272a;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #3b82f6;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .nav-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
    .key-stats, .method-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .th-dir, .td-dir,
    .th-tier, .td-tier,
    .th-lead, .td-lead { display: none; }
    .research-h1 { font-size: 22px; }
    .stat-highlight-value { font-size: 36px; }
}
