:root {
  --ink: #eef6ff;
  --muted: #8295ae;
  --panel: #0b1728;
  --panel-soft: #101f33;
  --line: #21344d;
  --cyan: #1fd0e4;
  --cyan-soft: #102f43;
  --green: #2dd38b;
  --amber: #ffb92e;
  --red: #ff5665;
  --header-height: 58px;
  --primary-width: 310px;
  --detail-width: 390px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #07111f; color: var(--ink); font-family: "DM Sans", sans-serif; }
.crud-document { min-height: 100%; height: auto; overflow-x: clip; overflow-y: auto; }
.crud-body { min-height: 100%; height: auto; overflow-x: hidden; overflow-y: auto; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.dashboard-shell { min-height: 100dvh; }
.topbar { height: var(--header-height); position: relative; z-index: 1100; display: flex; align-items: center; justify-content: space-between; background: #081427; border-bottom: 1px solid var(--line); box-shadow: 0 5px 22px rgba(0,0,0,.22); }
.brand-block { height: 100%; width: var(--primary-width); padding: 0 18px; display: flex; align-items: center; gap: 11px; border-right: 1px solid var(--line); }
.brand-mark { width: 33px; height: 33px; display: grid; place-items: center; color: #04101c; background: var(--cyan); box-shadow: 0 0 22px rgba(31,208,228,.3); }
.brand-mark svg { width: 20px; }
.brand-name { font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.brand-caption { margin-top: 2px; color: #7188a4; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.dataset-tabs { align-self: stretch; display: flex; align-items: center; gap: 4px; }
.dataset-tab { height: 36px; padding: 0 17px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 600; font-size: 12px; cursor: pointer; }
.dataset-tab.active { color: #06131e; background: var(--cyan); border-color: #43e3f4; box-shadow: 0 0 18px rgba(31,208,228,.2); }
.dataset-tab svg { width: 15px; }
.header-status { height: 100%; padding-right: 14px; display: flex; align-items: center; gap: 13px; }
.live-pill { padding: 4px 8px; border: 1px solid rgba(45,211,139,.32); color: var(--green); font: 600 9px "IBM Plex Mono", monospace; }
.live-pill span, .pulse-dot { width: 6px; height: 6px; display: inline-block; margin-right: 4px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(45,211,139,.12); }
.updated-time { display: grid; gap: 1px; }
.updated-time small { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.updated-time strong { font: 500 10px "IBM Plex Mono", monospace; }
.icon-button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel-soft); cursor: pointer; }
.icon-button:hover { color: var(--cyan); border-color: #315473; }
.icon-button svg { width: 16px; }
.mobile-menu, .close-mobile { display: none; }

.workspace { position: relative; height: calc(100dvh - var(--header-height)); display: grid; grid-template-columns: var(--primary-width) minmax(0, 1fr); overflow: hidden; }
.primary-sidebar { position: relative; z-index: 800; min-width: 0; padding: 20px 17px 15px; display: flex; flex-direction: column; gap: 16px; overflow: hidden; background: var(--panel); border-right: 1px solid var(--line); box-shadow: 8px 0 28px rgba(0,0,0,.18); }
.sidebar-heading { display: flex; justify-content: space-between; }
.eyebrow { color: #7085a1; font: 600 8px "IBM Plex Mono", monospace; letter-spacing: .12em; }
.sidebar-heading h1 { margin: 5px 0 0; font-size: 19px; letter-spacing: 0; }
.sidebar-tabs { min-height: 35px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.sidebar-tabs button { min-width: 0; padding: 0 7px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: #0d1a2b; color: #6f849d; font-size: 9px; font-weight: 600; cursor: pointer; }
.sidebar-tabs button + button { border-left: 1px solid var(--line); }
.sidebar-tabs button.active { color: var(--cyan); background: #10283a; box-shadow: inset 0 -2px var(--cyan); }
.sidebar-tabs svg { width: 13px; }
.sidebar-view { min-height: 0; flex: 1; display: none; flex-direction: column; gap: 12px; }
.sidebar-view.active { display: flex; }
.search-box { height: 39px; padding: 0 10px; display: flex; align-items: center; gap: 9px; border: 1px solid #29405b; background: #0e1c2e; }
.search-box:focus-within { border-color: var(--cyan); }
.search-box svg { width: 14px; color: #6d839d; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-box input::placeholder { color: #687b93; }
.search-box kbd { padding: 2px 5px; border: 1px solid #2a3e57; color: #637993; background: #132238; font: 500 8px "IBM Plex Mono", monospace; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: #0d1a2b; }
.summary-grid div { min-width: 0; padding: 10px 8px; border-right: 1px solid var(--line); }
.summary-grid div:last-child { border: 0; }
.summary-grid span { display: block; font: 600 17px "IBM Plex Mono", monospace; }
.summary-grid small { margin-top: 3px; display: block; color: #6f849e; font-size: 8px; line-height: 1.2; }
.cyan { color: var(--cyan) !important; }
.amber { color: var(--amber) !important; }
.section-title { min-height: 19px; display: flex; align-items: center; justify-content: space-between; color: #8093ad; font: 600 9px "IBM Plex Mono", monospace; letter-spacing: .06em; }
.section-title button { padding: 0; border: 0; background: transparent; color: #71849c; cursor: pointer; }
.section-title svg { width: 13px; }
.layer-list { display: grid; gap: 5px; }
.layer-row { min-height: 48px; padding: 7px 9px; display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 9px; border: 1px solid transparent; cursor: pointer; }
.layer-row:hover { border-color: var(--line); background: #0f1d2f; }
.layer-symbol { width: 29px; height: 29px; display: grid; place-items: center; }
.layer-symbol svg { width: 15px; }
.gauge-symbol { color: var(--cyan); background: rgba(31,208,228,.12); }
.rain-symbol { color: #71a7ff; background: rgba(113,167,255,.12); }
.river-symbol { color: #2fb4e7; background: rgba(47,180,231,.12); }
.boundary-symbol { color: #d2a863; background: rgba(210,168,99,.12); }
.layer-row strong, .layer-row small { display: block; }
.layer-row strong { font-size: 11px; font-weight: 600; }
.layer-row small { margin-top: 2px; color: #6d829c; font-size: 8px; }
.toggle { width: 28px; height: 15px; position: relative; appearance: none; border: 1px solid #354961; border-radius: 10px; background: #1c2b40; cursor: pointer; transition: .2s; }
.toggle::after { content: ""; width: 9px; height: 9px; position: absolute; top: 2px; left: 3px; border-radius: 50%; background: #7a8ca4; transition: .2s; }
.toggle:checked { border-color: var(--cyan); background: #126070; }
.toggle:checked::after { left: 14px; background: #e8fdff; }
.station-list { min-height: 100px; flex: 1; overflow-y: auto; }
.station-list::-webkit-scrollbar, .detail-sidebar::-webkit-scrollbar { width: 6px; }
.station-list::-webkit-scrollbar-thumb, .detail-sidebar::-webkit-scrollbar-thumb { background: #29415c; }
.station-item { width: 100%; padding: 9px 8px; display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 9px; border: 0; border-bottom: 1px solid rgba(33,52,77,.65); background: transparent; text-align: left; cursor: pointer; }
.station-item:hover { background: #101f32; }
.station-item strong, .station-item small { display: block; }
.station-item strong { font-size: 11px; }
.station-item small { margin-top: 2px; color: #687e99; font-size: 8px; }
.station-value { color: #c8d8eb; font: 500 9px "IBM Plex Mono", monospace; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.status-dot.normal { background: var(--green); box-shadow: 0 0 7px rgba(45,211,139,.5); }
.status-dot.watch { background: var(--amber); }
.status-dot.warning { background: var(--red); }
.legend-block { padding-top: 10px; border-top: 1px solid var(--line); }
.legend-block > strong { display: block; margin-bottom: 6px; color: var(--cyan); font: 600 10px "IBM Plex Mono", monospace; letter-spacing: .08em; }
.legend-block > .eyebrow { display: block; }
.legend-list { margin-top: 7px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; color: #a6b5c7; font-size: 8px; }
.legend-list span { min-width: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-swatch { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; }
.flood-normal { background: #12a629; }.flood-low { background: #0874c8; }.flood-medium { background: #ffbd16; }
.flood-high { background: #ff8124; }.flood-very-high { background: #ff2435; }.flood-exceptional { background: #b9091b; }
.rain-none { background: #9aabba; }.rain-trace { background: #76cfea; }.rain-moderate { background: #397fca; }
.rain-heavy { background: #f08024; }.rain-extreme { background: #c92631; }
.source-list { margin: 8px 0 10px; display: grid; gap: 5px; }
.source-list label { display: grid; grid-template-columns: 14px 12px 1fr auto; align-items: center; gap: 5px; color: #afbed0; font-size: 8px; cursor: pointer; }
.source-list input { width: 11px; height: 11px; margin: 0; accent-color: var(--cyan); }
.source-list b { color: #dce9f5; font: 600 8px "IBM Plex Mono", monospace; }
.source-shape { width: 9px; height: 9px; display: block; background: #81a1bd; }
.source-circle { border-radius: 50%; }.source-diamond { transform: rotate(45deg); }.source-triangle { width: 0; height: 0; background: transparent; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid #81a1bd; }
.rainfall-scale-title { margin-top: 2px; }
.channels-view { overflow: hidden; }
.channel-summary { padding: 9px; display: grid; grid-template-columns: 27px 1fr auto; align-items: center; gap: 7px; border: 1px solid var(--line); background: #0e1c2d; }
.channel-summary > svg { width: 16px; color: var(--cyan); }
.channel-summary strong, .channel-summary small { display: block; }
.channel-summary strong { font-size: 9px; }.channel-summary small { margin-top: 2px; color: #70849e; font-size: 7px; }
.channel-summary b { color: var(--cyan); font: 600 8px "IBM Plex Mono", monospace; }
.channel-tree-state { padding: 17px 8px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #768ba5; font-size: 8px; }
.tree-loader { width: 13px; height: 13px; border: 2px solid #29405a; border-top-color: var(--cyan); border-radius: 50%; animation: tree-spin .7s linear infinite; }
@keyframes tree-spin { to { transform: rotate(360deg); } }
.channel-tree { min-height: 0; flex: 1; overflow: auto; font-size: 9px; }
.channel-tree::-webkit-scrollbar { width: 6px; height: 6px; }.channel-tree::-webkit-scrollbar-thumb { background: #29415c; }
.channel-tree .jstree-default-dark { background: transparent; }
.channel-tree .jstree-anchor { height: 25px; line-height: 25px; color: #aab9cb; font-size: 9px; }
.channel-tree .jstree-wholerow { height: 25px; }
.channel-tree .jstree-wholerow-hovered { background: #12263a; }
.channel-tree .jstree-wholerow-clicked { background: #14384a; box-shadow: inset 2px 0 var(--cyan); }
.channel-tree .jstree-clicked { color: #eafcff; background: transparent; box-shadow: none; }
.channel-tree .jstree-icon { opacity: .82; }
.channel-selection { padding: 10px; display: grid; gap: 4px; border: 1px solid #1b7d91; background: #0d2637; }
.channel-selection strong { color: #dffbff; font-size: 10px; }.channel-selection small { color: #7890a9; font-size: 7px; line-height: 1.4; }

.map-stage { position: relative; min-width: 0; overflow: hidden; background: #0b1622; }
#map { position: absolute; inset: 0; z-index: 0; background: #0b1622; }
.leaflet-tile-pane { filter: saturate(.58) brightness(.63) contrast(1.12) hue-rotate(165deg); }
body.light-map .leaflet-tile-pane { filter: saturate(.8) brightness(.92) contrast(1.03); }
.leaflet-control-zoom { margin: 20px 20px 0 0 !important; border: 1px solid var(--line) !important; }
.leaflet-control-zoom a { width: 31px !important; height: 31px !important; line-height: 30px !important; color: var(--ink) !important; background: #0d1a2b !important; border-color: var(--line) !important; }
.leaflet-control-attribution { display: none; }
.map-toolbar { position: absolute; z-index: 500; top: 18px; left: 18px; padding: 5px; display: flex; gap: 4px; background: rgba(8,20,36,.93); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.map-toolbar > span { width: 1px; margin: 3px; background: var(--line); }
.map-tool { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent; color: #7e91aa; cursor: pointer; }
.map-tool:hover, .map-tool.active { color: #07111f; background: var(--cyan); }
.map-tool svg { width: 15px; }
.map-context { position: absolute; z-index: 500; top: 18px; left: 153px; padding: 8px 12px; display: grid; gap: 2px; background: rgba(8,20,36,.91); border: 1px solid var(--line); }
.map-context strong { font-size: 11px; }
.map-context small { color: #8194ad; font-size: 8px; }
.timeline-card { width: min(620px, calc(100% - 44px)); position: absolute; z-index: 500; bottom: 24px; left: 50%; padding: 12px 15px 9px; transform: translateX(-50%); background: rgba(8,20,36,.96); border: 1px solid #29415c; box-shadow: 0 12px 35px rgba(0,0,0,.32); }
.timeline-top { display: flex; align-items: center; gap: 11px; }
.timeline-top > div:nth-child(2) { display: grid; flex: 1; }
.timeline-top strong { margin-top: 2px; font: 600 10px "IBM Plex Mono", monospace; }
.play-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: var(--cyan); color: #07111f; cursor: pointer; }
.play-button svg { width: 14px; fill: currentColor; }
.time-mode { display: flex; border: 1px solid var(--line); }
.time-mode button { padding: 6px 9px; border: 0; background: transparent; color: #6f849e; font-size: 8px; cursor: pointer; }
.time-mode button.active { background: #182b42; color: var(--ink); }
#timeline { width: 100%; height: 3px; margin: 13px 0 5px; display: block; appearance: none; background: linear-gradient(90deg, var(--cyan) 0 86%, #344860 86%); }
#timeline::-webkit-slider-thumb { width: 13px; height: 13px; appearance: none; border: 3px solid #071522; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); cursor: pointer; }
.timeline-labels { display: flex; justify-content: space-between; color: #5e748e; font: 500 7px "IBM Plex Mono", monospace; }
.map-attribution { position: absolute; z-index: 450; right: 8px; bottom: 4px; color: rgba(194,210,228,.48); font-size: 7px; }
.gauge-marker { width: 28px; height: 28px; display: grid; place-items: center; border: 3px solid #071522; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--green); box-shadow: 0 0 0 2px rgba(45,211,139,.45), 0 4px 13px rgba(0,0,0,.45); }
.gauge-marker::after { content: ""; width: 7px; height: 7px; border: 2px solid #071522; border-radius: 50%; }
.gauge-marker.watch { background: var(--amber); box-shadow: 0 0 0 2px rgba(255,185,46,.4), 0 4px 13px rgba(0,0,0,.45); }
.gauge-marker.warning { background: var(--red); box-shadow: 0 0 0 2px rgba(255,86,101,.4), 0 4px 13px rgba(0,0,0,.45); }
.gauge-marker.rain { background: #71a7ff; box-shadow: 0 0 0 2px rgba(113,167,255,.4), 0 4px 13px rgba(0,0,0,.45); }
.station-tooltip { padding: 6px 8px !important; border: 1px solid #29435f !important; border-radius: 0 !important; background: #0a1829 !important; color: #edf7ff !important; box-shadow: 0 5px 16px rgba(0,0,0,.35) !important; font: 600 9px "DM Sans", sans-serif !important; }
.station-tooltip::before { border-top-color: #29435f !important; }

.detail-sidebar { width: var(--detail-width); position: absolute; z-index: 900; top: 0; right: 0; bottom: 0; overflow-y: auto; background: #091527; border-left: 1px solid #28415d; box-shadow: -16px 0 45px rgba(0,0,0,.34); transform: translateX(105%); transition: transform .28s ease; }
.detail-sidebar.open { transform: translateX(0); }
.detail-hero { min-height: 180px; padding: 18px 19px; position: relative; overflow: hidden; background: #112c3c; border-bottom: 1px solid #1bc6da; }
.detail-hero::after { content: ""; width: 260px; height: 260px; position: absolute; right: -120px; bottom: -170px; border: 45px solid rgba(31,208,228,.07); border-radius: 50%; }
.detail-actions { display: flex; justify-content: space-between; align-items: center; }
.station-code { color: #7f98b2; font: 600 9px "IBM Plex Mono", monospace; }
.detail-hero .icon-button { position: relative; z-index: 2; background: rgba(5,17,29,.3); }
.detail-type { margin-top: 10px; display: flex; align-items: center; gap: 6px; color: var(--cyan); font: 600 8px "IBM Plex Mono", monospace; letter-spacing: .1em; }
.detail-type svg { width: 13px; }
.detail-hero h2 { margin: 9px 0 2px; position: relative; z-index: 1; font-size: 26px; letter-spacing: 0; }
.detail-hero p { margin: 0; color: #9db1c7; font-size: 11px; }
.observation-time { margin-top: 17px; display: flex; align-items: center; gap: 6px; color: #7590a9; font: 500 8px "IBM Plex Mono", monospace; }
.observation-time svg { width: 12px; }
.detail-content { padding: 15px; display: grid; gap: 16px; }
.reading-card { padding: 13px 14px; border: 1px solid #178ca0; background: #0c2335; }
.reading-card > span { color: var(--cyan); font: 600 8px "IBM Plex Mono", monospace; letter-spacing: .06em; }
.reading-card div { margin-top: 5px; display: flex; align-items: baseline; gap: 6px; }
.reading-card strong { font: 600 28px "IBM Plex Mono", monospace; }
.reading-card small { color: #8198b1; font: 500 8px "IBM Plex Mono", monospace; }
.reading-card p { margin: 5px 0 0; display: flex; align-items: center; gap: 5px; color: var(--green); font-size: 8px; }
.reading-card p svg { width: 12px; }
.chart-section { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.trend-up { color: var(--green); }
.sparkline { width: 100%; height: 82px; margin-top: 8px; overflow: visible; }
.chart-grid { fill: none; stroke: #20354d; stroke-width: 1; stroke-dasharray: 2 4; }
.chart-area { fill: url(#areaFill); }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 2.5; }
.sparkline circle { fill: var(--cyan); stroke: #071522; stroke-width: 2; }
.chart-labels, .threshold-labels { display: flex; justify-content: space-between; color: #617690; font: 500 7px "IBM Plex Mono", monospace; }
.status-banner { min-height: 50px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; background: #113124; border-left: 3px solid var(--green); }
.status-banner > span { display: grid; grid-template-columns: 22px 1fr; }
.status-banner svg { grid-row: span 2; align-self: center; width: 16px; color: var(--green); }
.status-banner small { color: #77a28e; font-size: 7px; }
.status-banner strong { font-size: 12px; }
.status-banner b { padding: 4px 7px; color: var(--green); background: rgba(45,211,139,.11); font-size: 8px; }
.threshold-section { display: grid; gap: 9px; }
.threshold-bar { height: 8px; position: relative; border-radius: 5px; background: linear-gradient(90deg, var(--green) 0 45%, var(--amber) 45% 72%, #ff8b34 72% 88%, var(--red) 88%); }
.threshold-bar span { width: 61%; height: 100%; display: block; background: rgba(6,17,31,.38); }
.threshold-bar i { width: 14px; height: 14px; position: absolute; top: -3px; left: 57%; border: 3px solid #091527; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--amber); }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-grid > div { min-width: 0; padding: 12px; background: #0f1d31; border: 1px solid var(--line); }
.metric-grid span { display: block; color: #788da8; font: 600 7px "IBM Plex Mono", monospace; }
.metric-grid strong { margin-top: 7px; display: inline-block; font: 600 16px "IBM Plex Mono", monospace; }
.metric-grid small { margin-left: 3px; color: #6d819a; font: 500 7px "IBM Plex Mono", monospace; }
.report-button { min-height: 39px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid #2b4c68; background: transparent; color: #a7bdd2; font-size: 10px; font-weight: 600; cursor: pointer; }
.report-button:hover { border-color: var(--cyan); color: var(--cyan); }
.report-button svg { width: 14px; }
.report-button svg:last-child { margin-left: auto; }
.sidebar-scrim { display: none; }

@media (max-width: 980px) {
  :root { --primary-width: 285px; }
  .workspace { display: block; }
  .map-stage { width: 100%; height: 100%; }
  .primary-sidebar { width: var(--primary-width); position: absolute; inset: 0 auto 0 0; transform: translateX(-105%); transition: transform .25s ease; }
  .primary-sidebar.open { transform: translateX(0); }
  .mobile-menu, .close-mobile { display: grid; }
  .brand-block { width: auto; border: 0; padding-left: 11px; }
  .brand-mark { display: none; }
  .sidebar-scrim { position: absolute; z-index: 750; inset: 0; background: rgba(2,8,15,.58); }
  .sidebar-scrim.show { display: block; }
}

@media (max-width: 700px) {
  :root { --header-height: 54px; --detail-width: 100%; }
  .brand-caption, .updated-time, .live-pill { display: none; }
  .brand-name { font-size: 11px; }
  .dataset-tab { width: 36px; padding: 0; justify-content: center; }
  .dataset-tab { font-size: 0; }
  .dataset-tab svg { width: 17px; }
  .header-status { padding-right: 8px; }
  .map-context { display: none; }
  .timeline-card { width: calc(100% - 24px); bottom: 17px; }
  .time-mode { display: none; }
  .map-toolbar { top: 11px; left: 11px; }
  .leaflet-control-zoom { margin: 11px 11px 0 0 !important; }
  .detail-sidebar { border-left: 0; }
}