:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --ink: #17211c;
  --muted: #66736e;
  --line: #dce4df;
  --panel: #ffffff;
  --panel-soft: #eef6f1;
  --green: #177a4d;
  --blue: #2468a8;
  --cyan: #13858b;
  --amber: #b56d14;
  --red: #b4403b;
  --shadow: 0 14px 40px rgba(29, 45, 38, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans Thai", sans-serif;
  letter-spacing: 0;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

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

.subhead {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sheet-link,
.icon-button {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(29, 45, 38, 0.06);
}

.sheet-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.icon-button {
  width: 40px;
  border-radius: 6px;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-band {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.status-band.error {
  border-color: rgba(180, 64, 59, 0.35);
  color: var(--red);
  background: #fff6f5;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 170px;
  padding: 18px;
}

.pond-card {
  border-top: 4px solid var(--blue);
}

.total-card {
  border-top: 4px solid var(--cyan);
}

.days-card {
  border-top: 4px solid var(--amber);
}

.metric-topline,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.metric-topline span,
.metric-topline strong,
.panel-heading p,
.pill,
.metric-caption,
.detail-table th {
  color: var(--muted);
}

.metric-topline span {
  font-size: 14px;
  font-weight: 700;
}

.metric-topline strong {
  max-width: 150px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-value {
  margin-top: 24px;
  font-size: clamp(30px, 4.5vw, 46px);
  font-weight: 800;
  line-height: 1;
}

.metric-value small {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.metric-percent {
  margin-left: 8px;
  color: var(--blue);
  font-size: 20px;
  font-weight: 800;
}

.metric-caption {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-height: 240px;
  padding: 18px;
}

.panel.wide {
  grid-column: span 1;
}

.panel-heading {
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 18px;
  line-height: 1.25;
}

.panel-heading p {
  margin-top: 5px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chart {
  width: 100%;
  min-height: 210px;
}

.chart-large {
  min-height: 382px;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.axis-label {
  fill: #7a8782;
  font-size: 11px;
}

.series-one {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
}

.series-two {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
}

.grid-line {
  stroke: #e7ede9;
  stroke-width: 1;
}

.scrub-line {
  stroke: #9aa8a1;
  stroke-dasharray: 4 5;
  stroke-width: 1.5;
  pointer-events: none;
}

.chart-hit-area {
  cursor: ew-resize;
  fill: transparent;
}

.marker-one,
.marker-two {
  stroke: #fff;
  stroke-width: 2.5;
  pointer-events: none;
}

.marker-one {
  fill: var(--blue);
}

.marker-two {
  fill: var(--green);
}

.trend-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.trend-readout strong {
  color: var(--ink);
}

.trend-readout span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trend-readout i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.trend-scrubber {
  width: 100%;
  margin: 14px 0 4px;
  accent-color: var(--green);
  cursor: pointer;
}

.trend-dots {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 4px;
}

.trend-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #c9d4ce;
}

.trend-dots span.active {
  width: 8px;
  height: 8px;
  background: var(--green);
}

.legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.number-stack {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}

.number-stack span {
  font-size: 36px;
  font-weight: 800;
}

.number-stack small,
.rain-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) 2fr minmax(58px, auto);
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

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

.rain-grid div {
  min-height: 96px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.rain-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 28px;
  font-weight: 800;
}

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

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.detail-table th {
  font-size: 12px;
  text-transform: uppercase;
}

.detail-table td:nth-child(2) {
  font-weight: 800;
}

@media (max-width: 980px) {
  .metric-grid,
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.wide {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 20px, 1280px);
    padding-top: 18px;
  }

  .topbar,
  .metric-grid,
  .panel-grid,
  .rain-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .actions {
    justify-content: space-between;
  }

  .metric-grid,
  .panel-grid {
    display: grid;
  }

  .panel.wide {
    grid-column: span 1;
  }

  .metric-value {
    font-size: 34px;
  }

  .bar-row {
    grid-template-columns: 1fr minmax(56px, auto);
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bar-row strong {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
}
