/* ============================================================================
   Tank Monitor — instrument-panel theme.
   One family (system sans) for UI; a monospace only for the large numeric
   readouts and timestamps, where reading exact figures is the job.
   ============================================================================ */

:root {
  --bg:        #0d1526;
  --panel:     #142035;
  --panel-2:   #18263f;
  --line:      #26374f;
  --line-soft: #1d2c44;

  --ink:       #e8eef7;
  --ink-muted: #8ba0bf;
  --ink-faint: #5f7595;

  --accent:    #4cc4ff;    /* data cyan, used sparingly */

  /* semantic status — these carry meaning, not decoration */
  --ok:        #34d399;
  --alert:     #fb7185;
  --offline:   #64748b;
  --warn:      #fbbf24;

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: inherit; }

html, body { margin: 0; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, #16233b 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.25rem);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  background: rgba(13, 21, 38, 0.82);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.topbar__id { display: flex; align-items: center; gap: 0.6rem; }

.topbar__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--offline);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
}
.topbar__dot.is-live {
  background: var(--ok);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.topbar__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.topbar__meta { display: flex; align-items: center; gap: 0.9rem; }

.clock {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- status pills ---------- */
.pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill--ok      { color: #062e22; background: var(--ok); }
.pill--alert   { color: #3a0713; background: var(--alert); }
.pill--offline,
.pill--muted   { color: var(--ink-muted); background: transparent; border-color: var(--line); }

/* ---------- readout tiles ---------- */
.wrap { padding: clamp(1rem, 4vw, 2.25rem); max-width: 1100px; margin: 0 auto; }

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(0.75rem, 2vw, 1.25rem);
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
}
@media (max-width: 720px) {
  .tiles { grid-template-columns: 1fr; }
}

.tile {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 1.15rem 1.25rem 1.1rem;
  overflow: hidden;
}
/* status accent strip down the left edge */
.tile::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--offline);
}
.tile.is-ok::before      { background: var(--ok); }
.tile.is-alert::before   { background: var(--alert); }
.tile.is-offline::before { background: var(--offline); }

.tile__top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
}
.tile__label { font-size: 0.98rem; font-weight: 600; }
.tile__where { font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.1rem; }

.tile__reading {
  display: flex; align-items: baseline; gap: 0.4rem;
  margin: 0.9rem 0 0.35rem;
}
.tile__value {
  font-family: var(--mono);
  font-size: 2.7rem;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.tile__unit { font-size: 1rem; color: var(--ink-muted); }

.tile__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.76rem;
  color: var(--ink-faint);
}
.tile__age { font-family: var(--mono); }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 0.4rem; vertical-align: middle; background: var(--offline);
}
.dot.is-ok { background: var(--ok); }
.dot.is-alert { background: var(--alert); }
.dot.is-offline { background: var(--offline); }

/* ---------- chart panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 1.15rem clamp(1rem, 2.5vw, 1.5rem) 1.35rem;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.panel__title { margin: 0; font-size: 0.98rem; font-weight: 600; color: var(--ink); }

.range { display: inline-flex; gap: 0.25rem; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px; padding: 0.2rem; }
.range__btn {
  font: inherit; font-size: 0.8rem; color: var(--ink-muted);
  background: transparent; border: 0; border-radius: 7px;
  padding: 0.32rem 0.7rem; cursor: pointer;
}
.range__btn:hover { color: var(--ink); }
.range__btn.is-active { background: var(--panel-2); color: var(--ink); }
.range__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.chart-holder { position: relative; width: 100%; }

/* ---------- footer note ---------- */
.foot {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.8rem;
  padding: 0 1rem 2rem;
  margin: 0.5rem 0 0;
}
.foot.is-error { color: var(--alert); }

@media (prefers-reduced-motion: reduce) {
  .topbar__dot.is-live { animation: none; }
}
