/* Cumbria Flood Tracker — shared visual system */
:root {
  color-scheme: dark;
  --bg: #07141c;
  --bg-deep: #041016;
  --surface: rgba(14, 37, 49, 0.88);
  --surface-solid: #0e2531;
  --surface-raised: #14313e;
  --surface-soft: rgba(121, 210, 221, 0.07);
  --line: rgba(164, 222, 229, 0.15);
  --line-strong: rgba(164, 222, 229, 0.28);
  --text: #edf8f7;
  --muted: #a8c1c4;
  --brand: #45d0d0;
  --brand-bright: #8ce8e3;
  --brand-deep: #087b82;
  --blue: #6bbcf5;
  --good: #62d69b;
  --warning: #ffbd59;
  --danger: #ff6b73;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 18px 50px rgba(0, 8, 13, 0.3);
  --shadow-soft: 0 8px 24px rgba(0, 8, 13, 0.2);
}

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

html { min-height: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI Variable", "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 4%, rgba(42, 151, 163, 0.18), transparent 28rem),
    radial-gradient(circle at 92% 30%, rgba(39, 104, 149, 0.14), transparent 32rem),
    linear-gradient(160deg, var(--bg-deep) 0%, var(--bg) 45%, #091923 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(133, 213, 221, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(133, 213, 221, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

::selection { color: #041014; background: var(--brand-bright); }

a { color: var(--brand-bright); text-decoration: none; }
a:hover { color: #c3fffa; text-decoration: none; }

img { max-width: 100%; }

h1, h2, h3, h4 {
  margin: 0 0 0.65em;
  line-height: 1.16;
  letter-spacing: -0.025em;
  color: #f7ffff;
}

h1 {
  max-width: 850px;
  margin-top: 0.25rem;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 760;
}

h2 { font-size: clamp(1.25rem, 2.5vw, 1.65rem); font-weight: 700; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
strong { color: #fff; }

.container {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
  padding: 0;
}

.site-main { flex: 1; }
.site-main > .container { padding-block: clamp(2rem, 5vw, 4.5rem); }

.site-main h1:not(.hero h1)::before {
  content: "";
  display: block;
  width: 52px;
  height: 4px;
  margin-bottom: 1rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--blue));
}

.text-muted { color: var(--muted) !important; opacity: 1 !important; }

/* Homepage hero */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 0 2rem;
  padding: clamp(2rem, 7vw, 5.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(90deg, rgba(5, 22, 30, 0.96) 0%, rgba(7, 30, 40, 0.86) 54%, rgba(7, 30, 40, 0.25) 100%),
    url("../images/flood-background.jpg") center 58% / cover;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "LIVE CUMBRIA DATA";
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(140, 232, 227, 0.32);
  border-radius: 999px;
  color: var(--brand-bright);
  background: rgba(4, 18, 25, 0.72);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  backdrop-filter: blur(10px);
}

.hero h1 {
  max-width: 690px;
  margin: 0 0 1rem;
  font-size: clamp(2.7rem, 7vw, 5.4rem);
  font-weight: 790;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.hero-lead { max-width: 670px !important; font-size: clamp(1.05rem, 2vw, 1.25rem); color: #d8ecec; }
.hero-sub { max-width: 610px !important; color: var(--muted); font-size: 0.95rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.6rem; }

/* Buttons */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.65rem 1.05rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  background: rgba(139, 211, 218, 0.09);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:hover, button.btn:hover {
  transform: translateY(-2px);
  border-color: rgba(140, 232, 227, 0.6);
  color: #fff;
  background: rgba(139, 211, 218, 0.16);
  box-shadow: 0 8px 20px rgba(0, 9, 14, 0.22);
}

.btn-primary {
  border-color: transparent;
  color: #042027;
  background: linear-gradient(135deg, var(--brand-bright), var(--brand));
  box-shadow: 0 8px 24px rgba(69, 208, 208, 0.2);
}
.btn-primary:hover { color: #03191d; background: linear-gradient(135deg, #b8fffa, #60dfdc); }
.btn-secondary { background: var(--surface-raised); }
.btn-outline, .btn-ghost { background: transparent; }
.btn-small { min-height: 34px; padding: 0.45rem 0.75rem; font-size: 0.78rem; }
.btn-pill { white-space: nowrap; }

/* Cards and content groups */
.card {
  position: relative;
  margin: 0 0 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(18, 46, 59, 0.94), rgba(10, 29, 39, 0.92));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.card-grid > .card {
  height: 100%;
  margin: 0;
  transition: transform 180ms ease, border-color 180ms ease;
}

.card-grid > .card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.card-grid > .card h2::before {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  margin-bottom: 0.9rem;
  border-radius: 99px;
  background: var(--brand);
}
.card p:last-child { margin-bottom: 0; }

/* Town live-gauge dashboard */
.town-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 1.25rem;
  align-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 20%, rgba(140, 232, 227, 0.18), transparent 16rem),
    linear-gradient(145deg, rgba(18, 54, 68, 0.96), rgba(8, 27, 38, 0.94));
}

.town-actions {
  display: grid;
  gap: 0.65rem;
  align-content: center;
}

.town-actions .input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
}

.town-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.mini-card {
  padding: 1.15rem;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
  box-shadow: var(--shadow-soft);
}

.mini-card .label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-card .value {
  display: block;
  margin: 0.65rem 0 0.3rem;
  color: #fff;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
}

.mini-card .hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.town-severity-label {
  font-size: clamp(1.2rem, 2.4vw, 1.8rem) !important;
  line-height: 1.05 !important;
}

.town-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(18, 46, 59, 0.94), rgba(10, 29, 39, 0.92));
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 { margin-bottom: 0.25rem; }
.panel-head p { margin: 0; color: var(--muted); font-size: 0.93rem; }

.tag {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 30px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--brand-bright);
  background: rgba(140, 232, 227, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.town-list { display: grid; }

.town-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(164, 222, 229, 0.1);
  color: var(--text);
}

.town-item:last-child { border-bottom: 0; }
.town-item:hover { background: rgba(140, 232, 227, 0.045); color: #fff; }

.town-item .icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(140, 232, 227, 0.11);
  font-size: 1.25rem;
}

.town-item .icon img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.town-item h3 {
  margin: 0 0 0.18rem;
  font-size: 1rem;
}

.town-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.reading {
  text-align: right;
  color: var(--brand-bright);
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.1;
}

.reading small {
  display: block;
  max-width: 150px;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.trend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.45rem;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(140, 232, 227, 0.2);
  border-radius: 999px;
  color: #d8fffb;
  background: rgba(140, 232, 227, 0.08);
  font-size: 0.76rem;
  font-weight: 800;
}

.sparkline-wrap {
  width: min(100%, 230px);
  height: 46px;
  margin: 0.35rem 0 0.45rem;
  padding: 0.35rem;
  border: 1px solid rgba(164, 222, 229, 0.12);
  border-radius: 12px;
  background:
    linear-gradient(rgba(164, 222, 229, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(164, 222, 229, 0.035) 1px, transparent 1px),
    rgba(3, 17, 24, 0.28);
  background-size: 100% 50%, 33.333% 100%, auto;
}

.sparkline {
  display: block;
  width: 100%;
  height: 100%;
}

.sparkline polyline {
  fill: none;
  stroke: var(--brand-bright);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.sparkline-empty,
.sparkline-caption {
  margin: 0.3rem 0 0.35rem !important;
  color: var(--muted);
  font-size: 0.78rem !important;
}

.sparkline-caption {
  color: #c8e5e8;
  font-weight: 750;
}

/* Rainfall gauge detail page */
.rain-gauge-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 1.25rem;
  align-items: center;
  background:
    radial-gradient(circle at 92% 20%, rgba(106, 188, 245, 0.16), transparent 16rem),
    linear-gradient(145deg, rgba(18, 48, 66, 0.96), rgba(8, 27, 38, 0.94));
}

.rain-gauge-meta {
  display: grid;
  gap: 0.65rem;
  align-content: center;
  color: var(--muted);
}

.rain-gauge-meta span {
  display: block;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(3, 17, 24, 0.24);
}

.rain-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.rain-summary-value {
  font-size: clamp(1.15rem, 2.7vw, 1.85rem) !important;
  line-height: 1.1 !important;
}

.rain-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.rain-panel-body {
  padding: 1.25rem;
}

.rain-chart {
  width: 100%;
  min-height: 190px;
  padding: 0.8rem;
  border: 1px solid rgba(164, 222, 229, 0.13);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(164, 222, 229, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(164, 222, 229, 0.035) 1px, transparent 1px),
    rgba(3, 17, 24, 0.28);
  background-size: 100% 25%, 20% 100%, auto;
}

.rain-chart svg {
  display: block;
  width: 100%;
  height: 170px;
}

.rain-chart rect {
  fill: var(--brand-bright);
  opacity: 0.86;
}

.rain-chart line {
  stroke: rgba(164, 222, 229, 0.24);
  stroke-width: 1;
}

.rain-chart-empty {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(3, 17, 24, 0.22);
}

.linked-town-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.rain-readings-table table {
  min-width: 680px;
}

.severity-1 .reading { color: var(--danger); }
.severity-2 .reading { color: var(--warning); }
.severity-3 .reading { color: var(--brand-bright); }

.note {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 189, 89, 0.28);
  border-radius: var(--radius);
  color: #ffe0ad;
  background: rgba(255, 189, 89, 0.08);
  font-size: 0.95rem;
}

.small-print {
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .town-hero,
  .town-grid,
  .rain-gauge-hero,
  .rain-detail-grid {
    grid-template-columns: 1fr;
  }

  .town-stat-grid,
  .rain-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .town-stat-grid,
  .rain-summary-grid {
    grid-template-columns: 1fr;
  }

  .town-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .reading {
    grid-column: 2;
    text-align: left;
  }

  .sparkline-wrap {
    width: 100%;
  }
}

.highlight-card {
  overflow: hidden;
  padding-right: clamp(1.5rem, 8vw, 6rem);
  border-color: rgba(69, 208, 208, 0.27);
  background:
    radial-gradient(circle at 96% 20%, rgba(69, 208, 208, 0.17), transparent 13rem),
    linear-gradient(135deg, rgba(17, 58, 68, 0.96), rgba(9, 29, 39, 0.96));
}

.feature-list { display: grid; gap: 0.55rem; margin: 1rem 0 1.5rem; padding: 0; list-style: none; }
.feature-list li { position: relative; padding-left: 1.75rem; color: #c9dcdd; }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--brand-bright); font-weight: 900; }

/* Personal dashboard */
.dashboard-heading, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.dashboard-heading { align-items: flex-end; margin-bottom: 1.5rem; }
.dashboard-heading h1 { margin-bottom: 0.35rem; }
.dashboard-heading p:last-child, .section-heading h2 { margin-bottom: 0; }
.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--brand-bright);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.dashboard-hero + .card-grid { grid-template-columns: minmax(0, 2fr) minmax(250px, 1fr); }
.count-badge {
  display: inline-flex;
  min-width: 1.8rem;
  height: 1.8rem;
  align-items: center;
  justify-content: center;
  margin-left: 0.35rem;
  border-radius: 999px;
  color: var(--brand-bright);
  background: rgba(69, 208, 208, 0.11);
  font-size: 0.76rem;
  vertical-align: middle;
}
.data-health {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(2, 17, 24, 0.35);
  font-size: 0.8rem;
}
.data-health-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 0.32rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(98, 214, 155, 0.1); }
.data-health.is-stale { color: #f3d5aa; border-color: rgba(255, 189, 89, 0.32); background: rgba(255, 189, 89, 0.07); }
.data-health.is-stale .data-health-dot { background: var(--warning); box-shadow: 0 0 0 4px rgba(255, 189, 89, 0.1); }
.watch-empty { display: flex; align-items: center; gap: 1rem; margin-top: 1.2rem; padding: 1.1rem; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); }
.watch-empty h3, .watch-empty p { margin: 0; }
.watch-empty-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; color: var(--brand-bright); background: var(--surface-soft); font-size: 1.4rem; }
.watch-list { display: grid; gap: 0.55rem; margin-top: 1rem; }
.watch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: rgba(2, 17, 24, 0.38);
}
.watch-row::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--good); }
.watch-row:hover { color: #fff; border-color: var(--line-strong); background: rgba(69, 208, 208, 0.06); }
.watch-row > span { min-width: 0; display: flex; flex-direction: column; }
.watch-row strong { overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
.watch-row small { color: var(--muted); font-size: 0.68rem; }
.watch-row-status { flex: 0 0 auto; align-items: flex-end; text-align: right; font-size: 0.82rem; font-weight: 750; }
.watch-row.is-alert::before { background: var(--blue); }
.watch-row.is-warning::before { background: var(--warning); }
.watch-row.is-severe::before { background: var(--danger); }
.watch-row.is-stale::before { background: var(--muted); }

/* Status figures */
.alerts-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.summary-item {
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(2, 17, 24, 0.4);
}

.summary-label { color: var(--muted); font-size: 0.78rem; font-weight: 650; line-height: 1.35; }
.summary-value { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 780; line-height: 1; letter-spacing: -0.04em; }
.summary-value.summary-severe { color: var(--danger); }
.summary-value.summary-warning { color: var(--warning); }
.summary-value.summary-alert { color: var(--blue); }

/* Forms */
.form-card {
  width: 100%;
  max-width: 520px;
  margin: 1rem 0 0;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

label { color: #d9e9e9; font-size: 0.88rem; font-weight: 650; }
.form-card label { display: block; margin-bottom: 1rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: 44px;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: rgba(2, 15, 21, 0.65);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

select { color-scheme: dark; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: rgba(2, 15, 21, 0.9);
  box-shadow: 0 0 0 3px rgba(69, 208, 208, 0.13);
}
input::placeholder, textarea::placeholder { color: #789498; }
.form-note { margin-top: 1rem; color: var(--muted); font-size: 0.84rem; }

/* Unified search and related journeys */
.search-heading { margin-bottom: 1rem; }
.search-heading h1 { margin-bottom: 0.35rem; }
.site-search, .hero-search {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.site-search > label, .hero-search > label { display: block; margin-bottom: 0.4rem; }
.site-search-row, .hero-search > div { display: flex; align-items: flex-end; gap: 0.65rem; }
.site-search-row input, .hero-search input { margin-top: 0; }
.site-search-row .btn, .hero-search .btn { min-height: 44px; }
.hero-search { width: min(100%, 680px); margin: 1.4rem auto 0; text-align: left; background: rgba(4, 21, 27, 0.82); backdrop-filter: blur(8px); }
.search-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.75rem 0 1rem; color: var(--muted); }
.search-summary strong { color: var(--text); }
.search-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.search-group { margin: 0; }
.search-group h2 { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.search-group h2 span { min-width: 1.7rem; padding: 0.2rem 0.5rem; border-radius: 999px; color: var(--brand-bright); background: var(--surface-soft); font-size: 0.75rem; text-align: center; }
.search-results { display: grid; gap: 0.45rem; }
.search-results a { display: flex; flex-direction: column; gap: 0.18rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); background: rgba(2, 17, 24, 0.3); }
.search-results a:hover { border-color: var(--line-strong); background: rgba(69, 208, 208, 0.06); }
.search-results small { color: var(--muted); font-size: 0.75rem; }
.history-presets, .context-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.history-presets a, .context-links a { padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 0.78rem; }
.history-presets a:hover, .context-links a:hover { color: var(--text); border-color: var(--brand); }
.context-links { margin: 1rem 0 0; }
.breadcrumbs { margin: 0 0 1rem; color: var(--muted); font-size: 0.76rem; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.35rem; }
.breadcrumbs li:not(:last-child)::after { content: "/"; color: #668085; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs [aria-current="page"] { color: #cfe1e2; }

/* Standalone error and maintenance responses */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: radial-gradient(circle at 50% 0%, rgba(69, 208, 208, 0.12), transparent 38rem), var(--bg); }
.error-shell { width: min(100%, 760px); }
.error-brand { display: inline-flex; align-items: center; gap: 0.7rem; margin-bottom: 2.5rem; color: var(--text); font-weight: 800; }
.error-shell h1 { margin-bottom: 0.65rem; }
.error-lead { max-width: 620px; color: var(--muted); font-size: 1.05rem; }
.error-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1.25rem; }
.error-safety { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: #ffd3a0; font-size: 0.82rem; }
.cached-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 1rem; padding: 1rem; border: 1px solid rgba(255, 189, 89, 0.35); border-radius: var(--radius); background: rgba(255, 189, 89, 0.07); }
.cached-status h2, .cached-status p { margin: 0; }
.cached-status p { margin-top: 0.3rem; color: var(--muted); font-size: 0.78rem; }
.cached-counts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cached-counts span { min-width: 76px; padding: 0.5rem; border-radius: var(--radius-sm); background: rgba(2, 17, 24, 0.45); text-align: center; font-size: 0.72rem; }
.cached-counts strong { display: block; color: var(--text); font-size: 1.1rem; }
.cached-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.cached-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.cached-list li:last-child { border-bottom: 0; }
.cached-list span { color: var(--muted); text-align: right; }
.forecast-days { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:.75rem; margin:1rem 0; }
.forecast-day { min-height:190px; padding:1rem; border:1px solid var(--line); border-top:4px solid var(--muted); border-radius:var(--radius); background:var(--surface); }
.forecast-day.risk-2{border-top-color:var(--good)} .forecast-day.risk-3{border-top-color:var(--warning)} .forecast-day.risk-4{border-top-color:var(--danger)}
.forecast-day h2{margin:.2rem 0}.forecast-day time,.forecast-day p{color:var(--muted);font-size:.8rem}.forecast-intro{display:grid;grid-template-columns:2fr 1fr;gap:1.5rem}.forecast-intro dl{margin:0}.forecast-intro dl div{padding:.7rem;border-bottom:1px solid var(--line)}.forecast-intro dt{color:var(--muted);font-size:.72rem}.forecast-intro dd{margin:.2rem 0 0}.forecast-note{padding:.75rem 0;border-bottom:1px solid var(--line)}.forecast-note span{margin-left:.5rem;color:var(--warning)}.forecast-note p{margin:.3rem 0 0;color:var(--muted)}.forecast-sources{display:grid;grid-template-columns:repeat(2,1fr);gap:.75rem}.forecast-sources>div{padding:.8rem;border:1px solid var(--line);border-radius:var(--radius-sm)}.forecast-sources p{color:var(--muted);font-size:.8rem}.forecast-links{display:flex;gap:.6rem;margin:1rem 0}.forecast-disclaimer{padding:1rem;border:1px solid rgba(255,189,89,.35);border-radius:var(--radius);background:rgba(255,189,89,.07)}.forecast-disclaimer p{margin:.3rem 0 0;color:var(--muted)}.forecast-home-card{display:flex;align-items:center;justify-content:space-between;gap:1rem}.forecast-home-card h2{margin-bottom:.4rem}.forecast-home-card p{margin:.2rem 0}.forecast-home-card small{color:var(--muted)}

/* Keyboard access and visible system state */
.skip-link {
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 1000;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  color: #03181d;
  background: var(--brand-bright);
  font-weight: 800;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
:focus-visible {
  outline: 3px solid #ffcf70;
  outline-offset: 3px;
}
a:focus-visible, button:focus-visible { border-radius: 5px; }
.data-freshness {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0.9rem 0 1.2rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(98, 214, 155, 0.28);
  border-radius: var(--radius-sm);
  color: #cce5df;
  background: rgba(98, 214, 155, 0.07);
  font-size: 0.82rem;
}
.data-freshness-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #052017;
  background: var(--good);
  font-size: 0.72rem;
  font-weight: 900;
}
.data-freshness.is-stale, .data-freshness.is-unknown { color: #ffe5b9; border-color: rgba(255, 189, 89, 0.35); background: rgba(255, 189, 89, 0.08); }
.data-freshness.is-stale .data-freshness-icon, .data-freshness.is-unknown .data-freshness-icon { color: #271500; background: var(--warning); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 0.8rem !important;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
tbody td { padding: 0.85rem 0.8rem !important; border-bottom: 1px solid var(--line); }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: rgba(69, 208, 208, 0.055); }
tbody tr:last-child td { border-bottom: 0; }

/* Messages, badges and pills */
.alert { margin-bottom: 1rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; }
.alert-error { color: #ffd9dc; border: 1px solid rgba(255, 107, 115, 0.45); background: rgba(169, 35, 47, 0.22); }
.alert-success { color: #d9ffea; border: 1px solid rgba(98, 214, 155, 0.4); background: rgba(30, 128, 79, 0.2); }

.badge, .status-pill, .subscription-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 0.75rem;
}
.badge-success { color: var(--good); background: rgba(98, 214, 155, 0.11); }
.badge-muted { color: var(--muted); }
.badge-severe { color: var(--danger); background: rgba(255, 107, 115, 0.11); }
.badge-warning { color: var(--warning); background: rgba(255, 189, 89, 0.11); }
.badge-alert { color: var(--blue); background: rgba(107, 188, 245, 0.11); }
.subscription-grid, .account-status { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.75rem 0 1.25rem; }
.subscription-pill.disabled { opacity: 0.5; cursor: not-allowed; }
.status-pill.level { border-color: rgba(107, 188, 245, 0.5); }
.status-pill.login { border-color: rgba(98, 214, 155, 0.5); }
.status-pill.admin { border-color: rgba(255, 107, 115, 0.5); background: rgba(255, 107, 115, 0.08); }
.status-pill .label, .subscription-pill .label { font-weight: 750; }
.status-pill .value, .subscription-pill .note { color: var(--muted); }

/* Footer */
.site-footer {
  margin-top: 1rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(3, 14, 20, 0.6);
  font-size: 0.82rem;
}
.site-footer p { margin: 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.footer-actions { display: flex; align-items: center; gap: 1rem; }
.footer-link { padding: 0.35rem 0; border: 0; color: var(--muted); background: none; font: inherit; text-decoration: underline; cursor: pointer; }
.footer-link:hover { color: var(--text); }
.footer-status { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.footer-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(98, 214, 155, 0.1); }

.consent-banner {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 500;
  max-width: 920px;
  margin-inline: auto;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #071c24;
  box-shadow: 0 18px 60px rgba(0, 5, 8, 0.6);
}
.consent-banner:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.consent-banner p { max-width: 620px; margin: 0.25rem 0 0; color: var(--muted); font-size: 0.82rem; }
.consent-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; margin-top: 0.8rem; }
.consent-options label { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(2, 17, 24, 0.38); cursor: pointer; }
.consent-options input { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; margin-top: 0.12rem; accent-color: var(--brand); }
.consent-options span { display: flex; flex-direction: column; }
.consent-options small { margin-top: 0.12rem; color: var(--muted); font-size: 0.7rem; font-weight: 500; }
.consent-actions { display: flex; flex: 0 0 auto; gap: 0.55rem; }
.ad-slot { width: min(100%, 900px); min-height: 90px; display: grid; place-items: center; margin: 1.25rem auto; padding: 0.75rem; overflow: hidden; border: 1px dashed var(--line); border-radius: var(--radius-sm); color: var(--muted); background: rgba(2, 17, 24, 0.25); font-size: 0.75rem; text-align: center; }
.ad-slot .adsbygoogle { width: 100%; min-height: 90px; }
.readings-table { margin-top: 1rem; }
.readings-table summary { color: var(--brand-bright); font-weight: 750; cursor: pointer; }
.table-scroll { margin-top: 0.75rem; overflow-x: auto; }
.table-scroll:focus-visible { outline: 3px solid #ffcf70; outline-offset: 3px; }

@media (max-width: 760px) {
  .container { width: min(100% - 28px, 1180px); }
  .site-main > .container { padding-block: 1.8rem 3rem; }
  .hero { min-height: 470px; padding: 4.5rem 1.35rem 2rem; background-position: 60% center; }
  .hero::after { top: 1rem; right: 1rem; }
  .hero h1 { font-size: clamp(2.5rem, 14vw, 4rem); }
  .alerts-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item { min-height: 105px; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .footer-actions { width: 100%; align-items: flex-start; justify-content: space-between; }
  .consent-banner:not([hidden]) { align-items: stretch; flex-direction: column; }
  .consent-options { grid-template-columns: 1fr; }
  .consent-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .consent-actions .btn { min-height: 46px; white-space: normal; }
  table { min-width: 620px; }
  .card, section { max-width: 100%; }
  .card { overflow-x: auto; }
  .site-main { overflow-x: hidden; }
  .dashboard-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-hero + .card-grid { grid-template-columns: 1fr; }
  .search-sections { grid-template-columns: 1fr; }
  .search-summary { align-items: flex-start; flex-direction: column; }
  .cached-status { align-items: flex-start; flex-direction: column; }
  .forecast-days{grid-template-columns:1fr 1fr}.forecast-intro{grid-template-columns:1fr}.forecast-home-card{align-items:flex-start;flex-direction:column}
  .watch-row { align-items: flex-start; }
}

@media (max-width: 420px) {
  .container { width: min(100% - 20px, 1180px); }
  .alerts-summary-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .summary-item { padding: 0.8rem; }
  .hero-actions .btn { width: 100%; }
  .site-search-row, .hero-search > div { align-items: stretch; flex-direction: column; }
  .site-search-row .btn, .hero-search .btn { width: 100%; }
  .consent-actions { grid-template-columns: 1fr; }
  .footer-actions { flex-direction: column; }
  .forecast-days,.forecast-sources{grid-template-columns:1fr}
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
