:root {
  --bg: #f7efe4;
  --ink: #2e1a0e;
  --muted: #7a5a47;
  --rule: #dcc8b3;
  --amber: #f5a700;
  --amber-ink: #a86400;
  --teal: #17705e;
  --orange: #b35a00;
  --chart: #e8742a;
  --band: #dff1d4;
}

* { box-sizing: border-box; }

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

.page { max-width: 1080px; margin: 0 auto; padding: 0 32px; }

/* ---------- Header ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px; padding: 22px 0 18px;
  border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: block; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-sub { font-size: 13px; color: var(--muted); }

.topbar-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); }
.topbar-meta strong { color: var(--ink); font-weight: 600; }
.sep { width: 1px; height: 14px; background: var(--rule); }
.online { display: inline-flex; align-items: center; gap: 6px; color: var(--teal); font-weight: 600; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); display: inline-block; }
.online.offline { color: #a33a2a; }
.online.offline i { background: #a33a2a; }

/* ---------- Papan utama: satu bingkai, sel dipisah garis ---------- */
.board {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-template-areas:
    "temp ph"
    "temp day"
    "chart chart"
    "history history";
  background: var(--rule);           /* warna garis pemisah antar sel */
  gap: 1px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.cell { background: #fffdf9; display: flex; flex-direction: column; min-width: 0; }
.cell-temp { grid-area: temp; }
.cell-ph { grid-area: ph; }
.cell-day { grid-area: day; }
.cell-chart { grid-area: chart; }
.cell-history { grid-area: history; }

.cell-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 20px;
  background: #f3e7d8;
  border-bottom: 1px solid var(--rule);
  font-size: 12px; font-weight: 700; color: #5e4433;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.cell-head h2 { margin: 0; font-size: 12px; font-weight: 700; }
.cell-head .status, .cell-head .legend { margin-left: auto; }
.cell-body { padding: 20px; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; }

/* Suhu */
.big-value { display: flex; align-items: baseline; gap: 8px; }
.big-value .num { font-size: 104px; font-weight: 800; line-height: 0.95; letter-spacing: -0.04em; }
.big-value .unit { font-size: 30px; font-weight: 700; color: var(--amber-ink); }
.trend { margin: 10px 0 20px; font-size: 14px; color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { color: #3f7a2a; }
.status.warn { color: var(--orange); }
.status.info { color: var(--muted); }
.status.bad { color: #a33a2a; }

.gauge { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.gauge-track { position: relative; height: 6px; background: #eadbc9; }
.gauge-target {
  position: absolute; top: 0; bottom: 0;
  left: 66.67%; width: 16.67%;           /* 45–50 °C pada skala 25–55 °C */
  background: #6aa84f;
}
.gauge-marker {
  position: absolute; top: -5px; width: 3px; height: 16px;
  background: var(--ink); transform: translateX(-50%); transition: left .4s ease;
}
.gauge-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* pH & hari */
.mid-value { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.v-teal { color: var(--teal); }
.v-orange { color: var(--orange); }

/* Grafik */
.legend {
  display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { width: 16px; height: 3px; background: var(--chart); display: inline-block; }
.lg-band { width: 14px; height: 10px; background: var(--band); display: inline-block; }
.chart-wrap { position: relative; }
#chart { width: 100%; height: 220px; display: block; overflow: hidden; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.tooltip {
  position: absolute; pointer-events: none;
  background: var(--ink); color: #fbf5ec;
  padding: 6px 10px; border-radius: 4px; font-size: 13px; white-space: nowrap;
  transform: translate(-50%, -125%);
}
.tooltip b { color: var(--amber); }

.footer { padding: 24px 0 36px; font-size: 13px; color: var(--muted); }

/* ---------- HP ---------- */
@media (max-width: 720px) {
  .page { padding: 0 14px; }
  .topbar { padding: 16px 0 14px; }
  .topbar-meta { width: 100%; gap: 10px; }
  .board {
    margin-top: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "temp temp"
      "ph day"
      "chart chart"
      "history history";
  }
  .cell-head { padding: 9px 14px; }
  .cell-body { padding: 16px 14px; }
  .big-value .num { font-size: 80px; }
  .big-value .unit { font-size: 24px; }
  .mid-value { font-size: 36px; }
  #chart { height: 160px; }
  .lg-note { display: none !important; }
  .cell-head .legend { margin-left: 0; width: 100%; }
}

.nocase { text-transform: none; }
.sim { display: inline-flex; align-items: center; gap: 12px; }
.sim[hidden] { display: none; }

/* ---------- Riwayat ---------- */
.history-tools {
  margin-left: auto; display: inline-flex; align-items: center; gap: 12px;
  text-transform: none; letter-spacing: 0;
}
.history-count { font-size: 12px; font-weight: 500; color: var(--muted); }
#historyRange {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: #fffdf9; border: 1px solid var(--rule); border-radius: 4px;
  padding: 6px 28px 6px 10px; min-height: 36px; cursor: pointer;
}
.table-wrap { max-height: 360px; overflow: auto; }
.cell-history table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cell-history th {
  position: sticky; top: 0; background: #fffdf9; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 20px; border-bottom: 1px solid var(--rule);
}
.cell-history td { padding: 9px 20px; border-bottom: 1px solid #efe3d5; }
.cell-history tbody tr:hover { background: #fbf4ea; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.cell-history .empty { text-align: center; color: var(--muted); padding: 24px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (max-width: 720px) {
  .history-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .cell-history th, .cell-history td { padding: 8px 12px; }
  .cell-history table { font-size: 13px; }
}
.cell-history th.num-cell { text-align: right; }
.cell-history td:first-child { white-space: nowrap; }
