:root {
  color-scheme: light;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --page-bg: #eef4fb;
  --ink: #10243d;
  --text: var(--ink);
  --muted: #5d6f84;
  --line: #cfdcec;
  --blue-900: #0a2f63;
  --blue-800: #0b3f86;
  --blue-700: #0b4da2;
  --blue-500: #1e7fd8;
  --blue-200: #5bb8f5;
  --accent: var(--blue-700);
  --banner-bg: linear-gradient(90deg, #0b4da2 0%, #1e7fd8 50%, #0b4da2 100%);
  --btn-h: 34px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--page-bg); overflow-x: hidden;
  color: var(--text);
  font: 15px/1.45 var(--font);
}
.app { display: block; }

.notice { margin: 8px 16px 0; padding: 6px 12px; border-radius: 6px; font-size: 14px; background: #fef7e0; color: #7a4f01; text-align: center; }

/* ---------- bảng tổng hợp: khung cuộn, tiêu đề và cột thời gian cố định (position: sticky) ----------
   Không phần tử cha nào giữa bảng và khung được có overflow: hidden (sticky sẽ mất tác dụng). */
.sheet-wrap { max-width: 1280px; margin: 0 auto; padding: 4px 16px 12px; }
.sheet-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 10px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--blue-800);
  font: 600 13px var(--font); cursor: pointer; white-space: nowrap;
}
.tool-btn:hover { background: #e8f1fc; }
.tool-btn[aria-pressed="true"] { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.tool-btn:focus-visible { outline: 3px solid #a8c7fa; outline-offset: 2px; }
.tool-btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.sheet-scroll {
  overflow: auto; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px);
  background: #fff; border: 1px solid var(--line); border-radius: 0 10px 10px 10px; /* góc trên trái vuông: ô góc cố định không bị cắt */
  box-shadow: 0 1px 2px rgba(16, 42, 84, .06), 0 4px 14px rgba(16, 42, 84, .07);
}
.sheet-scroll:focus-visible { outline: 3px solid #a8c7fa; outline-offset: 2px; }
.sheet-content { width: max-content; }
.loading { padding: 32px; color: var(--muted); white-space: nowrap; }
table.sheet + table.sheet { margin-top: 18px; }

table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; color: #000; }
table.sheet :is(td, th) {
  padding: 0; border: 0; background-color: #fff; font-weight: 400; text-align: left;
  font-family: Arial, "Liberation Sans", Arimo, Helvetica, sans-serif; font-size: 10pt;
  vertical-align: top; background-clip: padding-box;
}
table.sheet :is(td, th) > div {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 3px; overflow: hidden; white-space: pre; line-height: 1.2;
}
table.sheet :is(td, th) > div.spill { overflow-x: visible; overflow-y: clip; }
table.sheet :is(td, th) > div.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
table.sheet :is(td, th) > div.va-top { justify-content: flex-start; }
table.sheet :is(td, th) > div.va-middle { justify-content: center; }
table.sheet :is(td, th) > div.n { text-align: right; }

/* chữ xoay */
table.sheet :is(td, th) > div.rotated { align-items: center; justify-content: center; }
table.sheet :is(td, th) > div.rotated.al-left { align-items: flex-start; }
table.sheet :is(td, th) > div.rotated.al-right { align-items: flex-end; }
table.sheet .rot-up { writing-mode: vertical-rl; transform: rotate(180deg); }
table.sheet .rot-down { writing-mode: vertical-rl; }
table.sheet .rot-stack { writing-mode: vertical-rl; text-orientation: upright; }

/* cố định: tiêu đề (top do JS đặt) z 3, cột thời gian z 2, ô góc z 4; ô số liệu không định vị (dưới cùng).
   Ô cố định luôn có nền đặc (mặc định #fff ở trên, hoặc màu nền của sheet). */
table.sheet thead th { position: sticky; top: 0; z-index: 3; }
table.sheet .sl { position: sticky; z-index: 2; }
table.sheet thead th.sl { z-index: 4; }
/* bóng đổ ranh giới khi đang cuộn: mép dưới tiêu đề, mép phải cột thời gian */
.sheet-scroll.sy table.sheet thead th { box-shadow: 0 5px 6px -4px rgba(10, 47, 99, .45); }
.sheet-scroll.sx table.sheet .sl-edge { box-shadow: 5px 0 6px -4px rgba(10, 47, 99, .45); }
.sheet-scroll.sx.sy table.sheet thead th.sl-edge { box-shadow: 5px 0 6px -4px rgba(10, 47, 99, .45), 0 5px 6px -4px rgba(10, 47, 99, .45); }
table.sheet .pad { background: transparent; box-shadow: none !important; }
/* chữ xuống dòng trong ô tiêu đề hẹp: dòng sát hơn để không bị cắt */
table.sheet thead div.wrap { line-height: 1.08; }
/* nền xen kẽ theo nhóm hồ/trạm (mỗi nhóm một ô gộp ở hàng tên) */
table.sheet td.gt { background-color: #f1f6fd; }
/* rê chuột: tô sáng hàng và cột, tô đậm tên hồ/trạm */
table.sheet tr.hl-row > td, table.sheet .hl-col { background-image: linear-gradient(rgba(30, 127, 216, .11), rgba(30, 127, 216, .11)); }
table.sheet tr.hl-row > td.hl-col { background-image: linear-gradient(rgba(30, 127, 216, .26), rgba(30, 127, 216, .26)); }
table.sheet th.hl-name { outline: 2px solid var(--blue-500); outline-offset: -2px; font-weight: 800 !important; color: var(--blue-800) !important; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 0 8px 8px; touch-action: pan-x pan-y; }
.tab {
  padding: 5px 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff;
  font: 500 14px var(--font); color: var(--text);
  cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #f1f3f4; }
.tab.active { background: #e8f0fe; border-color: #aecbfa; color: var(--accent); }
.tab:focus-visible { outline: 3px solid #a8c7fa; outline-offset: 1px; }

/* ---------- nút cố định góc dưới trái (không co giãn theo nội dung) ---------- */
.actions {
  position: fixed; z-index: 1000; left: 10px; bottom: 10px;
  display: flex; gap: 8px; touch-action: pan-x pan-y;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: var(--btn-h); padding: 0 14px 0 11px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--text);
  font: 500 14px var(--font);
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: #f1f3f4; }
.btn { box-shadow: 0 1px 3px rgba(10, 47, 99, .18); }
.btn.primary { background: var(--blue-700); border-color: var(--blue-700); color: #fff; box-shadow: 0 2px 6px rgba(10, 47, 99, .35); }
.btn.primary:hover { background: var(--blue-800); }
.btn:focus-visible { outline: 3px solid #a8c7fa; outline-offset: 2px; }
.btn svg { width: 17px; height: 17px; fill: currentColor; flex: none; }

/* ---------- banner đầu trang (theo ảnh mẫu) ---------- */
.hero {
  --cyan: #45d8f7;
  position: relative; overflow: hidden; isolation: isolate; color: #fff; text-align: center;
  padding: 26px 24px 120px;
  background:
    radial-gradient(ellipse 70% 90% at 50% 35%, rgba(70, 140, 255, .55), transparent 70%),
    linear-gradient(180deg, #0b5df2 0%, #0a57ec 60%, #1048f0 100%);
}
.hero-art { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-art svg { position: absolute; overflow: visible; filter: drop-shadow(0 0 3px rgba(69, 216, 247, .55)); }
.art-corner { width: 150px; height: 133px; }
.art-corner.tl { left: 6px; top: 6px; }
.art-corner.tr { right: 6px; top: 6px; transform: scaleX(-1); }
.art-corner.bl { left: 6px; bottom: 6px; transform: scaleY(-1); }
.art-corner.br { right: 6px; bottom: 6px; transform: scale(-1, -1); }
.art-satellite { width: 150px; height: 140px; right: 26px; top: 40px; }
.art-dam { width: 230px; height: 164px; left: 0; bottom: 0; }
.art-cloud { width: 92px; height: 100px; right: 34px; bottom: 82px; }
.art-river { position: absolute; left: 0; right: 0; bottom: 0; height: 140px; }
.art-river svg { inset: 0; width: 100%; height: 100%; }
.art-river path { vector-effect: non-scaling-stroke; }
.pin {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: #fff; border: 3px solid #45d8f7; box-shadow: 0 0 8px 3px rgba(69, 216, 247, .75);
}
.pin::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 14px; margin-left: -1px; background: #45d8f7; }

.hero-inner { position: relative; max-width: 1100px; margin: 0 auto; }
.hero-org { display: inline-flex; align-items: center; gap: 16px; text-align: left; }
.hero-logo { flex: none; width: 76px; height: 76px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 4px 14px rgba(0, 20, 80, .45); background: #fff; }
.hero-org-text { min-width: 0; line-height: 1.35; text-shadow: 0 1px 3px rgba(0, 20, 80, .45); }
.org-parent { font-size: 14px; font-weight: 600; letter-spacing: .04em; color: #c8eeff; }
.org-name { font-size: 17px; font-weight: 800; color: #fff; }
.hero h1 {
  margin: 18px 0 0; padding-top: 16px; font-size: min(30px, calc((100vw - 48px) / 36)); font-weight: 800; line-height: 1.3; letter-spacing: .02em; white-space: nowrap;
  text-transform: uppercase; text-shadow: 0 2px 6px rgba(0, 20, 80, .5), 0 0 18px rgba(69, 216, 247, .35);
  background: linear-gradient(90deg, transparent, var(--cyan), transparent) top center / min(560px, 80%) 2px no-repeat;
}
/* luôn đúng 2 dòng: "THÔNG TIN SỐ LIỆU QUAN TRẮC" / "CÁC HỒ CHỨA VÀ SÔNG …"; cỡ chữ co theo chiều rộng màn hình */
/* tiêu đề trên 1 dòng ở mọi màn hình: cỡ chữ co theo chiều rộng (cả dòng rộng khoảng 34–35 lần cỡ chữ) */
.hero h1 span { display: inline; }
.hero-time {
  display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 4px 14px;
  font-size: 14px; color: #e3f2ff; background: rgba(4, 30, 70, .28); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
}
.hero-time strong { color: #fff; font-weight: 700; }
.live-dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: #2ee66b; }
.live-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #2ee66b;
  animation: live-ping 1.6s ease-out infinite;
}
.live-dot.stale { background: #ffb020; }
.live-dot.stale::after { border-color: #ffb020; animation: none; opacity: 0; }
@keyframes live-ping { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- SectionHeader: dải tiêu đề mục (ui.js) ---------- */
.sec-banner {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 0 14px; padding: 10px 18px; color: #fff; text-align: center;
  background: var(--banner-bg); border-top: 2px solid var(--blue-200); border-bottom: 2px solid var(--blue-200);
  border-radius: 12px; box-shadow: 0 3px 10px rgba(11, 77, 162, .22);
}
.sec-banner::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .16; pointer-events: none;
  background: radial-gradient(circle, #fff 1px, transparent 1.5px) 0 0 / 14px 14px;
}
.sec-deco { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .18; pointer-events: none; }
.sec-ic { flex: none; width: 34px; height: 34px; color: #dff1ff; }
.sec-text { min-width: 0; }
.sec-banner h2 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 20, 60, .4);
}
.sec-banner p { margin: 2px 0 0; font-size: 13.5px; color: #e3f2ff; }
/* "THÔNG TIN CHI TIẾT": nền là ảnh họa tiết (khung, mây mưa, trạm đo, sóng nước); chữ đặt vào khoảng trống giữa ảnh */
.sec-banner.sec-lg {
  /* thấp gọn (2/3 bản cũ 2021/356): ảnh nền là bản ép dọc, mây mưa và trạm đo hai đầu giữ đúng tỉ lệ */
  aspect-ratio: 2021 / 237; justify-content: center; margin-bottom: 18px;
  padding: .7% 12% 3.2%; border: 0;
  background: #0057e4 url("/static/img/detail-banner-compact.jpg") center / cover no-repeat;
  box-shadow: 0 4px 14px rgba(0, 70, 200, .28);
}
.sec-banner.sec-lg::before, .sec-banner.sec-lg .sec-deco, .sec-banner.sec-lg .sec-ic { display: none; }
/* "BIỂU ĐỒ DIỄN BIẾN": cùng phong cách, hình vẽ SVG về biểu đồ thay cho ảnh (ui.js, art: "chart") */
/* khối tiêu đề bảng tổng hợp ("THÔNG TIN SỐ LIỆU QUAN TRẮC…") phía trên bảng, cùng khổ với phần chi tiết */
.summary-head { max-width: 1280px; margin: 0 auto; padding: 20px 16px 4px; }
.summary-head .sec-banner { margin-bottom: 6px; }
/* luôn đúng 2 dòng; cỡ chữ co theo chiều rộng vùng chữ (dòng 2 dài nhất ≈ 25 lần cỡ chữ) */
#sheet-title { font-size: min(30px, calc((min(100vw, 1280px) - 32px) * .78 / 26)); letter-spacing: .03em; line-height: 1.35; }
#sheet-title span { display: block; white-space: nowrap; }
.sec-banner.sec-art-summary,
.sec-banner.sec-art-chart { background: radial-gradient(ellipse 60% 80% at 50% 40%, rgba(60, 140, 255, .45), transparent 70%), #0057e4; }
/* bảng tổng hợp không có hình ở đáy: chữ căn giữa theo chiều dọc */
.sec-banner.sec-art-summary { padding-top: 1.9%; padding-bottom: 1.9%; }
.sec-art { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.sec-art svg { position: absolute; overflow: visible; filter: drop-shadow(0 0 3px rgba(69, 216, 247, .5)); }
.art-fcorner { top: 3px; width: 100px; height: 88px; }
.art-fcorner.l { left: 5px; }
.art-fcorner.r { right: 5px; transform: scaleX(-1); }
.art-fline {
  position: absolute; top: 15px; left: 104px; right: 104px; height: 2px; background: #45d8f7;
  box-shadow: 0 0 6px rgba(69, 216, 247, .8);
}
.art-trend { position: absolute; left: 0; right: 0; bottom: 0; height: 44%; }
.sec-art-chart .art-trend { height: 34%; }
.art-trend svg { inset: 0; width: 100%; height: 100%; filter: none; }
.art-trend path { vector-effect: non-scaling-stroke; }
/* hình minh họa hai bên: nhỏ gọn ở phần trên dải (biểu đồ: phía trên đường số liệu; bảng tổng hợp: giữa dải) */
.art-bars { left: 2.4%; top: 12px; width: 70px; height: 66px; }
.art-monitor { right: 2.4%; top: 12px; width: 72px; height: 68px; }
.sec-art-summary .art-bars, .sec-art-summary .art-monitor { top: 50%; width: 84px; height: 80px; margin-top: -38px; }
.sec-banner.sec-lg h2 { font-size: 26px; font-weight: 800; letter-spacing: .08em; text-shadow: 0 2px 6px rgba(0, 20, 80, .45), 0 0 16px rgba(69, 216, 247, .35); }
.sec-banner.sec-lg p { margin-top: 4px; font-size: 15px; color: #d4f3ff; }

/* ---------- phần 2: chi tiết (CSS riêng nằm trong detail/detail.css, giới hạn ở .v2-detail) ---------- */
.detail-section { background: var(--page-bg); }
.detail-section .v2-detail { min-height: 60vh; }

/* ---------- chân trang ---------- */
.site-footer {
  background: var(--blue-900); color: #dbe8f7; font-size: 13px;
  border-top: 3px solid var(--blue-200);
  /* chừa chỗ cho cụm nút cố định góc dưới, không che chữ */
  padding: 16px 16px calc(var(--btn-h) + 30px);
}
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 4px 24px; justify-content: space-between; }
.site-footer .org { color: #fff; font-weight: 700; }

/* màn hình lớn phòng họp */
@media (min-width: 1800px) {
  :root { --btn-h: 38px; }
  .btn { font-size: 15px; border-radius: 19px; }
  .hero { padding: 30px 24px 140px; }
  .hero-inner { max-width: 1400px; }
  .hero h1 { font-size: 36px; }
  .hero-logo { width: 92px; height: 92px; }
  .org-parent { font-size: 16px; }
  .org-name { font-size: 21px; }
  .hero-time { font-size: 16px; }
  .art-corner { width: 180px; height: 160px; }
  .art-satellite { width: 180px; height: 168px; }
  .art-dam { width: 280px; height: 200px; }
  .art-cloud { width: 110px; height: 120px; bottom: 96px; }
  .art-river { height: 165px; }
  .sec-banner h2 { font-size: 19px; }
  .sec-banner.sec-lg h2 { font-size: 32px; }
  .sec-banner.sec-lg p { font-size: 17px; }
}
@media (max-width: 760px) {
  .hero { padding: 16px 12px 70px; }
  .hero-org { gap: 10px; }
  .hero-logo { width: 48px; height: 48px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .85), 0 3px 8px rgba(0, 20, 80, .4); }
  .org-parent { font-size: 11px; }
  .org-name { font-size: 12.5px; }
  /* dòng 2 (dài nhất) rộng khoảng 24 lần cỡ chữ: cỡ chữ = (chiều rộng màn hình - lề) / 25 để luôn vừa một dòng */
  .hero h1 { font-size: calc((100vw - 24px) / 35); margin-top: 12px; padding-top: 12px; letter-spacing: 0; }
  .summary-head { padding: 12px 12px 2px; }
  .sheet-wrap { padding: 4px 12px 10px; }
  .sheet-tools { justify-content: flex-start; gap: 6px; }
  .tool-btn { height: 30px; font-size: 12.5px; padding: 0 10px 0 8px; }
  #sheet-title { font-size: calc((100vw - 56px) / 26); letter-spacing: 0; }
  .hero-time { font-size: 12.5px; padding: 3px 10px; margin-top: 8px; }
  .art-corner { width: 64px; height: 57px; }
  .art-corner.tl, .art-corner.tr { top: 4px; }
  .art-corner.tl, .art-corner.bl { left: 4px; }
  .art-corner.tr, .art-corner.br { right: 4px; }
  .art-corner.bl, .art-corner.br { bottom: 4px; }
  .art-satellite { display: none; } /* màn hình hẹp: tránh đè lên tên đơn vị */
  .art-dam { width: 104px; height: 74px; }
  .art-cloud { width: 40px; height: 44px; right: 12px; bottom: 36px; }
  .art-river { height: 62px; }
  .pin { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-width: 2px; }
  .pin::after { height: 8px; }
  .sec-banner { padding: 8px 10px; gap: 8px; border-radius: 10px; }
  .sec-banner h2 { font-size: 15px; letter-spacing: .03em; }
  .sec-banner p { font-size: 12.5px; }
  .sec-ic { width: 26px; height: 26px; }
  /* màn hình hẹp: ảnh phủ kín theo chiều cao, hai mép ảnh bị cắt bớt */
  .sec-banner.sec-lg { aspect-ratio: auto; min-height: 80px; padding: 9px 14px 14px; }
  .sec-banner.sec-lg h2 { font-size: 17px; }
  .sec-banner.sec-lg p { font-size: 11.5px; margin-top: 2px; line-height: 1.3; }
  .art-fcorner { width: 42px; height: 37px; top: 2px; }
  .art-fcorner.l { left: 3px; }
  .art-fcorner.r { right: 3px; }
  .art-fline { top: 7px; left: 45px; right: 45px; height: 1.5px; }
  .art-bars, .art-monitor { display: none; } /* màn hình hẹp: chừa chỗ cho chữ */
  .art-trend, .sec-art-chart .art-trend { height: 24%; }
  .sec-banner.sec-art-summary { padding-top: 9px; padding-bottom: 9px; }
}
@media (max-width: 640px) {
  .btn { font-size: 13px; padding: 0 12px 0 10px; }
  .footer-inner { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .live-dot::after { animation: none; } }
