:root {
  color-scheme: dark;
  --bg: #090a0d;
  --panel: #11151c;
  --panel-2: #171c24;
  --text: #f3f6fb;
  --muted: #8b96a8;
  --line: #283241;
  --accent: #36d1c4;
  --accent-2: #f7b267;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

body.light {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #edf2f7;
  --text: #17202f;
  --muted: #5c6778;
  --line: #d9e1ec;
  --accent: #087f8c;
  --accent-2: #c76b18;
  --danger: #c24141;
  --shadow: 0 24px 60px rgba(32, 43, 61, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left,
      rgba(54, 209, 196, 0.14),
      transparent 34rem),
    linear-gradient(135deg, var(--bg), #10141b 65%, var(--bg));
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.light {
  background:
    radial-gradient(circle at top left,
      rgba(8, 127, 140, 0.12),
      transparent 34rem),
    linear-gradient(135deg, var(--bg), #eaf0f7 65%, var(--bg));
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 132px;
  position: relative;
  text-align: center;
  animation: rise 520ms ease both;
}

.source-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.source-tab {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.source-tab:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.source-tab.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  position: absolute;
  right: 0;
  bottom: 12px;
}

.primary-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1.25rem;
}

.primary-button:hover,
.icon-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.summary {
  margin: 28px 0 16px;
}

.summary>div {
  min-height: 66px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 8%);
  box-shadow: var(--shadow);
  animation: rise 620ms ease both;
}

.summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary strong {
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  line-height: 1.2;
}

.station-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 420px);
  align-items: center;
  gap: 18px;
}

.station-identity {
  min-width: 0;
  display: none;
}

.station-identity strong {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-separator {
  color: var(--accent);
  opacity: 0.75;
}

.city-select-label {
  display: grid;
  gap: 6px;
  width: 100%;
}

.city-select-label span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.city-select-label select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
  outline: none;
}

.city-select-label select:focus {
  border-color: var(--accent);
}

.range-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 10%);
  box-shadow: var(--shadow);
  animation: rise 680ms ease both;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.range-row-window {
  justify-content: space-between;
}

.range-row-main {
  justify-content: flex-start;
}

.range-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.window-status {
  display: grid;
  gap: 6px;
}

.window-status span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.window-status strong {
  color: var(--text);
  font-size: 1rem;
}

.seasonality-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.seasonality-toggle input {
  accent-color: var(--accent);
}

.seasonality-toggle:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.52;
}

.model-components {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.model-components[hidden] {
  display: none;
}

.model-components label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-2), transparent 20%);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.model-components input {
  accent-color: var(--accent);
}

.model-components:has(input:disabled) {
  opacity: 0.52;
}

.model-components label:has(input:disabled) {
  cursor: not-allowed;
}

.range-button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}

.range-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.align-end-button {
  border-color: color-mix(in srgb, var(--accent), var(--line) 45%);
  color: var(--accent);
}

.align-end-button.is-active {
  background: var(--accent);
  color: var(--panel);
  border-color: var(--accent);
}

.chart-panel {
  position: relative;
  height: min(68vh, 720px);
  min-height: 440px;
  padding: 10px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 21, 28, 0.82);
  box-shadow: var(--shadow);
  animation: rise 720ms ease both;
}

#temperatureChart {
  touch-action: pan-y;
}

body.light .chart-panel {
  background: rgba(255, 255, 255, 0.86);
}

.end-date-control {
  display: grid;
  grid-template-columns: auto minmax(160px, 200px);
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.end-date-control span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.end-date-control input {
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  color-scheme: dark;
  font-weight: 800;
  outline: none;
}

body.light .end-date-control input {
  color-scheme: light;
}

.end-date-control input:focus {
  outline: 0;
}

.cut-list-panel {
  width: min(100%, 480px);
  margin: 14px auto 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--line), var(--text) 32%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 6%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  animation: fadeIn 140ms ease both;
}

.cut-list-panel[hidden] {
  display: none;
}

.cut-list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.cut-list-header span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.cut-list-header strong {
  color: var(--text);
  font-size: 0.95rem;
}

.cut-list-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cut-list-section+.cut-list-section {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.cut-list-section h2 {
  margin: 0 0 9px;
  color: var(--cut-color);
  font-size: 0.65rem;
  line-height: 1.15;
}

.cut-list-section ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cut-list-row {
  display: grid;
  grid-template-columns: 9px minmax(82px, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 6px;
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.25;
}

.cut-list-row span:last-child {
  color: color-mix(in srgb, var(--text), var(--muted) 32%);
}

.cut-list-row span:last-child {
  text-align: right;
}

.cut-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cut-color);
}

.cut-list-empty {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    align-items: center;
    flex-direction: column;
  }

  .actions {
    position: static;
    justify-content: flex-start;
  }

  .range-row-window {
    justify-content: flex-start;
  }

  .station-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 20px, 1440px);
    padding: 18px 0;
  }

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

  .chart-panel {
    min-height: 360px;
    padding: 10px;
  }

  .range-panel {
    padding: 12px;
  }

  .range-row {
    align-items: stretch;
  }

  .window-status,
  .end-date-control,
  .seasonality-toggle {
    width: 100%;
  }

  .range-actions {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .range-button {
    flex: 0 0 auto;
  }

  .end-date-control {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .end-date-control input {
    font-size: 1rem;
  }

  .cut-list-panel {
    padding: 12px;
  }

  .cut-list-header,
  .cut-list-grid {
    grid-template-columns: 1fr;
  }

  .cut-list-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
