:root {
  --bg: #f5f8f2;
  --paper: #fffef8;
  --card: rgba(255, 255, 255, 0.84);
  --ink: #1c302b;
  --muted: #687d74;
  --line: rgba(84, 122, 101, 0.22);
  --leaf: #2d7b62;
  --river: #2b7da8;
  --copper: #b46a2c;
  --gold: #c99a32;
  --dry: #b56b3d;
  --wet: #267a9a;
  --alert: #b6403a;
  --violet: #62508c;
  --shadow: 0 20px 55px rgba(69, 103, 83, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  background:
    linear-gradient(135deg, rgba(245, 248, 242, 0.94), rgba(248, 244, 232, 0.94)),
    radial-gradient(circle at 12% 8%, rgba(43, 125, 168, 0.16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(201, 154, 50, 0.16), transparent 24%);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.topbar,
.desk-head,
.filter-row,
.region-card,
.detail-panel,
.rain-map-panel,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 62px;
  padding: 12px 18px;
  border-radius: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--leaf), var(--river));
  font-family: var(--mono);
  font-size: 0.8rem;
}

.top-meta {
  min-width: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86rem;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.desk-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 22px;
  align-items: end;
  margin-top: 16px;
  padding: 28px;
  border-radius: 26px;
  background:
    linear-gradient(130deg, rgba(255, 254, 248, 0.9), rgba(239, 248, 238, 0.82)),
    radial-gradient(circle at 92% 20%, rgba(180, 106, 44, 0.12), transparent 30%);
  overflow: hidden;
}

.desk-head > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--leaf);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.title-row h1 {
  margin-bottom: 0;
}

.module-status {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(180, 106, 44, 0.32);
  border-radius: 999px;
  color: #8b5426;
  background: rgba(255, 245, 224, 0.78);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
}

.lead {
  max-width: 840px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.06rem;
  overflow-wrap: anywhere;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-strip div {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.score-strip span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.score-strip strong {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 2rem;
  line-height: 1.1;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px;
  border-radius: 20px;
  box-shadow: none;
}

.region-section {
  margin-top: 16px;
}

.region-section .filter-row {
  margin-top: 0;
}

.opportunity-section {
  margin-top: 16px;
  padding: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 248, 0.58);
}

.section-head,
.opportunity-detail-head,
.opportunity-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

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

.section-head h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
  line-height: 1.12;
}

.data-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.opportunity-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.opportunity-card,
.opportunity-empty {
  min-height: 226px;
  padding: 15px;
  border: 1px solid rgba(84, 122, 101, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.opportunity-card {
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.opportunity-card:hover,
.opportunity-card.active {
  transform: translateY(-2px);
  border-color: rgba(98, 80, 140, 0.38);
  background: rgba(255, 255, 255, 0.96);
}

.opportunity-card h3 {
  margin-bottom: 2px;
  font-size: 1rem;
  line-height: 1.2;
}

.opportunity-card-head span {
  color: var(--muted);
  font-size: 0.75rem;
}

.opportunity-status {
  flex: 0 0 auto;
  max-width: 96px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(84, 122, 101, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
}

.opportunity-status.high {
  color: var(--alert);
  border-color: rgba(182, 64, 58, 0.28);
  background: rgba(182, 64, 58, 0.1);
}

.opportunity-status.watch {
  color: var(--copper);
  border-color: rgba(180, 106, 44, 0.28);
  background: rgba(180, 106, 44, 0.1);
}

.opportunity-status.observe {
  color: var(--river);
  border-color: rgba(43, 125, 168, 0.28);
  background: rgba(43, 125, 168, 0.1);
}

.opportunity-status.pending {
  color: var(--violet);
  border-color: rgba(98, 80, 140, 0.25);
  background: rgba(98, 80, 140, 0.1);
}

.rain-map-panel {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 18px;
  box-shadow: none;
}

.rain-map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.rain-map-head h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.rain-map-head p,
.rain-map-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.rain-map-controls {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
}

.rain-map-mode {
  min-width: 52px;
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.rain-map-mode.active {
  color: #fff;
  background: linear-gradient(135deg, var(--river), var(--leaf));
}

.rain-map-stage {
  position: relative;
  min-height: 280px;
  border: 1px solid rgba(84, 122, 101, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(218, 237, 241, 0.96), rgba(244, 246, 235, 0.94)),
    radial-gradient(circle at 30% 25%, rgba(112, 155, 165, 0.16), transparent 36%);
  overflow: hidden;
}

#rainMapCanvas {
  display: block;
  width: 100%;
  height: 280px;
}

.rain-map-readout {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  gap: 2px;
  min-width: 138px;
  padding: 9px 10px;
  border: 1px solid rgba(84, 122, 101, 0.18);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 251, 0.78);
  backdrop-filter: blur(6px);
}

.rain-map-readout strong {
  font-family: var(--mono);
  font-size: 0.92rem;
}

.rain-map-readout span {
  color: var(--muted);
  font-size: 0.74rem;
}

.rain-map-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.opportunity-scoreline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 12px 0;
}

.opportunity-scoreline div,
.opportunity-metrics div {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(84, 122, 101, 0.14);
  border-radius: 12px;
  background: rgba(245, 248, 242, 0.72);
}

.opportunity-scoreline span,
.opportunity-metrics span,
.opportunity-score-badge span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.opportunity-scoreline strong,
.opportunity-metrics strong,
.opportunity-score-badge strong {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 1.35rem;
  line-height: 1.1;
}

.opportunity-scoreline strong.high,
.opportunity-score-badge.high strong {
  color: var(--alert);
}

.opportunity-scoreline strong.watch,
.opportunity-score-badge.watch strong {
  color: var(--copper);
}

.opportunity-scoreline strong.observe,
.opportunity-score-badge.observe strong {
  color: var(--river);
}

.opportunity-scoreline strong.pending,
.opportunity-score-badge.pending strong {
  color: var(--violet);
}

.opportunity-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.opportunity-detail {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid rgba(84, 122, 101, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.opportunity-detail-head {
  margin-bottom: 14px;
}

.opportunity-detail-head h2 {
  margin-bottom: 6px;
  font-size: clamp(1.4rem, 2.6vw, 2.35rem);
  line-height: 1.12;
}

.opportunity-detail-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.opportunity-score-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 104px;
  min-height: 86px;
  padding: 10px;
  border: 1px solid rgba(84, 122, 101, 0.18);
  border-radius: 16px;
  background: rgba(245, 248, 242, 0.78);
  text-align: center;
}

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

.opportunity-metrics em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.opportunity-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.opportunity-detail-grid article,
.futures-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(84, 122, 101, 0.14);
  border-radius: 14px;
  background: rgba(255, 254, 248, 0.74);
}

.opportunity-detail-grid h3,
.futures-panel h3 {
  margin-bottom: 10px;
  font-size: 0.96rem;
}

.opportunity-detail-grid ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.8rem;
}

.region-chain {
  display: grid;
  gap: 8px;
}

.region-chain div {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(84, 122, 101, 0.12);
}

.region-chain span,
.region-chain strong,
.region-chain em {
  display: block;
}

.region-chain span {
  color: var(--muted);
  font-size: 0.72rem;
}

.region-chain strong {
  font-size: 0.82rem;
}

.region-chain em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.watch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.watch-tags span {
  padding: 4px 7px;
  border-radius: 999px;
  color: #5e684f;
  background: rgba(201, 154, 50, 0.13);
  font-size: 0.72rem;
  font-weight: 800;
}

.futures-panel {
  margin-top: 12px;
  overflow-x: auto;
}

td.up {
  color: var(--alert);
  font-weight: 800;
}

td.down {
  color: var(--leaf);
  font-weight: 800;
}

.filter-btn {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.filter-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--leaf), var(--river));
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.region-card {
  min-height: 286px;
  padding: 17px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.region-card:hover,
.region-card.active {
  transform: translateY(-2px);
  border-color: rgba(45, 123, 98, 0.5);
  background: rgba(255, 255, 255, 0.96);
}

.region-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.region-head h2 {
  margin-bottom: 2px;
  font-size: 1.24rem;
  line-height: 1.22;
}

.region-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.risk-badge,
.risk-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 800;
}

.risk-badge.dry,
.risk-badge.severe-dry,
.risk-pill.dry,
.risk-pill.severe-dry {
  color: var(--dry);
  border-color: rgba(181, 107, 61, 0.28);
  background: rgba(181, 107, 61, 0.1);
}

.risk-badge.wet,
.risk-badge.severe-wet,
.risk-pill.wet,
.risk-pill.severe-wet {
  color: var(--wet);
  border-color: rgba(38, 122, 154, 0.28);
  background: rgba(38, 122, 154, 0.1);
}

.commodity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.commodity-tags span {
  padding: 2px 7px;
  border-radius: 999px;
  color: #5e684f;
  background: rgba(201, 154, 50, 0.13);
  font-size: 0.72rem;
  font-weight: 800;
}

.card-score {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  color: var(--ink);
  background: conic-gradient(var(--leaf) calc(var(--score) * 1%), rgba(45, 123, 98, 0.12) 0);
  font-family: var(--mono);
  font-size: 1.28rem;
  font-weight: 900;
}

.score-ring::before {
  content: "";
  position: absolute;
}

.card-score p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.card-metrics {
  display: grid;
  gap: 8px;
}

.card-metrics div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(84, 122, 101, 0.14);
  color: var(--muted);
  font-size: 0.78rem;
}

.card-metrics strong {
  color: var(--ink);
  font-family: var(--mono);
}

.detail-panel {
  margin-top: 18px;
  padding: 22px;
  border-radius: 24px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.detail-head h2 {
  margin-bottom: 6px;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1.12;
}

.detail-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.risk-pill {
  font-size: 0.86rem;
  padding: 8px 12px;
}

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

.metric {
  min-height: 96px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(84, 122, 101, 0.16);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 1.2rem;
  line-height: 1.15;
}

.metric em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.74rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 14px;
}

.chart-panel,
.table-panel {
  padding: 16px;
  border-radius: 18px;
  box-shadow: none;
}

.chart-panel h3,
.table-panel h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.chart-wrap {
  height: 360px;
}

.chart-wrap.primary {
  height: 430px;
}

.table-panel {
  display: grid;
  grid-template-columns: 0.36fr 0.64fr;
  gap: 16px;
  margin-top: 14px;
}

.table-panel p {
  color: var(--muted);
  font-size: 0.86rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 0.82rem;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(84, 122, 101, 0.16);
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 1180px) {
  .desk-head,
  .chart-grid,
  .table-panel {
    grid-template-columns: 1fr;
  }

  .region-grid,
  .opportunity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-strip,
  .opportunity-metrics,
  .opportunity-detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .resource-shell {
    width: min(100% - 20px, 1440px);
  }

  .topbar,
  .detail-head,
  .section-head,
  .rain-map-head,
  .rain-map-meta,
  .opportunity-detail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .top-meta {
    text-align: left;
    font-size: 0.78rem;
  }

  .desk-head {
    padding: 18px 14px;
  }

  h1 {
    font-size: 1.9rem;
    line-height: 1.08;
  }

  .lead {
    font-size: 0.95rem;
  }

  .rain-map-stage {
    min-height: 240px;
  }

  #rainMapCanvas {
    height: 240px;
  }

  .score-strip,
  .region-grid,
  .metric-strip,
  .opportunity-grid,
  .opportunity-metrics,
  .opportunity-detail-grid {
    grid-template-columns: 1fr;
  }

  .opportunity-section,
  .opportunity-detail {
    padding: 14px;
  }

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

  .chart-wrap,
  .chart-wrap.primary {
    height: 320px;
  }
}
