:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #64748b;
  --line: #dce4ee;
  --panel: rgba(255, 255, 255, 0.98);
  --navy: #172033;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --green: #16a86b;
  --green-soft: #e9f9f1;
  --yellow: #e7a61a;
  --yellow-soft: #fff8df;
  --red: #df3f52;
  --red-soft: #fff0f2;
  --unknown: #7b8798;
  --unknown-soft: #eef2f6;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

html {
  min-width: 320px;
  background: #e9eef6;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(124, 58, 237, 0.13), transparent 28rem),
    linear-gradient(135deg, #edf2f9 0%, #f8fafc 48%, #e8edf5 100%);
  font-family: Tahoma, "Noto Sans Thai", "Leelawadee UI", sans-serif;
  font-size: 16px;
}

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

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.65rem;
  color: #fff;
  background: var(--navy);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.public-dashboard {
  width: min(100%, 1920px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(8px, 1vw, 16px);
  border: clamp(4px, 0.45vw, 8px) solid var(--purple);
  background: rgba(238, 242, 248, 0.78);
}

.dashboard-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem clamp(1rem, 2vw, 2rem);
  border-radius: 0.8rem;
  color: #fff;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.04), transparent 38%),
    var(--navy);
  box-shadow: var(--shadow);
}

.dashboard-title-wrap {
  min-width: 0;
}

.dashboard-title-wrap h1,
.dashboard-title-wrap p {
  margin: 0;
}

.dashboard-title-wrap h1 {
  overflow: hidden;
  font-size: clamp(1.35rem, 2.15vw, 2.45rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-title-wrap > p:last-child {
  margin-top: 0.22rem;
  color: #cbd5e1;
  font-size: clamp(0.76rem, 0.9vw, 0.96rem);
  letter-spacing: 0.05em;
}

.dashboard-title-wrap .dashboard-eyebrow {
  margin-bottom: 0.24rem;
  color: #c4b5fd;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.header-status {
  min-width: min(27rem, 34vw);
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 0.78rem;
  background: rgba(255, 255, 255, 0.08);
}

.header-status .status-dot {
  width: 0.75rem;
  height: 0.75rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--unknown);
  box-shadow: 0 0 0 5px rgba(123, 135, 152, 0.2);
}

.header-status span:last-child {
  min-width: 0;
  display: grid;
  gap: 0.18rem;
}

.header-status strong,
.header-status small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status strong {
  font-size: 0.9rem;
}

.header-status small {
  color: #cbd5e1;
  font-size: 0.7rem;
}

.header-status[data-status="green"] .status-dot {
  background: #2ddd91;
  box-shadow: 0 0 0 5px rgba(45, 221, 145, 0.18);
}

.header-status[data-status="yellow"] .status-dot {
  background: #ffc84a;
  box-shadow: 0 0 0 5px rgba(255, 200, 74, 0.18);
}

.header-status[data-status="red"] .status-dot {
  background: #ff6b7d;
  box-shadow: 0 0 0 5px rgba(255, 107, 125, 0.18);
}

.dashboard-grid {
  height: calc(100dvh - 152px);
  min-height: 700px;
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(24rem, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(11rem, 0.46fr);
  grid-template-areas:
    "map canal"
    "map cctv";
  gap: clamp(8px, 0.75vw, 14px);
  margin-top: clamp(8px, 0.75vw, 14px);
}

.dashboard-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 0.95rem;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.map-panel {
  grid-area: map;
}

.cctv-panel {
  grid-area: cctv;
}

.canal-panel {
  grid-area: canal;
}

.panel-heading {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem clamp(0.85rem, 1.35vw, 1.3rem) 0.48rem;
  border-bottom: 1px solid #eef2f6;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-size: clamp(1rem, 1.3vw, 1.35rem);
  line-height: 1.2;
}

.section-kicker {
  margin-bottom: 0.18rem !important;
  color: var(--purple);
  font-size: clamp(0.58rem, 0.72vw, 0.7rem);
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.live-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.42rem 0.62rem;
  border: 1px solid #bee9d3;
  border-radius: 999px;
  color: #087443;
  background: var(--green-soft);
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
}

.live-source-badge span {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 168, 107, 0.14);
}

.panel-update {
  max-width: 40%;
  color: var(--muted);
  font-size: 0.66rem;
  text-align: right;
}

.map-stage {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  background: #d7e2e8;
}

.real-map {
  position: absolute;
  inset: 0;
}

.map-message {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 2rem;
  color: #334155;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(226, 232, 240, 0.92)),
    #eef2f6;
  text-align: center;
}

.map-message[hidden] {
  display: none;
}

.map-message.is-error {
  color: #991b1b;
  background: var(--red-soft);
}

.map-message small {
  color: currentColor;
  opacity: 0.75;
}

.map-loader,
.empty-pulse {
  width: 1.1rem;
  height: 1.1rem;
  border: 3px solid #ddd6fe;
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.map-legend {
  position: absolute;
  z-index: 3;
  right: 0.7rem;
  bottom: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.8rem;
  padding: 0.48rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(9px);
  font-size: 0.6rem;
  font-weight: 800;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-dot {
  width: 0.58rem;
  height: 0.58rem;
  display: inline-block;
  border-radius: 50%;
}

.legend-dot.green {
  background: var(--green);
}

.legend-dot.yellow {
  background: var(--yellow);
}

.legend-dot.red {
  background: var(--red);
}

.legend-dot.unknown {
  background: var(--unknown);
}

.public-map-overlay {
  position: absolute;
  z-index: 6;
  width: 0;
  height: 0;
  pointer-events: none;
}

.public-map-label {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: 330px;
  display: grid;
  gap: 0.76rem;
  padding: 0.8rem 1.04rem;
  border: 2px solid rgba(148, 163, 184, 0.44);
  border-radius: 1.04rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.23);
  transform: none;
  pointer-events: none;
}

.public-map-label::after {
  display: none;
}

.public-map-connector {
  position: absolute;
  z-index: 1;
  height: 2px;
  border-radius: 999px;
  background: rgba(236, 255, 251, 0.98);
  box-shadow:
    0 0 0 1px rgba(15, 77, 72, 0.5),
    0 0 14px rgba(95, 243, 221, 0.42);
  opacity: 0.94;
  transform-origin: left center;
  pointer-events: none;
}

.public-map-connector[hidden] {
  display: none;
}

.map-label-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.84rem;
}

.map-label-heading strong {
  min-width: 0;
  overflow: hidden;
  font-size: 1.32rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-map-label.has-flow-bars {
  width: 368px;
  max-width: 368px;
  padding: 1.04rem 1.16rem 1.12rem;
}

.map-label-flows {
  display: grid;
  gap: 0.6rem;
  padding-top: 0.68rem;
  border-top: 2px solid #e2e8f0;
}

.map-label-flow {
  display: grid;
  gap: 0.32rem;
}

.map-label-flow-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  color: #475569;
  font-size: 1.02rem;
  line-height: 1;
}

.map-label-flow-copy b {
  color: var(--purple);
  font-size: 1.16rem;
}

.map-label-progress {
  height: 0.56rem;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.map-label-progress-value {
  width: calc(var(--flow) * 1%);
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #16a86b);
}

.map-label-dot {
  width: 1.28rem;
  height: 1.28rem;
  flex: 0 0 auto;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 2px rgba(223, 63, 82, 0.17);
}

.public-map-label[data-status="green"] .map-label-dot {
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(22, 168, 107, 0.17);
}

.public-map-label[data-status="yellow"] .map-label-dot {
  background: var(--yellow);
  box-shadow: 0 0 0 2px rgba(231, 166, 26, 0.2);
}

.public-map-label[data-status="unknown"] .map-label-dot {
  background: var(--unknown);
  box-shadow: 0 0 0 2px rgba(123, 135, 152, 0.2);
}

.capacity-strip {
  --capacity-color: var(--unknown);
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.78rem;
  padding: 0.55rem clamp(0.75rem, 1.15vw, 1.15rem);
  border-top: 1px solid var(--line);
  background: linear-gradient(100deg, #fff, #f8fafc);
}

.capacity-strip[data-status="green"] {
  --capacity-color: var(--green);
}

.capacity-strip[data-status="yellow"] {
  --capacity-color: var(--yellow);
}

.capacity-gauge {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--capacity-color) calc(var(--capacity) * 1%), #e7edf3 0);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--capacity-color) 20%, transparent);
}

.capacity-gauge::before {
  width: 2.62rem;
  height: 2.62rem;
  grid-area: 1 / 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e8edf2;
  content: "";
}

.capacity-gauge > span {
  z-index: 1;
  grid-area: 1 / 1;
  text-align: center;
}

.capacity-gauge b,
.capacity-gauge small {
  display: block;
}

.capacity-gauge b {
  color: var(--capacity-color);
  font-size: 0.82rem;
  line-height: 1;
}

.capacity-gauge small {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.37rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.capacity-copy {
  min-width: 0;
}

.capacity-copy strong,
.capacity-copy p,
.capacity-copy small {
  display: block;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capacity-copy strong {
  font-size: clamp(0.72rem, 0.82vw, 0.88rem);
}

.capacity-copy p {
  margin-top: 0.12rem;
  color: #42526a;
  font-size: clamp(0.53rem, 0.62vw, 0.65rem);
}

.capacity-copy small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: clamp(0.48rem, 0.56vw, 0.59rem);
}

.panel-footer {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.55rem clamp(0.8rem, 1.2vw, 1.15rem);
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.panel-footer > div:last-child {
  min-width: 0;
}

.panel-footer strong,
.panel-footer p {
  margin: 0;
}

.panel-footer strong {
  display: block;
  font-size: clamp(0.72rem, 0.82vw, 0.86rem);
}

.panel-footer p {
  margin-top: 0.12rem;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.56rem, 0.66vw, 0.69rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-icon {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  color: #5b21b6;
  background: var(--purple-soft);
  font-size: 1rem;
  font-weight: 900;
}

.station-status-banner {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 0.72rem;
  margin: 0.72rem clamp(0.8rem, 1.2vw, 1.15rem) 0;
  padding: 0.62rem 0.8rem;
  border: 1px solid #d7dee8;
  border-radius: 0.68rem;
  color: #475569;
  background: var(--unknown-soft);
}

.station-status-banner .status-check {
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-weight: 900;
}

.station-status-banner span:last-child {
  display: grid;
  gap: 0.08rem;
}

.station-status-banner strong {
  font-size: clamp(0.75rem, 0.9vw, 0.92rem);
}

.station-status-banner small {
  font-size: 0.6rem;
  opacity: 0.78;
}

.station-status-banner[data-status="green"] {
  border-color: #98dfba;
  color: #fff;
  background: linear-gradient(100deg, #0f9f61, #1cba78);
}

.station-status-banner[data-status="yellow"] {
  border-color: #f1ce70;
  color: #704700;
  background: linear-gradient(100deg, #ffe293, #ffd05c);
}

.station-status-banner[data-status="red"] {
  border-color: #f293a0;
  color: #fff;
  background: linear-gradient(100deg, #cf3146, #ed5669);
}

.station-status-banner[data-status="data"] {
  border-color: #8fc8f6;
  color: #fff;
  background: linear-gradient(100deg, #156fb5, #2c91d4);
}

.station-status-banner.compact {
  min-width: min(16rem, 52%);
  min-height: 40px;
  margin: 0;
  padding: 0.42rem 0.58rem;
}

.station-status-banner.compact .status-check {
  width: 1.55rem;
  height: 1.55rem;
  font-size: 0.72rem;
}

.station-status-banner.compact strong {
  max-width: 12rem;
  overflow: hidden;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-status-banner.compact small {
  max-width: 12rem;
  overflow: hidden;
  font-size: 0.48rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subsection-title {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin: 0.72rem clamp(0.8rem, 1.2vw, 1.15rem) 0.48rem;
}

.subsection-title h3,
.subsection-title span {
  margin: 0;
}

.subsection-title h3 {
  font-size: 0.83rem;
}

.subsection-title span {
  color: var(--muted);
  font-size: 0.6rem;
}

.process-flow {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0.8rem 0.72rem;
  flex: 1 1 auto;
}

.process-stage {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #cfe1f2;
  border-radius: 0.78rem;
  background: linear-gradient(135deg, #f6fbff, #edf7ff);
  box-shadow: 0 5px 14px rgba(15, 65, 110, 0.08);
}

.process-stage.outlet {
  border-color: #bfe8d2;
  background: linear-gradient(135deg, #f4fff9, #eafbf2);
}

.process-stage-header {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.48rem 0.65rem;
  color: #0e5386;
  background: rgba(214, 237, 255, 0.68);
}

.process-stage.outlet .process-stage-header {
  color: #087443;
  background: rgba(206, 245, 225, 0.72);
}

.process-stage-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.process-stage-icon {
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #2788c9;
  font-size: 1rem;
  font-weight: 900;
}

.process-stage.outlet .process-stage-icon {
  background: var(--green);
}

.process-stage-heading strong,
.process-stage-heading small {
  display: block;
}

.process-stage-heading strong {
  font-size: 0.76rem;
}

.process-stage-heading small {
  margin-top: 0.04rem;
  font-size: 0.49rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.process-reading-count {
  flex: 0 0 auto;
  padding: 0.22rem 0.42rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.52rem;
  font-weight: 800;
}

.process-stage-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.48rem;
}

.process-metric {
  min-width: 0;
  padding: 0.42rem 0.46rem;
  border: 1px solid rgba(147, 197, 235, 0.52);
  border-radius: 0.58rem;
  background: rgba(255, 255, 255, 0.9);
}

.process-stage.outlet .process-metric {
  border-color: rgba(109, 207, 156, 0.45);
}

.process-metric-name,
.process-metric-value,
.process-metric-source,
.process-metric-time {
  display: block;
  min-width: 0;
}

.process-metric-name {
  color: #25699e;
  font-size: 0.58rem;
}

.process-stage.outlet .process-metric-name {
  color: #087443;
}

.process-metric-value {
  margin-top: 0.16rem;
  overflow: hidden;
  font-size: clamp(0.78rem, 1vw, 1rem);
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-metric-source {
  margin-top: 0.13rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.43rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-metric-time {
  margin-top: 0.1rem;
  color: #8290a3;
  font-size: 0.42rem;
}

.process-connector {
  position: relative;
  z-index: 2;
  width: 1.5rem;
  height: 1.1rem;
  display: grid;
  place-items: center;
  margin: -0.06rem auto;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#2788c9, var(--green));
  box-shadow: 0 3px 8px rgba(21, 111, 181, 0.2);
  font-size: 0.72rem;
  font-weight: 900;
}

.process-stage-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.55rem;
  color: var(--muted);
  font-size: 0.6rem;
  text-align: center;
}

.data-empty {
  min-height: 110px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.72rem;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.data-empty.compact {
  grid-column: 1 / -1;
  min-height: 70px;
}

.data-empty strong {
  font-size: 0.72rem;
}

.data-empty small {
  max-width: 30rem;
  font-size: 0.6rem;
  line-height: 1.5;
}

.status-note {
  background: #f8fafc;
}

.drainage-result-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.52rem;
  padding: 0.52rem;
  flex: 1 1 auto;
  background: linear-gradient(135deg, #f8fafc, #eef3f8);
}

.drainage-result-summary {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.72rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid #dce4ee;
  border-radius: 0.65rem;
  color: #475569;
  background: var(--unknown-soft);
}

.drainage-result-summary[data-status="green"] {
  border-color: #9edfc1;
  color: #08663d;
  background: linear-gradient(145deg, #effcf5, #dff7eb);
}

.drainage-result-summary[data-status="yellow"] {
  border-color: #efd486;
  color: #725000;
  background: linear-gradient(145deg, #fffbed, #fff1bd);
}

.drainage-result-summary[data-status="red"] {
  border-color: #f0a6b0;
  color: #991b32;
  background: linear-gradient(145deg, #fff5f6, #ffe1e6);
}

.drainage-result-dot {
  width: 0.78rem;
  height: 0.78rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--unknown);
  box-shadow: 0 0 0 4px rgba(123, 135, 152, 0.14);
}

.drainage-result-summary[data-status="green"] .drainage-result-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 168, 107, 0.14);
}

.drainage-result-summary[data-status="yellow"] .drainage-result-dot {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(231, 166, 26, 0.16);
}

.drainage-result-summary[data-status="red"] .drainage-result-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(223, 63, 82, 0.14);
}

.drainage-result-copy {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.drainage-result-copy small,
.drainage-result-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drainage-result-copy strong {
  font-size: clamp(0.7rem, 0.85vw, 0.9rem);
}

.drainage-result-copy small {
  color: currentColor;
  opacity: 0.72;
  font-size: 0.54rem;
}

.condition-pill {
  min-width: 4.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.34rem 0.58rem;
  border-radius: 999px;
  color: #475569;
  background: var(--unknown-soft);
  font-size: 0.62rem;
  font-weight: 900;
}

.condition-pill.green {
  color: #08663d;
  background: var(--green-soft);
}

.condition-pill.yellow {
  color: #725000;
  background: var(--yellow-soft);
}

.condition-pill.red {
  color: #991b32;
  background: var(--red-soft);
}

.cctv-result-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
}

.cctv-result-card {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.48rem 0.55rem;
  border: 1px solid #dce4ee;
  border-radius: 0.58rem;
  color: #475569;
  background: #fff;
}

.cctv-result-dot {
  width: 0.58rem;
  height: 0.58rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--unknown);
}

.cctv-result-card[data-status="green"] .cctv-result-dot { background: var(--green); }
.cctv-result-card[data-status="yellow"] .cctv-result-dot { background: var(--yellow); }
.cctv-result-card[data-status="red"] .cctv-result-dot { background: var(--red); }

.cctv-result-copy {
  min-width: 0;
  display: grid;
  gap: 0.08rem;
}

.cctv-result-copy small,
.cctv-result-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cctv-result-copy small {
  color: var(--muted);
  font-size: 0.5rem;
}

.cctv-result-copy strong {
  font-size: 0.66rem;
}

.station-count {
  min-width: 2.55rem;
  height: 2.15rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 0.42rem;
  border-radius: 0.5rem;
  color: #fff;
  background: var(--navy);
  font-size: 0.78rem;
  font-weight: 900;
}

.canal-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.58rem;
  padding: 0.62rem;
  flex: 1 1 auto;
}

.canal-card {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #dbe3ed;
  border-radius: 0.75rem;
  background: #fff;
}

.canal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.68rem 0.72rem 0.55rem;
  border-bottom: 1px solid #edf1f5;
}

.canal-card-header strong,
.canal-card-header small {
  display: block;
}

.canal-card-header strong {
  overflow: hidden;
  font-size: clamp(0.68rem, 0.8vw, 0.8rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canal-card-header small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.54rem;
}

.canal-status {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--unknown);
  font-size: 0.65rem;
  font-weight: 900;
}

.canal-status.green {
  background: var(--green);
}

.canal-status.yellow {
  color: #6b4500;
  background: #f6c84f;
}

.canal-status.red {
  background: var(--red);
}

.canal-readings {
  min-height: 0;
  display: grid;
  align-content: stretch;
  gap: 0.38rem;
  padding: 0.52rem;
  flex: 1 1 auto;
}

.canal-gauges {
  min-height: 0;
  display: grid;
  align-content: center;
  gap: 0.62rem;
  padding: 0.62rem;
  flex: 1 1 auto;
  background: linear-gradient(155deg, #fff, #f7fafc);
}

.canal-gauge {
  min-width: 0;
  padding: 0.5rem 0.58rem;
  border: 1px solid #e1e7ee;
  border-radius: 0.62rem;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.canal-gauge-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
}

.canal-gauge-header strong,
.canal-gauge-header small,
.canal-gauge-header b {
  display: block;
}

.canal-gauge-header strong {
  font-size: 0.65rem;
}

.canal-gauge-header small {
  margin-top: 0.04rem;
  color: var(--muted);
  font-size: 0.47rem;
}

.canal-gauge-header b {
  font-size: clamp(0.75rem, 0.9vw, 0.94rem);
  white-space: nowrap;
}

.gauge-track {
  position: relative;
  height: 0.52rem;
  display: flex;
  overflow: visible;
  margin-top: 0.52rem;
  border: 2px solid #fff;
  border-radius: 999px;
  outline: 1px solid #dce4ea;
  background: #edf1f5;
}

.gauge-band {
  min-width: 0;
  height: 100%;
}

.gauge-band:first-child { border-radius: 999px 0 0 999px; }
.gauge-band:last-of-type { border-radius: 0 999px 999px 0; }
.gauge-band.green { background: var(--green); }
.gauge-band.yellow { background: #f3bd32; }
.gauge-band.red { background: var(--red); }
.gauge-band.unknown { background: var(--unknown); }

.gauge-marker {
  position: absolute;
  top: 50%;
  left: calc(var(--marker) * 1%);
  width: 0;
  height: 0;
  border-right: 0.28rem solid transparent;
  border-bottom: 0.48rem solid #172033;
  border-left: 0.28rem solid transparent;
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.28));
  transform: translate(-50%, -135%) rotate(180deg);
}

.gauge-scale {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.43rem;
}

.gauge-scale small {
  overflow: hidden;
  color: #475569;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canal-reading {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.52rem;
  border-radius: 0.52rem;
  background: #eef4fb;
}

.canal-reading:nth-child(even) {
  background: #f7f9fc;
}

.canal-reading strong,
.canal-reading small,
.canal-reading b {
  display: block;
}

.canal-reading strong {
  overflow: hidden;
  font-size: 0.61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canal-reading small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.49rem;
}

.canal-reading b {
  font-size: clamp(0.72rem, 0.86vw, 0.9rem);
  white-space: nowrap;
}

.canal-no-readings {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.62rem;
  line-height: 1.5;
  text-align: center;
}

.dashboard-error {
  position: fixed;
  z-index: 1000;
  right: 1rem;
  bottom: 1rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.78rem 1rem;
  border: 1px solid #fecdd3;
  border-radius: 0.75rem;
  color: #9f1239;
  background: rgba(255, 241, 242, 0.97);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
}

noscript {
  position: fixed;
  z-index: 1100;
  inset: auto 1rem 1rem;
  padding: 1rem;
  border-radius: 0.7rem;
  color: #fff;
  background: #991b1b;
  text-align: center;
}

@media (max-width: 1180px) {
  .public-dashboard {
    min-height: 100dvh;
  }

  .dashboard-grid {
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas:
      "map"
      "canal"
      "cctv";
  }

  .map-panel {
    min-height: 700px;
  }

  .canal-panel {
    min-height: 480px;
  }

  .cctv-panel {
    min-height: 210px;
  }

  .dashboard-title-wrap h1 {
    white-space: normal;
  }
}

@media (max-width: 720px) {
  .public-dashboard {
    padding: 6px;
    border-width: 4px;
  }

  .dashboard-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  .dashboard-title-wrap h1 {
    font-size: 1.55rem;
    line-height: 1.14;
  }

  .header-status {
    width: 100%;
    min-width: 0;
  }

  .header-status strong,
  .header-status small {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .panel-heading {
    min-height: 58px;
  }

  .live-source-badge,
  .panel-update {
    display: none;
  }

  .map-panel {
    min-height: 640px;
  }

  .capacity-strip {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .capacity-copy small {
    display: none;
  }

  .dashboard-grid {
    grid-template-areas:
      "map"
      "canal"
      "cctv";
  }

  .canal-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .canal-panel {
    min-height: 620px;
  }

  .cctv-panel {
    min-height: 260px;
  }

  .drainage-result-copy small,
  .drainage-result-copy strong {
    white-space: normal;
  }

  .public-map-label {
    max-width: 248px;
    padding: 0.68rem 0.84rem;
  }

  .public-map-label.has-flow-bars {
    width: 308px;
    max-width: 308px;
  }

  .map-label-heading strong {
    font-size: 1.16rem;
  }

  .drainage-result-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .map-label-dot {
    width: 1.12rem;
    height: 1.12rem;
  }

  .map-legend {
    left: 0.55rem;
    right: 0.55rem;
    justify-content: center;
  }

  .panel-footer p {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
