/* ===================================================================
   Thời tiết & Lượng mưa · Open-Meteo
   Bố cục 2 cột: sidebar trái (quốc gia/tỉnh) + nội dung phải.
   Nền gradient đổi theo thời tiết. Thẻ kính mờ (glassmorphism).
   =================================================================== */

:root {
  --bg: #e8eef7;
  --card-bg: #ffffff;
  --card-bg-strong: #eef2f9;
  --card-border: #e3e8f1;
  --text: #101828;
  --text-dim: #3a475c;
  --text-faint: #5b6982;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 28px rgba(16, 24, 40, 0.06);
  --sidebar-w: 290px;
  --maxw: 980px;
  --accent: #2f6bed;
  --accent-soft: rgba(47, 107, 237, 0.10);
}

/* Nút/được chọn nổi bật hơn với bóng nhấn nhẹ */
.prov.active, .preset.active, .metric-tab.active, .layer-toggle.on, .map-ov.on {
  box-shadow: 0 4px 12px rgba(47, 107, 237, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Nền theo thời tiết */
body.theme-clear-day    { background: linear-gradient(160deg, #2b6cb0 0%, #4a98e0 55%, #6db8f0 100%); }
body.theme-clear-night  { background: linear-gradient(160deg, #0f2027 0%, #203a43 55%, #2c5364 100%); }
body.theme-clouds-day   { background: linear-gradient(160deg, #4b6584 0%, #6b7f9e 55%, #8a9bb5 100%); }
body.theme-clouds-night { background: linear-gradient(160deg, #1f2430 0%, #353b48 60%, #4a5160 100%); }
body.theme-rain         { background: linear-gradient(160deg, #16222a 0%, #2a4d5e 55%, #3a6073 100%); }
body.theme-snow         { background: linear-gradient(160deg, #5d7a9c 0%, #7591b3 55%, #93aecb 100%); }
body.theme-fog          { background: linear-gradient(160deg, #565d6e 0%, #757f9a 55%, #9aa1b3 100%); }
body.theme-thunder      { background: linear-gradient(160deg, #0f1620 0%, #1f2d3d 55%, #34495e 100%); }

/* ===================== Bố cục ===================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  padding: 20px 16px;
  background: #ffffff;
  border-right: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.main-col {
  flex: 1;
  min-width: 0;
  padding: 22px clamp(16px, 4vw, 40px) 48px;
  max-width: calc(var(--maxw) + 80px);
  margin: 0 auto;
  width: 100%;
}

/* ===================== Sidebar ===================== */
.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.25rem; font-weight: 700;
  text-shadow: none;
}
.brand-logo { width: 36px; height: 36px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }

.side-search {
  position: relative;
  display: flex; align-items: center;
  background: var(--card-bg-strong);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0 4px 0 12px;
}
.search-icon { width: 18px; height: 18px; color: var(--text-dim); flex: none; }
#searchInput {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  color: var(--text); font-size: 0.95rem; padding: 11px 8px;
}
#searchInput::placeholder { color: var(--text-faint); }

.icon-btn {
  flex: none; width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s, color 0.2s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(20, 40, 80, 0.06); color: var(--text); }
.icon-btn.busy { animation: spin 1s linear infinite; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  list-style: none;
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 14px; overflow: hidden;
  z-index: 60;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-height: 320px; overflow-y: auto;
}
.suggestions li {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid rgba(20, 40, 80, 0.05);
  transition: background 0.15s;
}
.suggestions li:hover, .suggestions li.active { background: rgba(37, 99, 235, 0.08); }
.suggestions .s-name { font-weight: 600; }
.suggestions .s-meta { color: var(--text-dim); font-size: 0.8rem; margin-top: 2px; }
.suggestions .s-head { padding: 8px 14px 4px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); cursor: default; }
.suggestions .s-head:hover { background: transparent; }

/* Cây quốc gia -> tỉnh */
.country-nav { display: flex; flex-direction: column; gap: 6px; }
.country { border-radius: 14px; overflow: hidden; background: var(--card-bg); border: 1px solid var(--card-border); }
.country-head {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  background: transparent; border: none; color: var(--text);
  font-size: 1.02rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.country-head:hover { background: var(--card-bg-strong); }
.country-head .flag { font-size: 1.25rem; line-height: 1; }
.country-head .caret { margin-left: auto; transition: transform 0.25s; color: var(--text-dim); }
.country.open .country-head .caret { transform: rotate(180deg); }
.country.open .country-head { background: var(--card-bg-strong); }

.country-body { display: none; padding: 4px 10px 12px; }
.country.open .country-body { display: block; }
.prov-list { display: flex; flex-wrap: wrap; gap: 6px; }
.prov {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(20, 40, 80, 0.05); color: var(--text-dim);
  font-size: 0.85rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.prov:hover { background: var(--card-bg-strong); color: var(--text); }
.prov.active { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

.side-note { font-size: 0.78rem; color: var(--text-faint); line-height: 1.6; margin-top: auto; }
.side-note b { color: var(--text-dim); }

/* ----- Bộ dữ liệu hành chính: tabs + lọc cà phê + cây + thanh đã chọn ----- */
.dataset-tabs { display: flex; flex-direction: column; gap: 6px; }
.ds-tab { display: flex; align-items: center; gap: 8px; justify-content: flex-start; width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--card-bg-strong); color: var(--text-dim); font-size: 0.88rem; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-tab:hover { color: var(--text); }
.ds-tab.active { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(47, 107, 237, 0.28); }

.coffee-filter { display: flex; gap: 6px; }
.cf-btn { flex: 1; padding: 6px 4px; border-radius: 999px; border: 1px solid var(--card-border); background: var(--card-bg-strong); color: var(--text-dim); font-size: 0.76rem; cursor: pointer; white-space: nowrap; }
.cf-btn:hover { color: var(--text); }
.cf-btn.active { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

.tree { flex: 1; min-height: 140px; overflow-y: auto; border: 1px solid var(--card-border); border-radius: 12px; background: var(--card-bg); padding: 4px; }
.tree::-webkit-scrollbar { width: 8px; }
.tree::-webkit-scrollbar-thumb { background: rgba(20, 40, 80, 0.18); border-radius: 4px; }
.tree-empty { color: var(--text-faint); font-size: 0.85rem; padding: 16px 10px; text-align: center; }
.tree-row { display: flex; align-items: center; gap: 2px; }
.tree-tog { width: 20px; height: 24px; flex: none; border: none; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 0.7rem; transition: transform 0.15s; }
.tree-tog.open { transform: rotate(90deg); }
.tree-sp { width: 20px; flex: none; }
.tree-item { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; padding: 4px 6px; border-radius: 7px; cursor: pointer; font-size: 0.86rem; }
.tree-item:hover, .tree-item.on { background: var(--accent-soft); }
.tree-item input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; cursor: pointer; }
.tree-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.tree-cf { flex: none; font-size: 0.78rem; }
.tree-cnt { flex: none; font-size: 0.7rem; color: var(--text-faint); background: var(--card-bg-strong); padding: 1px 7px; border-radius: 999px; }

.selected-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.sel-hint { color: var(--text-faint); font-size: 0.76rem; line-height: 1.5; }
.sel-count { font-weight: 700; color: var(--accent); font-size: 0.84rem; }
.sel-clear { border: 1px solid var(--card-border); background: var(--card-bg-strong); color: var(--text-dim); border-radius: 999px; padding: 4px 11px; font-size: 0.76rem; cursor: pointer; }
.sel-clear:hover { color: var(--text); }

/* Cascade Tỉnh/Huyện/Xã */
.cascade { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); }
.cascade-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.cascade-count { color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; }
.cas-select {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--card-border);
  background: var(--card-bg-strong) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%231b2433' fill-opacity='0.7' d='M0 0h10L5 6z'/></svg>") no-repeat right 12px center;
  color: var(--text);
  border-radius: 10px; padding: 9px 30px 9px 12px;
  font-size: 0.9rem; cursor: pointer;
}
.cas-select:disabled { opacity: 0.45; cursor: not-allowed; }
.cas-select option { color: #1c2638; }

/* Nút mở sidebar (mobile) + lớp phủ */
.sidebar-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 80;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--card-border);
  background: #ffffff; color: var(--text);
  font-size: 1.2rem; cursor: pointer;
  box-shadow: var(--shadow);
}
.backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 70;
}
.backdrop.show { display: block; }

/* ===================== Đầu cột nội dung ===================== */
.main-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.breadcrumb {
  font-size: 0.95rem; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.breadcrumb .bc-sep { opacity: 0.5; }
.breadcrumb .bc-last { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.head-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-date { font-size: 0.9rem; color: var(--text-dim); text-align: right; white-space: nowrap; line-height: 1.3; }

.controls { display: flex; align-items: center; gap: 8px; }
.pill {
  border: 1px solid var(--card-border);
  background: var(--card-bg-strong); color: var(--text);
  border-radius: 999px; padding: 9px 16px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background 0.2s, transform 0.1s;
}
.pill:hover { background: rgba(20, 40, 80, 0.18); }
.pill:active { transform: scale(0.96); }

.select-wrap { position: relative; display: inline-flex; }
#modelSelect {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--card-border);
  background: var(--card-bg-strong); color: var(--text);
  border-radius: 999px; padding: 9px 32px 9px 16px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#modelSelect option { color: #1c2638; }
.select-wrap::after {
  content: "▾"; position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: var(--text-dim); font-size: 0.8rem;
}

/* ===================== Thẻ chung ===================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 0.82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin-bottom: 16px;
}

.state { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 70px 20px; color: var(--text-dim); }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(20, 40, 80, 0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero ---------- */
.hero { padding: 26px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.hero-loc { font-size: 1.5rem; font-weight: 700; }
.hero-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 2px; }
.hero-main { display: flex; align-items: center; gap: 18px; margin: 14px 0 6px; flex-wrap: wrap; }
.hero-icon { width: 116px; height: 116px; flex: none; }
.hero-temp { font-size: 4.8rem; font-weight: 200; line-height: 1; letter-spacing: -2px; }
.hero-cond { font-size: 1.3rem; font-weight: 600; }
.hero-feels { color: var(--text-dim); margin-top: 4px; }
.hero-hilo { display: flex; gap: 18px; margin-top: 10px; font-size: 1.05rem; }
.hero-hilo b { font-weight: 700; }

/* ---------- Lưới chỉ số ---------- */
.grid-details { display: flex; gap: 10px; margin-bottom: 18px; }
.tile { flex: 1 1 0; min-width: 0; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px 13px; box-shadow: var(--shadow); }
.tile-label { display: flex; align-items: center; gap: 5px; font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.2px; }
.tile-label svg { width: 15px; height: 15px; opacity: 0.85; flex: none; }
.tile-value { font-size: 1.35rem; font-weight: 600; margin-top: 5px; }
.tile-value small { font-size: 0.8rem; font-weight: 400; color: var(--text-dim); }
.tile-note { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; color: #16202e; }

/* ---------- Lượng mưa theo khoảng ngày ---------- */
.rain-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.rain-head .card-title { margin-bottom: 0; }
.date-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dr-field { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-dim); }
.date-range input[type="date"] {
  border: 1px solid var(--card-border);
  background: var(--card-bg-strong); color: var(--text);
  border-radius: 10px; padding: 7px 10px; font-size: 0.85rem;
  color-scheme: light;
}
.presets { display: inline-flex; gap: 6px; }
.preset {
  border: 1px solid var(--card-border); background: rgba(20, 40, 80, 0.05);
  color: var(--text-dim); border-radius: 999px; padding: 6px 11px;
  font-size: 0.8rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.preset:hover { background: var(--card-bg-strong); color: var(--text); }
.preset.active { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

.rain-state { color: var(--text-dim); font-size: 0.9rem; padding: 8px 0; }
.rain-chart-wrap { overflow-x: auto; padding-bottom: 6px; margin-top: 8px; }
.rain-chart { display: flex; gap: 6px; align-items: flex-end; height: 180px; min-width: 100%; }
.rain-col { flex: 1 0 28px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.rain-mm { font-size: 0.72rem; font-weight: 600; color: #2563eb; margin-bottom: 6px; white-space: nowrap; }
.rain-bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.rain-bar { width: 70%; max-width: 34px; min-height: 2px; background: linear-gradient(180deg, #7fc4ff, #2b6cb0); border-radius: 6px 6px 0 0; }
.rain-bar.dry { background: linear-gradient(180deg, rgba(255,255,255,0.4), rgba(255,255,255,0.15)); }
.rain-day { font-size: 0.72rem; color: var(--text-dim); margin-top: 8px; text-align: center; line-height: 1.3; }
.rain-day small { display: block; color: var(--text-faint); font-size: 0.68rem; }
.rain-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; color: var(--text-dim); font-size: 0.85rem; flex-wrap: wrap; }
.rain-foot b { color: var(--text); font-weight: 700; }
.rain-foot .note { color: var(--text-faint); font-size: 0.76rem; }

/* Lượng mưa theo giờ hôm nay */
.hourly-rain { display: flex; gap: 3px; align-items: flex-end; height: 150px; padding-bottom: 4px; }
.hr-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.hr-mm { font-size: 0.62rem; font-weight: 600; color: #1d4ed8; margin-bottom: 4px; min-height: 0.8em; white-space: nowrap; }
.hr-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.hr-bar { width: 70%; max-width: 20px; min-height: 2px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 4px 4px 0 0; }
.hr-bar.dry { background: rgba(20, 40, 80, 0.14); }
.hr-h { font-size: 0.64rem; color: var(--text-dim); margin-top: 5px; white-space: nowrap; }

/* Biểu đồ đường cho dữ liệu theo ngày + nút chọn yếu tố */
.metric-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.metric-tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--card-border); background: rgba(20, 40, 80, 0.05);
  color: var(--text-dim); border-radius: 999px; padding: 6px 13px;
  font-size: 0.82rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.metric-tab:hover { background: var(--card-bg-strong); color: var(--text); }
.metric-tab.active { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.mt-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.range-chart { width: 100%; margin-bottom: 16px; }
.range-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-empty { color: var(--text-faint); padding: 30px; text-align: center; }
.chart-note { font-size: 0.76rem; color: var(--text-faint); margin-top: 4px; }

/* ---------- Bảng dữ liệu theo ngày ---------- */
.table-wrap { overflow-x: auto; margin-bottom: 16px; border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 540px; }
.data-table th, .data-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid rgba(20, 40, 80, 0.1); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.5px; }
.data-table tbody tr:hover { background: rgba(20, 40, 80, 0.05); }
.data-table .dt-rain { border-radius: 5px; padding: 2px 8px; color: #06243f; font-weight: 600; }
.data-table tfoot td { font-weight: 700; color: var(--text); border-top: 2px solid rgba(20, 40, 80, 0.2); border-bottom: none; }
.data-table tfoot tr:first-child td { padding-top: 11px; }
.data-table tfoot .ft-label { color: var(--text-dim); text-transform: uppercase; font-size: 0.74rem; letter-spacing: 0.5px; }

/* ---------- Bản đồ ---------- */
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.map-head .card-title { margin-bottom: 0; }
.map-layers { display: flex; gap: 6px; flex-wrap: wrap; }
.map-ov {
  font-size: 0.84rem; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--card-border); background: rgba(20, 40, 80, 0.05);
  color: var(--text-dim); cursor: pointer; user-select: none; font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.map-ov:hover { background: var(--accent-soft); color: var(--text); }
.map-ov.on { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.map { height: 460px; border-radius: 14px; overflow: hidden; border: 1px solid var(--card-border); background: #e8edf3; position: relative; }
.windy-frame { width: 100%; height: 100%; border: 0; display: block; }
.map-fallback { display: grid; place-items: center; height: 100%; color: var(--text-dim); padding: 20px; text-align: center; }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 0.8rem; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-grad { width: 84px; height: 11px; border-radius: 6px; border: 1px solid rgba(20, 40, 80, 0.18); }
.legend-scale { display: flex; gap: 4px; align-items: center; font-size: 0.72rem; color: var(--text-faint); }
.map-note { font-size: 0.76rem; color: var(--text-faint); margin-top: 10px; }
.wind-arrow div { font-size: 20px; font-weight: 700; line-height: 1; text-align: center; text-shadow: 0 0 4px rgba(0, 0, 0, 0.6); }
/* Popup Leaflet đọc rõ trên nền card */
.leaflet-popup-content { font-size: 0.85rem; line-height: 1.6; }
.leaflet-popup-content b { color: #16202e; }

/* ---------- Theo giờ ---------- */
.temp-chart { width: 100%; margin-bottom: 6px; }
.temp-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.hourly-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.hourly-strip::-webkit-scrollbar { height: 6px; }
.hourly-strip::-webkit-scrollbar-thumb { background: rgba(20, 40, 80, 0.18); border-radius: 3px; }
.hour { flex: 0 0 auto; width: 62px; text-align: center; padding: 10px 4px; border-radius: 14px; }
.hour.now { background: rgba(20, 40, 80, 0.06); }
.hour-time { font-size: 0.82rem; color: var(--text-dim); }
.hour-icon { width: 34px; height: 34px; margin: 6px auto; }
.hour-temp { font-size: 1.05rem; font-weight: 600; }
.hour-pop { font-size: 0.72rem; color: #2563eb; margin-top: 3px; min-height: 1em; }
.hour-rain { font-size: 0.72rem; color: #1d4ed8; font-weight: 600; margin-top: 1px; min-height: 1em; }
.chart-legend { display: flex; align-items: center; gap: 5px; font-size: 0.74rem; color: var(--text-dim); margin: -2px 0 8px; }
.chart-legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; }
.chart-legend i.lg-temp { background: #ef6c00; }
.chart-legend i.lg-rain { background: #3b82f6; margin-left: 10px; }

/* ---------- 7 ngày ---------- */
.daily-list { display: flex; flex-direction: column; }
.day-row { display: grid; grid-template-columns: 92px 38px 44px 1fr; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.day-row:last-child { border-bottom: none; }
.day-name { font-weight: 600; }
.day-name small { display: block; font-weight: 400; color: var(--text-dim); font-size: 0.78rem; }
.day-icon { width: 34px; height: 34px; }
.day-pop { font-size: 0.8rem; color: #2563eb; text-align: center; }
.day-bar-wrap { display: flex; align-items: center; gap: 10px; }
.day-min, .day-max { font-weight: 600; width: 38px; }
.day-min { color: var(--text-dim); text-align: right; }
.day-track { flex: 1; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; position: relative; }
.day-seg { position: absolute; height: 100%; border-radius: 3px; }

/* Thẻ 7 ngày (cuộn ngang giống giờ) */
.daily-strip { display: flex; gap: 0; padding-bottom: 8px; }
.dday { flex: 1 1 0; min-width: 0; text-align: center; padding: 10px 2px; border-radius: 14px; }
.dday:first-child { background: rgba(20, 40, 80, 0.06); }
.dday-name { font-size: 0.85rem; font-weight: 600; }
.dday-date { font-size: 0.72rem; color: var(--text-dim); }
.dday-icon { width: 36px; height: 36px; margin: 6px auto 4px; }
.dday-pop { font-size: 0.72rem; color: #2563eb; min-height: 1em; margin-bottom: 2px; }
.dday-temp { font-size: 0.92rem; }
.dday-temp b { font-weight: 700; }
.dday-temp span { color: var(--text-dim); margin-left: 5px; }

/* Hàng cột lượng mưa 7 ngày (căn thẳng với biểu đồ + thẻ) */
.daily-rain { display: flex; gap: 0; align-items: flex-end; height: 52px; margin-top: 4px; }
.dr-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.dr-mm { font-size: 0.66rem; font-weight: 600; color: #2563eb; min-height: 0.9em; margin-bottom: 3px; white-space: nowrap; }
.dr-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.dr-bar { width: 38%; max-width: 26px; min-height: 2px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 3px 3px 0 0; }
.dr-bar.dry { background: rgba(20, 40, 80, 0.12); }
.daily-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: 0.76rem; color: var(--text-dim); margin: 8px 0 2px; }
.daily-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Nguồn dữ liệu ---------- */
.attrib { text-align: center; color: var(--text-dim); font-size: 0.82rem; line-height: 1.7; padding: 8px 12px 0; }
.attrib a { color: var(--text); text-decoration: underline; }
.attrib .note { color: var(--text-faint); font-size: 0.78rem; }

.hidden { display: none !important; }

/* Hiệu ứng icon */
.ic-sun { animation: spin 22s linear infinite; transform-origin: center; }
.ic-cloud { animation: bob 5s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
.ic-drop { animation: fall 1.1s linear infinite; }
.ic-drop2 { animation: fall 1.1s linear infinite; animation-delay: 0.45s; }
@keyframes fall { 0% { opacity: 0; transform: translateY(-3px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(6px); } }
.ic-bolt { animation: flash 2.2s ease-in-out infinite; }
@keyframes flash { 0%,92%,100% { opacity: 1; } 94% { opacity: 0.25; } 96% { opacity: 1; } 98% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .ic-sun, .ic-cloud, .ic-drop, .ic-drop2, .ic-bolt { animation: none; } }

/* ===================== Responsive ===================== */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 75;
    height: 100vh; width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: 64px; /* chừa chỗ cho nút ☰ (cố định ở góc trên) khỏi che tab đầu */
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: grid; place-items: center; }
  .main-col { padding-top: 64px; }
  .grid-details { flex-wrap: wrap; }
  .tile { flex: 1 1 130px; }
}

@media (max-width: 520px) {
  .hero-temp { font-size: 3.8rem; }
  .hero-icon { width: 88px; height: 88px; }
  .hero-loc { font-size: 1.2rem; }
  .day-row { grid-template-columns: 74px 30px 38px 1fr; gap: 8px; }
  .rain-head { gap: 10px; }
  .date-range { width: 100%; }
}
