:root {
    --navy: #071426;
    --navy-2: #0d2138;
    --panel: rgba(12, 31, 52, .78);
    --line: rgba(148, 163, 184, .22);
    --text: #f8fafc;
    --muted: #9fb0c5;
    --red: #dc2626;
    --blue: #2484ff;
    --green: #22c55e;
    --yellow: #f59e0b;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { color: var(--text); background: radial-gradient(circle at top left, #142b49, #071426 48%); font-family: Arial, Helvetica, sans-serif; }
a { color: #7bb7ff; text-decoration: none; }
input, select, button { font: inherit; }
.hidden { display: none !important; }
.flame-navbar {
    position: fixed; inset: 0 0 auto; z-index: 3000; min-height: 58px; display: flex; align-items: center; gap: 14px;
    padding: 8px 14px; background: rgba(5, 17, 31, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.flame-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); min-width: 260px; }
.flame-brand strong { display: block; font-size: 20px; letter-spacing: .08em; }
.flame-brand small { display: block; color: #b8c7db; font-size: 11px; }
.flame-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, #dc2626, #7f1d1d); font-weight: 900; border: 1px solid #ffb4b4; }
.flame-nav-links { display: flex; align-items: center; gap: 6px; flex: 1; }
.flame-nav-links a { padding: 9px 11px; color: #dbeafe; border-radius: 8px; font-weight: 800; font-size: 13px; }
.flame-nav-links a.active, .flame-nav-links a:hover { background: #dc2626; color: #fff; }
.flame-user { display: flex; align-items: center; gap: 10px; color: #e5eefb; font-size: 12px; white-space: nowrap; }
.logout-link { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: #fff; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; display: inline-block; }
.status-dot.online { background: var(--green); box-shadow: 0 0 10px var(--green); }
.nav-toggle { display: none; color: white; background: #0f2947; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.flame-main { padding: 76px 18px 40px; max-width: 1680px; margin: 0 auto; }
.hero-strip, .page-head, .glass-panel, .summary-card { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.26); }
.hero-strip { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 20px; margin-bottom: 14px; }
.eyebrow { margin: 0 0 3px; color: #ffb4b4; font-size: 12px; font-weight: 900; letter-spacing: .12em; }
h1, h2, h3 { margin: 0; }
.hero-strip h1 { font-size: clamp(28px, 3vw, 44px); letter-spacing: .02em; }
.hero-strip p { color: #cbd5e1; }
.hero-status { text-align: right; display: grid; gap: 4px; }
.hero-status strong { font-size: 30px; }
.summary-grid { display: grid; grid-template-columns: repeat(8, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card { padding: 14px; min-height: 90px; }
.summary-card span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 900; }
.summary-card strong { display: block; margin-top: 8px; font-size: 30px; color: #fff; }
.summary-card.danger strong { color: #ff5b69; }
.summary-card.green strong { color: #4ade80; }
.summary-card.warning strong { color: #facc15; }
.summary-card.blue strong { color: #60a5fa; }
.summary-card.muted strong { color: #cbd5e1; }
.command-map-shell { position: relative; min-height: 620px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; margin-bottom: 14px; }
.map-toolbar { position: absolute; z-index: 1000; left: 14px; top: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 9px; }
.map-toolbar button, .map-toolbar label, .primary-btn { border: 1px solid var(--line); background: #102943; color: #fff; border-radius: 8px; padding: 9px 11px; font-weight: 800; }
.map-toolbar button:hover, .primary-btn { background: #1d6eea; }
.incident-panel { padding: 14px; overflow: auto; max-height: 620px; }
.incident-item { padding: 11px; margin: 8px 0; border-left: 4px solid #ef4444; background: rgba(239, 68, 68, .1); border-radius: 8px; }
.monitor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.monitor-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.glass-panel { padding: 14px; }
.glass-panel h3 { margin-bottom: 10px; font-size: 16px; }
.panel-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); color: #dbeafe; }
.alert-ticker { position: fixed; z-index: 3500; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; padding: 9px 16px; background: #0b1220; border-top: 1px solid var(--line); color: #f8fafc; }
.alert-ticker strong { color: #ff5b69; }
.page-head { padding: 18px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row input, .filter-row select { min-height: 42px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: #071426; }
.filter-row input { min-width: 320px; flex: 1; }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; color: #e5eefb; }
.data-table th, .data-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: #9fb0c5; text-transform: uppercase; font-size: 12px; }
.install-flame, .flame-toast { position: fixed; right: 16px; bottom: 50px; z-index: 5000; border: 0; border-radius: 999px; background: #dc2626; color: white; padding: 10px 14px; font-weight: 900; }
.flame-toast { left: 16px; right: auto; border-radius: 10px; background: #102943; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 1000px); display: grid; grid-template-columns: 1fr 420px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: rgba(10, 31, 53, .9); }
.login-brand, .login-panel { padding: 48px; }
.login-brand { background: linear-gradient(135deg, #061426, #123b66); display: flex; flex-direction: column; justify-content: center; }
.flame-logo-large { width: 130px; height: 130px; display: grid; place-items: center; border-radius: 28px; background: linear-gradient(135deg, #dc2626, #7f1d1d); border: 3px solid #fff; font-weight: 900; font-size: 28px; margin-bottom: 24px; }
.login-panel input { width: 100%; margin: 8px 0 18px; min-height: 48px; border-radius: 10px; border: 1px solid #315a83; background: #071a31; color: #fff; padding: 10px; }
.alert-error { padding: 12px; background: #7f1d1d; border: 1px solid #ef4444; border-radius: 10px; margin: 12px 0; }
@media (max-width: 1100px) {
    .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .command-map-shell { grid-template-columns: 1fr; }
    .incident-panel { max-height: none; }
    .monitor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .flame-navbar { flex-wrap: wrap; }
    .flame-brand { min-width: auto; flex: 1; }
    .nav-toggle { display: inline-block; }
    .flame-nav-links { display: none; width: 100%; flex-direction: column; align-items: stretch; }
    .flame-nav-links.open { display: flex; }
    .flame-user { width: 100%; overflow: auto; }
    .summary-grid, .monitor-grid, .monitor-grid.two, .login-shell { grid-template-columns: 1fr; }
    .flame-main { padding: 118px 10px 50px; }
    .hero-strip { display: block; }
    .hero-status { text-align: left; }
    .filter-row input { min-width: 100%; }
}

/* Live map concept update: map-first emergency display. */
.flame-main.map-command-main {
    max-width: none;
    padding-left: 12px;
    padding-right: 12px;
}

.map-command-main .hero-strip {
    min-height: 64px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 10px;
}

.map-command-main .eyebrow {
    margin-bottom: 0;
    color: #93c5fd;
    font-size: 10px;
}

.map-command-main .hero-strip h1 {
    font-size: clamp(22px, 2.2vw, 34px);
}

.map-command-main .hero-strip p {
    margin: 4px 0 0;
    font-size: 13px;
}

.map-command-main .summary-grid {
    grid-template-columns: repeat(8, minmax(110px, 1fr));
    gap: 7px;
    margin-bottom: 8px;
}

.map-command-main .summary-card {
    min-height: 64px;
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(7, 20, 38, .88);
}

.map-command-main .summary-card span {
    font-size: 10px;
}

.map-command-main .summary-card strong {
    margin-top: 3px;
    font-size: 24px;
}

.command-map-shell {
    display: block;
    min-height: 0;
    margin-bottom: 10px;
}

.map-toolbar {
    max-width: min(560px, calc(100vw - 28px));
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 10px 26px rgba(15, 23, 42, .18);
    backdrop-filter: blur(10px);
}

.map-toolbar button,
.map-toolbar label,
.map-toolbar .primary-btn {
    min-height: 34px;
    padding: 7px 10px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 12px;
}

.map-toolbar button:hover,
.map-toolbar .primary-btn {
    color: #ffffff;
    background: #0f63d8;
}

.map-version {
    align-self: center;
    padding: 4px 7px;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
}

.incident-panel {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 900;
    width: min(300px, calc(100% - 24px));
    max-height: min(440px, 48vh);
    padding: 10px;
    overflow: auto;
    border-radius: 10px;
    background: rgba(7, 20, 38, .86);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .28);
    backdrop-filter: blur(10px);
}

.incident-panel h2 {
    margin-bottom: 6px;
    font-size: 15px;
}

.incident-item {
    padding: 8px;
    margin: 6px 0;
    font-size: 12px;
}

.monitor-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.monitor-grid .glass-panel {
    max-height: 180px;
    overflow: auto;
    padding: 10px;
    border-radius: 10px;
}

.monitor-grid .glass-panel h3 {
    font-size: 13px;
}

.panel-row {
    padding: 6px 0;
    font-size: 12px;
}

.dashboard-priority-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 10px;
    margin-bottom: 10px;
}

.dashboard-home-main {
    max-width: 1480px;
}

.dashboard-entry-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding: 14px;
}

.dashboard-entry-actions h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.dashboard-entry-actions p {
    margin: 0;
    color: #a8bad0;
    font-size: 13px;
}

.dashboard-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.primary-btn.danger {
    background: #dc2626;
}

.primary-btn.dark {
    background: #102943;
}

.dashboard-summary-grid {
    grid-template-columns: repeat(8, minmax(120px, 1fr));
}

.dashboard-first-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
    margin-bottom: 12px;
}

.dashboard-first-panel {
    max-height: none;
}

.dashboard-first-panel #stationHydrantSummary,
.dashboard-first-panel #stationGpsSummary {
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.dashboard-monitor-grid {
    margin-bottom: 22px;
}

.priority-panel {
    max-height: 340px;
    overflow: auto;
}

.priority-panel h2,
.section-label-row h2 {
    margin: 0;
    font-size: 18px;
}

.panel-subtitle,
.section-label-row p {
    margin: 4px 0 12px;
    color: #a8bad0;
    font-size: 12px;
}

.station-summary-card {
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 10px;
    background: rgba(7, 20, 38, .54);
}

.station-summary-head,
.station-summary-counts,
.gps-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.station-summary-head strong {
    color: #fff;
}

.station-summary-head span {
    padding: 4px 8px;
    border-radius: 999px;
    color: #bfdbfe;
    background: rgba(37, 99, 235, .18);
    font-size: 12px;
    font-weight: 900;
}

.station-summary-counts {
    justify-content: flex-start;
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 12px;
}

.station-summary-counts span {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, .12);
}

.station-summary-counts .good { color: #86efac; }
.station-summary-counts .bad { color: #fca5a5; }
.station-summary-counts .warn { color: #fde68a; }

.barangay-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.barangay-chip {
    min-width: 130px;
    padding: 7px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
}

.barangay-chip span,
.barangay-chip small {
    display: block;
    color: #b8c7db;
    font-size: 11px;
}

.barangay-chip strong {
    display: block;
    color: #fff;
    font-size: 20px;
    line-height: 1.1;
}

.summary-more {
    align-self: center;
    color: #93c5fd;
}

.gps-summary-row {
    margin-bottom: 8px;
}

.gps-summary-row div {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(15, 41, 71, .72);
}

.gps-summary-row span {
    display: block;
    color: #a8bad0;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 900;
}

.gps-summary-row strong {
    display: block;
    margin-top: 4px;
    font-size: 24px;
}

.gps-ok {
    color: #86efac;
}

.section-label-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin: 4px 0 8px;
}

.missing-station-list {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid rgba(148, 163, 184, .28);
    color: #fbbf24;
    font-size: 12px;
}

.missing-station-list strong,
.missing-station-list span {
    display: block;
}

.missing-station-list span {
    margin-top: 4px;
    color: #fde68a;
}

@media (max-width: 1100px) {
    .map-command-main .summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .incident-panel {
        position: relative;
        top: auto;
        right: auto;
        width: auto;
        max-height: 220px;
        margin-top: 8px;
    }

    .dashboard-priority-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .flame-main.map-command-main {
        padding-left: 6px;
        padding-right: 6px;
    }

    .map-command-main .summary-grid {
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .map-command-main .summary-card {
        min-width: 132px;
    }

    .dashboard-entry-actions {
        display: block;
    }

    .dashboard-action-buttons {
        justify-content: stretch;
        margin-top: 12px;
    }

    .dashboard-action-buttons a {
        flex: 1 1 100%;
        text-align: center;
    }

    .dashboard-summary-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .map-toolbar {
        left: 8px;
        right: auto;
        max-width: calc(100vw - 16px);
    }

    .map-toolbar button,
    .map-toolbar label {
        min-height: 32px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .monitor-grid {
        grid-template-columns: 1fr;
    }
}
