:root {
  --bg: #f3f4f7; --surface: #ffffff; --surface-2: #f7f8fa; --line: #e5e7ec; --text: #12161d; --muted: #667085;
  --fire: #ea580c; --fire-soft: #fff1e7; --smoke: #64748b; --smoke-dot: #475569; --accent: #2563eb;
  --low: #16a34a; --moderate: #ca8a04; --high: #ea580c; --severe: #dc2626;
  --glass: rgba(255, 255, 255, .86);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px -6px rgba(16, 24, 40, .14);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Plus Jakarta Sans", "Noto Sans Devanagari", system-ui, sans-serif;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
body.hi { font-family: "Noto Sans Devanagari", "Plus Jakarta Sans", sans-serif; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand svg { color: #fff; background: linear-gradient(135deg, #f97316, #dc2626); border-radius: 9px; padding: 5px; width: 30px; height: 30px; }
.meta { color: var(--muted); font-size: 12.5px; flex: 1; }
.lang { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang button { background: none; border: 0; color: var(--muted); padding: 4px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; }
.lang button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- layout ---------- */
main { flex: 1; display: grid; grid-template-columns: 1fr 400px; min-height: 0; }
#mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #e9ebef; }
aside { overflow-y: auto; padding: 20px; background: var(--bg); border-left: 1px solid var(--line); }

/* floating map controls share one glass style */
.timebar, .legend, #banner, #notice, #focusChip {
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .7); box-shadow: var(--shadow); }

.timebar { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 500; display: flex; align-items: center; gap: 14px;
  border-radius: 999px; padding: 8px 18px 8px 8px; }
#play { background: var(--text); color: #fff; border: 0; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 13px; flex: none;
  transition: transform .15s; }
#play:hover { transform: scale(1.06); }
#slider { flex: 1; accent-color: var(--fire); }
#clock { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; min-width: 150px; text-align: right; line-height: 1.3; }
#clock em { font-style: normal; color: var(--fire); display: block; font-size: 11px; }
.legend { position: absolute; bottom: 80px; left: 16px; z-index: 500; display: flex; gap: 16px; font-size: 12px; border-radius: 999px; padding: 7px 14px; }
.legend b { font-weight: 500; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.fire { background: var(--fire); box-shadow: 0 0 0 3px var(--fire-soft); }
.dot.smoke { background: var(--smoke); }

.topbar { position: absolute; top: 14px; left: 58px; right: 16px; z-index: 600; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
#banner { --lv: var(--low); display: flex; align-items: center; gap: 12px; border-radius: var(--radius); padding: 10px 16px 10px 10px;
  font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; max-width: 100%; }
#bLevel { background: var(--lv); color: #fff; border-radius: 10px; padding: 5px 10px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; flex: none; }
#notice, #focusChip { border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 500; }
#notice { color: #854d0e; background: rgba(254, 249, 195, .92); border-color: #fde68a; }
#focusChip { color: var(--fire); }
.topbar button { background: none; border: 0; color: var(--text); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0 0 0 6px; }

/* ---------- loading / error ---------- */
#state { position: absolute; inset: 0; z-index: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(243, 244, 247, .9); backdrop-filter: blur(4px); text-align: center; padding: 16px; }
#state[hidden] { display: none; }
.nodata aside > :not(.foot), .nodata .topbar { visibility: hidden; }
#state p { margin: 0; max-width: 320px; font-weight: 500; }
#state.error .spinner { display: none; }
#retry { background: var(--text); color: #fff; border: 0; border-radius: 999px; padding: 9px 20px; font-weight: 600; cursor: pointer; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--fire); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- panel ---------- */
.runbox { margin-bottom: 14px; }
.runbox label, .card label { color: var(--muted); font-size: 12px; font-weight: 600; display: block; margin-bottom: 6px; }
select, #q { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow-sm); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-sm); }
.stats b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 11.5px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.verdict { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.badge { padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; }
.lv-low { background: #dcfce7; color: #166534; } .lv-moderate { background: #fef9c3; color: #854d0e; }
.lv-high { background: #ffedd5; color: #9a3412; } .lv-severe { background: #fee2e2; color: #991b1b; }
#when { color: var(--muted); font-size: 12.5px; }
#msg { margin: 6px 0 12px; font-weight: 500; }
.tlhead { color: var(--muted); font-size: 11.5px; font-weight: 600; margin: 4px 0 2px; }
#tl svg { width: 100%; height: 80px; display: block; margin-bottom: 12px; }
#tl rect { cursor: pointer; }
#tl rect.cur { stroke: var(--text); stroke-width: 1.5; }
#srcs { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
#srcs .bar { height: 6px; background: linear-gradient(90deg, #f97316, #dc2626); border-radius: 3px; margin: 4px 0 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: #25d366; color: #fff; font-weight: 700; text-decoration: none; padding: 9px 16px;
  border-radius: 999px; font-size: 13px; box-shadow: 0 4px 14px -4px rgba(37, 211, 102, .6); }
.btn:hover { background: #1fbd5a; }

#ask { margin-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chips button { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; text-align: left; }
.chips button:hover { border-color: var(--text); }
#askform { display: flex; gap: 8px; }
#q { flex: 1; min-width: 0; }
#askform button { background: var(--text); color: #fff; border: 0; border-radius: 10px; padding: 0 18px; font-weight: 600; cursor: pointer; }
#askform button:disabled { opacity: .5; }
#answer { white-space: pre-wrap; margin: 12px 0 0; padding: 12px; background: var(--surface-2); border-radius: 10px; }
#answer:empty { display: none; }
#answer.wait { color: var(--muted); }

h3 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin: 26px 0 8px; }
.sub { color: var(--muted); font-size: 12.5px; margin: -4px 0 10px; }
ul, ol { list-style: none; margin: 0; padding: 0; }

#priority li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s; }
#priority li:hover { border-color: #fdba74; transform: translateY(-1px); }
#priority li.on { border-color: var(--fire); background: var(--fire-soft); }
#priority li.empty { cursor: default; color: var(--muted); font-size: 13px; }
#priority .rank { width: 26px; height: 26px; border-radius: 8px; background: var(--fire-soft); color: var(--fire); font-weight: 800; font-size: 12px; display: grid; place-items: center; flex: none; }
#priority li.on .rank { background: var(--fire); color: #fff; }
#priority .pd { flex: 1; min-width: 0; }
#priority .ps { text-align: right; }
#priority b { display: block; font-size: 13.5px; }
#priority .ps b { color: var(--fire); }
#priority small { color: var(--muted); font-size: 11.5px; }
.prio-pin span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--fire); border: 2px solid #fff;
  color: #fff; font-weight: 800; font-size: 12px; cursor: pointer; box-shadow: 0 2px 8px rgba(234, 88, 12, .45); }

#list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
#list li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#list li:last-child { border-bottom: 0; }
#list li:hover { background: var(--surface-2); }
#list .pip { width: 9px; height: 9px; border-radius: 50%; flex: none; }
#list .nm { flex: 1; font-weight: 500; }
#list .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

#districts li { display: grid; grid-template-columns: 120px 1fr 58px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
#districts .b { height: 8px; background: linear-gradient(90deg, #fdba74, var(--fire)); border-radius: 4px; }
#districts .n { text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#pm { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-sm); }
#pm svg { width: 100%; height: 90px; display: block; }
.foot { color: var(--muted); font-size: 11.5px; margin-top: 22px; }

/* ---------- leaflet ---------- */
.leaflet-container { font: inherit; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { color: var(--text) !important; }
.leaflet-tooltip.rlabel { background: var(--surface); border: 0; border-radius: 8px; box-shadow: var(--shadow); padding: 3px 8px; }
.leaflet-tooltip.rlabel::before { display: none; }
.rlabel { color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; }

@media (max-width: 820px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: 58vh auto; }
  aside { min-width: 0; border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 16px; }
  .meta { display: none; }
  body { height: auto; }
  .topbar { left: 58px; right: 8px; }
  #banner { font-size: 13px; }
  #clock { min-width: 110px; }
}
