:root {
  color-scheme: light;
  --bg: #eef3f1;
  --ink: #18211f;
  --muted: #60706b;
  --panel: #ffffff;
  --line: #d9e2de;
  --critical: #7f1d1d;
  --risk: #ef4444;
  --warning: #d88a19;
  --normal: #1d8f5f;
  --water: #2574a9;
  --rain: #2d9ccf;
  --shadow: 0 20px 60px rgba(21, 38, 35, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Prompt, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.dark {
  --bg: #252524;
  --ink: #f4f4ef;
  --muted: #c3c3ba;
  --panel: #2d2d2b;
  --line: #44443f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 34.5% minmax(0, 1fr);
}

.app-shell.risk-collapsed {
  grid-template-columns: 34.5% minmax(0, 1fr);
}

.app-shell:not(.risk-collapsed) .command-header {
  grid-template-columns: minmax(240px, 0.74fr) minmax(360px, 1.26fr);
}

.app-shell:not(.risk-collapsed) .command-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.system-footer {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px clamp(18px, 4vw, 52px);
  background: #2b2f30;
  color: #f4f6f5;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.system-footer-logo {
  display: flex;
  align-items: center;
  padding-right: 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
}

.system-footer-logo img {
  width: 48px;
  height: 56px;
  object-fit: contain;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.system-footer-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: center;
  text-align: center;
}

.system-footer-copy strong {
  font-size: clamp(0.9rem, 1.08vw, 1.08rem);
  line-height: 1.25;
  white-space: nowrap;
}

.system-footer-copy span {
  color: rgba(255, 255, 255, 0.68);
  font-size: clamp(0.72rem, 0.95vw, 0.84rem);
  font-weight: 400;
}

.system-footer-partners {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.system-footer-partners img {
  width: min(380px, 29vw);
  max-height: 58px;
  object-fit: contain;
  object-position: center;
}

.sidebar,
.risk-sidebar {
  position: relative;
  z-index: 3;
  padding: 18px;
  background: #f8fbfa;
  overflow-y: auto;
  max-height: none;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.risk-sidebar {
  z-index: 40;
  border-left: 1px solid var(--line);
  background: rgba(248, 251, 250, 0.82);
  backdrop-filter: blur(10px);
  contain: layout paint;
}

.risk-sidebar.collapsed {
  padding: 10px 12px;
  overflow: hidden;
}

.risk-sidebar.collapsed .affected-panel {
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.risk-sidebar.collapsed .affected-list {
  display: none;
}

.risk-sidebar-toggle {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.risk-sidebar-toggle h2 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.15;
}

.risk-sidebar-toggle span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.risk-sidebar-chevron {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  transition: transform 180ms ease;
}

.risk-sidebar.collapsed .risk-sidebar-toggle {
  min-height: calc(100vh - 20px);
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 8px;
  padding: 12px 6px;
  border: 1px solid rgba(24, 33, 31, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 26px rgba(21, 38, 35, 0.12);
}

.risk-sidebar.collapsed .risk-sidebar-toggle h2 {
  width: auto;
  max-width: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: none;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  color: #10211c;
  white-space: nowrap;
  text-align: center;
}

.risk-sidebar.collapsed .risk-sidebar-toggle span:not(.risk-sidebar-chevron) {
  display: none;
}

.risk-sidebar.collapsed .risk-sidebar-chevron {
  transform: rotate(180deg);
}

.public-alert-button,
.population-impact-button,
.rain-forecast-button {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 8px 0;
  border: 1px solid rgba(201, 47, 55, 0.32);
  border-radius: 8px;
  background: #fff5f5;
  color: #a51f2a;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.population-impact-button {
  margin-top: 0;
  background: #f0f9ff;
  color: #075985;
  border-color: rgba(14, 116, 144, 0.25);
  font-size: 0.72rem;
}

.rain-forecast-button {
  margin-top: 0;
  background: #f7fee7;
  color: #3f6212;
  border-color: rgba(101, 163, 13, 0.26);
  font-size: 0.72rem;
}

.public-alert-button svg,
.population-impact-button svg,
.rain-forecast-button svg {
  width: 15px;
  height: 15px;
}

.risk-sidebar.collapsed .public-alert-button,
.risk-sidebar.collapsed .population-impact-button,
.risk-sidebar.collapsed .population-impact-panel,
.risk-sidebar.collapsed .rain-forecast-button,
.risk-sidebar.collapsed .rain-forecast-panel {
  display: none;
}

.population-impact-panel,
.rain-forecast-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.population-impact-panel[hidden],
.rain-forecast-panel[hidden] {
  display: none;
}

.visitor-counter {
  position: fixed;
  left: 14px;
  bottom: 12px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(24, 33, 31, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(21, 38, 35, 0.14);
  backdrop-filter: blur(10px);
  font-size: 0.72rem;
  font-weight: 800;
}

.visitor-counter svg {
  width: 14px;
  height: 14px;
}

.visitor-counter strong {
  font-size: 0.82rem;
  color: #173f38;
}

.visitor-counter small {
  color: var(--muted);
  font-size: 0.62rem;
}

.impact-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.impact-tab {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  cursor: pointer;
}

.impact-tab.active {
  background: #173f38;
  border-color: #173f38;
  color: #fff;
}

.population-impact-summary {
  display: grid;
  gap: 7px;
}

.impact-total {
  display: grid;
  gap: 1px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fbfa;
  border: 1px solid var(--line);
}

.impact-total strong {
  color: #10211c;
  font-size: 1rem;
  line-height: 1.1;
}

.impact-total span,
.impact-note {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.3;
}

.impact-list {
  display: grid;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}

.impact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.impact-row strong {
  display: block;
  color: #10211c;
  font-size: 0.7rem;
  line-height: 1.2;
}

.impact-row small {
  display: block;
  color: var(--muted);
  font-size: 0.6rem;
  line-height: 1.25;
}

.impact-row > span {
  color: #075985;
  font-size: 0.7rem;
  font-weight: 900;
  white-space: nowrap;
}

.forecast-total strong {
  color: #3f6212;
}

.forecast-total small {
  display: block;
  margin-top: 5px;
  color: #24443d;
  font-size: 0.66rem;
  line-height: 1.35;
}

.forecast-readiness {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.forecast-readiness span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.58rem;
  font-weight: 900;
}

.forecast-readiness span.ready {
  border-color: rgba(34, 197, 94, 0.22);
  background: #ecfdf5;
  color: #166534;
}

.forecast-section-title {
  color: #173f38;
  font-size: 0.68rem;
  font-weight: 1000;
}

.forecast-list .forecast-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.forecast-list .forecast-row:hover {
  border-color: rgba(23, 63, 56, 0.32);
  box-shadow: 0 8px 18px rgba(21, 38, 35, 0.08);
  transform: translateY(-1px);
}

.forecast-row.warning > span,
.forecast-row.watch > span {
  color: #a16207;
}

.forecast-row.risk > span {
  color: #b91c1c;
}

.forecast-row.critical > span {
  color: #7c3aed;
}

.station-forecast-list .forecast-row,
.station-forecast-list .forecast-row.warning,
.station-forecast-list .forecast-row.watch,
.station-forecast-list .forecast-row.risk,
.station-forecast-list .forecast-row.critical {
  border-color: #d1d5db;
  background: #fff;
}

.station-forecast-list .forecast-row > span {
  padding: 3px 7px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #f8fafc;
}

.command-side-panel {
  display: grid;
  gap: 8px;
}

.operation-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(23, 63, 56, 0.16);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.98), rgba(255, 255, 255, 0.98));
}

.operation-card .situation-badge {
  justify-self: start;
  min-height: 26px;
}

.operation-card strong {
  font-size: 0.78rem;
  line-height: 1.35;
}

.mini-section {
  display: grid;
  gap: 7px;
}

.mini-section h3 {
  margin: 0;
  color: #173f38;
  font-size: 0.78rem;
  line-height: 1.2;
}

.top-risk-list,
.timeline-list,
.guidance-list {
  display: grid;
  gap: 6px;
}

.guidance-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid rgba(29, 143, 95, 0.16);
  border-radius: 8px;
  background: #f0fdf4;
}

.guidance-item svg {
  width: 15px;
  height: 15px;
  color: #15803d;
  margin-top: 1px;
}

.guidance-item p {
  margin: 0;
  color: #14532d;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.35;
}

.top-risk-item {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.top-risk-item strong {
  font-size: 0.76rem;
  line-height: 1.2;
}

.top-risk-item span,
.top-risk-item small,
.top-risk-item em {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.25;
  font-style: normal;
}

.top-risk-item em {
  color: #a16207;
  font-weight: 850;
}

.top-risk-item.station-attention {
  border-color: rgba(202, 138, 4, 0.24);
  background: #fffdf2;
}

.timeline-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item strong {
  color: #173f38;
  font-size: 0.66rem;
}

.timeline-item span {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.35;
}

body[data-active-command-mode="public"] .officer-only,
body[data-active-command-mode="officer"] .public-only {
  display: none;
}

body[data-active-command-mode="public"] .public-alert-button,
body[data-active-command-mode="public"] .population-impact-button,
body[data-active-command-mode="public"] .population-impact-panel,
body[data-active-command-mode="public"] .rain-forecast-button,
body[data-active-command-mode="public"] .rain-forecast-panel {
  display: none;
}

.brand {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 14px 54px 14px 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(20, 34, 31, 0.08);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
  flex: 0 0 56px;
}

.brand h1,
.brand p,
.panel h2,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 1.22rem;
  line-height: 1.12;
}

.brand-light {
  font-weight: 400;
}

.brand p {
  color: var(--muted);
  font-size: 0.92rem;
}

.operation-switch {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
}

.operation-switch summary {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17, 52, 95, 0.09);
  border-radius: 10px;
  background: rgba(238, 247, 255, 0.42);
  color: rgba(17, 52, 95, 0.42);
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 800;
  opacity: 0.58;
  cursor: pointer;
  box-shadow: none;
  list-style: none;
  transition:
    opacity 0.18s ease,
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.operation-switch summary::-webkit-details-marker {
  display: none;
}

.operation-switch summary:hover,
.operation-switch summary:focus-visible,
.operation-switch[open] summary {
  opacity: 0.82;
  color: rgba(17, 52, 95, 0.68);
  background: rgba(238, 247, 255, 0.72);
  border-color: rgba(17, 52, 95, 0.16);
}

.operation-switch[open] summary {
  transform: rotate(90deg);
}

.operation-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 226px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(17, 52, 95, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(20, 34, 31, 0.16);
}

.operation-menu a {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 54px;
  padding: 7px;
  border: 1px solid rgba(17, 52, 95, 0.08);
  border-radius: 12px;
  background: rgba(238, 247, 255, 0.5);
  color: #173f38;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
}

.operation-menu a:hover,
.operation-menu a:focus-visible {
  background: rgba(224, 242, 254, 0.85);
  border-color: rgba(14, 116, 144, 0.22);
}

.operation-menu img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
}

.quick-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 9px;
}

.alert-report-button {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  border: 1px solid #9f1f2b;
  border-radius: 8px;
  background: #c92f37;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.12;
  box-shadow: 0 5px 12px rgba(201, 47, 55, 0.16);
}

.alert-report-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.history-event-button {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  border: 1px solid rgba(37, 116, 169, 0.22);
  border-radius: 8px;
  background: #eef7ff;
  color: #185b83;
  font-size: 0.62rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.12;
}

.history-event-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.report-download-button {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  border: 1px solid rgba(23, 63, 56, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: #173f38;
  font-size: 0.62rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.12;
  box-shadow: 0 5px 12px rgba(20, 34, 31, 0.05);
}

.report-download-button svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.report-download-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.top-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: stretch;
  margin-bottom: 10px;
}

.province-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 0;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.province-picker select,
.theme-toggle {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 7px;
  font-weight: 700;
}

.province-picker select {
  min-width: 0;
  font-size: 0.76rem;
}

.theme-toggle {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 0;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 0.66rem;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle input {
  width: 13px;
  height: 13px;
  accent-color: #1d8f5f;
}

.theme-toggle svg {
  width: 13px;
  height: 13px;
}

.theme-toggle b {
  font-weight: 900;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef5f2;
}

.mode-toggle button,
.mode-toggle a {
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
}

.mode-toggle button.active,
.mode-toggle a.active {
  background: #173f38;
  color: #fff;
  box-shadow: 0 6px 14px rgba(23, 63, 56, 0.16);
}

.analysis-toolbox {
  margin-bottom: 10px;
  border: 1px solid rgba(14, 116, 144, 0.28);
  border-radius: 10px;
  background: linear-gradient(180deg, #e8f8fb 0%, #f7fcfb 100%);
  box-shadow: 0 10px 24px rgba(14, 116, 144, 0.12);
  overflow: hidden;
}

.analysis-toolbox summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: #0f3d46;
  font-size: 0.84rem;
  font-weight: 950;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid rgba(14, 116, 144, 0.1);
}

.analysis-toolbox summary::-webkit-details-marker {
  display: none;
}

.analysis-toolbox summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 160ms ease;
}

.analysis-toolbox[open] summary::after {
  transform: rotate(180deg);
}

.analysis-toolbox summary svg {
  width: 17px;
  height: 17px;
  color: #0e7490;
}

.analysis-toolbox .command-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
  margin-top: 0;
  overflow: visible;
}

.analysis-toolbox .command-tools .public-alert-button,
.analysis-toolbox .command-tools .population-impact-button,
.analysis-toolbox .command-tools .rain-forecast-button,
.analysis-toolbox .command-tools .disabled-tool-button {
  width: 100%;
  min-height: 31px;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.68rem;
}

.analysis-toolbox .command-tools .public-alert-button {
  grid-column: 1 / -1;
}

.analysis-toolbox .command-tool-panel {
  margin: 0 8px 8px;
  max-height: 260px;
  overflow-y: auto;
  border-radius: 8px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--normal);
  border-radius: 6px;
  padding: 7px 8px;
  box-shadow: 0 6px 16px rgba(20, 34, 31, 0.05);
}

.status-card span {
  display: block;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1;
}

.status-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.15;
}

.status-card.danger {
  background: var(--critical);
  border-left-color: var(--critical);
  color: #fff;
}

.status-card.risk {
  background: var(--risk);
  border-left-color: var(--risk);
  color: #fff;
}

.status-card.warning {
  background: var(--warning);
  border-left-color: var(--warning);
  color: #fff;
}

.status-card.normal {
  background: var(--normal);
  border-left-color: var(--normal);
  color: #fff;
}

.status-card.danger p,
.status-card.risk p,
.status-card.warning p,
.status-card.normal p {
  color: rgba(255, 255, 255, 0.88);
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(20, 34, 31, 0.06);
}

.map-panel-right .panel {
  padding: 7px;
  margin-bottom: 6px;
  border-radius: 6px;
}

.map-panel-right .panel-title {
  margin-bottom: 5px;
  gap: 6px;
}

.map-panel-right .panel-title h2 {
  font-size: 0.74rem;
}

.map-panel-right .panel-title span {
  font-size: 0.58rem;
}

.map-panel-right .controls label {
  min-height: 21px;
  gap: 5px;
  font-size: 0.66rem;
}

.map-panel-right .controls input[type="checkbox"] {
  width: 12px;
  height: 12px;
}

.layer-count {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--muted);
  font-size: 0.58rem;
  text-align: center;
}

.map-panel-right .icon-button {
  width: 24px;
  height: 24px;
}

.map-panel-right .slider-row {
  grid-template-columns: 1fr 64px;
  gap: 5px;
  margin-top: 4px;
  font-size: 0.62rem;
}

.map-panel-right .search {
  height: 28px;
  font-size: 0.66rem;
  padding: 0 7px;
}

.map-panel-right .select-grid {
  gap: 5px;
  margin-top: 5px;
}

.map-panel-right .select-grid label {
  gap: 3px;
  font-size: 0.6rem;
}

.map-panel-right .select-grid select {
  min-height: 27px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 0.64rem;
}

.map-panel-right .chips {
  gap: 4px;
  margin-top: 6px;
}

.map-panel-right .chip {
  min-height: 23px;
  padding: 0 6px;
  font-size: 0.62rem;
}

.map-panel-right .mini-danger-button {
  width: 100%;
  min-height: 25px;
  margin-top: 5px;
  border: 1px solid rgba(201, 47, 55, 0.32);
  border-radius: 6px;
  background: #fff5f5;
  color: #a51f2a;
  font-size: 0.64rem;
  font-weight: 800;
  cursor: pointer;
}

.map-panel-right .mini-danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 1rem;
}

.panel-title span {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  color: #25322f;
}

.controls input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #1d8f5f;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #173f38;
  cursor: pointer;
}

.icon-button.loading svg {
  animation: spin 1s linear infinite;
}

.slider-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.slider-row input {
  width: 100%;
}

.layer-status {
  margin: 6px 0 0;
  color: #52606d;
  font-size: 11px;
  line-height: 1.35;
}

.tmd-nudge-panel {
  margin-top: 8px;
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px dashed rgba(23, 63, 56, 0.22);
  border-radius: 8px;
  background: rgba(248, 251, 250, 0.72);
  color: var(--muted);
  font-size: 0.68rem;
}

.tmd-nudge-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tmd-nudge-panel strong {
  color: var(--ink);
  font-size: 0.7rem;
}

.tmd-nudge-panel span,
.tmd-nudge-panel small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tmd-nudge-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.tmd-nudge-grid button {
  min-height: 30px;
  border: 1px solid rgba(23, 63, 56, 0.18);
  border-radius: 7px;
  background: #fff;
  color: #173f38;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
}

.search {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.search:focus {
  border-color: #2d9ccf;
  box-shadow: 0 0 0 3px rgba(45, 156, 207, 0.15);
}

.select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.select-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.select-grid select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.chip.active {
  color: #fff;
  background: #173f38;
  border-color: #173f38;
}

.hot-list,
.affected-list {
  display: grid;
  gap: 8px;
}

.station-browser-panel {
  max-height: 42vh;
  overflow-y: auto;
}

.station-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.station-tab {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.station-tab.active {
  background: #173f38;
  border-color: #173f38;
  color: #fff;
}

.station-item,
.affected-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 9px 1fr auto;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  cursor: pointer;
}

.affected-item {
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 7px;
  align-items: center;
  background: #fff !important;
  color: #10211c !important;
}

.affected-section {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.affected-section + .affected-section {
  margin-top: 8px;
}

.affected-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.15;
  color: inherit;
  cursor: pointer;
}

.affected-section-toggle span {
  min-width: 0;
  flex: 1;
  text-align: left;
}

.affected-section-toggle strong {
  font-size: 0.72rem;
  font-weight: 800;
}

.panel-help {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.historical-event-list {
  display: grid;
  gap: 7px;
}

.historical-event-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.historical-event-item svg {
  width: 17px;
  height: 17px;
  color: #2574a9;
}

.historical-event-item strong {
  display: block;
  font-size: 0.78rem;
  line-height: 1.25;
}

.historical-event-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.3;
}

.historical-event-item .historical-rain-context {
  color: #0f766e;
  font-weight: 700;
}

.historical-event-item em {
  padding: 3px 6px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #185b83;
  font-size: 0.62rem;
  font-style: normal;
  white-space: nowrap;
}

.affected-section-toggle i,
.affected-section-toggle svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.affected-section.collapsed .affected-section-body {
  display: none;
}

.affected-section-risk .affected-section-toggle {
  color: #6d28d9;
}

.affected-section-watch .affected-section-toggle {
  color: #b91c1c;
}

.empty-note.compact {
  padding: 8px;
  font-size: 0.66rem;
}

.station-item.compact {
  min-height: 0;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px;
}

.station-item strong,
.affected-item strong {
  display: block;
  font-size: 0.82rem;
}

.affected-item strong {
  font-size: 0.76rem;
}

.station-item.compact strong {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-item small,
.affected-item small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.station-item small {
  font-size: 0.68rem;
  line-height: 1.28;
}

.affected-item small {
  font-size: 0.62rem;
  line-height: 1.22;
}

.station-item.compact small {
  font-size: 0.64rem;
  line-height: 1.25;
}

.risk-bar {
  width: 9px;
  height: 100%;
  min-height: 48px;
  border-radius: 5px;
  background: var(--normal);
}

.affected-item .risk-bar {
  width: 8px;
  min-height: 42px;
}

.village-risk-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: #fff;
  color: #d88a19;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.village-risk-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.8;
}

.village-risk-icon .village-risk-wave {
  position: absolute;
  right: -3px;
  bottom: -4px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #fff;
}

.village-risk-icon .village-risk-wave svg {
  width: 10px;
  height: 10px;
  stroke-width: 3;
}

.station-item.compact .risk-bar {
  min-height: 44px;
}

.affected-item.watch .risk-bar {
  background: #ef4444;
}

.affected-item.watch .village-risk-icon {
  color: #ef4444;
  background: #fff1f2;
}

.affected-item.risk .risk-bar {
  background: #b91c1c;
}

.affected-item.risk .village-risk-icon {
  color: #b91c1c;
  background: #fff1f2;
}

.affected-item.critical .risk-bar {
  background: #7c3aed;
}

.affected-item.critical .village-risk-icon {
  color: #7c3aed;
  background: #f5f3ff;
}

.affected-item.impact .risk-bar {
  background: #991b1b;
}

.affected-item.impact .village-risk-icon {
  color: #ffffff;
  background: #991b1b;
}

.affected-item.impact .flood-impact-icon svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.8;
}

.affected-item.watch {
  border-color: var(--line);
}

.affected-item.risk {
  border-color: var(--line);
}

.affected-item.critical {
  border-color: var(--line);
}

.affected-item.impact {
  border-color: var(--line);
}

.empty-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: #fff;
  font-size: 0.78rem;
  line-height: 1.45;
}

.station-value {
  text-align: right;
  font-weight: 800;
  white-space: nowrap;
  font-size: 0.82rem;
}

.station-item.compact .station-value {
  font-size: 0.82rem;
}

.map-area {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto clamp(420px, 52vh, 560px) minmax(520px, 1fr);
  gap: 10px;
  padding: 10px;
  overflow: hidden;
  background: #e7eeeb;
}

.command-header {
  display: grid;
  grid-template-columns: minmax(240px, 0.74fr) minmax(360px, 1.26fr);
  gap: 4px 10px;
  align-items: start;
  align-content: start;
  padding: 6px 10px;
  border: 1px solid rgba(217, 226, 222, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(21, 38, 35, 0.12);
}

.command-headline {
  min-width: 0;
  display: block;
}

.command-headline h2 {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.15;
}

.command-headline p,
.command-recommendation {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.command-summary {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}

.command-summary strong {
  display: block;
  color: #10211c;
  font-size: 0.86rem;
  font-weight: 950;
  line-height: 1.15;
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  padding: 0 !important;
}

#headline {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  outline: 0 !important;
}

.command-summary strong.headline-status.risk,
.command-summary strong.headline-status.critical {
  color: #c92f37;
}

.command-summary strong.headline-status.warning {
  color: #b45309;
}

.command-summary strong.headline-status.normal {
  color: #10211c;
}

.command-summary p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  line-height: 1.25;
}

.assessment-disclaimer {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #dc2626;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.25;
}

.assessment-disclaimer svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.situation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 106px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
}

.command-status-group {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: start;
}

.situation-badge.normal {
  background: #15803d;
}

.situation-badge.watch {
  background: #ca8a04;
}

.situation-badge.prepare {
  background: #ea580c;
}

.situation-badge.alert {
  background: #dc2626;
}

.situation-badge.response {
  background: #7c2d12;
}

.command-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 5px;
}

.command-metrics div {
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.command-metrics strong,
.command-metrics span {
  display: block;
  line-height: 1.15;
}

.command-metrics strong {
  font-size: 0.92rem;
}

.command-metrics span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
}

.command-recommendation {
  min-width: 0;
  margin: 0;
  padding: 5px 9px 5px 10px;
  border: 1px solid rgba(23, 63, 56, 0.16);
  border-left: 3px solid #173f38;
  border-radius: 8px;
  background: #f8fbfa;
  color: #173f38;
  font-size: 0.7rem;
  line-height: 1.35;
  font-weight: 900;
}

.command-recommendation::before {
  content: "ควรทำต่อ: ";
  color: #0f766e;
  font-weight: 950;
}

.command-action-row {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 4px;
  overflow: visible;
  margin-top: 0;
  padding-top: 0;
}

.mission-actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  overflow: visible;
}

.mission-actions button {
  flex: 0 1 auto;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #173f38;
  padding: 0 9px;
  font-size: 0.66rem;
  font-weight: 900;
  cursor: pointer;
}

.mission-actions button.active {
  background: #173f38;
  border-color: #173f38;
  color: #fff;
}

.mission-actions .disabled-mission-button,
.mission-actions button:disabled {
  border-color: rgba(107, 114, 128, 0.28);
  background: #f3f4f6;
  color: #7a817d;
  cursor: not-allowed;
  opacity: 0.78;
}

.station-map-label,
.village-map-label {
  border: 1px solid rgba(23, 63, 56, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #173f38;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.16);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.15;
  padding: 5px 8px;
  white-space: nowrap;
}

.summary-station-label {
  appearance: none;
  display: grid;
  gap: 2px;
  width: 220px;
  border: 2px solid currentColor;
  border-radius: 10px;
  background: rgba(12, 14, 18, 0.94);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.12);
  padding: 6px 9px;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
  color: #ffffff !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-station-label:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.34), 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.summary-station-label.expanded {
  z-index: 2;
}

.summary-station-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
  line-height: 1.1;
}

.summary-station-label em {
  justify-self: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.56rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  padding: 3px 8px;
}

.summary-station-label span {
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.1;
}

.summary-station-label small {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.82);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.05;
}

.summary-station-villages {
  max-height: 142px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 6px 0 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  text-align: left;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.25;
}

.summary-station-villages li {
  margin: 2px 0;
}

.summary-station-more {
  color: #cbd5e1;
}

.station-map-label::before,
.village-map-label::before {
  display: none;
}

.station-map-label.severity-critical,
.village-map-label.level-critical,
.village-map-label.level-impact {
  border-color: rgba(124, 58, 237, 0.54);
  color: #5b21b6;
}

.station-map-label.severity-risk,
.village-map-label.level-risk {
  border-color: rgba(185, 28, 28, 0.48);
  color: #991b1b;
}

body.dark .station-map-label,
body.dark .village-map-label {
  background: rgba(31, 31, 29, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f8fafc;
}

body.dark .summary-station-villages {
  border-top-color: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}

body.dark .summary-station-more {
  color: #cbd5e1;
}

.command-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 6px;
  overflow: visible;
  margin-top: 0;
}

.command-tools .public-alert-button,
.command-tools .population-impact-button,
.command-tools .rain-forecast-button,
.command-tools .disabled-tool-button {
  width: auto;
  min-height: 26px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.66rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}

.command-tools .public-alert-button.active,
.command-tools .population-impact-button.active,
.command-tools .rain-forecast-button.active {
  filter: saturate(1.12);
  outline: 2px solid rgba(23, 63, 56, 0.18);
  outline-offset: 1px;
}

.command-tools .population-impact-button {
  background: #f0f9ff;
  color: #075985;
}

.command-tools .rain-forecast-button {
  background: #f7fee7;
  color: #365314;
  border-color: rgba(101, 163, 13, 0.25);
}

.command-tools .disabled-tool-button {
  border: 1px solid rgba(107, 114, 128, 0.25);
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
  opacity: 0.78;
}

.command-tools .disabled-tool-button svg {
  width: 15px;
  height: 15px;
}

.command-tool-panel {
  grid-column: 1 / -1;
  margin: -1px 0 0;
  max-height: 220px;
  overflow-y: auto;
}

.mission-hint {
  grid-column: 1 / -1;
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.35;
}

.map-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  justify-self: stretch;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #dbe7e2;
  box-shadow: 0 14px 38px rgba(21, 38, 35, 0.14);
  transition: margin 180ms ease;
}

.map-area.panel-open .map-frame {
  width: 100%;
  margin-right: 0;
}

#map {
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #dbe7e2;
}

.bottom-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(21, 38, 35, 0.1);
}

.bottom-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bottom-panel-head h2 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.15;
}

.bottom-panel-head span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.bottom-assessment-note {
  margin: 4px 0 0;
  color: #b45309;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.25;
}

.method-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #99d4c9;
  border-radius: 999px;
  background: #ecfdf5;
  color: #0f766e;
  padding: 0 10px;
  font-size: 0.7rem;
  font-weight: 950;
  cursor: pointer;
}

.method-button svg {
  width: 14px;
  height: 14px;
}

.bottom-panel-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.bottom-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef3f1;
}

.bottom-tabs button,
.bottom-panel-controls select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #173f38;
  padding: 0 10px;
  font-size: 0.7rem;
  font-weight: 900;
  cursor: pointer;
}

#bottomDistrictFilter {
  max-width: 170px;
}

.bottom-tabs button {
  border-color: transparent;
  background: transparent;
}

.bottom-tabs button.active {
  background: #173f38;
  color: #fff;
}

.bottom-ops-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.bottom-ops-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.bottom-ops-item.station {
  grid-template-columns: 10px minmax(0, 1fr) auto;
}

.bottom-ops-item.village.watch {
  border-left-color: #ef4444;
  background: #fff;
}

.bottom-ops-item.village.risk {
  border-left-color: #b91c1c;
  background: #fff;
}

.bottom-ops-item.village.critical,
.bottom-ops-item.village.impact {
  border-left-color: #7c3aed;
  background: #fff;
}

.bottom-ops-item.village.impact {
  border-left-color: #991b1b;
}

.bottom-ops-item .village-risk-icon {
  width: 24px;
  height: 24px;
  border-width: 1.5px;
  box-shadow: none;
}

.bottom-ops-item .village-risk-icon svg {
  width: 13px;
  height: 13px;
}

.bottom-ops-item .village-risk-icon .village-risk-wave {
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
}

.bottom-ops-item .village-risk-icon .village-risk-wave svg {
  width: 7px;
  height: 7px;
}

.bottom-ops-item.village.watch .village-risk-icon {
  color: #ef4444;
  background: #fff;
}

.bottom-ops-item.village.risk .village-risk-icon {
  color: #b91c1c;
  background: #fff;
}

.bottom-ops-item.village.critical .village-risk-icon {
  color: #7c3aed;
  background: #fff;
}

.bottom-ops-item.village.impact .village-risk-icon {
  color: #991b1b;
  background: #fff;
}

.bottom-ops-item strong,
.bottom-ops-item small {
  display: block;
  min-width: 0;
}

.bottom-ops-item strong {
  font-size: 0.76rem;
  line-height: 1.18;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-ops-item small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.6rem;
  line-height: 1.18;
}

.bottom-ops-item em {
  color: #173f38;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 950;
  white-space: nowrap;
}

.bottom-group-heading {
  grid-column: 1 / -1;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  border: 1px solid rgba(23, 63, 56, 0.14);
  border-radius: 7px;
  background: #eaf5ef;
  color: #173f38;
  font-size: 0.66rem;
  font-weight: 950;
  text-align: left;
  cursor: pointer;
}

.bottom-group-heading::after {
  content: "ซูม";
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 900;
}

.bottom-show-more {
  width: 100%;
  min-height: 34px;
  grid-column: 1 / -1;
  border: 1px dashed rgba(23, 63, 56, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #173f38;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.bottom-risk-dot {
  width: 8px;
  height: 100%;
  min-height: 36px;
  border-radius: 999px;
  display: block;
}

.bottom-station-list {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 31%);
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.toolbar {
  position: absolute;
  z-index: 10020;
  top: 152px;
  left: 20px;
  right: 122px;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 7px 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(217, 226, 222, 0.95);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(21, 38, 35, 0.12);
}

.map-area.panel-open .toolbar {
  right: 242px;
}

.map-panel {
  position: absolute;
  z-index: 10030;
  top: 84px;
  width: min(390px, calc(50vw - 28px));
  max-height: calc(100% - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}

.map-panel-right {
  right: 12px;
  width: 220px;
  transition: transform 180ms ease, opacity 180ms ease;
}

.map-panel-right.collapsed {
  transform: translateX(calc(100% + 18px));
  opacity: 0;
  pointer-events: none;
}

.panel-toggle {
  position: absolute;
  z-index: 10040;
  top: 48px;
  right: 12px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid rgba(217, 226, 222, 0.95);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #173f38;
  font-size: 0.68rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(21, 38, 35, 0.12);
  cursor: pointer;
}

.map-fullscreen-toggle {
  position: absolute;
  z-index: 10040;
  top: 12px;
  right: 12px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid rgba(217, 226, 222, 0.95);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #173f38;
  font-size: 0.68rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(21, 38, 35, 0.12);
  cursor: pointer;
}

.panel-toggle svg,
.map-fullscreen-toggle svg {
  width: 14px;
  height: 14px;
}

.panel-toggle.open {
  right: 230px;
}

.map-fullscreen-toggle.fullscreen-active {
  background: #173f38;
  color: #fff;
  border-color: #173f38;
}

.map-area:fullscreen,
.map-area.fullscreen-fallback {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  background: #e7eeeb;
}

.map-area:fullscreen .command-header,
.map-area.fullscreen-fallback .command-header,
.map-area:fullscreen .bottom-panel,
.map-area.fullscreen-fallback .bottom-panel,
.map-area:fullscreen .toolbar,
.map-area.fullscreen-fallback .toolbar {
  display: none !important;
}

.map-area:fullscreen .map-fullscreen-toggle,
.map-area.fullscreen-fallback .map-fullscreen-toggle {
  top: 10px;
  right: 10px;
  z-index: 100000;
}

.map-area:fullscreen .panel-toggle,
.map-area.fullscreen-fallback .panel-toggle {
  display: inline-flex !important;
  top: 48px;
  right: 10px;
  z-index: 100000;
}

.map-area:fullscreen .panel-toggle.open,
.map-area.fullscreen-fallback .panel-toggle.open {
  right: 244px;
}

.map-area:fullscreen .map-panel,
.map-area.fullscreen-fallback .map-panel {
  top: 10px;
  right: 10px;
  z-index: 99999;
  max-height: calc(100vh - 20px);
}

.map-area:fullscreen .map-frame,
.map-area.fullscreen-fallback .map-frame {
  min-height: 0;
  margin-right: 0;
  grid-column: 1 / -1;
  grid-row: 1 / -1 !important;
}

.map-area.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 99990;
}

.hot-panel {
  max-height: 36vh;
  overflow-y: auto;
}

.affected-panel {
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #fff;
  color: #10211c;
}

.toolbar strong {
  font-size: 0.82rem;
  line-height: 1.15;
}

.toolbar p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.criteria-stack {
  position: absolute;
  z-index: 700;
  left: 12px;
  right: 12px;
  bottom: 12px;
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 6px 8px;
  border: 1px solid rgba(217, 226, 222, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 22px rgba(21, 38, 35, 0.12);
  pointer-events: auto;
}

.criteria-row {
  max-width: min(100%, 820px);
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  color: var(--muted);
  font-size: 0.6rem;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.criteria-row::-webkit-scrollbar {
  display: none;
}

.criteria-row strong {
  color: #25322f;
  font-size: 0.62rem;
  font-weight: 900;
}

.legend {
  font-size: 0.66rem;
}

.rain-scale {
  font-size: 0.6rem;
}

.legend span,
.rain-scale span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.rain-scale i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  border: 1px solid rgba(24, 33, 31, 0.18);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 3px;
}

.critical {
  background: var(--critical);
}

.risk {
  background: var(--risk);
}

.warning {
  background: var(--warning);
}

.normal {
  background: var(--normal);
}

.forecast-list .forecast-row,
.forecast-list .forecast-row.warning,
.forecast-list .forecast-row.watch,
.forecast-list .forecast-row.risk,
.forecast-list .forecast-row.critical {
  border-color: #d1d5db;
  background: #fff;
}

.forecast-list .forecast-row > span {
  padding: 3px 7px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #f8fafc;
}

.forecast-list .forecast-row.warning,
.forecast-list .forecast-row.watch {
  border-color: #d88a19;
}

.forecast-list .forecast-row.risk {
  border-color: #ef4444;
}

.forecast-list .forecast-row.critical {
  border-color: #7c3aed;
}

.station-forecast-list .forecast-row,
.station-forecast-list .forecast-row.warning,
.station-forecast-list .forecast-row.watch,
.station-forecast-list .forecast-row.risk,
.station-forecast-list .forecast-row.critical {
  border-color: #d1d5db;
}

.station-marker {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 1)) drop-shadow(0 2px 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 6px 11px rgba(12, 24, 20, 0.36));
}

.station-marker svg {
  width: 34px;
  height: 34px;
  display: block;
  overflow: visible;
}

.rain-marker {
  width: 34px;
  height: 34px;
}

.rain-marker svg {
  width: 30px;
  height: 30px;
}

.rain-marker svg path {
  paint-order: stroke fill;
  stroke-linejoin: round;
  stroke: #ffffff;
  stroke-width: 1.65px;
}

.station-marker.radar-confirmed {
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.98)) drop-shadow(0 0 9px rgba(250, 204, 21, 0.7)) drop-shadow(0 7px 12px rgba(12, 24, 20, 0.35));
}

.station-marker.radar-confirmed svg {
  width: 32px;
  height: 32px;
}

.station-marker.stale-marker {
  filter: drop-shadow(0 2px 2px rgba(255, 255, 255, 0.85)) drop-shadow(0 4px 8px rgba(12, 24, 20, 0.22));
}

.station-marker.stale-marker > svg {
  opacity: 0.46;
}

.station-stale-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(15, 23, 42, 0.36);
  border-radius: 999px;
  background: #ffffff;
  color: #7c2d12;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
}

body.dark .station-stale-badge {
  border-color: rgba(253, 230, 138, 0.46);
  background: #17231f;
  color: #fde68a;
}

.rain-marker {
  color: inherit;
}

.water-marker {
  color: inherit;
}

.floodboy-marker {
  color: inherit;
}

.floodboy-marker .floodboy-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.36);
}

.risk-circle {
  stroke: #fff;
  stroke-width: 1;
}

.popup h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.popup p {
  margin: 3px 0;
}

.popup .pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.popup-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 7px;
}

.popup .popup-status-badge {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 900;
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.14);
}

.popup-primary-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: #173f38;
  font-weight: 900;
  line-height: 1;
}

.popup-primary-metric strong {
  font-size: 1.08rem;
}

.popup-primary-metric span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.popup-danger-button {
  min-height: 28px;
  margin-top: 8px;
  border: 1px solid rgba(201, 47, 55, 0.35);
  border-radius: 6px;
  background: #fff5f5;
  color: #a51f2a;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.flood-report-marker {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c92f37;
  color: #fff;
  box-shadow: 0 8px 18px rgba(89, 12, 19, 0.35);
}

.flood-report-marker svg {
  width: 21px;
  height: 21px;
}

.report-photo {
  width: 180px;
  max-width: 100%;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.report-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(13, 28, 25, 0.25);
}

.public-alert-dialog {
  width: min(760px, calc(100vw - 28px));
}

.historical-event-dialog {
  width: min(620px, calc(100vw - 28px));
}

.risk-method-dialog {
  width: min(820px, calc(100vw - 28px));
}

.risk-method-content {
  display: grid;
  gap: 12px;
  max-height: min(66vh, 680px);
  overflow: auto;
  padding-right: 4px;
}

.risk-method-content section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfa;
  padding: 12px;
}

.risk-method-content h3 {
  margin: 0 0 7px;
  font-size: 0.95rem;
}

.risk-method-content p,
.risk-method-content li {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.risk-method-content p {
  margin: 0 0 8px;
}

.risk-method-content ul {
  margin: 0;
  padding-left: 20px;
}

.public-alert-text {
  max-height: min(62vh, 620px);
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Prompt, Inter, system-ui, sans-serif;
  font-size: 0.86rem;
  line-height: 1.55;
}

.public-alert-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.public-alert-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.public-alert-controls select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.location-check-summary {
  display: grid;
  gap: 8px;
}

.location-check-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.location-check-card strong {
  color: #173f38;
  font-size: 0.86rem;
}

.location-check-card span,
.location-check-card small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.location-check-card.alert {
  border-color: rgba(220, 38, 38, 0.25);
  background: #fff5f5;
}

.location-check-card.watch {
  border-color: rgba(202, 138, 4, 0.28);
  background: #fffdf2;
}

.report-dialog::backdrop {
  background: rgba(12, 22, 20, 0.34);
}

.report-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #fff;
}

.report-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.report-head strong {
  font-size: 1.05rem;
}

.report-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.coord-grid label,
.report-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.coord-grid input,
.select-grid input,
.select-grid select,
.report-field textarea,
.report-field input[type="text"],
.report-field input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.report-field textarea {
  resize: vertical;
  min-height: 96px;
}

.report-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.secondary-button,
.submit-report-button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #173f38;
}

.submit-report-button {
  border: 1px solid #9f1f2b;
  background: #c92f37;
  color: #fff;
}

body.dark .sidebar,
body.dark .brand,
body.dark .panel,
body.dark .bottom-panel,
body.dark .bottom-tabs,
body.dark .bottom-tabs button,
body.dark .bottom-panel-controls select,
body.dark .bottom-ops-item,
body.dark .station-tab,
body.dark .status-card,
body.dark .province-picker,
body.dark .theme-toggle,
body.dark .station-item,
body.dark .affected-item,
body.dark .population-impact-panel,
body.dark .rain-forecast-panel,
body.dark .command-header,
body.dark .command-metrics div,
body.dark .command-recommendation,
body.dark .operation-card,
body.dark .top-risk-item,
body.dark .guidance-item,
body.dark .impact-total,
body.dark .impact-row,
body.dark .impact-tab,
body.dark .empty-note,
body.dark .toolbar,
body.dark .panel-toggle,
body.dark .icon-button,
body.dark .search,
body.dark .select-grid select,
body.dark .chip,
body.dark .coord-grid input,
body.dark .report-field textarea,
body.dark .report-field input[type="text"],
body.dark .report-field input[type="file"],
body.dark .report-form,
body.dark .secondary-button,
body.dark .report-download-button,
body.dark .history-event-button,
body.dark .historical-event-item,
body.dark .province-picker select {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

body.dark .operation-switch summary {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(226, 232, 240, 0.08);
  color: rgba(226, 232, 240, 0.34);
  opacity: 0.55;
}

body.dark .operation-switch summary:hover,
body.dark .operation-switch summary:focus-visible,
body.dark .operation-switch[open] summary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(226, 232, 240, 0.16);
  color: rgba(226, 232, 240, 0.62);
  opacity: 0.82;
}

body.dark .operation-menu {
  background: rgba(15, 31, 38, 0.97);
  border-color: rgba(226, 232, 240, 0.12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

body.dark .operation-menu a {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(226, 232, 240, 0.1);
  color: #eef7f3;
}

body.dark .operation-menu a:hover,
body.dark .operation-menu a:focus-visible {
  background: rgba(14, 116, 144, 0.18);
  border-color: rgba(125, 211, 252, 0.24);
}

body.dark .map-panel-right,
body.dark .map-panel-right .panel,
body.dark .map-panel-right .panel-title h2,
body.dark .map-panel-right .panel-title span,
body.dark .map-panel-right .controls label,
body.dark .map-panel-right .slider-row,
body.dark .legend,
body.dark .rain-scale,
body.dark .toolbar strong,
body.dark .toolbar p,
body.dark .command-recommendation,
body.dark .mini-section h3,
body.dark .timeline-item strong,
body.dark .search::placeholder,
body.dark .select-grid label {
  color: #eef7f3;
}

body.dark .map-panel-right .panel-title span,
body.dark .map-panel-right .slider-row,
body.dark .toolbar p,
body.dark .legend,
body.dark .rain-scale {
  color: #cfe0da;
}

body.dark .criteria-row strong {
  color: #eef7f3;
}

body.dark .criteria-stack {
  background: rgba(37, 37, 36, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark .sidebar {
  background: #252524;
}

body.dark .risk-sidebar {
  background: rgba(37, 37, 36, 0.88);
}

body.dark .affected-section {
  background: rgba(37, 37, 36, 0.8);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark .affected-panel,
body.dark .affected-item {
  background: var(--panel) !important;
  color: var(--ink) !important;
}

body.dark .risk-sidebar.collapsed .risk-sidebar-toggle h2 {
  color: var(--ink);
}

body.dark .village-risk-icon {
  background: #2d2d2b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark .village-risk-icon .village-risk-wave {
  background: #0c2a38;
  color: #7dd3fc;
  border-color: #17231f;
}

body.dark .risk-sidebar-toggle {
  color: var(--ink);
}

body.dark .command-summary strong.headline-status.risk,
body.dark .command-summary strong.headline-status.critical {
  color: #ff6b6b;
  text-shadow: none;
}

body.dark .command-summary strong.headline-status.warning {
  color: #fbbf24;
}

body.dark .command-summary strong.headline-status.normal {
  color: #f4f4ef;
}

body.dark .assessment-disclaimer {
  border-color: transparent;
  background: transparent;
  color: #ff6b6b;
}

body.dark .bottom-assessment-note {
  color: #fcd34d;
}

body.dark .method-button {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(20, 83, 75, 0.55);
  color: #ccfbf1;
}

body.dark .risk-sidebar.collapsed .risk-sidebar-toggle {
  border-color: rgba(238, 247, 243, 0.14);
  background: rgba(45, 45, 43, 0.84);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

body.dark .analysis-toolbox {
  border-color: rgba(125, 211, 252, 0.24);
  background: linear-gradient(180deg, #263332 0%, #2d2d2b 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

body.dark .analysis-toolbox summary {
  color: var(--ink);
  border-bottom-color: rgba(125, 211, 252, 0.12);
}

body.dark .analysis-toolbox summary svg {
  color: #7dd3fc;
}

body.dark .visitor-counter {
  border-color: rgba(238, 247, 243, 0.14);
  background: rgba(45, 45, 43, 0.88);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

body.dark .visitor-counter strong {
  color: #a7f3d0;
}

body.dark .toolbar,
body.dark .panel-toggle,
body.dark .map-fullscreen-toggle,
body.dark .panel {
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

body.dark .tmd-nudge-panel {
  background: rgba(45, 45, 43, 0.72);
  border-color: rgba(238, 247, 243, 0.16);
  color: var(--muted);
}

body.dark .tmd-nudge-panel strong {
  color: var(--ink);
}

body.dark .tmd-nudge-grid button {
  background: #2d2d2b;
  color: var(--ink);
  border-color: rgba(238, 247, 243, 0.16);
}

body.dark .map-area {
  background: #252524;
}

body.dark .map-frame {
  border-color: var(--line);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
}

body.dark .map-panel-right .mini-danger-button,
body.dark .popup-danger-button,
body.dark .public-alert-button {
  background: #31171a;
  color: #ffb8bd;
  border-color: rgba(248, 113, 113, 0.35);
}

body.dark .population-impact-button {
  background: #10283a;
  color: #bae6fd;
  border-color: rgba(125, 211, 252, 0.24);
}

body.dark .rain-forecast-button {
  background: #1d2a12;
  color: #d9f99d;
  border-color: rgba(190, 242, 100, 0.22);
}

body.dark .command-tools .disabled-tool-button {
  background: #343431;
  color: #9ca3af;
  border-color: rgba(209, 213, 219, 0.16);
}

body.dark .impact-tab.active {
  background: #d9f4ec;
  border-color: #d9f4ec;
  color: #10211c;
}

body.dark .impact-total strong,
body.dark .impact-row strong {
  color: var(--ink);
}

body.dark .impact-row > span {
  color: #7dd3fc;
}

body.dark .forecast-total strong {
  color: #d9f99d;
}

body.dark .forecast-total small {
  color: #d8efe8;
}

body.dark .forecast-readiness span {
  border-color: rgba(203, 213, 225, 0.16);
  background: #111f1b;
  color: #94a3b8;
}

body.dark .forecast-readiness span.ready {
  border-color: rgba(74, 222, 128, 0.24);
  background: #10251c;
  color: #bbf7d0;
}

body.dark .forecast-section-title {
  color: var(--ink);
}

body.dark .forecast-list .forecast-row:hover {
  border-color: rgba(167, 243, 208, 0.24);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

body.dark .station-forecast-list .forecast-row,
body.dark .station-forecast-list .forecast-row.warning,
body.dark .station-forecast-list .forecast-row.watch,
body.dark .station-forecast-list .forecast-row.risk,
body.dark .station-forecast-list .forecast-row.critical {
  border-color: rgba(148, 163, 184, 0.28);
  background: var(--panel);
}

body.dark .station-forecast-list .forecast-row > span {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

body.dark .guidance-item {
  background: #10251c;
  border-color: rgba(74, 222, 128, 0.18);
}

body.dark .guidance-item p {
  color: #bbf7d0;
}

body.dark .top-risk-item.station-attention {
  background: #2b220f;
  border-color: rgba(250, 204, 21, 0.22);
}

body.dark .public-alert-text {
  background: #101916;
  color: var(--ink);
  border-color: var(--line);
}

body.dark .public-alert-controls select {
  background: #252524;
  color: var(--ink);
  border-color: rgba(238, 247, 243, 0.14);
}

body.dark .risk-method-content section {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.62);
}

body.dark .risk-method-content p,
body.dark .risk-method-content li {
  color: #cbd5e1;
}

body.dark .popup-primary-metric {
  color: #d9f4ec;
}

body.dark .popup-primary-metric span {
  color: var(--muted);
}

body.dark .location-check-card {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

body.dark .location-check-card strong {
  color: var(--ink);
}

body.dark .location-check-card.alert {
  background: #31171a;
  border-color: rgba(248, 113, 113, 0.35);
}

body.dark .location-check-card.watch {
  background: #2b220f;
  border-color: rgba(250, 204, 21, 0.22);
}

body.dark .chip.active {
  background: #d9f4ec;
  border-color: #d9f4ec;
  color: #10211c;
}

body.dark .station-tab.active {
  background: #d9f4ec;
  border-color: #d9f4ec;
  color: #10211c;
}

body.dark .bottom-tabs button.active {
  background: #d9f4ec;
  color: #10211c;
}

body.dark .bottom-ops-item em {
  color: #d9f4ec;
}

body.dark .bottom-show-more {
  border-color: rgba(238, 247, 243, 0.2);
  background: rgba(45, 45, 43, 0.78);
  color: var(--ink);
}

body.dark .bottom-group-heading {
  border-color: rgba(238, 247, 243, 0.16);
  background: #263332;
  color: var(--ink);
}

body.dark .leaflet-tile {
  filter: brightness(0.78) saturate(0.85) contrast(1.08);
}

body.dark .leaflet-control-zoom a,
body.dark .leaflet-popup-content-wrapper,
body.dark .leaflet-popup-tip {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

body.dark .leaflet-control-attribution {
  background: rgba(23, 35, 31, 0.82);
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 300px 1fr;
  }

  .app-shell.risk-collapsed {
    grid-template-columns: 300px 1fr;
  }

  .sidebar,
  .risk-sidebar {
    padding: 12px;
  }

  .risk-sidebar {
    grid-column: 1 / -1;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .risk-sidebar.collapsed {
    padding: 12px;
  }

  .risk-sidebar.collapsed .affected-panel {
    padding: 16px;
    background: var(--panel);
    border-color: var(--line);
    box-shadow: 0 10px 24px rgba(20, 34, 31, 0.06);
  }

  .risk-sidebar.collapsed .affected-list {
    display: none;
  }

  .risk-sidebar.collapsed .risk-sidebar-toggle {
    min-height: 36px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: none;
    place-items: initial;
    align-content: initial;
    text-align: left;
  }

  .risk-sidebar.collapsed .risk-sidebar-toggle h2,
  .risk-sidebar.collapsed .risk-sidebar-toggle span:not(.risk-sidebar-chevron) {
    width: min(260px, calc(100% - 16px));
    height: auto;
    overflow: visible;
    opacity: 1;
    font-size: 0.72rem;
  }

  .risk-sidebar.collapsed .risk-sidebar-toggle h2 {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    transform: none;
    white-space: normal;
  }

  .risk-sidebar.collapsed .risk-sidebar-toggle span:not(.risk-sidebar-chevron) {
    display: none;
  }

  .risk-sidebar.collapsed .risk-sidebar-chevron {
    transform: rotate(180deg);
  }

  .affected-panel {
    max-height: 280px;
  }

  .map-area {
    padding: 8px;
    gap: 8px;
  }

  .command-header {
    grid-template-columns: 1fr;
  }

  .command-action-row {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .command-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bottom-station-list {
    grid-auto-columns: minmax(230px, 42%);
  }

  .toolbar {
    left: 8px;
    right: 104px;
    top: 190px;
    min-height: 0;
  }

  .map-area.panel-open .toolbar {
    right: 104px;
  }

  .map-area.panel-open .map-frame {
    width: auto;
    margin-right: 0;
    grid-row: auto;
  }

  .map-panel {
    position: absolute;
    top: 84px;
    left: auto;
    right: 8px;
    width: min(260px, calc(100% - 16px));
    max-height: calc(100% - 96px);
    overflow-y: auto;
  }

  .map-panel-right {
    right: 8px;
    transform: none;
  }

  .map-panel-right.collapsed {
    display: none;
  }

  .panel-toggle {
    top: 48px;
    right: 8px;
  }

  .map-fullscreen-toggle {
    top: 12px;
    right: 8px;
  }

  .panel-toggle.open {
    right: 8px;
  }

  .map-area.panel-open {
    grid-template-rows: auto clamp(420px, 52vh, 560px) minmax(520px, 1fr);
  }
}

@media (max-width: 720px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
    width: 100%;
    overflow-x: hidden;
  }

  .sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .risk-sidebar {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .quick-action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-action-row button {
    font-size: 0.58rem;
    padding: 0 3px;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    right: 104px;
  }

  .map-area.panel-open .toolbar {
    right: 104px;
  }

  .map-area.panel-open .map-frame {
    width: auto;
    margin-right: 0;
  }

  .map-panel {
    position: absolute;
    top: 84px;
    left: auto;
    right: 8px;
    width: min(260px, calc(100% - 16px));
    max-height: calc(100% - 96px);
    margin: 0;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  }

  .map-panel-right {
    right: 8px;
    transform: none;
  }

  .map-panel-right.collapsed {
    display: none;
  }

  .panel-toggle,
  .panel-toggle.open {
    position: absolute;
    top: 48px;
    right: 8px;
  }

  .map-fullscreen-toggle {
    position: absolute;
    top: 12px;
    right: 8px;
  }

  .map-area {
    display: grid;
    width: 100%;
    max-width: 100vw;
    min-height: 68vh;
    overflow-x: hidden;
    grid-template-rows: auto clamp(390px, 56vh, 560px) minmax(220px, auto);
  }

  .map-area.panel-open {
    grid-template-rows: auto clamp(390px, 56vh, 560px) minmax(220px, auto);
  }

  .command-header,
  .bottom-panel,
  .map-frame {
    width: 100%;
    max-width: calc(100vw - 16px);
  }

  .assessment-disclaimer {
    font-size: 0.58rem;
  }

  .bottom-assessment-note {
    white-space: normal;
  }

  .map-area.panel-open .map-frame {
    grid-row: auto;
  }

  .bottom-panel-head {
    display: grid;
    align-items: start;
  }

  .bottom-panel-controls {
    justify-content: flex-start;
  }

  .bottom-ops-list {
    grid-template-columns: 1fr;
    max-height: 260px;
  }

  .command-header {
    grid-template-columns: 1fr;
  }

  .command-action-row {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .command-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .visitor-counter {
    left: 10px;
    bottom: 10px;
    padding: 5px 8px;
    font-size: 0.66rem;
  }

  .bottom-station-list {
    grid-auto-columns: minmax(228px, 82%);
  }

  .system-footer {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 10px 14px;
  }

  .system-footer-logo img {
    width: 42px;
    height: 48px;
  }

  .system-footer-copy {
    justify-items: start;
    text-align: left;
  }

  .system-footer-copy strong {
    white-space: normal;
    font-size: 0.84rem;
  }

  .system-footer-copy span {
    font-size: 0.7rem;
  }

  .system-footer-partners {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding: 8px 0 0;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }

  .system-footer-partners img {
    width: min(280px, 76vw);
    max-height: 42px;
  }

  #map {
    height: 100%;
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .map-area {
    padding: 6px;
    grid-template-rows: auto clamp(360px, 54vh, 500px) minmax(220px, auto);
  }

  .map-area.panel-open {
    grid-template-rows: auto clamp(360px, 54vh, 500px) minmax(220px, auto);
  }

  .command-header,
  .bottom-panel,
  .map-frame {
    max-width: calc(100vw - 12px);
  }

  .map-panel {
    width: calc(100vw - 12px);
    right: 6px;
  }
}

.map-area:fullscreen,
.map-area.fullscreen-fallback {
  grid-template-rows: minmax(0, 1fr) !important;
}

.map-area:fullscreen .map-frame,
.map-area.fullscreen-fallback .map-frame,
.map-area:fullscreen #map,
.map-area.fullscreen-fallback #map {
  height: 100%;
}

.map-area:fullscreen .map-frame,
.map-area.fullscreen-fallback .map-frame {
  grid-row: 1 !important;
  width: auto !important;
  margin-right: 0 !important;
}
