:root {
  color-scheme: light;
  --ink: #173332;
  --muted: #70807b;
  --line: #e1e8e3;
  --surface: #ffffff;
  --page: #f5f7f4;
  --forest: #1e594b;
  --teal: #147a75;
  --solimoes: #2b817d;
  --madeira: #d1953d;
  --purus: #7476b8;
  --danger: #a85046;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; }

button, select { font: inherit; }

a { color: var(--forest); }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4.5vw, 72px);
  background: #102a2a;
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid #8ec6a8; border-radius: 12px; color: #a8dfbd;
  font: 800 20px "Segoe UI", sans-serif;
}
.brand strong, .brand small { display: block; letter-spacing: .08em; }
.brand strong { font: 700 11px "Segoe UI", sans-serif; }
.brand small { margin-top: 4px; color: #a5bcb4; font-size: 9px; }
.topbar-right { display: flex; align-items: center; gap: 22px; }
.environment { color: #b9d5c8; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.live-refresh-status { padding: 6px 8px; border: 1px solid #36534d; border-radius: 20px; color: #a9d7bf; font-size: 8px; font-weight: 700; letter-spacing: .06em; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #72c791; }
.refresh-button {
  padding: 9px 14px; border: 1px solid #48615b; border-radius: 8px;
  color: #edf5ef; background: #183b38; cursor: pointer; font-size: 12px; font-weight: 600;
}
.refresh-button:hover { background: #24514a; }
.refresh-button:focus-visible, select:focus-visible, a:focus-visible, .station-row:focus-visible {
  outline: 3px solid #e6b969; outline-offset: 2px;
}

.page { width: min(1440px, 100%); margin: 0 auto; padding: 38px clamp(20px, 4.5vw, 72px) 30px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 9px; color: #67817a; font-size: 9px; font-weight: 700; letter-spacing: .13em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font: 800 clamp(24px, 3vw, 34px)/1.2 "Segoe UI", sans-serif; letter-spacing: -.04em; }
.intro-copy { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.updated-block { min-width: 190px; padding: 0 0 2px 18px; border-left: 1px solid #d7e0d9; }
.updated-block span, .updated-block strong, .updated-block small { display: block; }
.updated-block span { color: #76877f; font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.updated-block strong { margin-top: 6px; font-size: 12px; }
.updated-block small { margin-top: 4px; color: var(--muted); font-size: 10px; }

.notice {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; padding: 11px 14px;
  border: 1px solid #eadcb9; border-radius: 9px; background: #fffaf0; color: #65563a;
}
.notice-icon { display: grid; flex: 0 0 17px; place-items: center; height: 17px; border-radius: 50%; background: #eadcb9; font: 700 11px "Segoe UI", sans-serif; }
.notice p { margin: 0; font-size: 11px; line-height: 1.6; }
.notice strong { color: #4f452f; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 2px 9px #233b2607; }
.metric-card { min-height: 112px; padding: 17px 18px; }
.metric-label { color: #75867f; font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.metric-value { display: flex; align-items: baseline; gap: 8px; margin: 11px 0 5px; }
.metric-value strong { font: 800 26px "Segoe UI", sans-serif; letter-spacing: -.04em; }
.metric-value span { color: #75867f; font-size: 11px; }
.metric-foot { color: #819089; font-size: 10px; }
.metric-card--quality .metric-value strong { font-size: 20px; }

.content-grid { display: grid; grid-template-columns: 1.13fr .87fr; gap: 14px; margin-bottom: 14px; }
.panel { min-width: 0; padding: 19px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font: 700 16px "Segoe UI", sans-serif; letter-spacing: -.02em; }
.panel-heading .eyebrow { margin-bottom: 6px; }
.panel-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.select-wrap select { min-width: 126px; padding: 8px 26px 8px 10px; border: 1px solid #dce5df; border-radius: 7px; background: #fff; color: #3c514c; font-size: 11px; }
#map { height: 338px; overflow: hidden; border: 1px solid #e2eae5; border-radius: 8px; background: #e8f0ed; }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 13px; padding-top: 12px; color: #5e726a; font-size: 9px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend small { margin-left: auto; color: #84938c; font-size: 9px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot--solimoes { background: var(--solimoes); }
.legend-dot--madeira { background: var(--madeira); }
.legend-dot--purus { background: var(--purus); }
.health-legend { color: #6d7c75; }
.health-legend-dot { width: 8px; height: 8px; border: 1px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #aebbb4; }
.health-legend-dot--fresh { background: #3c9968; }
.health-legend-dot--missing { background: #d09a3e; }
.health-legend-dot--stale { background: #c45a4c; }
.station-pin { position: relative; display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid #fff; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); box-shadow: 0 2px 7px #172c2866; }
.station-pin span { color: white; font-size: 8px; font-weight: 700; transform: rotate(45deg); }
.station-health-dot { position: absolute; right: -5px; bottom: -4px; width: 9px; height: 9px; border: 1.5px solid white; border-radius: 50%; box-shadow: 0 1px 3px #172c2866; transform: rotate(45deg); }
.station-health--fresh { background: #3c9968; }
.station-health--missing, .station-health--unknown { background: #d09a3e; }
.station-health--stale, .station-health--failed { background: #c45a4c; }
.station-pin.solimoes { background: var(--solimoes); }
.station-pin.madeira { background: var(--madeira); }
.station-pin.purus { background: var(--purus); }
.leaflet-popup-content-wrapper { border-radius: 8px; }
.map-popup strong, .map-popup span { display: block; }
.map-popup strong { margin-bottom: 4px; font-size: 12px; }
.map-popup span { color: #62736d; font-size: 10px; line-height: 1.6; }
.map-popup button { margin-top: 7px; padding: 5px 8px; border: 0; border-radius: 5px; color: white; background: var(--forest); cursor: pointer; font-size: 10px; }

.series-panel { display: flex; flex-direction: column; }
.chart-wrap { position: relative; min-height: 338px; flex: 1; }
.chart-wrap svg { display: block; width: 100%; height: 300px; overflow: visible; }
.chart-grid { stroke: #e8eeea; stroke-width: 1; }
.chart-line { fill: none; stroke: #287c72; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: #287c72; opacity: .1; }
.chart-point { fill: white; stroke: #287c72; stroke-width: 2; }
.chart-label { fill: #7a8a83; font: 10px "Segoe UI", sans-serif; }
.chart-reference { stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart-reference--maximum { stroke: #c36a4a; }
.chart-reference--minimum { stroke: #617ca6; }
.chart-reference-label { font: 9px "Segoe UI", sans-serif; paint-order: stroke; stroke: white; stroke-width: 3px; stroke-linejoin: round; }
.chart-content { width: 100%; }
.chart-reference-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0 8px 10px; color: #71817a; font-size: 9px; }
.chart-reference-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-reference-legend a { color: var(--forest); font-weight: 700; text-decoration: none; }
.chart-reference-legend a:hover { text-decoration: underline; }
.chart-reference-swatch { width: 15px; border-top: 2px dashed; }
.chart-reference-swatch--maximum { border-color: #c36a4a; }
.chart-reference-swatch--minimum { border-color: #617ca6; }
.chart-seasonal-reference { display: grid; gap: 6px; margin: 0 8px 10px; padding: 9px 10px; border: 1px solid #e8eee9; border-radius: 7px; background: #f8faf8; color: #697a72; font-size: 9px; }
.chart-seasonal-reference strong { color: #40564c; font-size: 9px; }
.chart-seasonal-reference span { display: flex; align-items: center; gap: 6px; }
.seasonal-swatch { width: 15px; height: 6px; border-radius: 3px; }
.seasonal-swatch--high { background: #d88768; }
.seasonal-swatch--low { background: #7893b8; }
.series-freshness { display: flex; flex-wrap: wrap; gap: 5px 14px; margin: 0 8px 10px; padding: 8px 10px; border: 1px solid #e8eee9; border-radius: 7px; background: #f8faf8; color: #687a71; font-size: 8px; }
.series-freshness--stale, .series-freshness--failed { border-color: #ecd1cc; background: #fff7f5; color: #995047; }
.series-freshness--missing, .series-freshness--unknown { border-color: #eadcb9; background: #fffaf0; color: #896c3a; }
.chart-reference-note { padding: 0 8px 10px; color: #7a6c54; font-size: 9px; line-height: 1.5; }
.empty-state { display: grid; min-height: 300px; place-items: center; padding: 30px; color: #829089; font-size: 12px; text-align: center; }
.chart-foot { display: flex; justify-content: space-between; gap: 10px; padding-top: 11px; border-top: 1px solid #edf1ee; color: #83918b; font-size: 9px; }

.indicator-section { margin: 14px 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 26px 2px 13px; }
.section-heading h2 { margin: 0; font: 700 19px "Segoe UI", sans-serif; letter-spacing: -.025em; }
.experimental-badge { padding: 6px 9px; border: 1px solid #e9d8b1; border-radius: 20px; background: #fff9eb; color: #82683c; font-size: 8px; font-weight: 700; letter-spacing: .06em; }
.indicator-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.indicator-card { display: flex; min-height: 265px; flex-direction: column; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.indicator-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.indicator-icon { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; background: #eaf3ef; color: #2c7460; font: 700 14px "Segoe UI", sans-serif; }
.indicator-icon--rain { background: #edf4fa; color: #4776a0; }
.indicator-icon--forecast { background: #f1effa; color: #7165a5; font-size: 11px; }
.indicator-icon--drought { background: #fbf0e8; color: #a46739; font-size: 10px; }
.indicator-state { padding: 5px 7px; border-radius: 12px; background: #eef5f0; color: #54755e; font-size: 8px; font-weight: 700; }
.indicator-state--partial { background: #fff5e4; color: #9a7638; }
.indicator-state--pending { background: #f1f2f1; color: #69756e; }
.indicator-card .eyebrow { margin-bottom: 7px; font-size: 8px; }
.indicator-card h3 { margin: 0 0 8px; color: #29423a; font: 700 13px/1.4 "Segoe UI", sans-serif; }
.indicator-card p:not(.eyebrow) { margin: 0 0 14px; color: #71817a; font-size: 10px; line-height: 1.65; }
.indicator-card a { display: inline-flex; align-items: center; gap: 5px; margin-top: auto; color: var(--forest); font-size: 10px; font-weight: 700; text-decoration: none; }
.indicator-card a:hover { text-decoration: underline; }
.indicator-warning { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border: 1px solid #eadcb9; border-radius: 8px; background: #fffaf0; color: #6d5a35; font-size: 10px; line-height: 1.5; }
.indicator-warning strong { color: #59472a; }
.indicator-warning a { color: #6b5631; font-weight: 700; }
.ai-assessment { margin-top: 12px; padding: 17px; border: 1px solid #d8e6df; border-radius: 10px; background: #fff; }
.ai-assessment-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.ai-assessment-heading h3 { margin: 0; color: #29423a; font: 700 14px "Segoe UI", sans-serif; }
.assessment-button { flex: 0 0 auto; padding: 9px 12px; border: 0; border-radius: 7px; color: #fff; background: var(--forest); cursor: pointer; font-size: 10px; font-weight: 700; }
.assessment-button:disabled { background: #9aa9a2; cursor: not-allowed; }
.assessment-button:focus-visible { outline: 3px solid #e6b969; outline-offset: 2px; }
.ai-assessment-note { margin: 10px 0; color: #71817a; font-size: 10px; line-height: 1.6; }
.assessment-result { padding: 11px 12px; border-radius: 7px; background: #f4f7f4; color: #62736d; font-size: 10px; line-height: 1.6; }
.assessment-result strong { color: #29423a; }
.assessment-result ul { margin: 7px 0 0; padding-left: 17px; }
.assessment-meta { display: block; margin-top: 8px; color: #83918b; font-size: 9px; }
.map-popup a { display: block; margin: 7px 0; color: var(--forest); font-size: 10px; font-weight: 700; }

.stations-panel { padding: 19px 0 13px; }
.table-heading { align-items: center; padding: 0 19px; }
.table-heading h2 { margin: 0; }
.table-caption { color: #7c8c84; font-size: 10px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
thead { background: #f7f9f7; }
th { padding: 10px 13px; color: #76867f; font-size: 8px; font-weight: 700; letter-spacing: .07em; text-align: left; }
td { padding: 12px 13px; border-top: 1px solid #edf1ee; color: #40534d; font-size: 10px; }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 19px; }
.station-row { cursor: pointer; transition: background .15s; }
.station-row:hover, .station-row.selected { background: #f1f7f3; }
.station-name { color: #243e37; font-weight: 700; }
.station-code { display: block; margin-top: 3px; color: #89978f; font-size: 9px; }
.station-freshness { display: block; margin-top: 4px; font-size: 8px; font-weight: 600; }
.station-freshness--fresh { color: #43815e; }
.station-freshness--missing, .station-freshness--unknown { color: #9a7538; }
.station-freshness--stale, .station-freshness--failed { color: #a85046; }
.river-tag { display: inline-flex; align-items: center; gap: 5px; }
.river-tag i { width: 6px; height: 6px; border-radius: 50%; }
.reading-status { display: inline-flex; align-items: center; gap: 6px; color: #47715e; }
.reading-status::before { width: 6px; height: 6px; border-radius: 50%; background: #55a375; content: ""; }
.reading-status--none { color: #927446; }
.reading-status--none::before { background: #d5a14e; }
.empty-cell { padding: 26px; color: #83918b; text-align: center; }
.table-footnote { margin: 12px 19px 0; color: #83918b; font-size: 9px; line-height: 1.5; }

.footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 20px; color: #7e8b85; font-size: 10px; }
.footer a { font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .content-grid { grid-template-columns: 1fr; }
  .chart-wrap { min-height: 300px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .indicator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar { height: auto; min-height: 66px; padding: 12px 16px; }
  .brand strong { font-size: 9px; }
  .brand small { font-size: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .environment { display: none; }
  .live-refresh-status { display: none; }
  .topbar-right { gap: 0; }
  .refresh-button { padding: 8px 9px; font-size: 10px; }
  .page { padding: 27px 15px 22px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 14px; }
  .updated-block { padding-left: 11px; }
  .metric-grid { gap: 9px; }
  .metric-card { min-height: 101px; padding: 13px; }
  .metric-label { font-size: 8px; }
  .metric-value strong { font-size: 23px; }
  .metric-value span { font-size: 9px; }
  .panel { padding: 14px; }
  .stations-panel { padding: 15px 0 11px; }
  .table-heading { padding: 0 14px; }
  #map { height: 285px; }
  .map-legend { gap: 9px; }
  .map-legend small { width: 100%; margin-left: 0; }
  .panel-heading h2 { font-size: 14px; }
  .select-wrap select { min-width: 105px; max-width: 125px; font-size: 10px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading h2 { font-size: 16px; }
  .indicator-grid { grid-template-columns: 1fr; }
  .indicator-card { min-height: unset; }
  .indicator-warning { grid-template-columns: 1fr; }
  .ai-assessment-heading { align-items: flex-start; flex-direction: column; }
  .assessment-button { width: 100%; }
  .footer { flex-direction: column; }
  .notice { padding: 10px; }
  .notice p { font-size: 10px; }
}
