/* ============================================================
   Bản đồ toàn màn hình (map_fullscreen.html) — layout + controls
   MapLibre thuần; các layer dùng GeoJSON canvas nên mượt.
   ============================================================ */

.mf-app {
    position: fixed;
    inset: 0;
    display: flex;
    background: #f1f5f9;
    z-index: 1000;
}

/* ---------- Sidebar ---------- */
.mf-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.05);
    transition: margin-left 0.25s ease;
}

.mf-app.is-sidebar-hidden .mf-sidebar {
    margin-left: -340px;
}

.mf-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.mf-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #0f172a;
}

.mf-brand-badge {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f766e, #0ea5a4);
    color: #ffffff;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.mf-brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.mf-brand-copy strong {
    font-size: 1.02rem;
    font-weight: 800;
}

.mf-brand-copy small {
    color: #64748b;
    font-size: 0.76rem;
}

/* ---------- Search ---------- */
.mf-search-wrap {
    position: relative;
    padding: 12px 16px 6px;
}

.mf-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #f8fafc;
}

.mf-search-box:focus-within {
    border-color: rgba(15, 118, 110, 0.5);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.mf-search-box i {
    color: #94a3b8;
}

.mf-search-box input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 0.92rem;
    color: #0f172a;
}

.mf-search-clear {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
}

.mf-search-clear:hover {
    color: #475569;
}

.mf-search-results {
    position: absolute;
    top: calc(100% - 2px);
    left: 16px;
    right: 16px;
    max-height: 320px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
    z-index: 30;
}

/* ---------- Tabs loại lớp ---------- */
.mf-layer-nav {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    flex-wrap: wrap;
}

.mf-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: #f8fafc;
    color: #475569;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mf-tab:hover {
    background: rgba(15, 118, 110, 0.08);
    border-color: rgba(15, 118, 110, 0.35);
}

.mf-tab.is-active {
    background: linear-gradient(135deg, #0f766e, #0ea5a4);
    border-color: transparent;
    color: #ffffff;
}

.mf-tab-count {
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    font-size: 0.72rem;
    font-weight: 800;
}

.mf-tab:not(.is-active) .mf-tab-count {
    background: rgba(148, 163, 184, 0.18);
    color: #475569;
}

/* ---------- Panels nội dung ---------- */
.mf-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding: 10px 16px 12px;
    overflow: hidden;
}

.mf-panel.is-active {
    display: flex;
}

/* Panel "Cảnh báo thiên tai" (đã hợp nhất tab Cảnh báo 2026-09-10: danh sách
   cảnh báo đang hiệu lực nằm cuối panel) và panel "Thời gian thực" nhiều mục →
   toàn panel cuộn được. */
.mf-panel[data-panel="forecast"],
.mf-panel[data-panel="realtime"] {
    overflow-y: auto;
}

.mf-panel[data-panel="forecast"] .mf-forecast-list {
    flex: 0 0 auto;
    overflow-y: visible;
}

.mf-panel[data-panel="forecast"] .mf-forecast-alerts {
    flex: 0 0 auto;
    min-height: 0;
    max-height: 260px;
}

.mf-panel[data-panel="realtime"] .mf-alert-list {
    flex: 0 0 auto;
    min-height: 0;
    max-height: 340px;
}

.mf-filter-row {
    margin-bottom: 10px;
}

/* Dropdown phân loại đồng bộ form giao diện (search box phía trên): bỏ select
   native macOS (mũi tên 2 chiều lệch chuẩn), thay chevron SVG + nền trắng +
   focus ring teal như .mf-search-box. */
.mf-select {
    width: 100%;
    min-height: 44px;
    padding: 8px 38px 8px 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background-color: #f8fafc;
    font: inherit;
    font-size: 0.88rem;
    color: #0f172a;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}

.mf-select:hover {
    border-color: rgba(15, 118, 110, 0.4);
}

.mf-select:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.5);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

/* ---------- Danh sách địa điểm ---------- */
.mf-place-list,
.mf-alert-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

.mf-place-list::-webkit-scrollbar,
.mf-alert-list::-webkit-scrollbar {
    width: 6px;
}

.mf-place-list::-webkit-scrollbar-thumb,
.mf-alert-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
}

/* THẺ ĐỒNG NHẤT: cao cố định 2 dòng (tên + địa chỉ), chấm màu + nhãn phân loại
   căn giữa. display:flex của class đè mất thuộc tính [hidden] của HTML nên
   lọc phân loại "vô hình" không hoạt động — phải khai báo tường minh. */
.mf-place-item,
.mf-alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #f8fafc;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mf-place-item[hidden],
.mf-alert-item[hidden] {
    display: none;
}

.mf-place-item:hover,
.mf-alert-item:hover {
    background: rgba(15, 118, 110, 0.08);
    border-color: rgba(15, 118, 110, 0.25);
}

.mf-place-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
    line-height: 1.3;
}

.mf-place-copy strong {
    font-size: 0.86rem;
    font-weight: 700;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mf-place-copy small {
    color: #64748b;
    font-size: 0.76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mf-place-copy small.mf-place-only-type {
    color: #0f766e;
    font-weight: 600;
}

.mf-empty {
    padding: 22px 12px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.86rem;
}

/* ---------- Dot màu theo loại ---------- */
/* Nhãn phân loại cột phải — nhịp 3 cột (dot · nội dung · nhãn) tạo bố cục
   khoa học, đúng yêu cầu "mất phân loại" (nhãn hiện ngay trên từng thẻ). */
.mf-place-type-tag {
    flex-shrink: 0;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #64748b;
    background: rgba(148, 163, 184, 0.14);
    border-radius: 999px;
    padding: 3px 8px;
}

.mf-place-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex-shrink: 0;
    margin-top: 0;
    background: #0f766e;
}

.mf-place-dot[data-type="cong_an"] { background: #2563eb; }
.mf-place-dot[data-type="hanh_chinh"] { background: #d97706; }
.mf-place-dot[data-type="y_te"] { background: #dc2626; }
.mf-place-dot[data-type="giao_duc"] { background: #7c3aed; }
.mf-place-dot[data-type="du_lich"] { background: #059669; }
.mf-place-dot[data-type="cho"] { background: #ea580c; }
.mf-place-dot[data-type="ngan_hang"] { background: #0369a1; }
.mf-place-dot[data-type="atm"] { background: #0891b2; }
.mf-place-dot[data-type="buu_dien"] { background: #b45309; }
.mf-place-dot[data-type="xang_dau"] { background: #525252; }
.mf-place-dot[data-type="citizen_id"] { background: #7c3aed; }

.mf-alert-sev {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex-shrink: 0;
    margin-top: 0;
    background: #d97706;
}

.mf-alert-sev[data-severity="high"] { background: #dc2626; }
.mf-alert-sev[data-severity="low"] { background: #16a34a; }

/* ---------- Footer ---------- */
.mf-sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.mf-link-detail {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0f766e;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
}

.mf-link-detail:hover {
    text-decoration: underline;
}

.mf-note {
    padding: 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #475569;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ---------- Nút ẩn/hiện sidebar ---------- */
.mf-sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 352px;
    z-index: 20;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
    transition: left 0.25s ease, background 0.15s ease;
}

.mf-app.is-sidebar-hidden .mf-sidebar-toggle {
    left: 12px;
}

.mf-sidebar-toggle:hover {
    background: rgba(15, 118, 110, 0.08);
}

/* ---------- Map container ---------- */
.mf-map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

#mfMap {
    position: absolute;
    inset: 0;
}

/* ---------- Basemap switcher ---------- */
.mf-map-controls {
    position: absolute;
    z-index: 10;
}

.mf-map-controls--tl {
    top: 12px;
    right: 12px;
}

.mf-basemap-group {
    display: flex;
    gap: 6px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(8px);
}

.mf-basemap-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #475569;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mf-basemap-btn:hover {
    background: rgba(15, 118, 110, 0.08);
    color: #0f766e;
}

.mf-basemap-btn.is-active {
    background: linear-gradient(135deg, #0f766e, #0ea5a4);
    color: #ffffff;
}

/* ---------- Legend ---------- */
.mf-legend {
    position: absolute;
    bottom: 26px;
    left: 12px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(8px);
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
}

.mf-legend-title {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
}

.mf-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mf-legend-row .mf-place-dot {
    margin-top: 0;
}

/* MapLibre popup style đồng bộ */
#mfMap .maplibregl-popup-content {
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    font-family: inherit;
    min-width: 200px;
}

#mfMap .maplibregl-popup-content h4 {
    margin: 0 0 4px;
    font-size: 0.92rem;
    font-weight: 800;
    color: #0f172a;
}

#mfMap .maplibregl-popup-content p {
    margin: 0 0 3px;
    font-size: 0.8rem;
    color: #475569;
}

#mfMap .maplibregl-popup-content a {
    color: #0f766e;
    font-weight: 700;
    font-size: 0.8rem;
    text-decoration: none;
}

#mfMap .maplibregl-popup-content a:hover {
    text-decoration: underline;
}

/* ---------- Dự báo thiên tai (tab Dự báo + legend cấp rủi ro) ---------- */
.mf-view-switch {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    padding: 3px;
    border-radius: 10px;
    background: #f1f5f9;
}

.mf-view-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-weight: 700;
    font-size: 0.76rem;
    cursor: pointer;
}

.mf-view-btn.is-active {
    background: #ffffff;
    color: #0f766e;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.mf-risk-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
    vertical-align: -1px;
}

/* Gợi ý trong popup lớp nền — chữ nhỏ, dịu, không tranh chấp với số liệu. */
#mfMap .maplibregl-popup-content .mf-hint {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(15, 23, 42, 0.15);
    font-size: 0.78rem;
    color: #64748b;
}

.mf-forecast-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--hero-color, #94a3b8) 45%, transparent);
    background: color-mix(in srgb, var(--hero-color, #94a3b8) 14%, #ffffff);
    margin-bottom: 10px;
}

.mf-forecast-hero-level {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--hero-color, #64748b);
    line-height: 1;
    min-width: 58px;
    text-align: center;
}

.mf-forecast-hero-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mf-forecast-hero-copy strong {
    font-size: 0.95rem;
    color: #0f172a;
}

.mf-forecast-hero-copy small {
    color: #64748b;
    font-size: 0.74rem;
}

.mf-forecast-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.mf-forecast-chip {
    font-size: 0.7rem;
    font-weight: 700;
    color: #334155;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--chip-color, #94a3b8) 55%, transparent);
    background: color-mix(in srgb, var(--chip-color, #94a3b8) 16%, #ffffff);
}

.mf-forecast-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.mf-forecast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    width: 100%;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.mf-forecast-item:hover {
    border-color: rgba(15, 118, 110, 0.45);
    background: rgba(15, 118, 110, 0.05);
}

.mf-forecast-item-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.82rem;
    color: #ffffff;
    background: var(--risk-color, #94a3b8);
}

.mf-forecast-footnote {
    margin-top: 10px;
}

.mf-legend--forecast .mf-legend-note {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 4px;
}

@media (prefers-reduced-transparency: reduce) {
    .mf-forecast-hero,
    .mf-forecast-chip {
        background: #f8fafc;
    }
}

/* ---------- Tab Thời gian thực ---------- */
/* (2026-09-17 tối) Panel realtime trong sidebar đã bỏ — bấm tab mở thẳng bảng
   LIVE toàn màn hình. Chỉ giữ lại tiêu đề mục dùng chung trong panel dự báo. */
.mf-tab--live { position: relative; }

.mf-tab-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    animation: mf-live-pulse 1.6s infinite;
    margin-left: auto;
    flex: none;
}

.mf-rt-section-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #0f172a;
    margin: 12px 0 8px;
}

.mf-rt-section-title i {
    color: #0f766e;
}

/* ---------- Mobile: FAB chuyển Danh sách ↔ Bản đồ ---------- */
.mf-mobile-fab {
    display: none;
}

.mf-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(15, 23, 42, 0.45);
    border: none;
    padding: 0;
}

.mf-detail-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    background: #ffffff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.25);
    padding: 8px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    max-height: 72vh;
    overflow-y: auto;
    transform: translateY(0);
    animation: mfSheetUp 0.22s ease;
}

@keyframes mfSheetUp {
    from { transform: translateY(40%); opacity: 0.4; }
    to { transform: translateY(0); opacity: 1; }
}

.mf-detail-sheet-grab {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #e2e8f0;
    margin: 4px auto 10px;
}

.mf-detail-sheet-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
}

.mf-detail-sheet-title strong {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
}

.mf-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 8px 0;
    border-top: 1px solid #f1f5f9;
    font-size: 0.86rem;
    color: #334155;
    line-height: 1.45;
}

.mf-detail-row i {
    color: #0f766e;
    width: 16px;
    text-align: center;
    margin-top: 2px;
}

.mf-detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.mf-detail-actions a,
.mf-detail-actions button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
    border-radius: 12px;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.mf-detail-actions .mf-detail-primary {
    border: none;
    background: linear-gradient(135deg, #0f766e, #0ea5a4);
    color: #ffffff;
}

.mf-detail-actions .mf-detail-secondary {
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #f8fafc;
    color: #334155;
}



/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .mf-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 20;
        width: min(320px, 86vw);
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.2);
    }

    .mf-app.is-sidebar-hidden .mf-sidebar {
        margin-left: 0;
        transform: translateX(-105%);
    }

    .mf-sidebar {
        transition: transform 0.25s ease;
        margin-left: 0 !important;
    }

    .mf-sidebar-toggle {
        left: auto;
        right: 12px;
    }

    .mf-app:not(.is-sidebar-hidden) .mf-sidebar-toggle {
        right: calc(min(320px, 86vw) + 12px);
    }

    .mf-legend {
        display: none;
    }
}

/* Mobile (≤768px): DANH SÁCH LÀ MẶC ĐỊNH — sidebar chiếm trọn màn hình,
   bản đồ ẩn hẳn (không render nặng); FAB góc dưới chuyển sang Bản đồ.
   Bấm xã/địa điểm/cảnh báo → sheet chi tiết phía dưới thay vì popup bản đồ. */
@media (max-width: 768px) {
    .mf-sidebar-toggle {
        display: none;
    }

    .mf-mobile-fab {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        position: fixed;
        right: 14px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        z-index: 30;
        padding: 11px 16px;
        border-radius: 999px;
        border: none;
        background: linear-gradient(135deg, #0f766e, #0ea5a4);
        color: #ffffff;
        font: inherit;
        font-size: 0.84rem;
        font-weight: 800;
        cursor: pointer;
        box-shadow: 0 10px 26px rgba(15, 118, 110, 0.4);
    }

    .mf-app.is-mobile-map .mf-sidebar {
        display: none;
    }

    .mf-app:not(.is-mobile-map) .mf-map-wrap {
        display: none;
    }

    .mf-app.is-mobile-map .mf-mobile-fab span {
        display: none;
    }

    .mf-app.is-mobile-map .mf-mobile-fab {
        padding: 12px;
    }

    .mf-sidebar {
        width: 100vw;
        max-width: 100vw;
        box-shadow: none;
    }
}

/* ===================== BẢNG LIVE THỜI GIAN THỰC (2026-09-17) ===================== */
/* (2026-09-17 tối) Tab "Thời gian thực" mở THẲNG overlay này — không còn nút
   mở trung gian trong sidebar. GIAO DIỆN SÁNG (yêu cầu tối 17/09): nền sáng
   kiểu dashboard giám sát chuyên nghiệp, pill trạng thái, đếm ngược cập nhật. */

/* Pill trạng thái cấp rủi ro trên header — màu theo cấp cao nhất toàn tỉnh */
.mf-live-pill {
    --pill: #22c55e;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--pill);
    background: color-mix(in srgb, var(--pill) 14%, #ffffff);
    color: color-mix(in srgb, var(--pill) 72%, #0f172a);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 0 12px color-mix(in srgb, var(--pill) 22%, transparent);
}
.mf-live-pill[hidden] { display: none; }

/* Đếm ngược tới lần cập nhật kế */
.mf-live-next {
    color: #64748b;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Overlay toàn màn hình — nền SÁNG */
.mf-live {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    background: radial-gradient(1200px 600px at 20% -10%, #ffffff 0%, #f1f5f9 55%, #e8eef5 100%);
    color: #0f172a;
    overflow-y: auto;
}
.mf-live[hidden] { display: none; }
body.mf-live-open { overflow: hidden; }

.mf-live-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    z-index: 2;
}
.mf-live-brand { display: flex; align-items: center; gap: 12px; }
.mf-live-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: mf-live-pulse 1.6s infinite;
    flex: none;
}
.mf-live-dot.is-paused { background: #f59e0b; animation: none; box-shadow: none; }
.mf-live-brand-copy strong { display: block; font-size: 16px; letter-spacing: 0.02em; }
.mf-live-brand-copy small { color: #64748b; font-size: 13px; font-variant-numeric: tabular-nums; }
.mf-live-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mf-live-updated { color: #64748b; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mf-live-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.mf-live-btn:hover { background: #f1f5f9; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); }
.mf-live-btn--close { border-color: rgba(239, 68, 68, 0.5); color: #b91c1c; }

/* Nút nhỏ trong tiêu đề card (vd "Làm mới" nhận định AI) */
.mf-live-mini-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}
.mf-live-mini-btn:hover { background: #f1f5f9; }
.mf-live-mini-btn:disabled { opacity: 0.6; cursor: default; }

.mf-live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    padding: 20px 24px;
    flex: 1;
    align-content: start;
}
.mf-live-card {
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    padding: 16px 18px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mf-live-card--wide { grid-column: 1 / -1; }
/* Card rủi ro: viền trái + hào quang đổi theo cấp (nhìn từ xa nhận biết ngay,
   kiểu status wall của trung tâm điều hành). */
.mf-live-card--risk { border-left: 5px solid #475569; transition: border-color 0.6s ease, box-shadow 0.6s ease; }
.mf-live-card--risk[data-level='0'] { border-left-color: #475569; }
.mf-live-card--risk[data-level='1'] { border-left-color: #22c55e; box-shadow: 0 0 24px rgba(34, 197, 94, 0.12); }
.mf-live-card--risk[data-level='2'] { border-left-color: #facc15; box-shadow: 0 0 24px rgba(250, 204, 21, 0.14); }
.mf-live-card--risk[data-level='3'] { border-left-color: #f97316; box-shadow: 0 0 28px rgba(249, 115, 22, 0.2); }
.mf-live-card--risk[data-level='4'] { border-left-color: #dc2626; box-shadow: 0 0 32px rgba(220, 38, 38, 0.3); }
.mf-live-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}
.mf-live-count {
    margin-left: auto;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eef2f7;
    color: #334155;
    font-variant-numeric: tabular-nums;
}
.mf-live-card-body { flex: 1; overflow-y: auto; }
.mf-live-card .mf-empty { color: #64748b; }

/* Card cấp rủi ro tỉnh */
.mf-live-level {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--level, #94a3b8) 22%, transparent);
    border-left: 6px solid var(--level, #94a3b8);
}
.mf-live-level[data-changed='true'] { animation: mf-live-flash 1.2s ease 3; }
.mf-live-level-value { font-size: 34px; font-weight: 800; color: var(--level, #94a3b8); line-height: 1; }
.mf-live-level-label { font-size: 18px; font-weight: 600; }
.mf-live-official {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: #b91c1c;
    font-size: 13px;
}
.mf-live-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mf-live-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    border-left: 4px solid var(--chip, #94a3b8);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.mf-live-source { display: block; margin-top: 10px; color: #64748b; font-size: 12px; }

/* Danh sách cảnh báo live */
.mf-live-alerts { display: flex; flex-direction: column; gap: 8px; }
.mf-live-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.mf-live-alert.is-new { animation: mf-live-flash 1.4s ease 4; border-color: rgba(239, 68, 68, 0.55); }
.mf-live-alert-sev { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.mf-live-alert-sev[data-severity='high'] { background: #ef4444; }
.mf-live-alert-sev[data-severity='medium'] { background: #f59e0b; }
.mf-live-alert-sev[data-severity='low'] { background: #22c55e; }
.mf-live-alert-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-live-alert-copy strong { font-size: 14px; }
.mf-live-alert-copy small { color: #64748b; font-size: 12px; }
.mf-live-new-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 6px;
    background: #dc2626;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    flex: none;
}

/* Điểm nóng theo ĐỊA ĐIỂM cụ thể — Impact Engine (2026-09-18) */
.mf-live-points { display: flex; flex-direction: column; gap: 8px; }
.mf-live-point-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--risk, #94a3b8);
}
.mf-live-point-row.is-new { animation: mf-live-flash 1.4s ease 4; border-color: rgba(239, 68, 68, 0.55); }
.mf-live-point-level {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--risk, #94a3b8);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.mf-live-point-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-live-point-copy strong { font-size: 14px; }
.mf-live-point-copy small { color: #64748b; font-size: 12px; }
.mf-live-point-copy small em { color: #b91c1c; font-style: normal; font-weight: 600; }

/* ---- GĐ2 Alarm Engine: card báo động + banner + âm thanh ---- */
.mf-live-card--alarm { border-color: #fecaca; }
.mf-live-card--alarm.is-hot {
    border-color: rgba(220, 38, 38, 0.55);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06);
}
.mf-live-alarm-note { color: #94a3b8; font-weight: 500; font-size: 11.5px; margin-left: 6px; }
.mf-live-alarms { display: flex; flex-direction: column; gap: 8px; }
.mf-live-alarm-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-left: 4px solid var(--risk, #dc2626);
}
.mf-live-alarm-row.is-new { animation: mf-live-flash 1.4s ease 4; border-color: rgba(239, 68, 68, 0.55); }
.mf-live-alarm-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--risk, #dc2626);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.mf-live-alarm-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-live-alarm-copy strong { font-size: 14px; }
.mf-live-alarm-copy small { color: #64748b; font-size: 12px; }
.mf-live-alarm-time { color: #94a3b8; }
.mf-live-btn.is-off { color: #94a3b8; }
.mf-live-alarm-banner {
    position: fixed;
    top: 84px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9010;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(640px, calc(100vw - 32px));
    padding: 14px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 10px 30px rgba(220, 38, 38, 0.35);
}
.mf-live-alarm-banner[hidden] { display: none; }
.mf-live-alarm-banner.is-running { animation: mf-live-alarm-pulse 0.9s ease-in-out 6; }
.mf-live-alarm-banner-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-live-alarm-banner-copy strong { font-size: 14.5px; }
.mf-live-alarm-banner-copy small { font-size: 12px; opacity: 0.9; }
.mf-live-alarm-banner-close {
    margin-left: auto;
    border: none;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    flex: none;
}
.mf-live-alarm-banner-close:hover { background: rgba(255, 255, 255, 0.28); }
@keyframes mf-live-alarm-pulse {
    0%, 100% { box-shadow: 0 10px 30px rgba(220, 38, 38, 0.35); }
    50% { box-shadow: 0 10px 44px rgba(220, 38, 38, 0.75); }
}

/* ---- GĐ4 crowd-sensor: panel đồng ý + card quan trắc thực đo ---- */
.mf-sensor-consent {
    position: absolute;
    left: 12px;
    bottom: 58px;
    z-index: 5;
    max-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mf-sensor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.94);
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}
.mf-sensor-toggle.is-on { border-color: #16a34a; color: #15803d; }
.mf-sensor-toggle.is-on i { animation: mf-live-alarm-pulse 2.4s ease-in-out infinite; }
.mf-sensor-note {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 11.5px;
    color: #64748b;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}
.mf-live-obs { display: flex; flex-direction: column; gap: 8px; }
.mf-live-obs-row {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: start;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #f0fdfa;
    border: 1px solid #ccfbf1;
}
.mf-live-obs-row[data-quality='suspect'] { background: #fffbeb; border-color: #fde68a; }
.mf-live-obs-row[data-quality='bad'] { background: #fef2f2; border-color: #fecaca; }
.mf-live-obs-dot { width: 10px; height: 10px; border-radius: 50%; background: #0d9488; margin-top: 5px; }
.mf-live-obs-row[data-quality='suspect'] .mf-live-obs-dot { background: #d97706; }
.mf-live-obs-row[data-quality='bad'] .mf-live-obs-dot { background: #dc2626; }
.mf-live-obs-community { background: #f1f5f9; border-color: #e2e8f0; }
.mf-live-obs-community .mf-live-obs-dot { background: #64748b; }
.mf-live-obs-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-live-obs-copy strong { font-size: 13.5px; }
.mf-live-obs-copy small { color: #64748b; font-size: 12px; }

/* Xã rủi ro cao nhất */
.mf-live-hot { display: flex; flex-direction: column; gap: 6px; }
.mf-live-hot-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border-left: 4px solid var(--risk, #94a3b8);
    font-size: 13.5px;
}
.mf-live-hot-row small { color: #64748b; font-variant-numeric: tabular-nums; }
.mf-live-hot-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--risk, #94a3b8);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}
.mf-live-ai-text { white-space: pre-wrap; line-height: 1.55; font-size: 14px; }

.mf-live-foot {
    padding: 12px 24px;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 12px;
}

@keyframes mf-live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@keyframes mf-live-flash {
    0%, 100% { background: #ffffff; }
    50% { background: rgba(220, 38, 38, 0.12); }
}

@media (max-width: 768px) {
    .mf-live-grid { grid-template-columns: 1fr; padding: 14px; }
    .mf-live-head { flex-wrap: wrap; padding: 12px 14px; }
    .mf-live-actions { width: 100%; justify-content: flex-start; }
    .mf-live-level-value { font-size: 28px; }
}

/* ---- Biểu đồ realtime (2026-09-17) ---- */
.mf-live-level { align-items: center; }
.mf-live-gauge { width: 130px; flex: none; }
.mf-live-gauge-arc { transition: all 0.8s ease; }
.mf-live-gauge-needle { transition: all 0.8s ease; }
.mf-live-flash-once { animation: mf-live-flash 1.2s ease 3; }

.mf-live-chip-btn {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    cursor: pointer;
}
.mf-live-chip-btn.is-active { background: #2563eb; border-color: #2563eb; color: #fff; }
.mf-live-station-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.mf-live-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 170px;
    padding: 8px 4px 4px;
    border-radius: 10px;
    background: #f1f5f9;
}
.mf-live-col { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 4px; }
.mf-live-col.is-now { outline: 1px dashed rgba(15, 23, 42, 0.45); outline-offset: 1px; border-radius: 3px 3px 0 0; }
.mf-live-col-fill {
    display: block;
    width: 100%;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    background: #cbd5e1;
    transition: height 0.9s ease;
}
.mf-live-col-fill[data-level='light'] { background: #38bdf8; }
.mf-live-col-fill[data-level='mid'] { background: #2563eb; }
.mf-live-col-fill[data-level='heavy'] { background: #1d4ed8; box-shadow: 0 0 8px rgba(29, 78, 216, 0.55); }

.mf-live-bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 56px;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
}
.mf-live-bar-name { color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-live-bar-track { display: block; height: 14px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.mf-live-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--risk, #94a3b8);
    transition: width 0.9s ease;
}
.mf-live-bar-value { color: #64748b; text-align: right; font-variant-numeric: tabular-nums; }

.mf-live-ticker {
    overflow: hidden;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 6px 0;
    margin-bottom: 8px;
    white-space: nowrap;
}
.mf-live-ticker-track {
    display: inline-block;
    padding-left: 100%;
    animation: mf-live-ticker-scroll 45s linear infinite;
    color: #334155;
    font-size: 13px;
}
.mf-live-ticker:hover .mf-live-ticker-track { animation-play-state: paused; }
.mf-live-ticker-item[data-severity='high'] { color: #b91c1c; }
.mf-live-ticker-item[data-severity='medium'] { color: #b45309; }
.mf-live-ticker-item[data-severity='low'] { color: #15803d; }
.mf-live-ticker-sep { color: #cbd5e1; padding: 0 10px; }
@keyframes mf-live-ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* Nhãn tên xã (DOM marker, không phụ thuộc glyph) — 2026-09-17 */
.mf-commune-label {
    font-size: 11px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    pointer-events: none;
    text-shadow:
        0 0 3px rgba(255, 255, 255, 0.95),
        0 0 6px rgba(255, 255, 255, 0.75),
        0 1px 2px rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

