:root {
  --bg: #f6f7f1;
  --paper: #ffffff;
  --ink: #1f2a1f;
  --muted: #697365;
  --line: #dfe4d6;
  --green: #2f7d4a;
  --green-dark: #215b37;
  --gold: #c78a17;
  --red: #bb3e2f;
  --barley: #8b6f2a;
  --shadow: 0 12px 36px rgba(43, 60, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--green-dark);
}

button.secondary {
  background: #e8ecdf;
  color: var(--ink);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.topbar,
.chart-section,
.method {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 920px;
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 1.04;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.subhead,
.muted,
.source-note,
.section-head p,
.method p {
  color: var(--muted);
}

.subhead {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.actions,
.inline,
.coords {
  display: flex;
  gap: 10px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline input {
  min-width: 0;
}

.coords > * {
  flex: 1;
}

.control-grid,
.summary-grid,
.detail-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.control-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.summary-grid {
  grid-template-columns: repeat(4, 1fr);
}

.detail-grid {
  grid-template-columns: 0.9fr 1.4fr;
}

.control-panel,
.metric,
.driver-panel,
.table-panel {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel-title,
.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-title h2,
.section-head h2 {
  margin: 0;
}

.status {
  border-radius: 999px;
  background: #e9f2e8;
  color: var(--green-dark);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.loading {
  background: #fff1d4;
  color: #8d5e09;
}

.status.error {
  background: #ffe2dc;
  color: #9f3023;
}

.wide {
  width: 100%;
}

.source-note {
  margin: -4px 0 0;
  font-size: 0.86rem;
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check input {
  width: auto;
  min-height: auto;
}

.range-readout {
  color: var(--ink);
  font-weight: 800;
}

.metric {
  min-height: 120px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 2.35rem;
  line-height: 1;
}

.chart-section {
  margin-top: 16px;
  padding: 20px;
}

.section-head {
  margin-bottom: 10px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 420px;
  overflow: hidden;
}

canvas {
  display: block;
  max-width: 100%;
}

.drivers {
  display: grid;
  gap: 10px;
}

.driver {
  border-left: 5px solid var(--green);
  background: #f7faf1;
  border-radius: 8px;
  padding: 12px;
}

.driver.warn {
  border-color: var(--gold);
}

.driver.high {
  border-color: var(--red);
}

.driver strong {
  display: block;
  margin-bottom: 3px;
}

.driver span {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.risk-low,
.risk-watch,
.risk-high {
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 800;
}

.risk-low {
  background: #e8f2e6;
  color: var(--green-dark);
}

.risk-watch {
  background: #fff0cc;
  color: #7e5409;
}

.risk-high {
  background: #ffe0dc;
  color: #9f3023;
}

.method {
  margin-top: 16px;
  padding: 20px;
}

.method p:last-child {
  margin-bottom: 0;
}

@media (max-width: 980px) {
  .topbar,
  .panel-title,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .chart-wrap {
    min-height: 340px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .control-panel,
  .metric,
  .driver-panel,
  .table-panel,
  .chart-section,
  .method {
    padding: 14px;
  }

  .inline,
  .coords {
    flex-direction: column;
  }

  .metric {
    min-height: auto;
  }
}
