:root {
  color-scheme: light;
  --page: #f4f8f9;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --panel-soft: #edf6f8;
  --ink: #102027;
  --muted: #60717a;
  --line: rgba(77, 102, 112, 0.18);
  --river: #109c9a;
  --river-dark: #08706f;
  --deep: #25506a;
  --leaf: #78a642;
  --warm: #e26d45;
  --sun: #f5b84b;
  --shadow: 0 18px 48px rgba(18, 43, 50, 0.12);
  --shadow-soft: 0 10px 30px rgba(18, 43, 50, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(16, 156, 154, 0.12), rgba(245, 184, 75, 0.10) 42%, rgba(37, 80, 106, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(244, 248, 249, 0.98)),
    var(--page);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(120deg, rgba(16, 156, 154, 0.10) 0 1px, transparent 1px 72px),
    linear-gradient(120deg, transparent 0 46px, rgba(245, 184, 75, 0.08) 46px 47px, transparent 47px 120px);
  opacity: 0.52;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(16, 156, 154, 0.20));
  transform-origin: 50% 80%;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--river-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.freshness {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) minmax(150px, 190px) auto auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
}

.search-box span,
.select-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--river);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(16, 156, 154, 0.14);
}

.toggle-button,
.icon-button,
.detail-button,
.favorite-button {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--ink);
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease, background 170ms ease, color 170ms ease;
}

.toggle-button {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 760;
}

.toggle-button[aria-pressed="true"] {
  border-color: rgba(226, 109, 69, 0.44);
  background: linear-gradient(135deg, rgba(255, 244, 232, 0.94), rgba(255, 255, 255, 0.86));
  color: #9b4423;
  box-shadow: 0 8px 20px rgba(226, 109, 69, 0.12);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}

.icon-button:disabled {
  cursor: progress;
  animation: spinRefresh 800ms linear infinite;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.summary div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-bottom: 3px solid var(--river);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 253, 252, 0.82));
  box-shadow: var(--shadow-soft);
}

.summary span {
  display: block;
  font-size: 26px;
  font-weight: 820;
}

.summary small {
  color: var(--muted);
  font-weight: 650;
}

.status-panel {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid rgba(226, 109, 69, 0.20);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 247, 237, 0.94), rgba(255, 255, 255, 0.80));
  color: #8b441f;
  box-shadow: 0 10px 24px rgba(139, 68, 31, 0.07);
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.station-card {
  display: flex;
  min-height: 266px;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 253, 252, 0.88));
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.station-card:hover {
  transform: translateY(-3px);
  border-color: rgba(16, 156, 154, 0.26);
  box-shadow: 0 18px 42px rgba(18, 43, 50, 0.13);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.river {
  margin: 0 0 5px;
  color: var(--river-dark);
  font-size: 13px;
  font-weight: 760;
}

.station-card h2 {
  font-size: 21px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.favorite-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--warm);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(18, 43, 50, 0.06);
}

.favorite-button.active {
  background: #fff3e6;
  border-color: rgba(226, 109, 69, 0.45);
  color: #cc552c;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 76px;
  padding: 10px;
  border: 1px solid rgba(77, 102, 112, 0.12);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(237, 246, 248, 0.92), rgba(248, 252, 251, 0.92));
}

.metric.primary {
  background: linear-gradient(180deg, rgba(225, 247, 244, 0.96), rgba(247, 252, 250, 0.92));
  border-color: rgba(16, 156, 154, 0.22);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.meta-row span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(239, 245, 243, 0.90);
}

.detail-button {
  margin-top: auto;
  min-height: 40px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--river), var(--deep));
  border-color: transparent;
  color: #fff;
  font-weight: 780;
  box-shadow: 0 12px 22px rgba(16, 156, 154, 0.18);
}

.detail-button:hover,
.icon-button:hover,
.toggle-button:hover,
.favorite-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(18, 43, 50, 0.12);
}

.detail-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(82vh, 780px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.25);
}

.detail-dialog::backdrop {
  background: rgba(12, 22, 19, 0.42);
}

.dialog-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-toolbar h2 {
  font-size: 24px;
  line-height: 1.14;
}

#detailBody {
  padding: 18px;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.sparkline {
  width: 100%;
  height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(237, 246, 248, 0.74));
}

.records-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 14px;
}

.records-table th,
.records-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.records-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

@keyframes spinRefresh {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .freshness {
    text-align: left;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .filters,
  .summary,
  .station-grid,
  .detail-metrics {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .station-card {
    min-height: 0;
  }
}
