/* =========================================================
    FLOOD MAP — style.css  MASTER (v4 - stacked layout)
    ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Áp Roboto toàn trang qua inheritance — KHÔNG !important
     để Font Awesome vẫn tự set font riêng trên <i class="fa-*"> */
html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #0f172a;
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

/* ── Ép Roboto trực tiếp trên các thẻ hay bị browser/Mapbox reset ──
     - KHÔNG dùng !important trên * (vỡ icon Font Awesome)
     - Dùng !important chỉ trên popup/panel Mapbox (FA vẫn thắng vì FA cũng !important) */
button,
input,
select,
textarea {
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Mapbox GL tự inject CSS riêng đặt lại font trên popup — override nó */
.mapboxgl-popup,
.mapboxgl-popup-content,
.mapboxgl-popup-content div,
.mapboxgl-popup-content span,
.mapboxgl-popup-content p,
.mapboxgl-popup-content button,
.mapboxgl-popup-content a {
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif !important;
}

/* Rescue popup & panel flood — đảm bảo Roboto toàn bộ */
.rescue-popup,
.rescue-popup *,
.rescue-modal__box,
.rescue-modal__box *,
#flood10-panel,
#flood10-panel * {
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif !important;
}

/* Khôi phục Font Awesome — FA dùng !important nên sẽ thắng rule trên */
/* (Dòng này chỉ để ghi chú, FA tự xử lý qua CSS của nó) */



.hidden {
  display: none !important;
}

/* =========================================================
    CSS VARIABLES  (overridden per breakpoint)
    ========================================================= */
:root {
  --tab-h: 50px;
  --panel-h: 40px;
  /* collapsed panel header height */
}

@media (max-width: 900px) {
  :root {
    --tab-h: 46px;
    --panel-h: 40px;
  }
}

@media (max-width: 480px) {
  :root {
    --tab-h: 44px;
    --panel-h: 38px;
  }
}

/* =========================================================
    TAB BAR
    ========================================================= */
.tab-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tab-h);
  background: rgba(15, 23, 42, 0.97);
  border-bottom: 1px solid #1e3a5f;
  display: flex;
  align-items: center;
  z-index: 9999;
  padding: 0 12px;
  gap: 4px;
}

.app-title {
  font-weight: 800;
  color: #38bdf8;
  margin-right: 16px;
  letter-spacing: 0.8px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: #94a3b8;
  height: 100%;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, .05);
}

.tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

/* Tab divider */
.tab-divider {
  width: 1px;
  height: 20px;
  background: #1e3a5f;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Mobile-only: tên tab đang active ────────────────────── */
.mobile-active-label {
  display: none;
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  gap: 5px;
  align-items: center;
  flex: 1;
}

/* ── Nút Hamburger ─────────────────────────────────────────── */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: auto;
}

.hamburger-btn:hover {
  background: rgba(56, 189, 248, 0.16);
}

.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: #38bdf8;
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1), opacity 0.2s;
}

/* Hamburger → X khi mở */
.hamburger-btn.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger-btn.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile Drawer Menu ────────────────────────────────────── */
.mobile-menu {
  display: none;
  /* hidden on desktop */
  position: fixed;
  top: var(--tab-h);
  left: 0;
  right: 0;
  z-index: 19000;
  background: rgba(10, 20, 40, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(56, 189, 248, 0.15);
  flex-direction: column;
  padding: 6px 0 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  /* Slide-down animation */
  transform: translateY(-110%);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(.4, 0, .2, 1), opacity 0.22s;
  pointer-events: none;
}

.mobile-menu.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.mobile-menu__item:hover,
.mobile-menu__item:active {
  background: rgba(56, 189, 248, 0.08);
  color: #e2e8f0;
}

.mobile-menu__item.active {
  color: #38bdf8;
  border-left-color: #38bdf8;
  background: rgba(56, 189, 248, 0.07);
}

.mobile-menu__item i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.mobile-menu__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 4px 16px;
}

/* ── Mobile breakpoint: bật hamburger, tắt tab buttons ───── */
@media (max-width: 768px) {

  .tab-btn,
  .tab-divider {
    display: none !important;
  }

  .mobile-active-label {
    display: flex;
  }

  .hamburger-btn {
    display: flex;
  }

  .mobile-menu {
    display: flex;
  }
}

/* Page wrappers (iframe tabs) */
.page-wrapper {
  display: none;
  position: fixed;
  top: var(--tab-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: #0f172a;
}

.page-wrapper.active {
  display: block;
}

.page-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* =========================================================
    MAP WRAPPERS
    — Desktop: fills full height below tab bar
    — Mobile: bottom edge = panel header so map is always visible
    ========================================================= */
.map-wrapper {
  position: fixed;
  top: var(--tab-h);
  left: 0;
  right: 0;
  bottom: 0;
  /* desktop default */
  visibility: hidden;
  opacity: 0;
  z-index: 0;
  transition: opacity .2s;
}

.map-wrapper.active {
  visibility: visible;
  opacity: 1;
  z-index: 10;
}

#windy,
#mapbox {
  width: 100%;
  height: 100%;
}

/* =========================================================
    RESULT PANEL
    — Desktop: left card
    — Mobile (≤900px): bottom-sheet pinned to bottom edge
    ========================================================= */
.panel {
  position: fixed;
  top: calc(var(--tab-h) + 12px);
  left: 12px;
  width: 360px;
  max-height: calc(100vh - var(--tab-h) - 24px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  color: #e2e8f0;
  border-radius: 14px;
  z-index: 10000;
  border: 1px solid rgba(56, 189, 248, .2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  overflow: visible;
  box-sizing: border-box;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  min-height: var(--panel-h);
  background: rgba(56, 189, 248, .08);
  border-bottom: 1px solid rgba(56, 189, 248, .15);
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 13px;
  color: #38bdf8;
  flex-shrink: 0;
}

.panel-header:hover {
  background: rgba(56, 189, 248, .14);
}

#resultPanelArrow {
  font-size: 10px;
  color: #cbd5e1;
  transition: transform .2s;
  line-height: 1;
}

/* Panel body: scrollable content, collapsible via max-height transition */
.panel-body {
  overflow-y: auto;
  /* scroll khi nội dung dài */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 14px;
  /* transition chỉ trên wrapper .panel-body-wrap */
}

/* Wrapper bọc body để animate collapse */
.panel-body-wrap {
  overflow: hidden;
  transition: max-height .28s ease, opacity .22s ease;
  max-height: 70vh;
  opacity: 1;
  border-radius: 0 0 14px 14px;
}

/* panel-collapsed: thu gọn body */
.panel.panel-collapsed .panel-body-wrap,
.panel.mobile-collapsed .panel-body-wrap {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.panel.panel-collapsed .panel-header,
.panel.mobile-collapsed .panel-header {
  border-bottom-color: transparent;
  border-radius: 14px;
  /* bo góc đủ khi collapsed */
}

.panel.panel-collapsed #resultPanelArrow,
.panel.mobile-collapsed #resultPanelArrow {
  transform: rotate(-90deg);
}

.ai-result {
  margin-top: 12px;
  padding: 12px;
  background: rgba(14, 165, 233, .08);
  border-radius: 10px;
  font-size: .9em;
  line-height: 1.55;
  border: 1px solid rgba(56, 189, 248, .18);
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-high {
  background: #ef4444;
  color: #fff;
}

.badge-med {
  background: #eab308;
  color: #000;
}

.badge-low {
  background: #22c55e;
  color: #fff;
}

.small {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 8px;
  line-height: 1.45;
}

/* =========================================================
    BOTTOM WEATHER BAR
    — Desktop: right of panel, full width minus panel
    — Mobile: HIDDEN (controlled by JS) – no overlap
    ========================================================= */
.weather-bar {
  position: fixed;
  left: 384px;
  /* desktop: right of panel */
  right: 12px;
  bottom: 12px;
  z-index: 12000;
  background: rgba(0, 0, 0, .9);
  border: 1px solid rgba(0, 150, 255, .22);
  border-radius: 14px;
  color: #e5e7eb;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.weather-bar.hidden {
  display: none;
}

.weather-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(135deg, rgba(0, 26, 51, .9), rgba(0, 61, 102, .7));
}

.weather-bar__title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #00ccff;
  font-weight: 600;
  font-size: 13px;
}

.weather-bar__controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-btn {
  background: rgba(0, 150, 255, .15);
  border: 1px solid rgba(0, 150, 255, .25);
  color: #e5e7eb;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.wb-btn.active {
  background: rgba(0, 150, 255, .32);
  border-color: rgba(0, 204, 255, .6);
  color: #00ccff;
}

.wb-icon {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .15);
  color: #e5e7eb;
  width: 30px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}

.weather-bar__content {
  padding: 10px 12px;
  max-height: 26vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.weather-bar__footer {
  padding: 6px 12px;
  border-top: 1px solid rgba(255, 255, 255, .05);
  font-size: 11px;
  color: #94a3b8;
}

.wb-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.wb-card {
  background: rgba(0, 50, 100, .25);
  border: 1px solid rgba(0, 150, 255, .15);
  border-radius: 10px;
  padding: 10px;
  min-width: 160px;
  flex: 1;
}

.wb-kv {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.6;
}

.wb-kv b {
  color: #00ccff;
}

.wb-hourly {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wb-chip {
  flex: 0 0 auto;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 130px;
  font-size: 12px;
}

.wb-chip .t {
  color: #00ccff;
  font-weight: 700;
  margin-bottom: 4px;
}

.wb-chip .m {
  color: #cbd5e1;
  opacity: .95;
}

/* =========================================================
    RAINVIEWER SIDEBAR (right side)
    ========================================================= */
.rv-sidebar {
  position: fixed;
  right: 12px;
  top: calc(var(--tab-h) + 16px);
  z-index: 10001;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  user-select: none;
}

.rv-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .88);
  border: 1px solid rgba(148, 163, 184, .25);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  color: #e2e8f0;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform .12s, border-color .12s;
}

.rv-pill:hover {
  transform: translateX(-2px);
  border-color: rgba(56, 189, 248, .45);
}

.rv-pill .label {
  font-size: 12px;
  font-weight: 700;
  opacity: .9;
  white-space: nowrap;
}

.rv-pill .dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, .65);
  border: 1px solid rgba(148, 163, 184, .22);
  color: #cbd5e1;
  flex-shrink: 0;
}

.rv-pill.active {
  background: rgba(56, 189, 248, .12);
  border-color: rgba(56, 189, 248, .55);
}

.rv-pill.active .dot {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, .45);
}

.rv-fab {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .88);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e2e8f0;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px);
}

.rv-fab.active {
  border-color: rgba(56, 189, 248, .6);
  color: #38bdf8;
}

.rv-mini {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10001;
  background: rgba(15, 23, 42, .9);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 14px;
  padding: 10px 12px;
  color: #e2e8f0;
  width: 250px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .4);
  backdrop-filter: blur(10px);
  font-size: 12px;
}

.rv-mini .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
}

.rv-mini input[type="range"] {
  width: 100%;
}

.rv-mini .muted {
  opacity: .72;
}

.rv-mini .btn {
  padding: 5px 10px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(2, 6, 23, .45);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 12px;
}

/* Custom Scrollbar cho EVN Popup */
.evn-scroll-area::-webkit-scrollbar {
  width: 4px;
}

.evn-scroll-area::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.evn-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 4px;
}

.evn-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.6);
}

/* =========================================================
    EVN SEARCH (nội dung bên trong #evnSearch.panel)
    ========================================================= */

#evnSearch .inp-wrap {
  display: flex;
  gap: 8px;
}

#evnSearch input {
  flex: 1;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(2, 6, 23, .5);
  color: #e2e8f0;
  outline: none;
  font-size: 13px;
}

#evnSearch input::placeholder {
  color: #94a3b8;
}

#evnSearch .meta {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 5px;
}

#evnSearch .list {
  margin-top: 8px;
  max-height: 30vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

#evnSearch .item {
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2, 6, 23, .38);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s;
}

#evnSearch .item:hover {
  border-color: rgba(56, 189, 248, .45);
  background: rgba(56, 189, 248, .08);
}

#evnSearch .item .t {
  font-weight: 800;
  color: #e2e8f0;
  font-size: 12px;
  margin-bottom: 2px;
}

#evnSearch .item .m {
  font-size: 11px;
  color: #b0bec5;
  line-height: 1.35;
}

/* =========================================================
    WEBCAMS
    ========================================================= */
.wc-fab {
  position: fixed;
  right: 12px;
  top: calc(var(--tab-h) + 16px);
  z-index: 16000;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(15, 23, 42, .88);
  color: #e2e8f0;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  font-size: 18px;
}

.wc-fab.active {
  border-color: rgba(56, 189, 248, .65);
  color: #38bdf8;
}

#webcamsPanel {
  position: fixed;
  right: 12px;
  top: calc(var(--tab-h) + 66px);
  z-index: 16000;
  width: min(360px, 92vw);
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, .96);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .5);
  backdrop-filter: blur(12px);
  color: #e2e8f0;
  padding: 10px;
  display: none;
}

.wc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wc-title {
  font-weight: 800;
  color: #38bdf8;
}

.wc-x {
  width: 30px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(2, 6, 23, .45);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e2e8f0;
}

.wc-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.wc-btn {
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  background: rgba(56, 189, 248, .12);
  border: 1px solid rgba(56, 189, 248, .35);
  color: #e2e8f0;
  font-weight: 700;
  font-size: 12px;
}

.wc-btn:active {
  transform: translateY(1px);
}

.wc-lbl {
  font-size: 12px;
  color: #cbd5e1;
  display: flex;
  gap: 6px;
  align-items: center;
}

.wc-inp {
  width: 70px;
  padding: 5px 8px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(2, 6, 23, .45);
  color: #e2e8f0;
}

.wc-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wc-item {
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2, 6, 23, .35);
  border-radius: 12px;
  padding: 10px;
}

.wc-item .t {
  font-weight: 800;
  margin-bottom: 6px;
}

.wc-item img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .1);
}

.wc-item a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 700;
}

.wc-item .m {
  font-size: 12px;
  color: #cbd5e1;
  opacity: .9;
  margin-top: 5px;
}

#wcModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, .78);
}

#wcModal .box {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(980px, 95vw);
  height: min(620px, 80vh);
  background: rgba(15, 23, 42, .98);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .65);
}

#wcModal .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

#wcModalTitle {
  color: #38bdf8;
  font-weight: 800;
  font-size: 14px;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#wcModalBody {
  width: 100%;
  height: calc(100% - 50px);
  background: rgba(2, 6, 23, .35);
}

/* =========================================================
    MAPBOX POPUP
    ========================================================= */
.mapboxgl-popup {
  max-width: min(310px, 88vw) !important;
  width: min(310px, 88vw) !important;
}

.mapboxgl-popup-content {
  background: rgba(13, 20, 40, .97) !important;
  border: 1px solid rgba(56, 189, 248, .3) !important;
  border-radius: 14px !important;
  color: #e2e8f0 !important;
  padding: 12px 10px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .7) !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  backdrop-filter: blur(12px) !important;
  overflow: hidden !important;
}

/* Nội dung bên trong popup không tràn */
.mapboxgl-popup-content>div {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

.mapboxgl-popup-content table {
  width: 100% !important;
  table-layout: fixed !important;
}

.mapboxgl-popup-content td {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 0 !important;
  /* table-layout:fixed cần cái này */
}

.mapboxgl-popup-close-button {
  color: #94a3b8 !important;
  font-size: 20px !important;
  padding: 4px 8px !important;
  top: 4px !important;
  right: 4px !important;
}

.mapboxgl-popup-close-button:hover {
  color: #f1f5f9 !important;
  background: rgba(255, 255, 255, .1) !important;
  border-radius: 6px !important;
}

.mapboxgl-popup-tip {
  border-top-color: rgba(56, 189, 248, .3) !important;
}

/* =========================================================
    TABLET ≤900px  — bottom sheet layout
    Map fills screen; panel is thin strip at very bottom
    Weather bar is HIDDEN on mobile (no overlap risk)
    ========================================================= */
@media (max-width: 900px) {
  .tab-bar {
    height: var(--tab-h);
    padding: 0 8px;
    gap: 2px;
  }

  .app-title {
    margin-right: 8px;
    font-size: 12px;
  }

  .tab-btn {
    padding: 0 10px;
    font-size: 11px;
    gap: 5px;
  }

  /* Map fills full height, panel sits on top at bottom */
  .map-wrapper {
    top: var(--tab-h);
    bottom: 0;
  }

  /* Panel: bottom sheet */
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: none;
    overflow: visible;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .panel-header {
    border-radius: 16px 16px 0 0;
    min-height: var(--panel-h);
  }

  .panel-body {
    max-height: calc(42vh - var(--panel-h));
  }

  .panel-body-wrap {
    max-height: 42vh;
    border-radius: 0;
  }

  .panel.panel-collapsed .panel-header,
  .panel.mobile-collapsed .panel-header {
    border-radius: 16px 16px 0 0;
  }

  /* Weather bar: always hidden on mobile - use panel instead */
  .weather-bar {
    display: none !important;
  }

  /* EVN search: mobile - compact strip below tab bar, collapsed by default */
  #evnSearch .list {
    max-height: 30vh;
  }

  /* RainViewer */
  .rv-sidebar {
    top: calc(var(--tab-h) + 8px);
    right: 8px;
    gap: 6px;
  }

  .rv-pill {
    padding: 5px 8px;
    gap: 7px;
  }

  .rv-pill .dot {
    width: 30px;
    height: 30px;
  }

  .rv-pill .label {
    font-size: 11px;
  }

  .rv-fab {
    width: 38px;
    height: 38px;
  }

  .rv-mini {
    right: 8px;
    bottom: calc(var(--panel-h) + 8px);
    width: min(240px, 80vw);
  }

  /* Webcam */
  .wc-fab {
    right: 8px;
    top: calc(var(--tab-h) + 8px);
  }

  #webcamsPanel {
    right: 8px;
    top: calc(var(--tab-h) + 56px);
    width: min(360px, 96vw);
  }
}

/* =========================================================
    PHONE ≤480px
    ========================================================= */
@media (max-width: 480px) {
  .app-title {
    display: none;
  }

  .tab-btn {
    padding: 0 8px;
    font-size: 10px;
    gap: 3px;
  }

  .tab-divider {
    margin: 0 2px;
  }

  .panel {
    max-height: 40vh;
    border-radius: 14px 14px 0 0;
  }

  .panel-header {
    padding: 9px 12px;
    font-size: 12px;
  }

  .panel-body {
    padding: 10px 12px;
  }


  #evnSearch .list {
    max-height: 28vh;
  }

  .rv-sidebar {
    top: calc(var(--tab-h) + 6px);
    right: 6px;
    gap: 4px;
  }

  .rv-pill .dot {
    width: 28px;
    height: 28px;
  }

  .rv-pill .label {
    font-size: 10px;
  }

  .rv-fab {
    width: 36px;
    height: 36px;
  }

  .rv-mini {
    right: 6px;
    width: calc(100vw - 12px);
    left: 6px;
    bottom: calc(var(--panel-h) + 6px);
  }

  .wc-fab {
    right: 6px;
    top: calc(var(--tab-h) + 6px);
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  #webcamsPanel {
    right: 6px;
    top: calc(var(--tab-h) + 50px);
    width: calc(100vw - 12px);
    max-height: 52vh;
  }

  .mapboxgl-popup {
    max-width: min(290px, 92vw) !important;
    width: min(290px, 92vw) !important;
  }

  .mapboxgl-popup-content {
    max-width: 100% !important;
    width: 100% !important;
    font-size: 11px !important;
    padding: 10px 8px !important;
  }
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .28);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, .52);
}

/* =========================================================
    LEFT SIDEBAR — flex column chứa tất cả panel trái
    Không có chồng chéo vì các panel nằm trong 1 container
    ========================================================= */
#left-sidebar {
  position: fixed;
  top: calc(var(--tab-h) + 10px);
  left: 10px;
  width: 368px;
  max-height: calc(100vh - var(--tab-h) - 20px);
  z-index: 15100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: none;
  box-sizing: border-box;
  scrollbar-width: none;
}

#left-sidebar::-webkit-scrollbar {
  display: none;
}

/* Các panel con trong sidebar được pointer-events trở lại */
#left-sidebar>* {
  pointer-events: auto;
  flex-shrink: 0;
}

/* Override .panel khi nằm trong #left-sidebar:
    Không dùng position:fixed nữa, để sidebar tự stack */
#left-sidebar .panel {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

/* Giới hạn chiều cao của evnSearch khi mở
   để flood-panel-slot bên dưới không bị đẩy ra ngoài viewport */
#evnSearch .panel-body-wrap {
  max-height: 35vh !important;
  overflow-y: auto;
}

/* FIX: Khi evnSearch bị collapse, phải override lại max-height về 0
   Dùng #evnSearch (ID) để thắng rule trên */
#evnSearch.panel-collapsed .panel-body-wrap,
#evnSearch.mobile-collapsed .panel-body-wrap {
  max-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

/* Đảm bảo sidebar có thể scroll để xem flood panel bên dưới */
#left-sidebar {
  padding-bottom: 6px;
}



/* #flood-panel-slot: container cho flood panel */
#flood-panel-slot {
  width: 100%;
}

#flood-panel-slot:empty {
  display: none;
}

/* Flood panel CẦN override để hoạt động trong slot */
#flood10-panel {
  position: static !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  max-height: 520px;
  border-radius: 12px;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Mobile: flood panel scroll fix — đặt riêng để không conflict với block 900px dưới */
@media (max-width: 900px) {
  #flood10-panel {
    max-height: 50vh !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 480px) {
  #flood10-panel {
    max-height: 46vh !important;
  }
}

/* Mobile: sidebar ở dưới màn hình */
@media (max-width: 900px) {
  #left-sidebar {
    top: auto;
    bottom: calc(var(--panel-h) + 20px);
    left: 0;
    right: 0;
    width: 100%;
    /* overflow:hidden để #flood10-panel tự scroll, không bị #left-sidebar cướp gesture */
    overflow: hidden;
    max-height: 65vh;
    padding: 0 8px;
    gap: 6px;
    z-index: 10000;
    box-sizing: border-box;
  }

  #left-sidebar .panel {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    left: auto !important;
    right: auto !important;
  }

  /* Ẩn bảng Mưa/Mây RainViewer trên mobile để không đè lên panel */
  .rv-mini {
    display: none !important;
  }

  /* Thu gọn Mapbox Popup trên điện thoại để không bị tràn ngang */
  .mapboxgl-popup {
    max-width: 92vw !important;
    z-index: 15000 !important;
  }

  .mapboxgl-popup-content {
    padding: 12px 10px !important;
  }

  /* Giới hạn ảnh trong rescue popup trên mobile — tránh popup quá to */
  .rescue-popup__photo img {
    max-height: 120px !important;
    object-fit: cover;
  }

  .rescue-popup {
    min-width: unset !important;
    font-size: 12px;
  }

  /* Bảng nhỏ RainViewer */
  .rv-mini {
    bottom: calc(var(--panel-h) + 20px) !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: 300px !important;
    z-index: 10050 !important;
  }

  /* Thu nhỏ font size của bảng thông tin đập */
  .evn-popup {
    width: 100% !important;
    font-size: 13px !important;
  }

  .evn-popup .val {
    font-size: 13px !important;
  }
}

/* =========================================================
   🆘 RESCUE MODULE — Cứu hộ Cứu nạn
   ========================================================= */

/* ── FAB Button ──────────────────────────────────────────── */
.rescue-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 18000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(239, 68, 68, .55);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(239, 68, 68, .35), 0 0 0 0 rgba(239, 68, 68, .4);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
  animation: rescue-pulse-fab 2.5s infinite;
}

.rescue-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(239, 68, 68, .55), 0 0 0 6px rgba(239, 68, 68, .12);
}

@keyframes rescue-pulse-fab {

  0%,
  100% {
    box-shadow: 0 4px 20px rgba(239, 68, 68, .35), 0 0 0 0 rgba(239, 68, 68, .4);
  }

  50% {
    box-shadow: 0 4px 20px rgba(239, 68, 68, .45), 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

.rescue-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  border: 2px solid #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Location Request Modal ──────────────────────────────── */
.rescue-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s, visibility .25s;
}

.rescue-modal--visible {
  visibility: visible;
  opacity: 1;
}

.rescue-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
}

.rescue-modal__box {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, rgba(15, 23, 42, .98), rgba(30, 41, 59, .97));
  border: 1px solid rgba(239, 68, 68, .4);
  border-radius: 20px;
  padding: 32px 28px 24px;
  max-width: 420px;
  width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .7), 0 0 0 1px rgba(239, 68, 68, .15);
  text-align: center;
  animation: rescue-modal-in .3s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes rescue-modal-in {
  from {
    transform: translateY(20px) scale(.95);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.rescue-modal__icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 12px;
  animation: rescue-pulse-icon 1.8s infinite;
}

@keyframes rescue-pulse-icon {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

.rescue-modal__title {
  color: #f1f5f9;
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 10px;
}

.rescue-modal__desc {
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 14px;
}

.rescue-modal__ttl {
  display: inline-block;
  margin-top: 6px;
  color: #fbbf24;
  font-size: 12px;
}

.rescue-modal__note-wrap {
  margin-bottom: 18px;
}

.rescue-modal__note {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, .3);
  background: rgba(2, 6, 23, .5);
  color: #e2e8f0;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}

.rescue-modal__note:focus {
  border-color: rgba(239, 68, 68, .65);
}

.rescue-modal__note::placeholder {
  color: #475569;
}

.rescue-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rescue-modal__btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}

.rescue-modal__btn:active {
  transform: scale(.97);
}

.rescue-modal__btn--primary {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 16px rgba(239, 68, 68, .4);
}

.rescue-modal__btn--primary:hover {
  box-shadow: 0 6px 22px rgba(239, 68, 68, .6);
}

.rescue-modal__btn--secondary {
  background: rgba(148, 163, 184, .1);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #94a3b8;
}

.rescue-modal__btn--secondary:hover {
  background: rgba(148, 163, 184, .18);
}

.rescue-modal__privacy {
  color: #475569;
  font-size: 11px;
  margin: 14px 0 0;
}

/* ── Photo Capture Modal ─────────────────────────────────── */
.rescue-photo-modal {
  position: fixed;
  inset: 0;
  z-index: 21000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .22s, visibility .22s;
}

.rescue-photo-modal--visible {
  visibility: visible;
  opacity: 1;
}

.rescue-photo-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
}

.rescue-photo-modal__box {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, rgba(15, 23, 42, .98), rgba(30, 41, 59, .97));
  border: 1px solid rgba(56, 189, 248, .3);
  border-radius: 18px;
  padding: 0;
  width: min(400px, calc(100vw - 24px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, .65);
  overflow: hidden;
  animation: rescue-modal-in .28s cubic-bezier(.34, 1.56, .64, 1);
}

.rescue-photo-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(56, 189, 248, .08);
  border-bottom: 1px solid rgba(56, 189, 248, .18);
  font-weight: 700;
  color: #38bdf8;
  font-size: 14px;
}

.rescue-photo-modal__close {
  background: rgba(2, 6, 23, .45);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e2e8f0;
  width: 30px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.rescue-photo-modal__desc {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px 16px 6px;
  margin: 0;
}

.rescue-photo-modal__file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 16px;
  padding: 16px;
  border: 2px dashed rgba(56, 189, 248, .35);
  border-radius: 12px;
  cursor: pointer;
  color: #38bdf8;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.rescue-photo-modal__file-label:hover {
  border-color: rgba(56, 189, 248, .7);
  background: rgba(56, 189, 248, .06);
}

.rescue-photo-modal__file-input {
  display: none;
}

.rescue-photo-modal__preview {
  display: block;
  width: calc(100% - 32px);
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 16px 8px;
  border: 1px solid rgba(255, 255, 255, .1);
}

.rescue-photo-modal__status {
  min-height: 18px;
  padding: 0 16px;
  font-size: 12px;
  color: #38bdf8;
  margin-bottom: 4px;
}

.rescue-photo-modal__upload-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 4px 16px 16px;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 14px rgba(14, 165, 233, .4);
}

.rescue-photo-modal__upload-btn:hover {
  box-shadow: 0 6px 20px rgba(14, 165, 233, .6);
}

.rescue-photo-modal__upload-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ── Photo Viewer (fullscreen) ───────────────────────────── */
.rescue-photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 25000;
  background: rgba(0, 0, 0, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s, visibility .2s;
  cursor: zoom-out;
}

.rescue-photo-viewer--visible {
  visibility: visible;
  opacity: 1;
}

.rescue-photo-viewer__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(15, 23, 42, .8);
  border: 1px solid rgba(148, 163, 184, .3);
  color: #e2e8f0;
  width: 38px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  z-index: 1;
}

.rescue-photo-viewer__img {
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
  cursor: default;
  object-fit: contain;
}

/* =========================================================
   🗺️ MAPBOX MAP CONTAINER — Clip marker overlays
   ========================================================= */
/* Clip SOS ring animations (và mọi marker overflow) tại biên bản đồ */
.mapboxgl-canvas-container {
  overflow: hidden;
}

/* =========================================================
   🆘 RESCUE MODULE — Marker
   =========================================================
   Marker dùng Mapbox SYMBOL LAYER (WebGL) — không dùng HTML Marker.
   map có projection:"globe" + pitch:60° + terrain:1.5 → HTML Marker
   chiếu tọa độ sai → lệch. Symbol Layer render trong GL pipeline,
   luôn đúng GPS dù globe/pitch/terrain.
   CSS bên dưới chỉ cho Popup, Modal, Toast — không có CSS marker.
*/

/* ── Rescue Popup ────────────────────────────────────────── */
.rescue-popup {
  color: #e2e8f0;
  font-size: 13px;
  min-width: 200px;
}

.rescue-popup__header {
  font-weight: 800;
  color: #ef4444;
  margin-bottom: 6px;
  font-size: 14px;
}

.rescue-popup__me-badge {
  display: inline-block;
  background: rgba(239, 68, 68, .2);
  border: 1px solid rgba(239, 68, 68, .4);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: #fca5a5;
  margin-right: 6px;
  vertical-align: middle;
}

/* Badge SOS đỏ nổi bật trong popup header */
.rescue-popup__sos-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 5px;
  vertical-align: middle;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Chú thích cho markers của người khác (chưa có ảnh) */
.rescue-popup__other-note {
  color: #64748b;
  font-size: 12px;
  font-style: italic;
  margin-top: 4px;
}


.rescue-popup__coord {
  color: #64748b;
  font-size: 11px;
  font-family: monospace;
  margin-bottom: 6px;
}

.rescue-popup__note {
  background: rgba(56, 189, 248, .08);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #cbd5e1;
}

.rescue-popup__time {
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 8px;
}

.rescue-popup__time b {
  color: #fbbf24;
}

/* Dòng mực nước quan trắc — màu xanh dương nổi bật */
.rescue-popup__water {
  background: rgba(6, 182, 212, .1);
  border: 1px solid rgba(6, 182, 212, .25);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #67e8f9;
}

.rescue-popup__water b {
  color: #22d3ee;
  font-weight: 800;
}

.rescue-popup__photo img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .1);
  cursor: zoom-in;
  margin-bottom: 4px;
}

.rescue-popup__photo-ttl {
  color: #64748b;
  font-size: 11px;
}

.rescue-popup__photo-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(14, 165, 233, .12);
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s;
}

.rescue-popup__photo-btn:hover {
  background: rgba(14, 165, 233, .25);
}

/* ── Toast Notification ──────────────────────────────────── */
#rescueToast {
  position: fixed;
  top: calc(var(--tab-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  z-index: 30000;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), opacity .3s;
  opacity: 0;
  background: rgba(15, 23, 42, .95);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e2e8f0;
  backdrop-filter: blur(12px);
}

.rescue-toast--visible {
  transform: translateX(-50%) translateY(0) !important;
  opacity: 1 !important;
}

.rescue-toast--success {
  border-color: rgba(34, 197, 94, .5);
  color: #86efac;
}

.rescue-toast--error {
  border-color: rgba(239, 68, 68, .5);
  color: #fca5a5;
}

.rescue-toast--info {
  border-color: rgba(56, 189, 248, .5);
  color: #7dd3fc;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .rescue-fab {
    /* Dời SOS lên góc trên bên trái trên mobile */
    bottom: auto;
    right: auto;
    top: calc(var(--tab-h, 48px) + 12px);
    left: 12px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .rescue-modal__box {
    padding: 24px 18px 20px;
  }

  .rescue-photo-modal__box {
    width: calc(100vw - 16px);
  }
}

/* ── Action Menu (Chụp ảnh / Cập nhật vị trí / Hủy SOS) ─── */
.rescue-action-menu {
  position: fixed;
  inset: 0;
  z-index: 20500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s, visibility .25s;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.rescue-action-menu--visible {
  visibility: visible;
  opacity: 1;
}

/* Backdrop mờ phía sau */
.rescue-action-menu::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .60);
  backdrop-filter: blur(4px);
}

.rescue-action-menu__content {
  position: relative;
  z-index: 1;
  width: min(440px, 100vw);
  background: linear-gradient(160deg, rgba(15, 23, 42, .99), rgba(23, 37, 60, .99));
  border: 1px solid rgba(239, 68, 68, .35);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 28px;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, .6);
  animation: rescue-sheet-in .3s cubic-bezier(.34, 1.4, .64, 1);
}

@keyframes rescue-sheet-in {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.rescue-action-menu__title {
  color: #fca5a5;
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .3px;
}

.rescue-action-menu__btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(30, 41, 59, .75);
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: left;
  transition: background .14s, border-color .14s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}

.rescue-action-menu__btn:hover {
  background: rgba(51, 65, 85, .85);
  border-color: rgba(148, 163, 184, .35);
}

.rescue-action-menu__btn:active {
  transform: scale(.97);
}

.rescue-action-menu__btn i {
  font-size: 20px;
  flex-shrink: 0;
  width: 26px;
  text-align: center;
}

.rescue-action-menu__btn--danger {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(127, 29, 29, .25);
}

.rescue-action-menu__btn--danger:hover {
  background: rgba(127, 29, 29, .45);
  border-color: rgba(239, 68, 68, .55);
}

.rescue-action-menu__close {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .2);
  background: rgba(148, 163, 184, .08);
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, transform .12s;
}

.rescue-action-menu__close:hover {
  background: rgba(148, 163, 184, .15);
}

.rescue-action-menu__close:active {
  transform: scale(.97);
}

/* Responsive mobile: full width bottom sheet */
@media (max-width: 480px) {
  .rescue-action-menu__content {
    width: 100vw;
    border-radius: 16px 16px 0 0;
    padding: 18px 14px 24px;
  }
}