/* Saltwater disposal demo — same tokens, same mobile-first strategy as
   chemdash's static/style.css (that file's header explains the reasoning in
   full; this is the same design system, extended with cards for tanks,
   alarms and the money screen, not a new look). Mobile first: base rules are
   the phone layout, and the 52rem query adds the desktop layout back. No
   framework, no build step — copy/paste plus new component classes, so the
   two stylesheets can be compared line for line if they ever need to be. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #14171c;
  --muted: #5b6472;
  --line: #dfe3e9;
  --accent: #1f5f9e;
  --on-accent: #ffffff;
  --control-line: #767e8c;
  --ok: #17703d;
  --low: #8f5608;
  --critical: #b3261e;
  --unknown: #6b7280;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a; --card: #171b24; --ink: #e8eaee; --muted: #9aa4b2;
    --line: #262c38; --control-line: #6b7484;
    --accent: #79b3e8; --on-accent: #10131a;
    --ok: #4ec27f; --low: #e0a444; --critical: #ef7d75; --unknown: #8b94a3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.nav-links a.active:focus-visible { outline-color: var(--ink); outline-offset: 3px; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  position: static; display: block; padding: .75rem 1rem;
  background: var(--accent); color: var(--on-accent);
}

/* ---------------------------------------------------------------- chrome */
.top {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  padding: .85rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -.01em;
  display: inline-flex; align-items: center; min-height: 44px;
}
.top .sub { color: var(--muted); font-size: .95rem; font-weight: 400; margin: 0; }

.nav {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  flex-wrap: wrap; padding: .5rem 1rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  max-height: 40vh; overflow-y: auto;
}
@media (max-height: 30rem) { .nav { position: static; } }
.nav-links { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none; color: var(--ink); padding: .5rem .7rem;
  border-radius: var(--radius); font-size: .95rem;
  min-height: 44px; display: inline-flex; align-items: center;
}
.nav-links a:hover { background: var(--bg); }
.nav-links a.active { background: var(--accent); color: var(--on-accent); }

main { padding: 1rem; max-width: 78rem; margin: 0 auto; }
.foot { padding: 1.5rem 1rem 2.5rem; color: var(--muted); font-size: .85rem; text-align: center; }
.muted { color: var(--muted); font-weight: 400; }
.lede { margin-top: 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h2:first-of-type { margin-top: 0; }

.card, .stat, .alarm, .grid td, .notice { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- blocks */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
}
.notice { background: var(--card); border: 1px solid var(--line);
          border-radius: var(--radius); padding: 1rem; margin-top: 1.25rem; }
.pill { display: inline-block; font-size: .72rem; padding: .12rem .45rem;
        border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.pill.warn { color: var(--critical); }
.pill.unknown { color: var(--unknown); }
.pill.ok { color: var(--ok); }

/* ---------------------------------------------------------------- meter */
.meter {
  display: block; width: 100%; max-width: 16rem; height: 10px;
  background: var(--line); border: 1px solid var(--control-line);
  border-radius: 999px; overflow: hidden; margin: .35rem 0 .35rem;
}
.meter > span { display: block; height: 100%; background: var(--ok); }
.band-low          .meter > span,
.band-critical-low .meter > span { background: var(--low); }
.band-critical-low .meter > span { background: var(--critical); }
.band-high          .meter > span { background: var(--low); }
.band-critical-high .meter > span { background: var(--critical); }
.band-unknown       .meter > span { background: var(--unknown); width: 100% !important; opacity: .25; }

.band-low strong, .band-high strong { color: var(--low); }
.band-critical-low strong, .band-critical-high strong { color: var(--critical); }
.band-unknown strong { color: var(--unknown); }
/* Colour is not the only signal — sunlight standing next to a tank kills
   colour first, and this also reaches a screen reader. */
.band-low strong::after          { content: " · low"; }
.band-critical-low strong::after { content: " · CRITICAL LOW"; }
.band-high strong::after         { content: " · high"; }
.band-critical-high strong::after{ content: " · CRITICAL HIGH"; }
.band-unknown strong::after      { content: " · no data"; }

/* ---------------------------------------------------------------- demo & control banners */
.demobar {
  margin: 0; padding: .55rem 1rem; text-align: center;
  background: var(--low); color: #fff; font-weight: 600; font-size: .9rem;
}
.demobar code { background: rgba(255,255,255,.22); padding: .05rem .3rem; border-radius: 4px; }

.controlbar {
  margin: 0; padding: .6rem 1rem; text-align: center;
  background: var(--accent); color: var(--on-accent); font-size: .88rem;
}

/* ---------------------------------------------------------------- tank grid */
.tankgroup { margin-bottom: 1.75rem; }
.tankgroup h2 { display: flex; align-items: baseline; gap: .5rem; }
.tankgroup h2 .count { font-size: .8rem; color: var(--muted); font-weight: 400; }
.tanks { display: grid; grid-template-columns: 1fr; gap: .8rem; }
@media (min-width: 30rem) { .tanks { grid-template-columns: 1fr 1fr; } }
@media (min-width: 52rem) { .tanks { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 68rem) { .tanks { grid-template-columns: repeat(4, 1fr); } }

.tank-id { font-weight: 700; }
.tank-row { display: flex; justify-content: space-between; gap: .5rem; margin-top: .3rem; }
.tank-row dt { color: var(--muted); font-size: .82rem; white-space: nowrap; flex: 0 0 auto; }
.tank-row dd { margin: 0; font-weight: 600; text-align: right; flex: 1 1 auto; white-space: nowrap; }
.source-tag { font-size: .78rem; color: var(--muted); margin-top: .5rem; }
.source-tag .src-hand { color: var(--accent); font-weight: 600; }
.source-tag .src-connected { color: var(--ink); font-weight: 600; }

/* equipment + chemical cards on the overview */
.equip-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-bottom: 1.75rem; }
@media (min-width: 40rem) { .equip-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 68rem) { .equip-grid { grid-template-columns: repeat(4, 1fr); } }
.status-line { display: flex; align-items: center; gap: .5rem; font-weight: 700; margin: .2rem 0 .5rem; }
.dot { width: .6rem; height: .6rem; border-radius: 999px; background: var(--ok); flex: none; }
.dot.down { background: var(--critical); }

/* ---------------------------------------------------------------- alarms */
.alarms { list-style: none; padding: 0; margin: 0; }
.alarm {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem;
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--critical);
  border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .7rem;
}
.alarm[data-sev="4"] { border-left-color: var(--critical); }
.alarm[data-sev="3"] { border-left-color: var(--low); }
.alarm[data-sev="2"] { border-left-color: var(--low); }
.alarm[data-sev="1"] { border-left-color: var(--unknown); }
.alarm .what { font-weight: 600; }
.alarm .since { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
         padding: 2rem 1rem; text-align: center; color: var(--ink); }

/* ---------------------------------------------------------------- money */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.5rem; }
@media (min-width: 40rem) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 68rem) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1rem; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.stat .value.big { font-size: 1.9rem; }
.stat .sub { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.stat.net { grid-column: 1 / -1; border-color: var(--accent); border-width: 2px; }
@media (min-width: 40rem) { .stat.net { grid-column: auto; } }

/* ---------------------------------------------------------------- forms (hand gauge entry) */
.form label { display: block; margin: .9rem 0 .3rem; font-weight: 600; font-size: .95rem; }
.form input {
  width: 100%; padding: .7rem .6rem; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--control-line);
  border-radius: var(--radius); min-height: 44px;
}
.form button {
  margin-top: .8rem; padding: .7rem 1rem; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--radius);
  cursor: pointer; min-height: 44px;
}
.gauge-note { font-size: .82rem; color: var(--muted); margin-top: .4rem; }

@media print {
  .nav, .foot, .controlbar { display: none; }
  main { max-width: none; padding: 0; }
}
