:root {
    --ink: #102b3b;
    --muted: #69808b;
    --teal-950: #083e53;
    --teal-800: #09677a;
    --teal-100: #e5f3f3;
    --paper: #f7f5f0;
    --white: #fffefd;
    --line: #dbe5e4;
    --normal: #2d8c68;
    --attention: #d28a1f;
    --alert: #cc563a;
    --flood: #9b3b4c;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Arial, Helvetica, sans-serif; }
button, select { font: inherit; }
button { cursor: pointer; }

.topbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 5vw; color: white; background: var(--teal-950); }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: white; text-decoration: none; line-height: .9; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid rgba(255,255,255,.48); border-radius: 50%; color: #8bd5d5; font-family: Georgia, serif; font-size: 2rem; transform: rotate(-10deg); }
.brand strong, .brand em { display: inline-block; font-size: 1.15rem; letter-spacing: -.06em; }
.brand em { margin-left: .14rem; color: #8bd5d5; font-family: Georgia, serif; font-weight: 600; }
.brand small { display: block; margin-top: .35rem; color: #c5dde0; font-size: .54rem; letter-spacing: .13em; text-transform: uppercase; }
.topbar-info { display: flex; align-items: center; color: #c5dde0; font-size: .75rem; }
.live-dot { width: 7px; height: 7px; margin-right: .42rem; border-radius: 50%; background: #6fd0aa; box-shadow: 0 0 0 4px rgba(111,208,170,.12); }
.divider { width: 1px; height: 16px; margin: 0 .85rem; background: rgba(255,255,255,.25); }

.dashboard { width: min(1280px, 90vw); margin: 0 auto; padding: 4.3rem 0 3.75rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2.2rem; }
.eyebrow { margin: 0 0 .55rem; color: var(--teal-800); font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 670px; margin-bottom: .72rem; color: var(--teal-950); font-family: Georgia, serif; font-size: clamp(2.35rem, 5vw, 4.15rem); font-weight: 600; letter-spacing: -.045em; line-height: 1.05; }
h2 { margin-bottom: .25rem; color: var(--teal-950); font-family: Georgia, serif; font-size: 1.62rem; letter-spacing: -.035em; }
.hero-copy { max-width: 600px; margin-bottom: 0; color: var(--muted); font-size: .98rem; line-height: 1.65; }
.refresh-button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .5rem; border: 1px solid #b8cecf; border-radius: 2px; padding: .78rem 1rem; color: var(--teal-950); background: transparent; font-size: .78rem; font-weight: 800; transition: .18s ease; }
.refresh-button:hover { border-color: var(--teal-800); color: white; background: var(--teal-800); }
.refresh-button:disabled { opacity: .6; cursor: wait; }
.refresh-button span { font-size: 1.2rem; line-height: .7; }

.notice { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 2.25rem; padding: .85rem 1rem; border-left: 3px solid #d49a32; background: #fff7e7; color: #77591d; font-size: .78rem; line-height: 1.55; }
.notice p { margin: 0; }
.notice-icon { display: grid; flex: 0 0 17px; place-items: center; width: 17px; height: 17px; margin-top: .1rem; border-radius: 50%; color: white; background: #d49a32; font-family: Georgia, serif; font-size: .76rem; font-weight: bold; }
.ad-slot { display: grid; min-height: 90px; place-items: center; margin: 0 0 2.25rem; border: 1px dashed #bed1d0; color: var(--muted); background: rgba(255, 254, 253, .58); text-align: center; }
.ad-slot span { margin-top: .85rem; font-size: .6rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ad-slot p { margin: -.8rem 0 1rem; font-size: .72rem; }

.metrics { display: grid; grid-template-columns: 1.1fr repeat(3, 1fr); gap: 1px; margin-bottom: 2.1rem; border: 1px solid var(--line); background: var(--line); }
.metric-card { min-height: 134px; padding: 1.15rem 1.2rem; background: var(--white); }
.metric-card p { margin-bottom: .45rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
.metric-card strong { display: block; margin-bottom: .3rem; color: var(--teal-950); font-family: Consolas, monospace; font-size: 2rem; font-weight: 500; letter-spacing: -.08em; }
.metric-card span { color: var(--muted); font-size: .67rem; }
.metric-normal strong { color: var(--normal); }
.metric-attention strong { color: var(--attention); }
.metric-alert strong { color: var(--alert); }

.monitoring-panel, .detail-panel { border: 1px solid var(--line); background: var(--white); }
.monitoring-panel { padding: 1.6rem; }
.section-heading, .detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.result-count { padding-top: .25rem; color: var(--muted); font-size: .7rem; white-space: nowrap; }
.filters { display: flex; gap: .85rem; margin: 1.35rem 0 1rem; padding: .9rem; background: #f3f7f6; }
.filters label { flex: 1; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.filters select { display: block; width: 100%; margin-top: .4rem; border: 0; border-bottom: 1px solid #b7c9c9; border-radius: 0; outline: 0; padding: .2rem 1.45rem .35rem 0; color: var(--teal-950); background: transparent; font-size: .84rem; font-weight: 700; }
.filters select:focus { border-color: var(--teal-800); }
.trend { font-size: .68rem !important; font-weight: 800; }
.trend.up { color: var(--alert); }
.trend.down { color: var(--normal); }
.trend.steady { color: var(--muted); }
.status-tag { display: inline-block; width: max-content; border-radius: 99px; padding: .3rem .55rem; font-size: .64rem; font-weight: 800; letter-spacing: .02em; }
.status-tag.normal { color: #176246; background: #e2f2e9; }
.status-tag.attention { color: #945b00; background: #fff0d6; }
.status-tag.alert { color: #9d351e; background: #fde6df; }
.status-tag.flood { color: #76303e; background: #f5dfe5; }
.status-tag.unknown { color: #52646b; background: #e9eeee; }
.detail-panel { margin-top: 1rem; padding: 1.55rem; overflow: hidden; }
.detail-heading p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); font-size: .72rem; }
.level-summary { display: grid; grid-template-columns: minmax(190px, .75fr) minmax(280px, 1.25fr); align-items: end; gap: 2rem; margin: 2rem 0 1.45rem; }
.current-level { margin: 0; }
.current-level > span { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.current-level strong { display: block; color: var(--teal-950); font-family: Consolas, monospace; font-size: 3.2rem; font-weight: 500; letter-spacing: -.12em; line-height: 1; }
.current-level strong small { font-size: 1rem; letter-spacing: 0; }
.current-level p { margin: .65rem 0 0; }
.level-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 0; }
.level-legend div { min-height: 58px; border-left: 2px solid var(--line); padding-left: .65rem; }
.level-legend div.attention { border-color: var(--attention); }
.level-legend div.alert { border-color: var(--alert); }
.level-legend div.flood { border-color: var(--flood); }
.level-legend dt { color: var(--ink); font-size: .66rem; font-weight: 800; line-height: 1.4; }
.level-legend dt span { display: inline-block; width: 17px; margin: 0 .35rem .18rem 0; border-top: 2px dashed currentColor; }
.level-legend .attention dt { color: #945b00; }
.level-legend .alert dt { color: #9d351e; }
.level-legend .flood dt { color: #76303e; }
.level-legend dd { margin: .32rem 0 0; color: var(--muted); font-size: .62rem; line-height: 1.38; }
.history-chart { margin-top: 1.8rem; border-top: 1px solid var(--line); padding-top: 1.35rem; }
.chart-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.chart-heading h3 { margin: 0; color: var(--teal-950); font-family: Georgia, serif; font-size: 1.1rem; }
.period-filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem; }
.period-filters button { border: 1px solid #cfdfde; border-radius: 2px; padding: .36rem .5rem; color: var(--teal-950); background: transparent; font-size: .65rem; font-weight: 800; }
.period-filters button:hover, .period-filters button.active { border-color: var(--teal-800); color: white; background: var(--teal-800); }
.level-chart { display: block; width: 100%; height: auto; margin-top: 1rem; overflow: visible; }
.chart-grid { stroke: #dbe8e7; stroke-width: 1; }
.chart-axis { stroke: #aac4c4; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--teal-800); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-point-hit { fill: #000; stroke: none; cursor: crosshair; pointer-events: all; }
.chart-reading:focus { outline: none; }
.chart-tooltip { opacity: 0; pointer-events: none; transition: opacity .12s ease; }
.chart-tooltip rect { fill: var(--teal-950); stroke: #2b6777; stroke-width: 1; }
.chart-tooltip text { fill: white; font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight: 700; }
.chart-tooltip text + text { fill: #dbe8e7; font-size: 9px; font-weight: 400; }
.chart-reading:hover .chart-tooltip, .chart-reading:focus .chart-tooltip { opacity: 1; }
.chart-current { fill: var(--teal-950); stroke: var(--white); stroke-width: 2; pointer-events: none; }
.chart-reference { stroke-width: 1; stroke-dasharray: 5 5; }
.chart-reference.attention { stroke: var(--attention); }
.chart-reference.alert { stroke: var(--alert); }
.chart-reference.flood { stroke: var(--flood); }
.chart-reference-label, .chart-y-label, .chart-x-label { fill: var(--muted); font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
.chart-reference-label { font-size: 11px; dominant-baseline: middle; }
.chart-y-label { text-anchor: end; }
.chart-x-label.end { text-anchor: end; }
.chart-caption, .chart-message { margin: .25rem 0 0; color: var(--muted); font-size: .68rem; }
.measurement-time { margin: 1.3rem 0 0; color: var(--muted); font-size: .68rem; }
.no-reference { margin: 1.65rem 0 0; border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); font-size: .73rem; line-height: 1.55; }
.no-station { margin: 1rem 0 0; border: 1px dashed #b9cecd; padding: 1.2rem; color: var(--muted); font-size: .8rem; }
.data-error { display: grid; gap: .3rem; margin-bottom: 2.25rem; border-left: 3px solid var(--alert); padding: .9rem 1rem; color: #8a351f; background: #fff0ea; font-size: .8rem; }
.data-error span { color: #9e5a49; }
.loading { color: var(--muted); }
.data-source-note { width: min(90vw, 1180px); margin: 0 auto 2.25rem; border: 1px solid var(--line); border-left: 3px solid var(--teal-700); padding: 1.25rem 1.4rem; background: #f5f9f8; }
.data-source-note h2 { margin: .3rem 0 .65rem; color: var(--teal-950); font-family: Georgia, serif; font-size: 1.05rem; }
.data-source-note p:last-child { max-width: 940px; margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.65; }
footer { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid #cededc; padding: 1.2rem 5vw 1.6rem; color: var(--muted); font-size: .67rem; }
footer span:first-child { color: var(--teal-950); font-weight: 800; }

@media (max-width: 900px) {
    .dashboard { width: min(94vw, 700px); padding-top: 3rem; }
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .hero { align-items: start; flex-direction: column; }
}
@media (max-width: 570px) {
    .topbar { min-height: 64px; padding: 0 4vw; }
    .topbar-info span:not(.live-dot) { display: none; }
    .divider { display: none; }
    .dashboard { padding: 2.4rem 0 2.2rem; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .metric-card { min-height: 112px; padding: .9rem; }
    .metric-card strong { font-size: 1.7rem; }
    .monitoring-panel, .detail-panel { padding: 1.1rem; }
    .filters { flex-direction: column; gap: .8rem; }
    .chart-heading { align-items: start; flex-direction: column; }
    .period-filters { justify-content: flex-start; }
    .chart-reference-label { display: none; }
    .level-summary { grid-template-columns: 1fr; gap: 1.2rem; }
    .level-legend { grid-template-columns: 1fr; gap: .45rem; }
    .level-legend div { min-height: 0; }
    footer { padding: 1.1rem 4vw; flex-direction: column; gap: .35rem; }
}
