:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #102c38;
  background: #f1f6f7;
  --ink: #102c38;
  --accent: #09675f;
  --muted: #46616d;
  --border: #cddde0;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 2rem, 91rem); margin-inline: auto; }
.top { background: #fff; border-bottom: 1px solid var(--border); }
.top .wrap, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.top .wrap { padding-block: 1.1rem; }
.top span { color: var(--muted); font-weight: 500; }
a { color: var(--accent); font-weight: 650; text-underline-offset: .22em; }
.hero { margin-top: 1.4rem; padding: clamp(1.5rem, 6vw, 4.3rem); border-radius: 1.25rem; color: #fff; background: linear-gradient(112deg, #102c38, #125457 75%, #146b62); }
h1 { font-size: clamp(2.65rem, 8vw, 5.7rem); line-height: .98; letter-spacing: -.06em; margin: 0; }
.hero p { max-width: 31rem; margin: 1.25rem 0 0; line-height: 1.6; color: #e4f5f5; font-size: 1.08rem; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 1rem; margin-block: 1.1rem; padding: clamp(1rem, 3.5vw, 1.75rem); }
form { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; }
label { display: block; margin-bottom: .45rem; font-weight: 700; }
input, select, button { font: inherit; border-radius: .55rem; padding: .65rem .85rem; min-height: 2.75rem; }
input, select { width: min(100%, 17rem); border: 1px solid #809aa3; color: var(--ink); background-color: #fff; }
select { appearance: none; padding-inline-end: 2.1rem; background: linear-gradient(45deg, transparent 50%, var(--ink) 50%) right 1rem center / .35rem .35rem no-repeat, linear-gradient(135deg, var(--ink) 50%, transparent 50%) right .65rem center / .35rem .35rem no-repeat #fff; }
button { cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 650; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #268caf; outline-offset: 3px; }
.selection { margin: .85rem 0 0; font-weight: 700; }
h2 { margin: 0; font-size: clamp(1.25rem, 4vw, 1.65rem); letter-spacing: -.025em; }
.links { display: flex; flex-wrap: wrap; gap: .75rem 1.2rem; }
.status { color: var(--muted); margin: .85rem 0 0; }
.sample-panel { background: #f8fcfc; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.metric-card { display: flex; flex-direction: column; padding: .85rem; border: 1px solid var(--border); border-top: 3px solid #278078; border-radius: .75rem; background: #fff; }
.metric-card dt { height: 3.4rem; font-weight: 750; }
.metric-card { position: relative; }
.metric-open { min-height: 0; padding: 0; border: 0; border-radius: 0; color: var(--ink); background: transparent; text-align: left; font-weight: inherit; }
.metric-open::after { content: ''; position: absolute; inset: 0; border-radius: .75rem; }
.metric-open:focus-visible::after { outline: 3px solid #268caf; outline-offset: 3px; }
.metric-card:has(.metric-open:hover) { border-color: var(--accent); }
#metric-dialog { width: min(100% - 2rem, 36rem); max-height: calc(100% - 2rem); padding: clamp(1rem, 4vw, 1.65rem); color: var(--ink); background: #fff; border: 1px solid var(--border); border-radius: 1rem; }
#metric-dialog::backdrop { background: #102c387f; }
#metric-dialog form { margin: 0; }
#metric-dialog-explanation { line-height: 1.55; }
#metric-dialog-explanation:empty { display: none; }
.hardness-ticks { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; }
.metric-track.hardness-detail-track { margin-top: .3rem; background: linear-gradient(90deg, #8fd8d5, #83c991 10%, #f3c866 25%, #df8955 55%, #b74c3e); }
.metric-track.ph-detail-track { margin-top: .3rem; background: linear-gradient(90deg, var(--band-1) 10%, var(--band-2) 25%, var(--band-3) 38%, var(--band-4) 48%, var(--band-5) 55%, var(--band-6) 65%, var(--band-7) 75%, var(--band-8) 90%); }
.hardness-method { text-align: center; margin-bottom: .75rem; }
.metric-dialog-value { margin: 0; color: var(--accent); font-size: 1.35rem; font-weight: 750; }
.metric-dialog-value:empty { display: none; }
#metric-dialog .metric-hardness .metric-legend { grid-template-columns: 1fr; grid-template-rows: none; }
#metric-dialog .metric-hardness .metric-legend li { flex-direction: row; justify-content: space-between; padding: .45rem .65rem; font-size: .9rem; }
#metric-dialog .metric-hardness .metric-legend li span { margin: 0; font-size: .85rem; }
#metric-dialog-result > p { line-height: 1.55; }
#metric-dialog-result > h3 { margin-block: 1.35rem .35rem; }
#metric-dialog-result > h3 + p { margin-top: 0; }
.metric-dialog-formula { padding: .65rem .85rem; border-radius: .45rem; background: #edf5f5; font-variant-numeric: tabular-nums; }
.ph-ranges td, .ph-ranges th { padding: .42rem .6rem; font-size: .9rem; }
.ph-ranges td:first-child { box-shadow: inset 3px 0 var(--band); }
.ph-ranges tr[aria-current] { background: #e1f2ee; font-weight: 750; }
.metric-context, .metric-card small { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; }
.metric-card dd { margin: .85rem 0 0; padding-top: .65rem; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.metric-card strong { display: flex; align-items: center; height: 3.2rem; color: var(--accent); font-size: clamp(1.25rem, 2.5vw, 1.75rem); line-height: 1.15; }
.metric-card .metric-note { margin-top: .55rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.ewsa-scale { margin-top: .8rem; padding: .65rem .55rem; border-radius: .5rem; background: #edf5fb; }
.ewsa-scale > small { font-weight: 750; }
.ewsa-ticks { position: relative; height: 1.2rem; margin-top: .5rem; font-size: .65rem; font-weight: 700; }
.ewsa-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ewsa-ticks span:first-child { transform: none; }
.ewsa-ticks span:last-child { transform: translateX(-100%); }
.ewsa-track { position: relative; height: .65rem; border: 1px solid #bdd1e4; border-radius: 1rem; background: linear-gradient(90deg, #fff, #c6dff5 24%, #679acb 60%, #203d71); }
.ewsa-track .metric-marker { background: #285582; }
.ewsa-labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem; list-style: none; padding: 0; margin: .6rem 0 0; }
.ewsa-labels li { display: grid; place-items: center; min-width: 0; padding: .2rem .1rem; font-size: .67rem; line-height: 1.2; text-align: center; overflow-wrap: anywhere; hyphens: auto; }
.ewsa-labels li[aria-current] { border-radius: .3rem; background: #d9e9f7; font-weight: 750; box-shadow: inset 0 -2px #285582; }
.ewsa-result { margin: .7rem 0 0; text-align: center; font-size: clamp(1.15rem, 4vw, 1.6rem); font-weight: 800; color: #203d71; }
.ewsa-estimate { margin: .15rem 0 0; text-align: center; color: #203d71; font-weight: 750; }
.ewsa-scale > .ewsa-method { display: block; margin: .35rem 0 0; text-align: center; font-weight: 400; }
.tds-mouthfeel { display: grid; grid-template-columns: clamp(3.75rem, 22%, 7.5rem) minmax(0, 1fr); align-items: center; gap: .85rem; margin-block: 1rem; padding: .75rem; border: 1px solid var(--border); border-radius: .65rem; background: #edf5f5; }
.tds-mouthfeel img { display: block; width: 100%; height: auto; border-radius: .45rem; }
.tds-mouthfeel img[src="ph-vode.png"] { aspect-ratio: 1; object-fit: cover; }
.tds-mouthfeel h3 { margin: 0 0 .25rem; }
.tds-mouthfeel p { margin: 0; line-height: 1.45; }
.metric-track { position: relative; height: .7rem; margin: .65rem 0 .75rem; border-radius: 1rem; background: var(--metric-gradient); }
.metric-tds, #map-tds-legend {
  --band-1: #c8eef0; --band-2: #86cde2; --band-3: #4aabd1; --band-4: #28729e; --band-5: #184767;
  --metric-gradient: linear-gradient(90deg, var(--band-1) 10%, var(--band-2) 30%, var(--band-3) 50%, var(--band-4) 70%, var(--band-5) 90%);
}
.metric-hardness {
  --band-1: #8fd8d5; --band-2: #83c991; --band-3: #f3c866; --band-4: #df8955; --band-5: #d65842;
  --metric-gradient: linear-gradient(90deg, var(--band-1) 10%, var(--band-2) 30%, var(--band-3) 50%, var(--band-4) 70%, var(--band-5) 90%);
}
.metric-ph {
  --band-1: #d62e47; --band-2: #ed8b2c; --band-3: #adcf68; --band-4: #72c38b;
  --band-5: #3c9a69; --band-6: #056650; --band-7: #d97b24; --band-8: #a93c20;
  --metric-gradient: linear-gradient(90deg, var(--band-1) 6.25%, var(--band-2) 18.75%, var(--band-3) 31.25%, var(--band-4) 43.75%, var(--band-5) 56.25%, var(--band-6) 68.75%, var(--band-7) 81.25%, var(--band-8) 93.75%);
}
.metric-character {
  --band-1: #428bb1; --band-2: #d5a439; --band-3: #a1396a;
  --metric-gradient: linear-gradient(90deg, #245783, var(--band-1) 17%, #77af82 35%, var(--band-2) 50%, #d77948 69%, var(--band-3) 90%);
}
.metric-marker { position: absolute; top: 50%; width: 1rem; height: 1rem; transform: translate(-50%, -50%); border: 2px solid white; border-radius: 50%; background: #123844; box-shadow: 0 0 0 1px #49636c; }
.metric-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, 3rem); align-content: start; gap: .25rem; list-style: none; padding: 0; margin: 0; }
.metric-legend li { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: .25rem .15rem; border-radius: .35rem; color: var(--ink); background: color-mix(in srgb, var(--band) 40%, white); box-shadow: inset 0 -2px var(--band); text-align: center; font-size: .72rem; line-height: 1.15; overflow-wrap: anywhere; hyphens: auto; }
.metric-legend li span { display: block; font-size: .65rem; margin-top: .16rem; }
.metric-legend li[aria-current] { outline: 2px solid var(--ink); outline-offset: -2px; font-weight: 800; }
.metric-character .metric-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#metric-dialog .metric-character .metric-legend { grid-template-rows: minmax(4rem, auto); }
#sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend li { grid-column: span 2; }
#sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend li:nth-child(4) { grid-column: 2 / span 2; }
#sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend li:nth-child(5) { grid-column: 4 / span 2; }
.metric-tds, .metric-hardness { container-type: inline-size; }
@container (min-width: 15.5rem) {
  #sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  #sample-metrics :is(.metric-tds, .metric-hardness) .metric-legend li:nth-child(n) { grid-column: auto; }
}
.metric-character strong { font-size: 1.1rem; }
.metric-classification { margin: .35rem 0 0; padding: .55rem .45rem; border-radius: .35rem; background: #edf5f5; color: var(--accent); font-size: .85rem; font-weight: 750; text-align: center; }
.metric-classification:empty { visibility: hidden; }
@media (max-width: 61rem) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 29rem) { .metrics { grid-template-columns: minmax(0, 1fr); } }
#sample-map { height: clamp(24rem, 58vh, 44rem); margin-top: 1rem; border: 1px solid var(--border); border-radius: .75rem; background: #edf5f5; z-index: 0; }
.sample-marker { border: 3px solid var(--ink); border-radius: 50%; background: var(--map-dot-color, #a4adb4); box-shadow: 0 0 0 2px white, 0 2px 6px #102c3870; }
.municipality-dots { position: absolute; top: 0; left: 0; pointer-events: none; }
.table-scroll { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .65rem .7rem; border-bottom: 1px solid #e1ecee; }
th { background: #edf5f5; font-size: .9rem; }
td:first-child { white-space: nowrap; }
#pages { display: flex; gap: .75rem; margin-top: 1rem; }
footer { color: var(--muted); padding: .75rem 0 2rem; }
.bottom-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; font-size: clamp(1.15rem, 3vw, 1.4rem); font-weight: 750; list-style: none; }
.bottom-panel > summary::-webkit-details-marker { display: none; }
.bottom-panel > summary::after { content: ''; flex: 0 0 .55rem; height: .55rem; margin-inline-end: .25rem; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); }
.bottom-panel[open] > summary::after { transform: rotate(225deg); }
.bottom-panel[open] > summary { margin-bottom: .85rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border); }

#map-tds-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; padding: 0; list-style: none; font-size: .82rem; }
#map-tds-legend li { display: inline-flex; gap: .35rem; align-items: center; }
#map-tds-legend li::before { content: ''; width: .75rem; height: .75rem; border: 1px solid #536576; border-radius: 50%; background: var(--map-dot-color); }
