:root {
  --bg: #f3f0e7;
  --paper: rgba(255, 255, 255, 0.82);
  --ink: #213128;
  --muted: #647267;
  --line: rgba(33, 49, 40, 0.12);
  --sage: #59795c;
  --rain: #4d8bb6;
  --etc: #c96d3d;
  --surplus: #5c8f5c;
  --deficit: #b44d4d;
  --shadow: 0 24px 60px rgba(45, 60, 50, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  background:
    radial-gradient(circle at top left, rgba(89, 121, 92, 0.25), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(77, 139, 182, 0.18), transparent 24rem),
    linear-gradient(180deg, #fbfaf6 0%, var(--bg) 100%);
}
.shell {
  width: min(1400px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}
.hero,
.card,
.station-card {
  border: 1px solid var(--line);
  background: var(--paper);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.hero {
  border-radius: 28px;
  padding: 1.75rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.hero-copy {
  flex: 1 1 34rem;
  min-width: 0;
}
.hero-mark {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
}
.hero-visuals {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.hero-logo {
  display: block;
  width: min(118px, 10vw);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.hero-map-card {
  width: min(210px, 18vw);
  padding: 0.5rem;
  border-radius: 22px;
  background: rgba(89, 121, 92, 0.08);
  border: 1px solid var(--line);
}
.hero-map-heading {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.station-map {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}
.station-map-image {
  display: block;
  width: 100%;
  height: auto;
}
.eyebrow,
.label,
.meta,
.station-meta,
.hero-meta p,
.section-heading p {
  color: var(--muted);
}
.meta-tight {
  margin-bottom: 0;
  color: var(--muted);
}
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2.3rem, 4.5vw, 4rem); line-height: 0.95; margin-bottom: 0.7rem; }
h2 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.lede { max-width: 62ch; font-size: 1.04rem; }
.hero-meta {
  min-width: 12rem;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  background: rgba(89, 121, 92, 0.08);
}
.back-link {
  display: inline-block;
  margin-bottom: 0.85rem;
  color: var(--sage);
  text-decoration: none;
  font-weight: 600;
}
.card-grid,
.station-list {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.station-list {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.card {
  border-radius: 24px;
  padding: 1.2rem;
}
.copy-card p:last-child,
.metric-card p:last-child {
  margin-bottom: 0;
}
.station-card {
  border-radius: 22px;
  padding: 1.1rem;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.station-card:hover {
  transform: translateY(-2px);
}
.station-card-top,
.section-row,
.legend-row,
.button-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.station-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.station-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(89, 121, 92, 0.14);
  color: var(--sage);
  font-size: 0.9rem;
}
.table-wrap {
  overflow-x: auto;
}
.saved-state-panel {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
}
.section-panel {
  display: block;
}
.section-panel-summary,
.explain-panel summary {
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  list-style: none;
}
.section-panel-summary::-webkit-details-marker,
.explain-panel summary::-webkit-details-marker {
  display: none;
}
.section-panel-summary::after,
.explain-panel summary::after {
  content: "+";
  float: right;
  color: var(--sage);
  font-size: 1.1rem;
}
.section-panel[open] .section-panel-summary,
.explain-panel[open] summary {
  margin-bottom: 1rem;
}
.section-panel[open] .section-panel-summary::after,
.explain-panel[open] summary::after {
  content: "−";
}
.section-heading-tools {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.inline-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.inline-control select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
  background: white;
  color: var(--ink);
  font: inherit;
}
.model-help {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 0.9rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
th, td {
  padding: 0.78rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
#weekly-table {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.94rem;
}
#weekly-table tbody tr:nth-child(even),
#saved-states-table tbody tr:nth-child(even),
.moisture-guide-table tbody tr:nth-child(even) {
  background: rgba(89, 121, 92, 0.05);
}
.table-stage-select,
.state-name-input,
#planting-date {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}
.table-irrigation-input {
  width: 5.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}
.saved-state-actions {
  margin-bottom: 0.9rem;
}
.unit-toggle {
  margin-top: 0.75rem;
}
.state-name-input {
  min-width: 220px;
  max-width: 320px;
}
.saved-state-buttons {
  display: flex;
  gap: 0.5rem;
}
.empty-row {
  color: var(--muted);
}
.metric-positive {
  color: var(--surplus);
  font-weight: 700;
}
.metric-negative {
  color: var(--deficit);
  font-weight: 700;
}
.metric-neutral {
  color: var(--muted);
  font-weight: 600;
}
th {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(89, 121, 92, 0.1);
  position: sticky;
  top: 0;
  z-index: 1;
}
.button-row {
  flex-wrap: wrap;
}
.formula-block {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(89, 121, 92, 0.08);
  border: 1px solid var(--line);
}
.formula-block code {
  display: block;
  margin: 0.35rem 0 0.7rem;
  font-size: 0.96rem;
  white-space: normal;
}
.formula-note {
  margin-bottom: 0;
  color: var(--muted);
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.94rem;
}
.control-field select {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}
.control-field input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}
.table-summary {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.filter-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font: inherit;
}
.crop-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.crop-pill {
  white-space: nowrap;
}
.filter-btn.is-active {
  background: var(--sage);
  color: white;
}
.crop-notes-input {
  min-height: 5.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}
.legend-row {
  flex-wrap: wrap;
  color: var(--muted);
  margin-bottom: 0.8rem;
}
.legend-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-right: 0.35rem;
  vertical-align: text-bottom;
}
.chip-rain { background: var(--rain); }
.chip-etc { background: var(--etc); }
.chip-surplus { background: var(--surplus); }
.chip-deficit { background: var(--deficit); }
.weekly-chart {
  width: 100%;
  height: auto;
}
.axis-line, .grid-line {
  stroke: rgba(33, 49, 40, 0.18);
  stroke-width: 1;
}
.axis-label {
  fill: var(--muted);
  font-size: 10px;
}
.bar-rain { fill: var(--rain); }
.bar-etc { fill: var(--etc); }
.bar-surplus { fill: var(--surplus); }
.bar-deficit { fill: var(--deficit); }
.notes-list {
  margin-bottom: 0;
}
.card .table-wrap {
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(33, 49, 40, 0.06);
}
.explain-panel p:last-of-type {
  margin-bottom: 0.8rem;
}
.empty-chart {
  padding: 2rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}
@media (max-width: 760px) {
  .hero,
  .section-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-mark {
    width: 100%;
    justify-content: flex-start;
  }
  .hero-visuals {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }
  .hero-logo {
    width: min(180px, 60vw);
  }
  .hero-map-card {
    width: min(100%, 320px);
  }
  .shell {
    width: min(100% - 1rem, 1180px);
  }
}
