/* FieldReach by Hayland — ISA-101 style: grey is normal, colour means "look here". */
:root {
  --canvas: #D6DADE;
  --panel: #ECEEF0;
  --panel-2: #E2E5E8;
  --ink: #1C2228;
  --muted: #5A646E;
  --line: #B3BAC1;
  --pv: #24405E;          /* process values */
  --band: #C3CAD1;        /* normal operating band on range bars */
  --crit: #C8102E;
  --crit-bg: #F6D5DA;
  --warn: #D99000;
  --warn-bg: #F7E7C2;
  --comm: #7B4FB8;
  --comm-bg: #E6DCF3;
  --ok: #2E7D4F;
  --focus: #1F6FD1;
  --shadow: 0 1px 0 rgba(28,34,40,.08);
  --font: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #23282D; --panel: #2E343A; --panel-2: #353C43; --ink: #E3E7EA; --muted: #9AA4AD;
    --line: #48515A; --pv: #A9C4E0; --band: #48525C; --crit: #FF5A6E; --crit-bg: #4A2228;
    --warn: #F2B23A; --warn-bg: #4A3A17; --comm: #B993F0; --comm-bg: #392E4D; --ok: #5CC28A;
    --focus: #6FA8F5; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #23282D; --panel: #2E343A; --panel-2: #353C43; --ink: #E3E7EA; --muted: #9AA4AD;
  --line: #48515A; --pv: #A9C4E0; --band: #48525C; --crit: #FF5A6E; --crit-bg: #4A2228;
  --warn: #F2B23A; --warn-bg: #4A3A17; --comm: #B993F0; --comm-bg: #392E4D; --ok: #5CC28A;
  --focus: #6FA8F5; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--canvas); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.4; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---- shell ------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.nav {
  background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 4px 16px; font-weight: 700; font-size: 16px; white-space: nowrap; letter-spacing: -.01em; }
.brand svg { flex: none; }
.brand .bn { display: flex; flex-direction: column; line-height: 1.1; }
.brand .bn small { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav a {
  text-decoration: none; padding: 8px 10px; border-radius: 4px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.on { background: var(--panel-2); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--pv); }
.nav .spacer { flex: 1; }
.nav .who { font-size: 13px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--line); }
.count {
  min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; text-align: center;
  background: var(--crit); color: #fff; font-weight: 600;
}
.count.warn { background: var(--warn); color: #1C2228; }

main { min-width: 0; }

/* The alarm strip is the one loud thing on the screen. Quiet when all is well. */
.strip {
  display: flex; align-items: center; gap: 14px; padding: 8px 20px; min-height: 42px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 14px;
  position: sticky; top: 0; z-index: 5;
}
.strip.crit { background: var(--crit); color: #fff; border-color: var(--crit); }
.strip.warn { background: var(--warn); color: #1C2228; border-color: var(--warn); }
.strip.offline { background: var(--ink); color: var(--canvas); border-color: var(--ink); }
.strip.crit .muted, .strip.warn .muted { color: inherit; opacity: .85; }
.strip .msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip .pulse { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; }
.strip.crit .pulse { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .strip.crit .pulse { animation: none; } }
.strip .btn, .strip button { border-color: currentColor; background: transparent; color: inherit; text-decoration: none; }
.strip .btn:hover { background: rgba(255,255,255,.15); }

.page { padding: 20px; max-width: 1500px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head p { margin: 2px 0 0; color: var(--muted); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- controls ----------------------------------------------------------- */
.btn, button {
  border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 4px;
  cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover, button:hover { background: var(--panel-2); }
.btn.primary { background: var(--pv); border-color: var(--pv); color: var(--canvas); font-weight: 600; }
.btn.danger { color: var(--crit); }
.btn.small { padding: 4px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 4px; padding: 7px 9px; min-width: 0;
}
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--pv); }
label.f, div.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > span { color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--ink); font-size: 15px; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--pv); color: var(--canvas); }

/* ---- overview: well tiles ---------------------------------------------- */
.group { margin-bottom: 26px; }
.group > h2 { margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 12px 12px 10px;
  text-decoration: none; display: block; box-shadow: var(--shadow); position: relative;
}
.tile:hover { border-color: var(--muted); }
.tile.crit { border-color: var(--crit); box-shadow: inset 4px 0 0 var(--crit); }
.tile.warn { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.tile.comm { border-color: var(--comm); box-shadow: inset 4px 0 0 var(--comm); }
.tile .top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tile .top h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 12px; color: var(--muted); }
.flag { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 3px; white-space: nowrap; align-self: flex-start; }
.flag.crit { background: var(--crit); color: #fff; }
.flag.warn { background: var(--warn); color: #1C2228; }
.flag.comm { background: var(--comm); color: #fff; }
.flag.ok { color: var(--muted); font-weight: 400; padding: 0; }

/* value row + range bar */
.pv { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; padding: 5px 0 6px; }
.pv + .pv { border-top: 1px solid var(--panel-2); }
.pv .name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv .val { font-size: 19px; font-weight: 600; color: var(--pv); white-space: nowrap; }
.pv .val small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.pv .val.crit { color: var(--crit); }
.pv .val.warn { color: var(--warn); }
.pv .val.stale { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.pv .val.bad { color: var(--comm); }
.range { grid-column: 1 / -1; display: block; height: 8px; position: relative; margin-top: 4px; }
.range .rail { position: absolute; inset: 3px 0; background: var(--panel-2); border-radius: 1px; }
.range .band { position: absolute; top: 2px; bottom: 2px; background: var(--band); }
.range .lim { position: absolute; top: 0; bottom: 0; width: 2px; }
.range .lim.lw { background: var(--warn); }
.range .lim.lc { background: var(--crit); }
.range .mark { position: absolute; top: -1px; width: 3px; height: 10px; background: var(--ink); margin-left: -1px; border-radius: 1px; }
.range .mark.crit { background: var(--crit); }
.range .mark.warn { background: var(--warn); }
.tile .foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- panels / tables -------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.panel > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel > .body { padding: 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--panel-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.sel td { background: var(--panel-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.tablewrap { overflow-x: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--comm); }
.sev { font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 3px; }
.sev.s1 { background: var(--crit); color: #fff; }
.sev.s2 { background: var(--warn); color: #1C2228; }
tr.unack td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
tr.cleared td { color: var(--muted); }

/* ---- trend ----------------------------------------------------------- */
.trend svg { width: 100%; height: 260px; display: block; }
.trend .grid line { stroke: var(--panel-2); }
.trend .axis text { fill: var(--muted); font-size: 11px; }
.trend .limit { stroke-dasharray: 4 3; stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: 3px; }

/* ---- dashboards ---------------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; grid-auto-flow: dense; }
.w { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 12px; min-height: 130px; position: relative; display: flex; flex-direction: column; }
.w.sz-s { grid-column: span 1; }
.w.sz-m { grid-column: span 2; }
.w.sz-l { grid-column: span 3; }
.w.sz-w { grid-column: span 4; }
.w > h3 { font-size: 14px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.w .big { font-size: 40px; font-weight: 600; color: var(--pv); line-height: 1.05; }
.w .big small { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.w .big.crit { color: var(--crit); }
.w .big.warn { color: var(--warn); }
.w .wbody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.w .wbody.trend { display: block; }
.w .when { font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.w.editing { outline: 2px dashed var(--line); outline-offset: -2px; cursor: grab; }
.w.dragging { opacity: .4; }
.w.dropto { outline-color: var(--pv); }
.wbody .tile { border: 0; box-shadow: none; padding: 0; background: none; }
.wbody .tile .top h3 { font-size: 17px; }
.w .edit { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
/* ---- control-room skin (dashboards) ----------------------------------------
   Dark slate canvas, cards a step darker, values in near-white, trends in
   ice blue, running/OK in green. Alarm red/amber keep their meaning. */
.shell.hmi-dark {
  --canvas: #2B3137; --panel: #1D2125; --panel-2: #2C3238; --ink: #ECEFF2; --muted: #8D97A1;
  --line: #3B434B; --pv: #F3F6F8; --band: #3B434B; --crit: #FF4D61; --warn: #F5B53D;
  --comm: #B48CF5; --ok: #3DDC84; --focus: #6FB3FF;
  --s1: #7CC4FA; --s2: #3DDC84; --s3: #F3F6F8; --s4: #F5B53D;
  --run: #3DDC84; --tank: #2D7FF9; --nav: #22272C; --edge: #15181B; color-scheme: dark;
}
/* Medium: classic plant-HMI grey. Darker accents keep contrast on grey. */
.shell.hmi-medium {
  --canvas: #7D8892; --panel: #B9C1C8; --panel-2: #A9B2BA; --ink: #11161B; --muted: #39424B;
  --line: #8E99A2; --pv: #0E2A46; --band: #97A2AB; --crit: #B0001E; --warn: #8F5A00;
  --comm: #5A2C9E; --ok: #146B3A; --focus: #0B57C2;
  --s1: #0E4C86; --s2: #146B3A; --s3: #11161B; --s4: #8F5A00;
  --run: #146B3A; --tank: #1F5FB8; --nav: #A3ADB5; --edge: #6E7983; color-scheme: light;
}
/* Classic: white screens, grey window frame, bold black labels, blue values. */
.shell.hmi-classic {
  --canvas: #E4E4E4; --panel: #FFFFFF; --panel-2: #F0F0F0; --ink: #000000; --muted: #4D4D4D;
  --line: #ABABAB; --pv: #1A2ECC; --band: #DADADA; --crit: #CC0000; --warn: #A65F00;
  --comm: #6A2FB0; --ok: #1C8A3A; --focus: #0A64D6;
  --s1: #1A2ECC; --s2: #CC0000; --s3: #1C8A3A; --s4: #000000;
  --run: #1C8A3A; --tank: #1A2ECC; --nav: #F0F0F0; --edge: #ABABAB; color-scheme: light;
  font-family: Tahoma, "Segoe UI", Verdana, Arial, sans-serif;
}
.shell.hmi-classic .w { border-radius: 2px; box-shadow: none; }
.shell.hmi-classic .btn, .shell.hmi-classic button { border-radius: 3px; background: linear-gradient(#FDFDFD, #E5E5E5); border-color: #ADADAD; }
.shell.hmi-classic .btn.primary, .shell.hmi-classic .seg button.on { background: #CCE4F7; border-color: #2A7AD2; color: #000; }
.shell.hmi { background: var(--canvas); color: var(--ink); }
.shell.hmi .nav { background: var(--nav); border-color: var(--edge); }
.shell.hmi .nav a { color: var(--muted); }
.shell.hmi .nav a.on, .shell.hmi .nav a:hover { color: var(--ink); background: var(--panel-2); }
.shell.hmi .nav a.on { box-shadow: inset 3px 0 0 var(--s1); }
.shell.hmi .strip:not(.crit):not(.warn):not(.offline) { background: var(--nav); border-color: var(--edge); }
.shell.hmi-dark .btn.primary { background: var(--s1); border-color: var(--s1); color: #12171C; }
.shell.hmi-medium .btn.primary { background: var(--pv); border-color: var(--pv); color: #fff; }
.shell.hmi .w { border-color: var(--edge); border-radius: 6px; box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.shell.hmi .w > h3 { color: var(--ink); font-weight: 600; letter-spacing: .01em; }
.shell.hmi .empty { border-color: var(--line); }
:root { --s1: var(--pv); --s2: #2A8C8C; --s3: #A4622B; --s4: #7B6A9E; --run: #2E7D4F; --tank: #2D6CC8; }

/* ring gauge */
.gauge { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; }
.gauge svg { width: 100%; max-width: 190px; max-height: 170px; }
.ring-track { stroke: var(--panel-2); }
.ring-band { stroke: var(--band); }
.ring-val { stroke: var(--pv); transition: stroke-dashoffset .6s ease; }
.ring-val.warn { stroke: var(--warn); }
.ring-val.crit { stroke: var(--crit); }
@media (prefers-reduced-motion: reduce) { .ring-val { transition: none; } }

/* sparkline */
.spark { display: block; width: 100%; height: 46px; }
.spark path.ln { fill: none; stroke: var(--s1); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark path.ar { fill: var(--s1); opacity: .12; }

/* well card: one per well, like an equipment faceplate */
.wc { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.wc-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: -12px -12px 0; border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--panel-2), var(--panel)); border-radius: 6px 6px 0 0; text-decoration: none; }
.wc-head b { font-size: 15px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-head .k { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.led { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.led.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.led.fail { background: var(--comm); box-shadow: 0 0 6px var(--comm); }
.led.crit { background: var(--crit); box-shadow: 0 0 6px var(--crit); }
.led.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.wc-main { display: grid; grid-template-columns: 46% 1fr; gap: 8px; align-items: stretch; }
.wc-main > .wc-cell { display: flex; flex-direction: column; }
.wc-main > .wc-cell .spark { margin-top: auto; height: 52px; }
.wc-cell { background: var(--panel-2); border-radius: 4px; padding: 7px 8px; min-width: 0; }
.wc-cell .lbl { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-cell .lbl svg { flex: none; width: 14px; height: 14px; stroke: var(--muted); }
.wc-cell .v { font-size: 20px; font-weight: 600; color: var(--pv); line-height: 1.15; white-space: nowrap; }
.wc-cell .v small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.wc-cell .v.crit { color: var(--crit); } .wc-cell .v.warn { color: var(--warn); }
.wc-cell .v.stale { color: var(--muted); } .wc-cell .v.bad { color: var(--comm); }
.wc-cell .v.run { color: var(--run); letter-spacing: .04em; font-size: 16px; }
.wc-cell .v.stop { color: var(--crit); letter-spacing: .04em; font-size: 16px; }
.wc-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.wc-tiles .lbl { white-space: normal; display: block; line-height: 1.2; min-height: 2.4em; font-size: 11.5px; }
.wc-tiles .lbl svg { display: none; }
.wc-tiles .v { font-size: 17px; }
.wc-ring { display: flex; align-items: center; justify-content: center; }
.wc-ring .gauge svg { max-width: 150px; }
.wc-foot { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

/* meter run screen */
.mr { display: flex; flex-direction: column; height: 100%; }
.mr-tabs { display: flex; gap: 0; margin: -4px -4px 0; overflow-x: auto; }
.mr-tabs button { border: 1px solid var(--line); border-bottom: 0; border-radius: 3px 3px 0 0; background: var(--panel-2); padding: 4px 10px; font-size: 12.5px; margin-right: -1px; color: var(--ink); }
.mr-tabs button.on { background: var(--panel); position: relative; top: 1px; font-weight: 600; }
.mr-body { border: 1px solid var(--line); background: var(--panel); padding: 6px; flex: 1; min-height: 300px; margin: 0 -4px; }
.mr-svg { width: 100%; height: auto; display: block; }
.mr-svg text { font-family: Tahoma, "Segoe UI", Verdana, Arial, sans-serif; font-size: 13px; fill: var(--ink); }
.mr-svg .ml { font-weight: 700; }
.mr-svg .mv { fill: var(--pv); font-weight: 400; }
.mr-svg .mv.crit { fill: var(--crit); font-weight: 700; } .mr-svg .mv.warn { fill: var(--warn); font-weight: 700; }
.mr-svg .mv.stale { fill: var(--muted); } .mr-svg .mv.bad { fill: var(--comm); }
.mr-svg .mr-title { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.mr-svg .mr-sub { font-size: 11.5px; font-weight: 700; fill: var(--muted); }
.mr-svg .mr-tiny { font-size: 6.5px; font-weight: 700; fill: #444; letter-spacing: .04em; }
.mr-svg .mr-lcd { font-size: 8px; font-family: "Consolas", "Courier New", monospace; fill: #2f3d29; }
.shell.hmi-dark .mr-svg .mr-art, .shell.hmi-medium .mr-svg .mr-art { opacity: .92; }
.mr-table table { font-size: 12.5px; }
.mr-table td, .mr-table th { padding: 4px 8px; white-space: nowrap; }
.mr-bar { display: flex; align-items: center; gap: 10px; padding-top: 8px; font-size: 12.5px; }
.mr-bar .muted { flex: 1; }

/* tank fill */
.tankw { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; }
.tankw svg { width: 100%; max-width: 170px; max-height: 170px; }
.tank-fill { fill: var(--tank); transition: y .6s ease, height .6s ease; }
.tank-fill.warn { fill: var(--warn); } .tank-fill.crit { fill: var(--crit); }

/* bar meter */
.barw { display: grid; grid-template-columns: 26px 1fr; gap: 14px; align-items: stretch; flex: 1; min-height: 150px; }
.barw .track { background: var(--panel-2); border-radius: 3px; position: relative; overflow: hidden; }
.barw .fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--run); transition: height .6s ease; }
.barw .fill.warn { background: var(--warn); } .barw .fill.crit { background: var(--crit); }
.barw .lim { position: absolute; left: -2px; right: -2px; height: 2px; }
.barw .meta { display: flex; flex-direction: column; justify-content: flex-end; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 4px; }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 auto 14px; max-width: 46ch; }

/* ---- reports ----------------------------------------------------------- */
.rep-form { margin-bottom: 14px; }
.rep-form .formgrid { align-items: end; }
.rep-run { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.wellpick { position: relative; }
.wellpick summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 4px; padding: 7px 9px; color: var(--ink); font-size: 15px; }
.wellpick summary::after { content: "▾"; float: right; color: var(--muted); }
.wellpick[open] .picker { position: absolute; z-index: 10; left: 0; right: 0; min-width: 260px; background: var(--panel); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.rep-tools { margin-bottom: 8px; }
.rep-range { margin: 4px 0 12px; }
.rep .panel + .panel, .rep-sum { margin-bottom: 14px; }
.rep-well header { align-items: flex-start; }
.rep-well header h2 { margin-bottom: 2px; }
.rep-well header .muted { font-size: 13px; }
.rep-table td, .rep-table th { white-space: nowrap; }
.rep-table th { vertical-align: bottom; line-height: 1.25; }
.rep-table .mm { display: block; font-size: 11px; color: var(--muted); }
.rep-table tr.tot td { border-top: 2px solid var(--line); font-weight: 600; }
td.gap { color: var(--warn); font-weight: 600; }
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  :root, .shell { --canvas: #fff; --panel: #fff; --panel-2: #f2f2f2; --ink: #000; --muted: #555; --line: #bbb; --warn: #8a5a00; }
  body { background: #fff; font-size: 11px; }
  .nav, .strip, .no-print, .toast, .rep > .head { display: none !important; }
  .shell { display: block; padding: 0; }
  .page { padding: 0; max-width: none; }
  .print-only { display: block; }
  .rep-title h1 { font-size: 18px; margin: 0; }
  .panel { box-shadow: none; border-color: #bbb; break-inside: avoid; margin-bottom: 10px; }
  .tablewrap { overflow: visible; }
  .rep-table { font-size: 9px; }
  .rep-table td, .rep-table th { padding: 3px 4px; white-space: normal; }
  a { text-decoration: none; }
}

/* ---- alert rules ---------------------------------------------------- */
.ar { margin-bottom: 14px; }
.ar header { align-items: flex-start; }
.ar header .muted { font-size: 13px; }
.ar-table th.c, .ar-table td.c { text-align: center; }
.ar-table th.sub { font-weight: 500; font-size: 12px; padding-top: 0; }
.ar-table thead tr:first-child th.c { border-bottom: 0; }
.ar-table tr.wellrow td { background: var(--panel-2); }
.ar-table tr.follows td:not(:first-child) { opacity: .55; }
.ar-table td.c.muted { font-size: 12px; }
.chk.mini { font-size: 12px; color: var(--muted); gap: 5px; margin-top: 2px; }
.chk.mini input { width: 15px; height: 15px; }

/* ---- forms / dialogs ------------------------------------------------- */
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.formgrid .span2 { grid-column: span 2; }
.formgrid .full { grid-column: 1 / -1; }
dialog {
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink);
  padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(20, 26, 32, .45); }
dialog header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
dialog .body { padding: 18px; overflow: auto; max-height: calc(100vh - 170px); }
dialog footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.err { color: var(--crit); font-size: 14px; margin-right: auto; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--pv); font-weight: 600; }
.picker { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.picker label { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--panel-2); align-items: center; font-size: 14px; }
.picker label:hover { background: var(--panel-2); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--canvas); padding: 9px 16px; border-radius: 4px; z-index: 50; font-size: 14px; }

/* ---- login ---------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background-color: #1c0e16;
  background-image: linear-gradient(rgba(10,6,10,.2), rgba(10,6,10,.4)), url(/login-bg.jpg);
  background-position: center, 20% 80%; background-size: cover, cover; background-repeat: no-repeat; }
/* phones: the wide photo sits along the bottom so the pump jack shows below the sign-in box */
@media (max-width: 860px) {
  .login { place-items: start center; padding-top: max(7vh, env(safe-area-inset-top));
    background-image: linear-gradient(#1c0e16 0, rgba(28,14,22,0) 30%), url(/login-bg-small.jpg);
    background-position: left bottom, 12% bottom; background-size: 100% 46vh, auto 46vh; }
}
.login form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.login .empty { background: var(--panel); border-radius: 6px; padding: 26px; }
.install { display: contents; }
.install[hidden] { display: none; }
.login .brand { padding: 0 0 6px; font-size: 20px; }

/* ---- mobile --------------------------------------------------------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .nav {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
  }
  .nav .brand, .nav .spacer, .nav .who { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 8px; flex: 1; justify-content: center; }
  .nav a.on { box-shadow: inset 0 3px 0 var(--pv); }
  .nav a .count { font-size: 10px; min-width: 16px; }
  .page { padding: 14px 16px; }
  .strip { padding: calc(8px + env(safe-area-inset-top)) 16px 8px; }
  .cols { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .w.l, .w.w, .w.sz-m { grid-column: span 2; }
  .trend svg { height: 210px; }
  .hide-sm { display: none; }
}
