/* DISTRICT ANALYSIS — the Overview's วิเคราะห์รายอำเภอ panel and its left-hand drawer
 * (districtview.js). Colours come from the shared tokens (style.css / theme.js) so §09's
 * surface and accent settings re-skin this too; a PM2.5 figure is always coloured by the map's
 * own scale (an inline --c), never by these tokens. */

/* ============ PANEL (left rail) ============ */
.dx-panel .sub-th { margin-bottom: 8px; }
.dx-body { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.dx-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.dx-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.dx-flag {
  /* inline-block, not flex: a flex gap would also split "<b>23</b>/25" into "23 /25" */
  display: inline-block; max-width: 100%;
  font-size: 10.5px; line-height: 1.35; color: var(--muted);
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-2); border-radius: 6px;
  padding: 2px 7px;
}
.dx-flag b { color: var(--text); font-variant-numeric: tabular-nums; }
.dx-flag.warn { color: #f5b67a; border-color: rgba(230, 126, 34, 0.45); background: rgba(230, 126, 34, 0.08); }
.dx-flag.warn b { color: #ffc58f; }
.dx-flag.bad { color: #ff9b8f; border-color: rgba(231, 76, 60, 0.45); background: rgba(231, 76, 60, 0.08); }
.dx-flag.bad b { color: #ffb4aa; }
.dx-flag.fire { color: #ffb08a; border-color: rgba(255, 96, 40, 0.4); background: rgba(255, 96, 40, 0.07); }
.dx-flag.ok { color: #84e0aa; border-color: rgba(46, 204, 113, 0.4); background: rgba(46, 204, 113, 0.07); }
.dx-flag.wait { color: var(--muted); }
.dx-flag .dx-spin { display: inline-block; vertical-align: -1px; margin-right: 5px; }

.dx-when {
  display: flex; align-items: flex-start; gap: 6px; font-size: 10.5px; line-height: 1.4; color: var(--muted);
}
.dx-when .dx-when-dot { margin-top: 4px; }
/* the line under it while the strip is off ตอนนี้: what the forecast columns count from */
.dx-when.sub { padding-left: 12px; font-size: 10px; }
.dx-when-dot {
  flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 197, 240, 0.18);
}

/* the table scrolls inside its own box (a 25-row province must not push the rail's other
   panels a screen down); the header stays put while it does */
.dx-scroll {
  max-height: 238px; overflow-y: auto; overflow-x: hidden;
  /* the scrollbar gets its own gutter instead of sitting on top of the ไฟ column */
  scrollbar-gutter: stable;
  border: 1px solid var(--border); border-radius: 8px; background: rgba(0, 0, 0, 0.12);
}
.dx-scroll::-webkit-scrollbar, .dx-tscroll::-webkit-scrollbar, .dx-d-body::-webkit-scrollbar { width: 6px; height: 6px; }
.dx-scroll::-webkit-scrollbar-thumb, .dx-tscroll::-webkit-scrollbar-thumb, .dx-d-body::-webkit-scrollbar-thumb {
  background: var(--border-2); border-radius: 3px;
}

.dx-tbl { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 11px; }
.dx-tbl th, .dx-tbl td { padding: 0; }
.dx-tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2); border-bottom: 1px solid var(--border-2);
  font-weight: 700; color: var(--muted); text-align: left; vertical-align: bottom;
}
.dx-tbl thead th button {
  all: unset; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end;
  width: 100%; padding: 5px 3px 4px; cursor: pointer; font-size: 10px; line-height: 1.2; color: inherit;
  white-space: nowrap;
}
.dx-tbl thead th.c-num button { align-items: flex-end; text-align: right; }
.dx-tbl thead th button:hover { color: var(--text); }
.dx-tbl thead th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.dx-tbl thead th small { font-size: 9px; font-weight: 500; color: var(--muted); }
.dx-tbl thead th.on { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.dx-tbl thead th.on small { color: var(--accent); opacity: 0.75; }
.dx-th { display: inline-flex; align-items: baseline; gap: 2px; }
.dx-arr { font-size: 9px; }
.dx-tbl .c-rank { width: 18px; text-align: center; }
.dx-tbl thead .c-rank { padding: 5px 0 4px; font-size: 10px; text-align: center; }
/* the numbers take what they need and the อำเภอ name the rest: on the 260px rail of a laptop the
   name keeps ~70px (it fell to 22px with even 46px columns), on the 300px rail ~110px */
.dx-tbl .c-num { width: 40px; }
.dx-tbl .c-over24 { width: 31px; }
/* the last column carries extra room on its right so the scrollbar never covers its figures;
   the อำเภอ name gives up those few pixels */
.dx-tbl .c-fires { width: 36px; }
.dx-tbl th.c-fires button, .dx-tbl td.c-fires { padding-right: 9px; }
/* an overlay scrollbar (.ovl, set by districtview.js) gets no gutter and draws ~10px wide over the
   box's right edge, so the column itself makes that room (the gutter it frees pays for it) */
.dx-scroll.ovl .dx-tbl .c-fires { width: 42px; }
.dx-scroll.ovl .dx-tbl th.c-fires button, .dx-scroll.ovl .dx-tbl td.c-fires { padding-right: 15px; }
.dx-tbl td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.07); height: 25px; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.dx-tbl tbody tr:last-child td { border-bottom: 0; }
.dx-tbl td.c-rank { color: var(--muted); font-size: 10px; font-weight: 700; }
.dx-tbl td.c-name {
  padding: 0 3px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dx-tbl td.c-num { text-align: right; padding: 0 3px 0 0; }
.dx-nm { font-weight: 600; color: #dcebf8; }
.dx-tbl td.c-name .dx-nm { overflow: hidden; text-overflow: ellipsis; }
.dx-st { margin-left: 4px; font-size: 7px; color: #e7edf3; opacity: 0.7; vertical-align: 2px; }
/* the sorted column carries a touch more weight, so the eye lands on the sort key first */
.dx-tbl td.on { background: rgba(53, 197, 240, 0.045); }
.dx-tbl td.on .dx-v { font-weight: 800; }

/* a PM2.5 figure: its band colour as text on a tint of itself */
.dx-v {
  display: inline-block; min-width: 31px; text-align: right; padding: 1px 3px; border-radius: 4px;
  font-weight: 700; color: var(--ci, var(--c, var(--text)));
  background: color-mix(in srgb, var(--c, #8ba0b6) 13%, transparent);
}
.dx-hrs { color: var(--muted); font-weight: 600; }
.dx-hrs.on { color: #f5a65b; font-weight: 800; }
.dx-fire { color: var(--muted); font-weight: 600; }
.dx-fire.on { color: #ff7a4d; font-weight: 800; }
.dx-t { display: block; font-size: 9px; color: var(--muted); line-height: 1; margin-top: 1px; }

.dx-row { cursor: pointer; outline: none; }
.dx-row:hover td { background: rgba(53, 197, 240, 0.07); }
.dx-row:focus-visible td { background: rgba(53, 197, 240, 0.1); }
.dx-row:focus-visible td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
/* the อำเภอ the drawer is open on — accent, not green: a selection is not a verdict */
.dx-row.sel td { background: rgba(53, 197, 240, 0.12); }
.dx-row.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); color: var(--accent); }

.dx-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px;
  font-size: 10px; line-height: 1.4; color: var(--muted);
}
.dx-foot-cta { color: var(--accent); font-weight: 700; white-space: nowrap; }

/* loading / empty */
.dx-wait {
  display: flex; align-items: center; gap: 8px; padding: 10px; font-size: 11px; color: var(--muted);
  border: 1px dashed var(--border-2); border-radius: 8px;
}
.dx-wait.bad { color: #f5b67a; border-color: rgba(230, 126, 34, 0.45); }
.dx-spin {
  flex: none; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(53, 197, 240, 0.25); border-top-color: var(--accent);
  animation: dxSpin 0.8s linear infinite;
}
.dx-spin.sm { width: 9px; height: 9px; border-width: 1.5px; }
@keyframes dxSpin { to { transform: rotate(360deg); } }
.dx-skel { display: flex; flex-direction: column; gap: 6px; }
.dx-skel i, .dx-shim {
  display: block; height: 14px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.06));
  background-size: 200% 100%; animation: dxShim 1.2s ease-in-out infinite;
}
.dx-shim { display: inline-block; width: 30px; height: 11px; vertical-align: middle; }
.dx-shim.w { width: 70%; height: 30px; }
@keyframes dxShim { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============ DRAWER (slides in from the left) ============ */
.dx-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 8, 14, 0.55); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.3s ease;
}
.dx-backdrop.show { opacity: 1; }
.dx-drawer {
  position: fixed; top: 0; left: 0; z-index: 41;
  /* one screen tall under §09's UI scale too (theme.css divides the page shells the same way) */
  width: min(900px, calc(100vw - 16px)); height: calc(100dvh / var(--ui-zoom, 1));
  display: flex; flex-direction: column; outline: none;
  background:
    radial-gradient(700px 260px at 0% 0%, rgba(53, 197, 240, 0.07), transparent 70%),
    linear-gradient(180deg, #101a28, #0a0f16);
  border-right: 1px solid var(--border-2);
  box-shadow: 24px 0 60px rgba(0, 0, 0, 0.55);
  transform: translateX(-102%); transition: transform 0.38s cubic-bezier(0.22, 0.61, 0.36, 1);
  font-size: 13px;
}
.dx-drawer.show { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
  .dx-drawer, .dx-backdrop { transition: none; }
}

.dx-d-head { flex: none; padding: 14px 20px 0; border-bottom: 1px solid var(--border); }
.dx-d-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dx-d-eyebrow {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dx-d-glyph svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; display: block; }
.dx-d-ctrl { display: flex; align-items: center; gap: 8px; flex: none; }
.dx-nav { display: flex; align-items: center; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.dx-navb {
  width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1;
}
.dx-navb:hover, .dx-navb:focus-visible { color: var(--accent); background: rgba(53, 197, 240, 0.08); outline: none; }
.dx-nav-pos {
  min-width: 52px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums; border-left: 1px solid var(--border-2); border-right: 1px solid var(--border-2);
  line-height: 28px;
}
.dx-locate {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px 0 8px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  background: rgba(53, 197, 240, 0.08); border: 1px solid rgba(53, 197, 240, 0.45); color: var(--accent);
  font: inherit; font-size: 11px; font-weight: 700;
}
.dx-locate svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.dx-locate:hover, .dx-locate:focus-visible { background: rgba(53, 197, 240, 0.16); border-color: var(--accent); outline: none; }
.dx-close {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-2); color: var(--muted); font-size: 13px;
}
.dx-close:hover, .dx-close:focus-visible { color: var(--text); border-color: var(--faint); outline: none; }

.dx-d-title { padding: 10px 0 10px; }
.dx-d-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dx-d-title h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: 0; color: var(--text); line-height: 1.2; }
.dx-d-pastchip {
  font-size: 10px; font-weight: 700; color: #f5a524; border: 1px solid rgba(245, 165, 36, 0.55);
  border-radius: 999px; padding: 1px 8px;
}
.dx-d-meta { display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.dx-d-meta span + span::before { content: "·"; margin: 0 7px; color: var(--faint); }

.dx-tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.dx-tabs button {
  position: relative; background: transparent; border: 0; cursor: pointer;
  padding: 9px 12px 10px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.dx-tabs button:hover { color: var(--text); }
.dx-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.dx-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 6px; }
.dx-tab-n {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 999px;
  font-size: 10px; line-height: 16px; text-align: center; background: rgba(148, 163, 184, 0.14); color: var(--muted);
}
.dx-tabs button[aria-selected="true"] .dx-tab-n { background: rgba(53, 197, 240, 0.16); color: var(--accent); }

.dx-d-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px 20px 28px; }

.dx-sec { margin-bottom: 20px; min-width: 0; }
.dx-sec h3 {
  margin: 0 0 2px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent);
}
.dx-sub { font-size: 11px; line-height: 1.45; color: var(--muted); margin-bottom: 10px; }
.dx-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dx-note {
  display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 10px;
  background: rgba(245, 165, 36, 0.07); border: 1px solid rgba(245, 165, 36, 0.35); color: #f3c98b;
  font-size: 12px; line-height: 1.5;
}
.dx-note svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; margin-top: 1px; }

/* ---- hero ---- */
.dx-hero { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dx-hero-l {
  position: relative; padding: 14px 16px 14px 18px; border-radius: 14px;
  background:
    radial-gradient(220px 120px at 0% 0%, color-mix(in srgb, var(--c) 22%, transparent), transparent 75%),
    var(--panel-2);
  border: 1px solid var(--border-2); overflow: hidden;
}
.dx-hero-l::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.dx-hero-k { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.dx-hero-v { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.dx-hero-num {
  font-size: 52px; font-weight: 800; line-height: 1; color: var(--ci, var(--c)); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 26px color-mix(in srgb, var(--c) 45%, transparent);
}
.dx-hero-u { font-size: 13px; color: var(--muted); }
.dx-hero-band { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--ci, var(--c)); }
.dx-hero-band .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.dx-hero-std { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.dx-hero-std.ok { color: #84e0aa; border: 1px solid rgba(46, 204, 113, 0.45); }
.dx-hero-std.over { color: #ffb08a; border: 1px solid rgba(231, 76, 60, 0.55); background: rgba(231, 76, 60, 0.1); }
.dx-hero-when { display: flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.dx-hero-when svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.dx-hero-range { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.dx-hero-range b { font-variant-numeric: tabular-nums; }

/* the band scale under the hero number, with the hour on the map, the 24-h peak and 37.5 */
.dx-scale { position: relative; margin: 26px 0 22px; }
.dx-scale-bar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; opacity: 0.85; }
.dx-scale-bar i { display: block; height: 100%; }
.dx-mk { position: absolute; top: -3px; width: 0; height: 13px; }
.dx-mk::before { content: ""; position: absolute; left: -1px; top: 0; width: 2px; height: 13px; border-radius: 1px; background: #fff; }
.dx-mk b { position: absolute; transform: translateX(-50%); white-space: nowrap; font-size: 9.5px; font-weight: 800; }
.dx-mk.now b { bottom: 16px; color: var(--text); }
.dx-mk.now::after {
  content: ""; position: absolute; left: -5px; top: -7px; border: 5px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.dx-mk.peak::before { background: #ffd2a8; }
.dx-mk.peak b { top: 16px; color: #ffc58f; }
.dx-mk.std::before { background: transparent; border-left: 2px dashed #e67e22; height: 15px; top: -1px; width: 0; }
.dx-mk.std b { color: #f0a35e; font-weight: 700; }
.dx-mk.std b { bottom: 16px; top: auto; }
.dx-mk.std.quiet b { display: none; }
.dx-mk.l b { transform: translateX(-6px); }
.dx-mk.r b { transform: translateX(calc(-100% + 6px)); }

.dx-hero-r {
  padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border);
}
.dx-hero-r h3 { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }
.dx-brief { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.dx-brief li {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: start;
  font-size: 12.5px; line-height: 1.5; color: var(--text);
  opacity: 0; transform: translateY(4px); animation: dxIn 0.4s ease forwards;
}
.dx-brief li:nth-child(2) { animation-delay: 0.05s; }
.dx-brief li:nth-child(3) { animation-delay: 0.1s; }
.dx-brief li:nth-child(4) { animation-delay: 0.15s; }
.dx-brief li:nth-child(5) { animation-delay: 0.2s; }
.dx-brief li:nth-child(6) { animation-delay: 0.25s; }
.dx-brief li:nth-child(7) { animation-delay: 0.3s; }
@keyframes dxIn { to { opacity: 1; transform: none; } }
.dx-again .dx-brief li { animation: none; opacity: 1; transform: none; }
.dx-bi { display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 5px; background: rgba(148, 163, 184, 0.1); color: var(--muted); }
.dx-bi svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dx-brief li.warn .dx-bi { background: rgba(230, 126, 34, 0.16); color: #f5a65b; }
.dx-brief li.bad .dx-bi { background: rgba(231, 76, 60, 0.16); color: #ff8a7a; }
.dx-brief li.ok .dx-bi { background: rgba(46, 204, 113, 0.14); color: #6ee59e; }
.dx-brief li.muted { color: var(--muted); }
.t-over { color: #ffb08a; }
.t-fire { color: #ff8f66; }

/* ---- KPI tiles ---- */
.dx-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.dx-kpi {
  min-width: 0; padding: 10px 10px 9px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border);
}
.dx-kpi-k {
  display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dx-kpi-k svg { flex: none; width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dx-kpi-v { margin-top: 5px; font-size: 22px; font-weight: 800; line-height: 1.05; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dx-kpi-v small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.dx-kpi-s { margin-top: 4px; font-size: 10px; line-height: 1.35; color: var(--muted); }
.dx-kpi.warn { border-color: rgba(230, 126, 34, 0.4); }
.dx-kpi.warn .dx-kpi-v { color: #f5a65b; }
.dx-kpi.bad { border-color: rgba(231, 76, 60, 0.45); }
.dx-kpi.bad .dx-kpi-v { color: #ff7a4d; }
.dx-kpi.ok .dx-kpi-v { color: #6ee59e; }
.dx-kpi.muted .dx-kpi-v { color: var(--muted); }
.dx-kpi.shim { display: grid; place-items: center; min-height: 78px; }

/* ---- chart ---- */
.dx-chart { height: 250px; }
.dx-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 10.5px; color: var(--muted); }
.dx-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dx-legend i { display: inline-block; flex: none; }
.lg-line { width: 18px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--b1), var(--b2), var(--b3), var(--b4)); }
.lg-band { width: 16px; height: 10px; border-radius: 2px; }
.lg-band.tam { background: rgba(53, 197, 240, 0.32); }
.lg-band.env { background: rgba(139, 160, 182, 0.24); }
.lg-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text); }

/* ---- days ---- */
.dx-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; }
.dx-day {
  min-width: 0; padding: 8px 8px 7px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1px;
}
.dx-day.part { border-style: dashed; }
.dx-day-d { font-size: 11px; font-weight: 800; color: var(--text); white-space: nowrap; }
.dx-day-span { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.dx-day-max { margin-top: 4px; font-size: 20px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.dx-day-k { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.dx-day-mean { margin-top: 3px; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dx-day-over { font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.dx-day-over.on { color: #f5a65b; }
.dx-day-strip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 1px; margin-top: 6px; height: 9px; }
.dx-day-strip i { display: block; border-radius: 1px; }
.dx-day-strip i.na { background: rgba(148, 163, 184, 0.09); }

/* ---- maps ---- */
.dx-map {
  position: relative; border-radius: 12px; background: rgba(0, 0, 0, 0.18); border: 1px solid var(--border);
  overflow: hidden;
}
.dx-map .dx-svg { display: block; width: 100%; height: auto; }
.dx-mt { stroke-width: 0.6; cursor: pointer; transition: opacity 0.15s ease, filter 0.15s ease; }
/* the province map: the open อำเภอ at full strength, the rest stepped back but still readable */
.dx-mfill .dx-mt { opacity: 0.5; }
.dx-mfill .dx-mt.on { opacity: 1; }
.dx-mfill .dx-mt.t { opacity: 0.92; }
.dx-mfill .dx-mt:hover, .dx-mfill .dx-mt.hl { filter: brightness(1.2); }
.dx-mfill .dx-mt.hl { opacity: 0.85; }
.dx-mt.t { stroke: rgba(6, 12, 20, 0.85); stroke-width: 0.9; opacity: 0.92; }
.dx-mt.t.on { stroke: #fff; stroke-width: 2.2; opacity: 1; }
.dx-mlines { fill: none; stroke: rgba(6, 12, 20, 0.9); stroke-width: 1; pointer-events: none; }
.dx-msel { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(53, 197, 240, 0.6)); }
.dx-mout { fill: none; stroke: rgba(231, 237, 243, 0.85); stroke-width: 1.6; stroke-linejoin: round; pointer-events: none; }
.dx-mpts { pointer-events: none; }
.dx-mfire { fill: rgb(255, 179, 102); stroke: rgb(153, 76, 0); stroke-width: 1; }
.dx-mfire.today { fill: rgb(235, 30, 30); stroke: rgb(110, 0, 0); }
.dx-mst circle { fill: #0b1119; stroke: #fff; stroke-width: 1.4; }
.dx-mst circle.in { fill: #fff; stroke: none; }
.dx-mring { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 3 2; pointer-events: none; }
.dx-mlabel {
  font-size: 11px; font-weight: 800; fill: #fff; text-anchor: middle; dominant-baseline: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(4, 8, 14, 0.9); stroke-width: 3px;
}
.dx-tlabel { font-size: 10px; font-weight: 700; fill: #f4f8fc; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(4, 8, 14, 0.85); stroke-width: 2.6px; }
.dx-tlabel .v { font-size: 9.5px; font-weight: 800; fill: #fff; }

.dx-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 7px; font-size: 10px; color: var(--muted); }
.dx-key-b, .dx-key-x { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.dx-key-b i { width: 10px; height: 10px; border-radius: 2px; }
.dx-key-x i { width: 9px; height: 9px; border-radius: 50%; }
.dx-key-x i.fire { background: rgb(235, 30, 30); border: 1px solid rgb(110, 0, 0); }
.dx-key-x i.st { background: #fff; border: 2px solid #0b1119; box-shadow: 0 0 0 1px #fff; }
.dx-key-ramp { width: 90px; height: 9px; border-radius: 3px; }
.dx-key-l { font-variant-numeric: tabular-nums; }

.dx-seg {
  display: inline-flex; flex-wrap: wrap; margin-bottom: 8px; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden;
}
.dx-seg button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 5px 10px; font: inherit; font-size: 11px; font-weight: 700;
}
.dx-seg button + button { border-left: 1px solid var(--border-2); }
.dx-seg button[aria-pressed="true"] { background: rgba(53, 197, 240, 0.16); color: var(--accent); }
.dx-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- drivers ---- */
.dx-drvs { display: flex; flex-direction: column; gap: 8px; }
.dx-drv {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 9px 11px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border);
}
.dx-drv.bad { border-color: rgba(231, 76, 60, 0.4); }
.dx-drv.muted .dx-drv-v { color: var(--muted); }
.dx-drv-ic {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: rgba(148, 163, 184, 0.08); color: var(--muted);
}
.dx-drv-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dx-drv-ic.wind svg { width: 34px; height: 34px; }
.dx-drv-ic.wind .ring { stroke: rgba(148, 163, 184, 0.3); stroke-width: 1.2; }
.dx-drv-ic.wind .arr { stroke: var(--accent); stroke-width: 2.4; }
.dx-drv-ic.fire { color: #ff7a4d; background: rgba(255, 96, 40, 0.1); }
.dx-drv-ic.st { color: #e7edf3; }
.dx-drv-k { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.dx-drv-v { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 1px; }
.dx-drv-s { font-size: 11px; line-height: 1.45; color: var(--muted); margin-top: 2px; }
.dx-drv-s.dim { color: var(--muted); font-size: 10px; }
.dx-off { font-size: 10.5px; color: #f3c98b; }

/* ---- advice + actions ---- */
.dx-adv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.dx-adv-c { padding: 11px 13px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); }
.dx-adv-c.risk { border-color: rgba(230, 126, 34, 0.35); }
.dx-adv-k { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 11px; font-weight: 800; color: var(--text); }
.dx-adv-k small { font-size: 10px; font-weight: 500; color: var(--muted); }
.dx-adv-k svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 1.8; }
.dx-adv-c.risk .dx-adv-k svg { stroke: #f5a65b; }
.dx-adv-c p { margin: 6px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.dx-acts-h { margin: 14px 0 6px; font-size: 11px; font-weight: 800; color: var(--text); }
.dx-acts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dx-acts li {
  display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 10px; align-items: start;
  font-size: 12px; line-height: 1.5; color: var(--text);
  padding: 7px 10px; border-radius: 9px; background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
}
.dx-act-tier {
  justify-self: start; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap;
  border: 1px solid currentColor; margin-top: 1px;
}
.dx-acts li.urgent .dx-act-tier { color: #ff8a7a; background: rgba(231, 76, 60, 0.1); }
.dx-acts li.plan .dx-act-tier { color: #f5a65b; background: rgba(230, 126, 34, 0.08); }
.dx-acts li.info .dx-act-tier { color: var(--muted); }
.dx-acts li.ok .dx-act-tier { color: #6ee59e; }
.dx-adv-src { margin-top: 8px; font-size: 10px; color: var(--muted); line-height: 1.45; }

/* ---- ตำบล tab ---- */
.dx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dx-chip {
  font-size: 11.5px; color: var(--muted); padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border-2);
}
.dx-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.dx-chip.warn { border-color: rgba(230, 126, 34, 0.45); color: #f5b67a; }
.dx-chip.ok { border-color: rgba(46, 204, 113, 0.4); color: #84e0aa; }
.dx-chip.bad { border-color: rgba(231, 76, 60, 0.45); color: #ff9b8f; }
.dx-tam-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dx-tcard-wrap { min-width: 0; padding-top: 18px; }
.dx-tcard {
  position: relative; padding: 13px 14px 12px 17px; border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(200px 110px at 0% 0%, color-mix(in srgb, var(--c) 20%, transparent), transparent 75%),
    var(--panel-2);
  border: 1px solid var(--border-2);
}
.dx-tcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.dx-tcard-k { font-size: 10px; font-weight: 700; color: var(--muted); }
.dx-tcard-name { margin-top: 2px; font-size: 19px; font-weight: 800; color: var(--text); }
.dx-tcard-en { font-size: 10.5px; color: var(--muted); }
.dx-tcard-v { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.dx-tcard-v span { font-size: 36px; font-weight: 800; line-height: 1; color: var(--ci, var(--c)); font-variant-numeric: tabular-nums; }
.dx-tcard-v small { font-size: 11px; color: var(--muted); }
.dx-tcard-band { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; font-weight: 700; color: var(--ci, var(--c)); }
.dx-tcard-band .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.dx-spark { margin-top: 10px; }
.dx-spark svg { display: block; width: 100%; height: 70px; }
.dx-spark .ln { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.dx-spark .std { stroke: #e67e22; stroke-dasharray: 4 3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.dx-spark .day { stroke: rgba(148, 163, 184, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
.dx-spark .pk { fill: #fff; stroke: var(--c); stroke-width: 2; vector-effect: non-scaling-stroke; }
.dx-spark-k { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); margin-top: 2px; }

.dx-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; margin: 10px 0 0; font-size: 11.5px; }
.dx-facts dt { color: var(--muted); white-space: nowrap; }
.dx-facts dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; min-width: 0; }
.dx-facts.wide { grid-template-columns: 150px minmax(0, 1fr); font-size: 12px; padding: 12px 14px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); margin: 0; }
.dx-tfires { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.dx-tfires span { font-size: 10px; padding: 1px 7px; border-radius: 999px; color: #ffb366; border: 1px solid rgba(255, 179, 102, 0.45); }
.dx-tfires span.today { color: #ff6b6b; border-color: rgba(235, 30, 30, 0.55); }

.dx-tscroll {
  max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: rgba(0, 0, 0, 0.14);
}
.dx-tscroll.short { max-height: 280px; }
.dx-ttbl { font-size: 12px; table-layout: auto; }
.dx-ttbl td { height: 31px; }
.dx-ttbl td.c-name { padding: 0 6px; max-width: 150px; }
.dx-ttbl td.c-num { padding: 0 8px 0 4px; white-space: nowrap; }
.dx-ttbl thead th button { font-size: 10.5px; padding: 6px 8px 5px 4px; }
.dx-ttbl .c-day { width: 40px; text-align: center; padding: 0 2px; }
.dx-ttbl thead th.c-day { font-size: 10px; padding: 6px 2px 5px; text-align: center; color: var(--muted); white-space: nowrap; }
.dx-ttbl thead th.c-day.part { text-decoration: underline dashed; text-underline-offset: 3px; }
.dx-ttbl td.c-day span {
  display: block; margin: 0 auto; width: 34px; padding: 3px 0; border-radius: 5px; text-align: center;
  font-size: 10.5px; font-weight: 800; color: var(--ct, #06121c); background: var(--c);
}
.dx-ttbl td.c-day.part span { outline: 1px dashed rgba(231, 237, 243, 0.7); outline-offset: -3px; }
.dx-ttbl .dx-v { min-width: 40px; }
.dx-tbl-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.dx-csv {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-2); color: var(--text); font: inherit; font-size: 11px; font-weight: 700;
}
.dx-csv svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dx-csv:hover, .dx-csv:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }

/* ---- method tab ---- */
.dx-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.dx-steps li {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: start;
  padding: 10px 11px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border);
}
.dx-step-n {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(53, 197, 240, 0.14); color: var(--accent); font-size: 11px; font-weight: 800;
}
.dx-steps b { font-size: 12px; color: var(--text); }
.dx-steps p { margin: 3px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.dx-ctbl { font-size: 11.5px; table-layout: auto; }
.dx-ctbl thead th { padding: 6px 8px 5px 4px; font-size: 10.5px; }
.dx-ctbl td { padding: 0 8px 0 4px; height: 28px; color: var(--muted); }
.dx-ctbl td.c-num { white-space: nowrap; }
.dx-share { display: inline-block; vertical-align: middle; width: 54px; height: 6px; margin-right: 6px; border-radius: 3px; background: rgba(148, 163, 184, 0.14); overflow: hidden; }
.dx-share i { display: block; height: 100%; background: var(--accent); }
.dx-caveats { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.dx-caveats b { color: var(--text); }

/* ---- tooltip over the drawer's maps ---- */
.dx-tip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; max-width: 260px;
  padding: 7px 10px; border-radius: 8px; font-size: 11.5px; line-height: 1.45;
  background: rgba(12, 19, 29, 0.97); border: 1px solid var(--border-2); color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.dx-tip b { display: block; font-size: 12.5px; }
.dx-tip .dim { color: var(--muted); font-size: 10.5px; }
.dx-tip span.dim { display: block; margin-bottom: 3px; }
.dx-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ---- narrower screens: one column ---- */
@media (max-width: 960px) {
  .dx-hero, .dx-two, .dx-tam-top, .dx-adv { grid-template-columns: minmax(0, 1fr); }
  .dx-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dx-tcard-wrap { padding-top: 0; }
}
@media (max-width: 560px) {
  .dx-d-head, .dx-d-body { padding-left: 14px; padding-right: 14px; }
  .dx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dx-locate span { display: none; }
  .dx-hero-num { font-size: 44px; }
}
