/* Stakeout — "surveillance instrument panel" theme.
   Dark ops-room glass, blueprint grid + faint scanlines, orange accent, green
   "on watch" status, monospace numerals. Family genes from Cellmate/Joyride,
   its own identity: corner-reticle framed tiles, a REC pulse, evidence tone. */

@font-face { font-family: 'Archivo'; src: url('/vendor/fonts/archivo-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('/vendor/fonts/archivo-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Chivo Mono'; src: url('/vendor/fonts/chivomono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Chivo Mono'; src: url('/vendor/fonts/chivomono-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #08090c;
  --surface: #0f1318;
  --surface-2: #161d25;
  --line: #212a33;
  --hairline: rgba(255, 255, 255, 0.08);
  --text: #e8edf2;
  --muted: #7f8b97;
  --accent: #ff7a18;          /* brand orange */
  --accent-dim: #6f3510;
  --accent-soft: rgba(255, 122, 24, 0.12);
  --live: #35e0a1;            /* "on watch" — status only, not brand */
  --warn: #f5c542;
  --bad: #ff5468;
  --cold: #57b6ff;           /* cool readout tint for low temps */

  --radius: 10px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --sans: 'Archivo', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Chivo Mono', ui-monospace, 'SF Mono', monospace;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  --grid: rgba(87, 182, 255, 0.035);   /* blueprint blue, very faint */
  --scan: rgba(255, 255, 255, 0.015);
  --num-hero: clamp(40px, 12vw, 60px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { font-size: 17px; }
body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  background:
    repeating-linear-gradient(0deg, var(--scan) 0 1px, transparent 1px 3px),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 30px 30px,
    radial-gradient(120% 80% at 50% -10%, #101821 0%, var(--bg) 62%);
}
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.5rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button, input, select { font-family: inherit; color: inherit; }
a { color: inherit; }

/* ---- App bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.7rem calc(1rem + env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(8, 9, 12, 0.94), rgba(8, 9, 12, 0.66));
  backdrop-filter: blur(9px);
  border-bottom: 1px solid var(--line);
}
.appbar__spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.brand__logo { display: block; }
.brand__name { font-weight: 700; letter-spacing: 0.22em; font-size: 0.98rem; }
.brand__rec {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 8px 1px var(--live); animation: rec 2s infinite; margin-left: 2px;
}
@keyframes rec { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.unit-toggle__btn {
  min-width: 44px; min-height: 34px; padding: 0 0.4rem; border: 0; background: transparent;
  color: var(--muted); font: 600 0.85rem var(--mono); cursor: pointer;
}
.unit-toggle__btn.is-active { background: var(--accent); color: #1a0d02; }

/* ---- Layout ---- */
main#view {
  max-width: 820px; margin: 0 auto;
  padding: 1rem calc(1rem + env(safe-area-inset-right)) 2rem calc(1rem + env(safe-area-inset-left));
}
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin: 0.2rem 0 1rem; }
.view-head h2 { font-size: 1.05rem; letter-spacing: 0.06em; text-transform: uppercase; margin: 0; }
.view-head .sub { color: var(--muted); font: 0.72rem var(--mono); }
.tagline { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; margin: -0.4rem 0 1rem; font-style: italic; }

/* ---- Bottom tab bar / desktop rail ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; border-top: 1px solid var(--line);
  background: rgba(10, 13, 16, 0.96); backdrop-filter: blur(10px);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; text-decoration: none; color: var(--muted);
  font: 600 11px var(--sans); letter-spacing: 0.06em; text-transform: uppercase;
}
.tabbar__glyph { font-size: 1.05rem; line-height: 1; filter: grayscale(1) opacity(0.85); }
.tabbar a.is-active { color: var(--accent); }
.tabbar a.is-active .tabbar__glyph { filter: none; }

/* ---- Cards & tiles (corner-reticle framed) ---- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: var(--sp-4);
}
.grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.tile {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-4); overflow: hidden; text-decoration: none; color: var(--text);
  transition: border-color 0.15s, transform 0.08s;
}
.tile:active { transform: scale(0.99); }
.tile:hover { border-color: var(--accent-dim); }
/* corner reticle brackets — targeting frame */
.tile::before, .tile::after {
  content: ''; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border: 0 solid var(--accent-dim); opacity: 0.8; transition: border-color 0.15s;
}
.tile::before { top: 7px; left: 7px; border-top-width: 2px; border-left-width: 2px; }
.tile::after { bottom: 7px; right: 7px; border-bottom-width: 2px; border-right-width: 2px; }
.tile:hover::before, .tile:hover::after { border-color: var(--accent); }

.tile__head { display: flex; align-items: center; gap: 0.5rem; }
.tile__name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tile__name b { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__name small { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; }
.tile__temp { font: 700 var(--num-hero)/1 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--accent); }
.tile__temp .u { font-size: 0.4em; color: var(--muted); margin-left: 2px; }
.tile__temp.is-cold { color: var(--cold); }
.tile__temp.is-stale { color: var(--muted); }
.tile__mm { display: flex; gap: 1.1rem; font: 0.72rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.tile__mm b { color: var(--text); font-weight: 600; }
.tile__spark { width: 100%; height: 34px; display: block; margin-top: auto; }
.tile__foot { display: flex; align-items: center; gap: 0.4rem; font: 0.66rem var(--mono); color: var(--muted); }

/* freshness / status dot */
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--live); box-shadow: 0 0 6px 1px var(--live); animation: rec 2.4s infinite; }
.dot.stale { background: var(--warn); }
.dot.dead { background: var(--bad); }

/* ---- Awaiting credentials ---- */
.awaiting {
  max-width: 30rem; margin: 3rem auto; text-align: center;
  border: 1px dashed var(--line); border-radius: 14px; padding: 2.4rem 1.6rem; background: var(--surface);
}
.awaiting__eye { font-size: 2.6rem; filter: grayscale(1); opacity: 0.6; }
.awaiting h3 { margin: 0.8rem 0 0.4rem; font-size: 1.15rem; letter-spacing: 0.04em; }
.awaiting p { color: var(--muted); line-height: 1.6; margin: 0.4rem 0; }
.awaiting code { font-family: var(--mono); background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 6px; color: var(--accent); }

/* ---- Controls (chips / presets / segmented) ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: var(--sp-3); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: 0.74rem var(--sans); letter-spacing: 0.03em; padding: 0.42rem 0.7rem; min-height: 36px;
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.chip.is-active { color: var(--text); border-color: var(--accent); }
.chip__swatch { width: 9px; height: 9px; border-radius: 2px; background: var(--c, var(--muted)); }
.presets { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.presets button {
  min-height: 36px; padding: 0 0.85rem; border: 0; background: transparent; color: var(--muted);
  font: 600 0.76rem var(--mono); cursor: pointer;
}
.presets button.is-active { background: var(--accent); color: #1a0d02; }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.55rem 0.95rem; font-size: 0.88rem; cursor: pointer; min-height: 44px;
  transition: border-color 0.15s, background 0.15s; text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--accent-dim); }
.btn--accent { background: var(--accent); color: #1a0d02; border-color: var(--accent); font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field label { font: 0.66rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.inp {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.6rem;
  color: var(--text); font: 0.9rem var(--mono); min-height: 42px;
}

/* ---- Chart ---- */
.chart-readout {
  min-height: 1.4rem; font: 0.78rem var(--mono); font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; margin-bottom: 0.4rem; color: var(--muted);
}
.chart-readout .t { color: var(--muted); }
.chart-readout .v { color: var(--text); }
.chart-host { width: 100%; overflow-x: auto; min-height: 260px; }
.chart-host .uplot { margin: 0 auto; font-family: var(--mono); }
.uplot { font-family: var(--mono); }

/* ---- Alibi day table ---- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.days { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.days th, table.days td { padding: 0.55rem 0.7rem; text-align: right; white-space: nowrap; }
table.days th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--muted);
  font: 600 0.66rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--line);
}
table.days th.day, table.days td.day { text-align: left; font-family: var(--mono); }
table.days tbody tr { border-bottom: 1px solid var(--hairline); }
table.days tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.012); }
table.days td { font: 0.82rem var(--mono); }
table.days td b { color: var(--text); font-weight: 600; }
table.days td.hi b { color: var(--accent); }
table.days td.lo b { color: var(--cold); }
table.days td.empty { color: var(--muted); }
.day-group { border-left: 1px solid var(--line); }

.empty { color: var(--muted); text-align: center; padding: 2.4rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { color: var(--muted); text-align: center; padding: 2rem; font: 0.85rem var(--mono); }

/* ---- Desktop: rail + wide ---- */
@media (min-width: 900px) {
  html { font-size: 16px; }
  .tabbar {
    top: 0; bottom: 0; right: auto; width: 208px; flex-direction: column; align-items: stretch; gap: 0.15rem;
    border-top: none; border-right: 1px solid var(--line); padding-top: 3.6rem;
  }
  .tabbar a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 0.7rem; padding: 0.85rem 1.5rem; font-size: 0.86rem; border-left: 2px solid transparent; }
  .tabbar a.is-active { border-left-color: var(--accent); background: var(--surface); }
  .tabbar a:hover { color: var(--text); background: var(--surface); }
  .appbar { padding-left: calc(208px + 1rem); z-index: 7; }
  main#view { margin-left: 208px; max-width: 1100px; padding: 1.6rem 2.2rem 3rem; }
  body { padding-bottom: 0; }
}
