/* ==========================================================================
   LEVELSTAT — shared stylesheet
   ========================================================================== */

:root {
  --c-bg: #f6f9fb;
  --c-surface: #ffffff;
  --c-surface-alt: #eef4f8;
  --c-border: #e2e8f0;
  --c-border-strong: #cbd5e1;
  --c-text: #0f172a;
  --c-text-muted: #475569;
  --c-text-faint: #94a3b8;
  --c-primary: #0369a1;
  --c-primary-hover: #075985;
  --c-accent: #06b6d4;
  --c-accent-soft: #cffafe;
  --c-success: #10b981;
  --c-warning: #f59e0b;
  --c-danger: #ef4444;
  --c-temp: #f97316;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 20px 40px -24px rgba(15, 23, 42, 0.28);

  --container: min(1120px, 100% - 2rem);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--c-primary);
  text-decoration: none;
}
a:hover {
  color: var(--c-primary-hover);
  text-decoration: underline;
}

h1,
h2,
h3 {
  color: var(--c-text);
  /* 1.2 was tight enough that descenders (y, g, p) visually clipped
     on large display type — especially on elements using
     background-clip: text. 1.25 gives them breathing room. */
  line-height: 1.25;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2rem, 1.2rem + 3vw, 3.25rem);
  letter-spacing: -0.02em;
  font-weight: 700;
}

h2 {
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2rem);
  letter-spacing: -0.01em;
  font-weight: 700;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--c-surface-alt);
  color: var(--c-primary-hover);
}

.container {
  width: var(--container);
  margin-inline: auto;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-primary);
  margin: 0 0 0.75em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.625rem 1.1rem;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease,
    color 120ms ease, transform 120ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.btn--sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
}
.btn--lg {
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
}

.btn--primary {
  background: var(--c-primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--c-primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn--outline {
  background: transparent;
  color: var(--c-primary);
  border-color: var(--c-border-strong);
}
.btn--outline:hover {
  background: var(--c-surface);
  border-color: var(--c-primary);
  color: var(--c-primary-hover);
  text-decoration: none;
}

.btn--ghost {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn--ghost:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
  text-decoration: none;
}

/* ---------- Header / Brand / Nav ---------- */
.site-header,
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner,
.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--c-primary);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover {
  color: var(--c-primary-hover);
  text-decoration: none;
}
.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--c-primary);
}
.brand__name {
  color: var(--c-text);
  letter-spacing: 0.08em;
}

.site-nav,
.app-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-lookup {
  display: inline-flex;
  align-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.2rem 0.25rem 0.2rem 0.75rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.site-lookup:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}
.site-lookup input {
  font: inherit;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0.35rem 0.25rem;
  width: 9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text);
}
.site-lookup input::placeholder {
  color: var(--c-text-faint);
  letter-spacing: 0.04em;
}
.site-lookup .btn {
  padding: 0.4rem 0.75rem;
}
.site-lookup--compact input {
  width: 8rem;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(3rem, 2rem + 6vw, 6rem) 0 4rem;
  background:
    radial-gradient(
      1200px 420px at 10% -10%,
      rgba(6, 182, 212, 0.18),
      transparent 60%
    ),
    radial-gradient(
      900px 400px at 90% 0%,
      rgba(3, 105, 161, 0.15),
      transparent 60%
    ),
    linear-gradient(180deg, #ffffff, var(--c-bg) 80%);
  overflow: hidden;
}

.hero__inner {
  max-width: 760px;
}

.hero__title {
  margin-top: 0.25em;
  margin-bottom: 0.5em;
}

.hero__title-accent {
  display: block;
  /* Tiny padding keeps descenders (y, g) inside the background-clip
     mask; without it, the gradient text fill trims them. */
  padding-bottom: 0.1em;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lede {
  font-size: 1.125rem;
  color: var(--c-text-muted);
  max-width: 58ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 1rem;
}

.hero__hint {
  font-size: 0.9rem;
  color: var(--c-text-faint);
  margin-top: 0.75rem;
}

.hero__waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  color: var(--c-primary);
  pointer-events: none;
}
.hero__waves svg {
  display: block;
  width: 100%;
  height: 90px;
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(3rem, 2rem + 4vw, 5rem) 0;
}
.section--alt {
  background: var(--c-surface);
  border-block: 1px solid var(--c-border);
}
.section__title {
  max-width: 24ch;
}
.section__lede {
  max-width: 64ch;
  color: var(--c-text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* ---------- Features ---------- */
.feature-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.feature-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease,
    border-color 180ms ease;
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--c-border-strong);
}
.feature-card h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}
.feature-card p {
  color: var(--c-text-muted);
  margin-bottom: 0;
}
.feature-card__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--c-accent-soft);
  color: var(--c-primary);
}
.feature-card__icon svg {
  width: 22px;
  height: 22px;
}

/* ---------- Steps ---------- */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.step {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
}
.step h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}
.step p {
  color: var(--c-text-muted);
  margin: 0;
}
.step__num {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

.steps__footer {
  margin: 2rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  color: var(--c-text-muted);
  font-size: 0.95rem;
}
.steps__footer > span {
  max-width: 40ch;
}

/* ---------- Deep-dive / long-form content ---------- */
.prose {
  max-width: 68ch;
  color: var(--c-text);
}
.prose p {
  color: var(--c-text-muted);
}
.prose h3 {
  margin-top: 1.75rem;
  font-size: 1.15rem;
}
.prose ul {
  margin: 0.5rem 0 1.25rem;
  padding-left: 1.2rem;
  color: var(--c-text-muted);
}
.prose ul li {
  margin-bottom: 0.4rem;
}

.figure {
  margin: 2rem 0;
}
/* Two or more figures shown side-by-side. Collapses to a single
   column when the viewport gets tight. */
.figure-pair {
  display: grid;
  gap: 1.5rem 2rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  margin: 2rem 0;
}
.figure-pair .figure {
  margin: 0;
}
.figure__media {
  aspect-ratio: 16 / 9;
  background: var(--c-surface-alt);
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  color: var(--c-text-muted);
  font-size: 0.9rem;
  overflow: hidden;
}
/* Once a real image lands, drop the placeholder chrome (dashed border,
   forced 16:9) and let the image display at its natural aspect. */
.figure__media:has(img) {
  aspect-ratio: auto;
  background: transparent;
  border: 0;
  padding: 0;
  max-width: 800px;
  margin-inline: auto;
}
.figure__media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}
.figure figcaption {
  margin-top: 0.75rem;
  color: var(--c-text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- CTA ---------- */
.cta {
  padding: clamp(3rem, 2rem + 4vw, 5rem) 0;
  background: linear-gradient(
    135deg,
    #ecfeff 0%,
    #e0f2fe 50%,
    #f0f9ff 100%
  );
}
.cta__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.cta h2 {
  margin-bottom: 0.25em;
}
.cta p {
  color: var(--c-text-muted);
  margin: 0;
}

/* Enrollment CTA — a brighter, premium-feeling variant of the
   standard .cta band. A single highlight sweeps left-to-right on a
   slow cadence to draw the eye toward the "Enroll" button without
   being distracting. Respects prefers-reduced-motion. */
.cta--enroll {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(
      1000px 320px at 85% 0%,
      rgba(6, 182, 212, 0.28),
      transparent 65%
    ),
    linear-gradient(135deg, #e0f7fa 0%, #e0f2fe 45%, #ede9fe 100%);
  border-block: 1px solid #bae6fd;
}
.cta--enroll::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 0%,
    transparent 38%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 62%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: cta-shimmer 5.5s ease-in-out 1.5s infinite;
  pointer-events: none;
}
.cta--enroll .cta__inner {
  position: relative;
  z-index: 1;
}
.cta--enroll h2 {
  /* Same descender-clipping guard as .hero__title-accent. */
  padding-bottom: 0.1em;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cta--enroll .btn--primary {
  box-shadow: 0 10px 24px -12px rgba(3, 105, 161, 0.55);
  transition: transform 150ms ease, box-shadow 150ms ease,
    background-color 120ms ease;
}
.cta--enroll .btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -12px rgba(3, 105, 161, 0.6);
}

.btn__arrow {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  transition: transform 150ms ease;
}
.btn:hover .btn__arrow {
  transform: translateX(2px);
}

@keyframes cta-shimmer {
  0% {
    transform: translateX(-100%);
  }
  45% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cta--enroll::before {
    animation: none;
    display: none;
  }
  .cta--enroll .btn--primary {
    transition: none;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  padding: 1.5rem 0;
  margin-top: auto;
}
.site-footer--app {
  margin-top: 3rem;
}
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--c-text-muted);
  font-size: 0.92rem;
}
.site-footer__inner p {
  margin: 0;
}

/* ==========================================================================
   App / data page
   ========================================================================== */

.page-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  padding: clamp(1.5rem, 1rem + 2vw, 3rem) 0 3rem;
  display: grid;
  gap: 1.5rem;
}

.site-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-summary__heading h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.5vw, 2.5rem);
  margin-bottom: 0.15em;
}
.site-summary__location {
  color: var(--c-text-muted);
  margin: 0;
}

.site-summary__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.site-summary__status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--c-text-muted);
}

.unit-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.unit-switcher__field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 0.25rem 0.35rem 0.25rem 0.85rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.unit-switcher__field:hover {
  border-color: var(--c-border-strong);
}
.unit-switcher__field:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
}
.unit-switcher__label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--c-text-muted);
}
.unit-switcher__field select {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text);
  background: transparent;
  border: 0;
  padding: 0.25rem 1.4rem 0.25rem 0.25rem;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23475569' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--c-text-faint);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}
.status-dot--ok {
  background: var(--c-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.status-dot--warn {
  background: var(--c-warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}
.status-dot--offline {
  background: var(--c-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}
/* Signals to users that the status pill is interactive — native
   browser tooltip appears on hover via the `title` attribute set
   in data-page.js. */
.site-summary__status[title] {
  cursor: help;
}
.site-summary__updated::before {
  content: "·";
  margin: 0 0.35rem;
  color: var(--c-text-faint);
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
}
.stat-card--primary {
  background: linear-gradient(180deg, #f0f9ff, #ffffff 60%);
  border-color: #bae6fd;
}
.stat-card__label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.stat-card__value {
  font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
  color: var(--c-text);
}
.stat-card__value--small {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
}
.stat-card__unit {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-left: 0.25rem;
}
.stat-card__delta {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--c-text-muted);
  min-height: 1.2em;
}
.stat-card__delta--up {
  color: var(--c-success);
}
.stat-card__delta--down {
  color: var(--c-danger);
}
/* Stacked-deltas container. Below the top line ("vs previous
   reading"), the 24h / 7d comparison lines read as secondary
   context — smaller, tighter spacing, dimmer. The `--muted`
   variant intentionally defeats the up/down color classes so the
   trend for longer windows doesn't pull focus from the most-recent
   change, which is typically the actionable one. */
.stat-card__deltas {
  display: grid;
  gap: 0.15rem;
}
.stat-card__deltas .stat-card__delta {
  margin: 0;
}
.stat-card__deltas .stat-card__delta + .stat-card__delta {
  margin-top: 0.05rem;
}
.stat-card__delta--muted,
.stat-card__delta--muted.stat-card__delta--up,
.stat-card__delta--muted.stat-card__delta--down {
  color: var(--c-text-faint, var(--c-text-muted));
  font-size: 0.78rem;
}

/* Third stat card: current weather + 72h rainfall forecast.
   Replaces the retired "Last reading" card. Icon sits left of the
   temperature in a flex row so the value reads the same size as the
   other cards' values but with pictographic context. Hidden wholesale
   when the weather backend fails — no placeholder UI, no pretending. */
.stat-card--weather .stat-card__weather-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.stat-card__weather-icon {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  color: var(--c-primary);
  align-self: center;
}
.stat-card__weather-icon[data-condition="sunny"] {
  color: #f59e0b;
}
.stat-card__weather-icon[data-condition="night-clear"],
.stat-card__weather-icon[data-condition="night-partly-cloudy"] {
  color: #6366f1;
}
.stat-card__weather-icon[data-condition="thunderstorm"] {
  color: #a855f7;
}
.stat-card__weather-icon[data-condition="snow"],
.stat-card__weather-icon[data-condition="fog"] {
  color: #64748b;
}
.stat-card__value--weather {
  margin: 0;
}
.stat-card--hidden {
  display: none;
}

/* 72h rainfall forecast below the current temp. Summary text is the
   quick read ("0.4 in of rain expected over next 72h"); the sparkline
   shows distribution so an operator can see whether the rain hits
   tonight or two days out. Thin — one hour per bar, 72 bars wide. */
.weather-forecast {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.35rem;
}
.weather-forecast__summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--c-text-muted);
}
.weather-forecast__sparkline {
  width: 100%;
  height: 1.5rem;
  overflow: hidden;
}
.weather-sparkline__svg {
  display: block;
  width: 100%;
  height: 100%;
}
.weather-sparkline__bar {
  fill: var(--c-accent, #06b6d4);
}
.weather-sparkline__baseline {
  stroke: var(--c-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-card,
.readings-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chart-card__header,
.readings-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chart-card__header h2,
.readings-card__header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.chart-card__header p,
.readings-card__header p {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

.chart-card__chart {
  width: 100%;
  /* Container dimensions are chosen explicitly here; renderChart()
     measures the box at render time and builds an SVG viewBox that
     matches those exact pixel dimensions, so the chart fills the card
     with no letterboxing regardless of aspect ratio. A ResizeObserver
     re-renders on any size change (including phone rotation). */
  height: 260px;
  max-height: 45vh;
  touch-action: none;
}
.chart-card__chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  cursor: crosshair;
}
.chart-card__caption {
  margin: 0.75rem 0 0;
  color: var(--c-text-muted);
  font-size: 0.85rem;
  min-height: 1.3em;
}
.chart-card__caption--hover {
  color: var(--c-text);
  font-weight: 500;
}

.chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  align-items: center;
}
.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  white-space: nowrap;
}
.chart-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--c-primary);
  display: inline-block;
}
.chart-legend__item--temp .chart-legend__swatch {
  background: var(--c-temp);
}

/* Time-range segmented control in the chart card header. Compact
   pill group; active button flips to the primary brand colour so
   the current range reads at a glance without needing a label. */
.chart-range {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px;
  background: var(--c-surface-alt, #f1f5f9);
  border: 1px solid var(--c-border, #e2e8f0);
}
.chart-range__btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.chart-range__btn:hover {
  color: var(--c-text);
}
.chart-range__btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
.chart-range__btn--active {
  background: var(--c-primary);
  color: #fff;
}
.chart-range__btn--active:hover {
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

.readings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--c-surface);
}
.readings-table th,
.readings-table td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.readings-table th {
  background: var(--c-surface-alt);
  color: var(--c-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.readings-table tbody tr:last-child td {
  border-bottom: 0;
}
.readings-table__empty {
  text-align: center;
  color: var(--c-text-muted);
  font-style: italic;
  padding: 1.25rem;
}

/* Inline delta next to a cell value — arrow + magnitude in smaller,
   slightly de-emphasized text. Up/down colours match the stat-card
   convention (green up, red down) so the full dashboard reads
   consistently even though direction doesn't always map to
   "good/bad" for water level. */
.readings-table__delta {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.75em;
  font-weight: 500;
  color: var(--c-text-muted);
  white-space: nowrap;
}
.readings-table__delta--up {
  color: var(--c-success);
}
.readings-table__delta--down {
  color: var(--c-danger);
}

.disclaimer {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.disclaimer p {
  margin: 0;
}

/* ---------- Not-found view ---------- */
.not-found {
  max-width: 640px;
  margin-inline: auto;
  text-align: center;
  padding: clamp(2rem, 1rem + 4vw, 4rem) 1.5rem;
}
.not-found__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-accent-soft);
  color: var(--c-primary);
}
.not-found__icon svg {
  width: 40px;
  height: 40px;
}
.not-found h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.5vw, 2.5rem);
  margin-top: 0.25em;
  margin-bottom: 0.5em;
}
.not-found__lede {
  color: var(--c-text-muted);
  font-size: 1.05rem;
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}
.not-found__lede code {
  background: var(--c-surface-alt);
  padding: 0.1em 0.45em;
  border-radius: var(--radius-sm);
  font-size: 0.95em;
  color: var(--c-primary-hover);
}
.not-found__tips {
  margin: 1.75rem auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-align: left;
  max-width: 52ch;
  box-shadow: var(--shadow-sm);
}
.not-found__tips h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-primary);
  margin: 0 0 0.75rem;
}
.not-found__tips ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--c-text);
}
.not-found__tips li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
.not-found__tips li:last-child {
  margin-bottom: 0;
}
.not-found__support {
  color: var(--c-text-muted);
  max-width: 52ch;
  margin: 0.5rem auto 1.5rem;
}
.not-found__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ---------- Small screens ---------- */
/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  /* Free up the top of the viewport — data is the focus, the brand bar
     should scroll away with the rest of the content. */
  .site-header,
  .app-header {
    position: static;
    backdrop-filter: none;
    background: var(--c-surface);
  }

  .site-header__inner,
  .app-header__inner {
    flex-wrap: wrap;
    gap: 0.6rem;
  }
  .site-nav,
  .app-nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .site-lookup {
    flex: 1 1 auto;
    min-width: 0;
  }
  .site-lookup input {
    width: 100%;
    min-width: 0;
  }
  .site-lookup--compact input {
    width: 100%;
  }

  /* Hero CTAs stack vertically so they don't shrink to unreadable sizes. */
  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero__actions .btn {
    justify-content: center;
  }

  /* Dashboard layout density. */
  .app-main {
    padding: 1rem 0 2rem;
    gap: 1rem;
  }
  .site-summary__controls {
    align-items: stretch;
    width: 100%;
  }
  .unit-switcher {
    justify-content: flex-start;
    width: 100%;
  }
  .unit-switcher__field {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    justify-content: space-between;
  }
  .unit-switcher__field select {
    flex: 1 1 auto;
    min-width: 0;
  }

  .chart-card,
  .readings-card {
    padding: 1rem;
  }
  .chart-card__chart {
    height: 240px;
    max-height: none;
  }
  .chart-card__header {
    gap: 0.5rem;
  }
  .chart-legend {
    width: 100%;
    justify-content: flex-start;
  }

  .stat-card {
    padding: 1rem 1.1rem;
  }
  .stat-card__value {
    font-size: 2rem;
  }
}

/* ---------- Landscape phones (wide and short) ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .app-main {
    padding: 0.75rem 0 1.5rem;
    gap: 0.85rem;
  }
  .chart-card__chart {
    height: 200px;
  }
}
