/* Tokeny z panelu Agrosignals (src/web): papier, atrament, zieleń marki.
   Każda metryka ma własny kolor: temperatura rdzawa, wilgotność wodna, ciśnienie zieleń marki. */
:root {
  --paper: #f6f8f3;
  --surface: #ffffff;
  --ink: #1f2621;
  --muted: #5c665e;
  --border-soft: #e4e8df;
  --border: #c4cdbe;
  --accent: #3e8a1c;
  --ok: #3e8a1c;
  --stale: #c27411;
  --temp: #c25a1c;
  --hum: #2b6c94;
  --press: #3e8a1c;
  --font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131915;
    --surface: #1a211c;
    --ink: #e5ebe2;
    --muted: #9aa59c;
    --border-soft: #262f28;
    --border: #3a453c;
    --accent: #7cc35a;
    --ok: #7cc35a;
    --stale: #f0a443;
    --temp: #ec8b52;
    --hum: #6fb3dc;
    --press: #7cc35a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Nagłówek */
.top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  align-items: end;
  justify-content: space-between;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 40px; height: 40px; flex: none; }
.logo circle { fill: var(--accent); }
.logo path { fill: var(--paper); }
h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.device-line { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; display: flex; gap: 8px; align-items: center; }
.device-pick select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}

.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.status { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.95rem; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.status[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.status[data-state="stale"] { color: var(--stale); }
.status[data-state="stale"] .dot { background: var(--stale); }

.range { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.range button {
  font: inherit; font-size: 0.9rem; font-weight: 500;
  padding: 6px 14px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer;
}
.range button + button { border-left: 1px solid var(--border); }
.range button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.range button:focus-visible, .device-pick select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Panel: trzy wiersze-przyrządy, odczyt po lewej, przebieg po prawej. */
main, .empty, .foot { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
main {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 0;
}
.metric {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 24px;
  padding: 24px 28px 20px;
  border-top: 1px solid var(--border-soft);
}
.metric:first-child { border-top: 0; }
.metric[data-metric="air_temperature"] { --c: var(--temp); }
.metric[data-metric="air_humidity"] { --c: var(--hum); }
.metric[data-metric="air_pressure"] { --c: var(--press); }

.reading h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 600; color: var(--muted); }
.value {
  margin: 0;
  display: flex; align-items: baseline; gap: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--c);
}
.value .num { font-size: clamp(2.75rem, 5vw, 3.75rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.value .unit { font-size: 1.25rem; font-weight: 500; }
.reading p { margin: 0; }
.when { margin-top: 8px !important; font-size: 0.9rem; color: var(--muted); min-height: 1.35em; }
.metric.hovering .when { color: var(--ink); font-weight: 500; }
.delta, .range-24 { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.metric.hovering .delta, .metric.hovering .range-24 { visibility: hidden; }

.chart { min-width: 0; height: 190px; }
.chart .u-legend { display: none; }
.chart .u-cursor-x { border-right: 1px dashed var(--border) !important; }
.chart .u-cursor-y { display: none; }

.empty { padding: 48px 32px; max-width: 640px; }
.empty h2 { margin: 0 0 8px; font-size: 1.25rem; }
.empty p { margin: 0; color: var(--muted); }
.empty code { font-size: 0.95em; background: var(--border-soft); padding: 1px 6px; border-radius: 4px; }

.foot { padding-top: 16px; padding-bottom: 32px; }
.foot p { margin: 0; font-size: 0.85rem; color: var(--muted); max-width: 70ch; }

@media (max-width: 760px) {
  .top { padding: 20px 16px 16px; }
  main { margin: 0 16px; }
  .empty, .foot { padding-left: 16px; padding-right: 16px; }
  .metric { grid-template-columns: 1fr; gap: 12px; padding: 20px 16px 16px; }
  .reading { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: end; }
  .reading h2 { grid-column: 1 / -1; }
  .reading .value { grid-row: 2 / span 3; }
  .reading .when { margin-top: 0 !important; }
  .chart { height: 160px; }
}
