:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --ink: #162016;
  --muted: #667064;
  --line: #d8dfd2;
  --surface: #ffffff;
  --accent: #2c7a4b;
  --accent-strong: #195c35;
  --warn: #c07a21;
  --danger: #b23b3b;
  --water: #2a78a8;
  --shadow: 0 18px 45px rgba(28, 46, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(44, 122, 75, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(42, 120, 168, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

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

.hero {
  min-height: 340px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  align-items: center;
  gap: 32px;
  padding: 40px 0 32px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.subtitle {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.8;
}

.sensor-panel,
.panel {
  border: 1px solid rgba(216, 223, 210, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.sensor-panel {
  display: grid;
  place-items: center;
  gap: 20px;
  padding: 28px;
}

.gauge {
  position: relative;
  width: min(100%, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--line) 0deg, var(--line) 360deg);
  display: grid;
  place-items: center;
}

.gauge::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--surface);
}

.gauge-fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, var(--accent) 0deg, transparent 0deg);
}

.gauge-value {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 800;
}

.gauge-value span {
  font-size: 4.6rem;
  line-height: 1;
}

.gauge-value small {
  color: var(--muted);
  font-size: 1.25rem;
}

.reading-meta {
  text-align: center;
}

.reading-meta strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.reading-meta span,
.panel-heading span,
.section-heading span {
  color: var(--muted);
  font-size: 0.92rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 20px;
  margin-bottom: 26px;
}

.panel {
  padding: 22px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.advice-message {
  margin-bottom: 20px;
  font-size: 1.08rem;
  line-height: 1.75;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 20px;
}

.tag {
  border: 1px solid rgba(44, 122, 75, 0.25);
  border-radius: 999px;
  background: rgba(44, 122, 75, 0.1);
  color: var(--accent-strong);
  padding: 8px 12px;
  font-weight: 700;
}

.action-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.9;
}

.manual-form {
  display: grid;
  gap: 14px;
}

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

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 12px 13px;
  font: inherit;
}

input:focus {
  outline: 3px solid rgba(44, 122, 75, 0.18);
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.endpoint {
  display: block;
  margin-top: 16px;
  border-radius: 8px;
  background: #eef3ea;
  color: var(--accent-strong);
  padding: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.resources-section,
.history-section {
  padding-top: 4px;
}

.resources-section {
  margin-bottom: 26px;
}

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

.resource-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 16px;
}

.resource-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.resource-item strong {
  display: block;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.state-dry,
.state-low {
  color: var(--warn);
}

.state-good {
  color: var(--accent-strong);
}

.state-wet {
  color: var(--water);
}

.state-danger {
  color: var(--danger);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .hero,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

  .hero {
    gap: 22px;
    padding-top: 20px;
  }

  .panel-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .gauge {
    width: min(100%, 230px);
  }
}

@media (max-width: 520px) {
  .resource-grid {
    grid-template-columns: 1fr;
  }
}
