/* Watch It Meander - built to be legible one-handed on a phone, in a dim
   brewhouse, at 3 a.m. Dark by default for that reason. */

:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #24282f;
  --line: #333844;
  --text: #e8eaed;
  --muted: #9aa2b1;
  --accent: #5aa9e6;
  --ok: #3ddc84;
  --hot: #ff4b4b;
  --cold: #4b9dff;
  --probe: #ff5cf4;
  --comms: #ffa726;
  --off: #5b6170;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 3rem;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; margin-top: 1.6rem; }

header.topbar {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
  padding: .7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.topbar .brand { font-weight: 700; letter-spacing: .02em; margin-right: auto; }
header.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
header.topbar nav a {
  padding: .35rem .7rem; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-size: .9rem;
}
header.topbar nav a:hover { background: var(--panel-2); color: var(--text); }
header.topbar nav a.active { background: var(--accent); color: #08121c; font-weight: 600; }

main { padding: 1rem; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; margin-bottom: 1rem;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }

/* -- tank grid ---------------------------------------------------------- */
.grid {
  display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--off);
  border-radius: 10px; padding: .6rem .7rem;
}
.tile .name { font-weight: 600; font-size: .95rem; }
.tile .temp { font-size: 1.6rem; font-weight: 700; margin: .15rem 0; font-variant-numeric: tabular-nums; }
.tile .range { font-size: .78rem; color: var(--muted); }
.tile .status { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; margin-top: .35rem; }

.state-in_range { border-left-color: var(--ok); }
.state-in_range .status { color: var(--ok); }
.state-disabled { border-left-color: var(--off); opacity: .6; }
.state-hot_unacked { border-left-color: var(--hot); animation: blink 1s steps(2, start) infinite; }
.state-cold_unacked { border-left-color: var(--cold); animation: blink 1s steps(2, start) infinite; }
.state-hot_acked, .state-hot_snoozed { border-left-color: var(--hot); }
.state-cold_acked, .state-cold_snoozed { border-left-color: var(--cold); }
.state-hot_snoozed, .state-cold_snoozed { animation: breathe 4.5s ease-in-out infinite; }
.state-probe_fault { border-left-color: var(--probe); animation: blink 1s steps(2, start) infinite; }
.state-no_comms { border-left-color: var(--comms); animation: breathe 2s ease-in-out infinite; }
.state-hot_unacked .temp, .state-hot_acked .temp, .state-hot_snoozed .temp { color: var(--hot); }
.state-cold_unacked .temp, .state-cold_acked .temp, .state-cold_snoozed .temp { color: var(--cold); }
.state-probe_fault .temp { color: var(--probe); }

@keyframes blink { 50% { opacity: .45; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .tile { animation: none !important; }
}

/* -- alerts ------------------------------------------------------------- */
.alert {
  border: 1px solid var(--line); border-left: 5px solid var(--hot);
  background: var(--panel-2); border-radius: 10px; padding: .7rem .8rem; margin-bottom: .6rem;
}
.alert.cold { border-left-color: var(--cold); }
.alert.probe_missing { border-left-color: var(--probe); }
.alert.node_offline { border-left-color: var(--comms); }
.alert .title { font-weight: 600; }
.alert .actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--comms); border-color: var(--comms); }
.badge.bad { color: var(--hot); border-color: var(--hot); }

/* -- forms and buttons -------------------------------------------------- */
button, .btn {
  font: inherit; font-size: .9rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #08121c; border-color: var(--accent); font-weight: 600; }
button.danger { border-color: var(--hot); color: var(--hot); }
button.small, .btn.small { padding: .3rem .6rem; font-size: .8rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .2rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .5rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input[type="checkbox"] { width: auto; margin-right: .4rem; }
.field-row { display: grid; gap: .5rem 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.inline { display: inline-block; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

.notice { background: rgba(90, 169, 230, .12); border: 1px solid var(--accent); border-radius: 8px; padding: .6rem .8rem; margin-bottom: 1rem; }
.notice.warn { background: rgba(255, 167, 38, .12); border-color: var(--comms); }
.notice.bad { background: rgba(255, 75, 75, .12); border-color: var(--hot); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px; border: 1px solid var(--line); vertical-align: middle; }
.chart-wrap { position: relative; height: 260px; }
