/* CaliforniaStormwater.com design system (S7.9B). Order: tokens, base, layout, components, pages.
   Every colour is a token with a dark-mode value; contrast is checked by scripts/contrast_check.py. */

/* ------------------------------------------------------------------ tokens */
:root {
  /* colour: surfaces and text */
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eef2f0; --ink: #1d2b28; --muted: #5d6b67;
  --line: #dde3df; --control-border: #7a8a85;
  /* colour: brand and actions */
  --brand: #0f5c55; --brand-ink: #ffffff; --accent: #1f7a6d; --accent-hover: #17645a; --accent-active: #11514a;
  --accent-soft: #e3f1ee; --on-accent: #ffffff;
  /* colour: focus (blue on light surfaces, amber on the teal header) */
  --focus: #0b6bcb; --focus-on-brand: #f2b632;
  /* colour: status */
  --ok: #1d6b3a; --ok-bg: #e5f2e9; --off: #6b5c4a; --off-bg: #f1ece4; --warn: #8a4b08; --warn-bg: #fdf1dc;
  --danger: #a3261b; --danger-bg: #fbe9e5;
  /* colour: evidence labels (where a statement comes from) */
  --ev-state: #1f4e79; --ev-state-bg: #e4edf6; --ev-rep: #4b5563; --ev-rep-bg: #eef0f2; --ev-cor: #1d6b3a; --ev-cor-bg: #e5f2e9;
  --ev-sp: #6d28d9; --ev-sp-bg: #efe7fb; --ev-px: #1d4ed8; --ev-px-bg: #e6edfc; --ev-un: #8a4b08; --ev-un-bg: #fdf1dc;
  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --fs-display: 2.25rem; --fs-h1: 1.9rem; --fs-h2: 1.3rem; --fs-h3: 1.08rem; --fs-body: 1rem; --fs-small: .875rem; --fs-label: .75rem;
  /* space, size, shape */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --w-page: 1180px; --w-prose: 760px; --target: 44px;
  --radius: 8px; --radius-control: 6px;
  --shadow: 0 1px 2px rgba(20, 40, 35, .06), 0 2px 8px rgba(20, 40, 35, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111917; --surface: #18221f; --surface-2: #1e2a27; --ink: #e5ece9; --muted: #9aaba6;
    --line: #2c3a36; --control-border: #6f827c;
    --brand: #0c4a44; --accent: #6cc7b8; --accent-hover: #86d4c7; --accent-active: #a3e0d5;
    --accent-soft: #1b322d; --on-accent: #0b1f1c;
    --focus: #8cc4ff; --focus-on-brand: #8cc4ff;
    --ok: #8fd3a5; --ok-bg: #1d3326; --off: #d6c3a7; --off-bg: #352d23; --warn: #f3c37a; --warn-bg: #3a2c14;
    --danger: #f3a596; --danger-bg: #3a1f1a;
    --ev-state: #9cc3ea; --ev-state-bg: #1c2b3b; --ev-rep: #c8ced6; --ev-rep-bg: #2a3036; --ev-cor: #8fd3a5; --ev-cor-bg: #1d3326;
    --ev-sp: #c4b0f5; --ev-sp-bg: #2b2340; --ev-px: #9db7f5; --ev-px-bg: #1c2540; --ev-un: #f3c37a; --ev-un-bg: #3a2c14;
    --shadow: none;
    color-scheme: dark;
  }
}

/* -------------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs-body)/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.site-header :focus-visible { outline-color: var(--focus-on-brand); }
h1 { font-size: var(--fs-h1); line-height: 1.2; margin: 0 0 var(--s-3); text-wrap: balance; }
h2 { font-size: var(--fs-h2); line-height: 1.3; margin: 0 0 var(--s-3); }
h3 { font-size: var(--fs-h3); margin: var(--s-5) 0 10px; }
.wrap { max-width: var(--w-page); margin: 0 auto; padding: 0 var(--s-4); }
.skip { position: absolute; left: -999px; } .skip:focus { left: var(--s-4); top: var(--s-2); background: var(--surface); color: var(--accent); padding: var(--s-2); z-index: 1001; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: var(--w-prose); }
.muted { color: var(--muted); } .small { font-size: var(--fs-small); } .mono { font-family: var(--mono); font-size: .9em; }
.note { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }
.prose { max-width: var(--w-prose); }
.prose h2 { margin-top: 28px; }

/* ------------------------------------------------------------ header, nav */
.site-header { background: var(--brand); color: var(--brand-ink); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { color: var(--brand-ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; display: flex; flex-direction: column; line-height: 1.2; padding: var(--s-1) 0; }
.brand:hover { color: var(--brand-ink); }
.brand-sub { font-weight: 400; font-size: .8rem; opacity: .88; }
.site-header nav { display: flex; gap: var(--s-1); flex-wrap: wrap; margin: 0 calc(-1 * var(--s-2)); }
.site-header nav a { color: var(--brand-ink); text-decoration: none; display: inline-block; line-height: 24px; min-height: var(--target);
  padding: 10px var(--s-2) 7px; border-radius: var(--radius-control); border-bottom: 3px solid transparent; }
.site-header nav a:hover { color: var(--brand-ink); background: rgba(255, 255, 255, .1); text-decoration: underline; }
.site-header nav a[aria-current="page"] { font-weight: 700; border-bottom-color: var(--brand-ink); border-radius: var(--radius-control) var(--radius-control) 0 0; }
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .header-row { padding-top: var(--s-2); padding-bottom: 0; }
  .site-header nav { width: calc(100% + 2 * var(--s-2)); justify-content: space-between; }
  .nav-long { display: none; }
}

main { padding-top: var(--s-5); padding-bottom: var(--s-7); min-height: 60vh; }

/* ------------------------------------------------------------------ footer */
.site-footer { border-top: 1px solid var(--line); padding: var(--s-6) 0; color: var(--muted); font-size: .88rem; background: var(--surface); }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr); gap: var(--s-5); margin-bottom: var(--s-5); }
.footer-cols h2 { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 var(--s-2); }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.footer-cols a { display: inline-block; padding: 2px 0; }
.footer-cols p { margin: 0 0 var(--s-2); }
.footer-legal { border-top: 1px solid var(--line); padding-top: var(--s-4); }
.footer-legal p { margin: 0 0 var(--s-2); max-width: 900px; }
.ydos-mark { font-weight: 600; color: var(--ink); }
@media (max-width: 760px) { .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } .footer-about { grid-column: 1 / -1; } }

/* ------------------------------------------------------------ form controls */
input[type=search], input[type=text], input[type=email], select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: var(--radius-control);
  background: var(--surface); color: var(--ink); min-height: var(--target); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }
.field-error { color: var(--danger); font-size: var(--fs-small); font-weight: 600; }

/* ----------------------------------------------------------------- buttons */
button, .button { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--target); padding: 10px 18px; border: 2px solid var(--accent); border-radius: var(--radius-control);
  background: var(--accent); color: var(--on-accent); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
button:active, .button:active { background: var(--accent-active); border-color: var(--accent-active); color: var(--on-accent); }
.button.secondary, button.secondary { background: transparent; color: var(--accent); }
.button.secondary:hover, button.secondary:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled, button[aria-disabled="true"], .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
button:disabled:hover, button[aria-disabled="true"]:hover { background: var(--accent); border-color: var(--accent); }
.link-button { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; }
.link-button:hover, .link-button:active { background: none; color: var(--accent-hover); }
.text-link { font-weight: 600; }

/* ------------------------------------------------------------ cards, panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: var(--s-4) 0; box-shadow: var(--shadow); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s-4); }
.grid-2 .panel { margin: 0; }
.grid-2 > * { min-width: 0; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
@media (min-width: 861px) { .grid-2.inner { grid-template-columns: 1.2fr 1fr; } }

/* -------------------------------------------------------- alerts, statuses */
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: var(--radius); }
.coverage-ok { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: var(--radius); margin: 0 0 var(--s-3); }
.coverage-banner { margin: var(--s-3) 0 0; }
.alert-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: var(--radius); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.off { background: var(--off-bg); color: var(--off); }
.badge.warn-b { background: var(--warn-bg); color: var(--warn); }

/* evidence labels */
.ev { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: 1px 8px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
h2 .ev, h3 .ev, dt .ev { margin-left: 6px; }
.ev-state { color: var(--ev-state); background: var(--ev-state-bg); } .ev-reported { color: var(--ev-rep); background: var(--ev-rep-bg); }
.ev-corroborated { color: var(--ev-cor); background: var(--ev-cor-bg); } .ev-spatial { color: var(--ev-sp); background: var(--ev-sp-bg); }
.ev-proximity { color: var(--ev-px); background: var(--ev-px-bg); } .ev-smarts { color: var(--ev-state); background: var(--ev-state-bg); }
.ev-unconfirmed { color: var(--ev-un); background: var(--ev-un-bg); }
.finding { border-left: 4px solid var(--line); padding: 8px 14px; margin: 14px 0; background: var(--bg); border-radius: 0 var(--radius) var(--radius) 0; }
.finding.corroborated { border-left-color: var(--ev-cor); } .finding.unconfirmed { border-left-color: var(--ev-un); }
.finding p { margin: 6px 0; } .finding-head { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.disclaimer { background: var(--ev-px-bg); color: var(--ink); border-radius: var(--radius); padding: 8px 12px; font-size: .92rem; }
.notice-nal { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 8px 12px; font-size: .92rem; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.data caption { text-align: left; padding: 10px 12px 0; font-weight: 600; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { background: var(--surface-2); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  white-space: nowrap; position: sticky; top: 0; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.data.compact th, table.data.compact td { padding: 7px 10px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qual { color: var(--muted); font-size: .85em; }

/* ---------------------------------------------------- search and filters */
.search { display: flex; gap: var(--s-2); margin-top: 18px; flex-wrap: wrap; }
.search input { flex: 1 1 340px; min-width: 0; }
.search select { flex: 1 1 160px; min-width: 0; }
.search > * { max-width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: var(--s-3) 0 var(--s-2); }
.filters label { display: flex; flex-direction: column; gap: var(--s-1); font-size: .85rem; color: var(--muted); flex: 1 1 180px; min-width: 0; max-width: 100%; }
.filters label:first-child { flex: 2 1 260px; }
.filters input[type=search], .filters select { width: 100%; }
.filters label.check { flex: 0 0 auto; flex-direction: row; align-items: center; gap: var(--s-2); min-height: var(--target); }
.filter-actions { display: flex; gap: 14px; align-items: center; }
.more-filters { flex: 1 1 100%; } .more-filters summary { font-size: .9rem; padding: 4px 0; }
.filters-inner { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-2); }
.filters-inner label { flex: 1 1 200px; }
.assoc-note { margin: 4px 0 10px; }
.count { color: var(--muted); }
.source-line { margin: -4px 0 var(--s-3); }
.pager { display: flex; gap: var(--s-4); align-items: center; justify-content: center; margin: var(--s-4) 0; color: var(--muted); flex-wrap: wrap; }
.pager a { margin: 0 4px; }
details summary { cursor: pointer; color: var(--accent); }

/* ----------------------------------------------------------- home (S7.9B) */
.hero { padding: var(--s-4) 0 var(--s-2); }
.hero h1 { font-size: var(--fs-display); max-width: 860px; line-height: 1.15; }
.hero .lead { margin: 0 0 var(--s-2); }
.examples { margin: var(--s-3) 0 0; color: var(--muted); font-size: var(--fs-small); display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); margin: var(--s-6) 0 0; padding: 0; list-style: none; }
.path { display: flex; flex-direction: column; gap: var(--s-2); }
.path h2 { font-size: 1.1rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.path h2 svg { flex: none; color: var(--accent); }
.path p { margin: 0; color: var(--muted); }
.path .path-n { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.path .go { margin-top: auto; font-weight: 600; }
.section-title { font-size: var(--fs-h2); margin: var(--s-7) 0 var(--s-1); }
.section-intro { color: var(--muted); margin: 0 0 var(--s-4); max-width: var(--w-prose); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); margin: 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-4); box-shadow: var(--shadow); margin: 0; min-width: 0; }
.stat-n { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-l { display: block; font-weight: 600; margin-top: 2px; }
.stat-d { display: block; color: var(--muted); font-size: var(--fs-small); margin: var(--s-1) 0 0; }
.freshness { margin: var(--s-4) 0 0; }
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.sources li { border-left: 3px solid var(--line); padding: 2px 0 2px var(--s-3); }
.sources b { display: block; }
@media (max-width: 860px) { .paths { grid-template-columns: 1fr; } .hero h1 { font-size: 1.8rem; } }

/* engagement (S7.5) */
.engage { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-4); margin: var(--s-7) 0 var(--s-2); }
.engage > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.engage-main { border-top: 4px solid var(--accent) !important; }
.engage h2 { font-size: 1.35rem; margin-bottom: var(--s-2); } .engage h3 { margin: 0 0 6px; font-size: 1rem; }
.engage p { margin: 0 0 14px; color: var(--muted); max-width: 640px; }
.engage-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) { .engage { grid-template-columns: 1fr; } }

/* ------------------------------------------------------- facility profile */
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: var(--s-2); }
.fac-head { margin-bottom: var(--s-4); }
.fac-sub { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); margin: 0; }
.facts { display: grid; grid-template-columns: minmax(150px, 38%) 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; } .facts dd { margin: 0; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: var(--s-2); } }
.section-nav { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: var(--s-3); font-size: .9rem; }
h3.first, p.first { margin-top: 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 6px; } ul.plain li { margin: 4px 0; }
.legend-list { padding-left: 0; list-style: none; } .legend-list li { margin: 6px 0; }

/* ------------------------------------------- profiles (S7.9D): summary, sticky sections, stacked tables */
.glance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: var(--s-4) 0;
          box-shadow: var(--shadow); }
.glance h2 { margin-bottom: var(--s-3); }
.glance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--s-3) var(--s-5); margin: 0; }
.glance-item { min-width: 0; border-top: 1px solid var(--line); padding-top: var(--s-2); }
.glance-item dt { font-size: var(--fs-label); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
                  margin-bottom: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.glance-item dt .ev { text-transform: none; letter-spacing: .02em; margin-left: 0; }
.glance-item dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.glance .note { margin-top: var(--s-3); }

.sticky-nav { position: sticky; top: 0; z-index: 1100; background: var(--bg); border-bottom: 1px solid var(--line);
              margin: var(--s-4) calc(-1 * var(--s-4)) 0; padding: 6px var(--s-4); flex-wrap: nowrap; overflow-x: auto;
              scrollbar-width: thin; gap: 4px; -webkit-overflow-scrolling: touch; }
.sticky-nav a { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 999px;
                text-decoration: none; white-space: nowrap; color: var(--accent); border: 1px solid transparent; }
.sticky-nav a:hover { background: var(--accent-soft); color: var(--accent-hover); }
.sticky-nav a[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); font-weight: 600; }
main section[id], main div[id].panel, #results, #permit-history, #evidence-key, #compliance-history, #glance-compliance { scroll-margin-top: 64px; }

.subsection { margin-top: var(--s-5); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.subsection h3 { margin-top: 0; }
details.more { margin: var(--s-2) 0; }
details.more > summary { font-weight: 600; min-height: 36px; display: flex; align-items: center; }
details.more[open] > summary { margin-bottom: var(--s-2); }
h3.decision-group { margin: var(--s-5) 0 var(--s-2); }
.meaning ul { margin: var(--s-2) 0 0; padding-left: 1.2rem; max-width: var(--w-prose); }
.meaning li { margin: 6px 0; } .meaning p { max-width: var(--w-prose); margin: 0; }
.evidence-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-2); }
.evidence-compare > div { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--bg); }
.evidence-compare p { margin: 4px 0; }
.ev-review { color: var(--ev-un); background: var(--ev-un-bg); outline: 1px dashed currentColor; outline-offset: -1px; }
.ev-unavailable { color: var(--muted); background: var(--surface-2); }

@media (max-width: 640px) {
  .table-wrap:has(table.stack) { border: 0; background: transparent; overflow: visible; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.stack tr { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 var(--s-2); padding: 6px 0; }
  table.data.stack td { border: 0; padding: 3px 12px; display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 8px;
                        text-align: left !important; white-space: normal; overflow-wrap: anywhere; }
  table.data.stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-small); font-weight: 600; }
  table.data.stack td:not([data-label]) { display: block; }
  table.data.stack td:not([data-label])::before { content: none; }
  table.data.stack td:empty { display: none; }
  table.data.stack tbody tr:hover { background: var(--surface); }
}

/* maps (shared) */
.map { border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); }
.small-map { height: 280px; }
.mid-map { height: 340px; }
.big-map { height: 68vh; min-height: 420px; }
.map.no-tiles { background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 10px, var(--surface) 10px, var(--surface) 20px); }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; color: var(--muted); margin: var(--s-2) 0 0; }
.key { display: inline-block; width: 18px; height: 0; border-top: 3px solid; margin-right: 6px; vertical-align: middle; }
.key-fac { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #2b82cb; }
.key-huc { border-color: #7c3aed; border-top-style: dashed; } .key-rw { border-color: #047857; border-top-width: 5px; } .key-near { border-color: #2563eb; }

/* Statewide map (S7.3, refined S7.9C): side panel with layers, filters, counts; viewport-bounded layers. */
.map-title { margin-bottom: var(--s-2); }
.map-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.map-main { min-width: 0; }
.map-frame { position: relative; }
.map-layout .big-map { height: 78vh; min-height: 480px; }
.map-side { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.side-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0;
              display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.side-block legend, .side-label { font-weight: 700; font-size: .95rem; margin: 0; padding: 0; color: var(--ink); }
.side-block label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); }
.side-block label.check { flex-direction: row; align-items: center; gap: var(--s-2); color: var(--ink); min-height: 32px; }
.side-block select, .side-block input[type=search] { width: 100%; min-height: 40px; padding: 6px 8px; }
.side-block .more-filters summary { font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.more-filters-body { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.filter-count { font-weight: 400; color: var(--muted); margin-left: 4px; }
.side-block .filter-actions { flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-top: var(--s-1); }
button.compact, .button.compact { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.inline-search { display: flex; gap: 6px; } .inline-search input { flex: 1 1 auto; min-width: 0; } .inline-search button { min-height: 40px; padding: 6px 12px; }
.map-results { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow-y: auto; font-size: .88rem; }
.map-results li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.layer-status { list-style: none; padding: 0; margin: 0; font-size: .85rem; display: flex; flex-direction: column; gap: 6px; }
.layer-status li.loading { color: var(--muted); } .layer-status li.error, .layer-status li.partial { color: var(--warn); } .layer-status li.muted { color: var(--muted); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; } .sw-active { background: #0f766e; border: 1px solid #fff; }
.sw-hist { background: #9a6b3c; border: 2px solid #5c3d1e; } .sw.sq { border-radius: 3px; }
.ln { display: inline-block; width: 18px; height: 0; border-top: 3px solid; flex: none; } .ln-river { border-color: #1d4ed8; }
.ln-area { height: 10px; border: 2px solid #0e7490; background: rgba(56, 189, 248, .3); } .ln-huc { border-color: #7c3aed; border-top-style: dashed; }
.map-filters-toggle, .map-filters-close { display: none; }
@media (max-width: 900px) {
  .map-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .map-filters-toggle { display: inline-flex; justify-self: start; order: 0; }
  .map-side { order: 1; display: none; }
  .map-side.open { display: flex; }
  .map-filters-close { display: inline-flex; align-self: flex-start; }
  .map-main { order: 2; }
  .map-layout .big-map { height: 66vh; min-height: 360px; }
}
.map.no-tiles { background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 10px, var(--surface) 10px, var(--surface) 20px); }

/* in-map loading and problem line */
.map-status { position: absolute; top: 10px; left: 64px; right: 172px; z-index: 1000; display: flex; flex-direction: column;
              gap: 4px; align-items: center; pointer-events: none; }
.map-status[hidden] { display: none; }
.map-status-item { margin: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
                   padding: 4px 12px; font-size: .85rem; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); text-align: center; }
.map-status-item.loading::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
                                   margin-right: 8px; vertical-align: middle; animation: map-pulse 1s ease-in-out infinite alternate; }
.map-status-item.error, .map-status-item.partial { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
@keyframes map-pulse { from { opacity: .3; } to { opacity: 1; } }
@media (max-width: 560px) { .map-status { top: 64px; left: 64px; right: 10px; align-items: flex-end; } }

/* Leaflet controls: 44 px targets and theme tokens */
.map.leaflet-container .leaflet-bar a { width: var(--target); height: var(--target); line-height: var(--target); font-size: 22px; }
.map.leaflet-container .leaflet-bar a, .map-reset button { background: var(--surface); color: var(--ink); border-color: var(--line); }
.map.leaflet-container .leaflet-bar a:hover, .map-reset button:hover { background: var(--surface-2); color: var(--ink); }
.map.leaflet-container .leaflet-bar a.leaflet-disabled { background: var(--surface-2); color: var(--muted); }
.map-reset button { min-height: var(--target); padding: 0 12px; border: 0; border-radius: 4px; font-size: .85rem; font-weight: 600; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; font-size: 22px; line-height: 30px; color: var(--muted); }
.map-popup { display: flex; flex-direction: column; gap: 4px; font: .9rem/1.4 var(--font); padding-right: 10px; }
.map-popup-title { font-size: 1rem; }
.leaflet-container .map-popup a.button { color: var(--on-accent); align-self: flex-start; margin: 4px 0; text-decoration: none; }
.map-legend-box { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px;
                  max-width: 250px; font: .78rem/1.3 var(--font); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.map-legend-box summary { font-weight: 700; color: var(--ink); min-height: 28px; display: flex; align-items: center; }
.legend-items { list-style: none; margin: 2px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.legend-items li { display: flex; gap: 8px; align-items: center; } .legend-items li[hidden] { display: none; }
.lg-clusters { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.lg-clusters i { display: inline-block; border-radius: 50%; background: #0f766e; border: 1px solid #fff; }
.lg-1 { width: 12px; height: 12px; } .lg-2 { width: 15px; height: 15px; } .lg-3 { width: 18px; height: 18px; } .lg-4 { width: 21px; height: 21px; }
.legend-note { margin: 0; color: var(--muted); }
@media (max-width: 560px) { .map-legend-box { max-width: 230px; } }
.leaflet-marker-icon.cluster { display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font: 700 12px/1 system-ui, sans-serif;
           border: 2px solid rgba(255, 255, 255, .95); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); cursor: pointer; }
.cluster-active { background: #0f766e; } .leaflet-marker-icon.cluster-historical { background: #8a5d31; border-radius: 6px; }

/* ----------------------------------------------------------- feedback form */
.form-page { max-width: 720px; }
.feedback-form { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-4); }
.feedback-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.feedback-form fieldset.invalid { border-color: var(--danger); }
.feedback-form legend { font-weight: 600; padding: 0 4px; }
.feedback-form label { display: flex; flex-direction: column; gap: var(--s-1); font-weight: 500; }
.feedback-form label.check { flex-direction: row; align-items: center; gap: var(--s-2); font-weight: 400; min-height: 32px; }
.feedback-form textarea, .feedback-form input[type=text], .feedback-form input[type=email], .feedback-form select { width: 100%; }
.feedback-form .hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
.feedback-form button { align-self: flex-start; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* --------------------------------- records, documents and forms (S7.9E) */
.record-types { gap: 6px; }
.record-types a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 999px; text-decoration: none;
                  border: 1px solid var(--line); background: var(--surface); }
.record-types a.current { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); font-weight: 600; }
.year-index { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin: var(--s-2) 0; }
.year-index a { display: inline-block; padding: 6px 2px; }
table.records tr.year-row th { background: var(--surface-2); color: var(--ink); font-size: .9rem; text-transform: none; letter-spacing: 0;
                               padding: 6px 12px; position: static; }
.empty-state { border: 1px dashed var(--control-border); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); }
.empty-state p { margin: 4px 0; }
.record-glance { margin-top: var(--s-2); }
.req { font-size: var(--fs-label); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--danger);
       border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; vertical-align: middle; }
.error-summary { border-left: 4px solid var(--danger); margin: var(--s-4) 0; }
.error-summary h2 { font-size: 1.05rem; margin: 0 0 6px; color: var(--danger); }
.error-summary ul { margin: 0 0 6px; padding-left: 1.2rem; }
.error-summary a { color: var(--danger); font-weight: 600; }
.error-summary p { margin: 0; color: var(--ink); }
.feedback-form .field-error { display: block; margin-top: 2px; }
.label-line { display: block; }
.success-box p { margin: 0; }
.doc-status.is-warn { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: var(--radius); }
.doc-result p { margin: 4px 0; } .doc-result { margin: var(--s-4) 0; }
form.doc-get { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.doc-loading:empty { display: none; }
@media (max-width: 640px) {
  table.data.stack tr.year-row { border: 0; background: transparent; padding: 0; margin: var(--s-4) 0 var(--s-2); }
  table.data.stack tr.year-row th { display: block; border-radius: var(--radius); }
}

/* SMARTS documents panel (S7.8B) */
.doc-status { margin: .2rem 0 .6rem; }
h3.doc-group { margin: 1.1rem 0 .3rem; font-size: 1rem; }
table.docs td:last-child { white-space: nowrap; }
tr.doc-earlier-head td { background: transparent; padding-top: .6rem; }
form.doc-get { margin: 0; }
form.doc-get button { font-size: .85rem; min-height: 36px; padding: 4px 12px; }
details.doc-fallback { margin-top: .8rem; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------ S7.9F accessibility fixes */
/* links inside status boxes take the box's own text colour (accent on --ok-bg was 4.48:1) */
.coverage-ok a { color: var(--ok); } .warn a { color: var(--warn); }
/* WCAG 2.5.8: short standalone and listed text links get a 24 px tall target, and wrapped link lists 24 px lines */
.crumbs a, .glance-item dd a, table.data td a, .note a, .source-line a, .doc-get a, .examples a, .link-line a { padding-block: 5px; }
.crumbs, .glance-item dd, table.data td.small, .link-line { line-height: 1.75; }
/* stacked tables: the visible column label is decorative; screen readers use the real column header (roles: site.js) */
@media (max-width: 640px) {
  table.data.stack td::before { content: attr(data-label); content: attr(data-label) / ""; }
  table.docs.stack td:last-child { white-space: normal; }          /* "Over 40 MB: open in SMARTS" wraps at 320px */
}
/* map: "skip past the markers" link, shown when focused */
.map-skip a { position: absolute; left: -9999px; }
.map-skip a:focus { position: static; display: inline-flex; align-items: center; min-height: var(--target); padding: 0 12px;
                    background: var(--surface); color: var(--accent); border-radius: 4px; font-weight: 600; }
