/* Fixed Point Control System
   Colours, type, and the header lockup match the Fixed Point jobs app
   (navy #13294B, amber #E8A33D, paper #f5f3ee, system-ui, ui-monospace).
   The plant page is a dark HMI built from those tokens. */

:root {
  --navy: #13294b;
  --navy-2: #1c3966;
  --amber: #e8a33d;
  --amber-ink: #8a5a0f;
  --paper: #f5f3ee;
  --white: #fff;
  --text: #181b20;
  --muted: #5b616c;
  --line: #e2ded4;
  --ok: #1d7a46;
  --ok-bg: #e3f3e9;
  --warn-bg: #fdf1dc;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 12px;
  --hmi: #0d1b33;
  --hmi-card: #13294b;
  --hmi-raise: #1c3966;
  --hmi-line: #2c4a73;
  --hmi-text: var(--paper);
  --hmi-muted: #c5cdd8;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  background: var(--paper);
  color: var(--text);
}
body.paper { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
body.noauth { padding-bottom: 0; min-height: 100vh; min-height: 100dvh; }
img { max-width: 100%; }
a { color: var(--navy); }
button, input { font: inherit; }
h1 { font-size: 1.35rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.top-left { display: flex; align-items: center; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; display: block; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand b { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand small {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  color: var(--amber);
  font-weight: 400;
}
.desk { display: none; }
.who { flex: none; }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 99px;
  background: #eef1f6;
  color: var(--navy);
  white-space: nowrap;
}
.pill.example {
  background: var(--warn-bg);
  color: var(--amber-ink);
  border: 1px dashed #e0b56a;
}
.pill.complete, .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad, .pill.cancelled { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: #eef1f6; color: var(--navy); }

.tabs {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1;
  text-align: center;
  padding: 9px 4px 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}
.tabs a svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--navy); font-weight: 650; }
.tabs a.on svg { stroke: var(--navy); }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin: 0 0 10px;
}
.meta { color: var(--muted); font-size: 0.86rem; margin: 0; }
.group {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-ink);
  margin: 18px 2px 8px;
}
.group:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.banner {
  background: var(--warn-bg);
  border: 1px dashed #e0b56a;
  color: var(--amber-ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin: 0 0 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.btn.sec { background: #fff; color: var(--navy); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: #1a1205; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.88rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 4px 0 0; }
.err {
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 600;
}
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; }
input[type="number"], input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid #cfcabd;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.login { max-width: 380px; margin: 8vh auto 0; padding: 0 20px 40px; }
.logo { display: flex; align-items: center; gap: 12px; margin: 0 0 22px; color: var(--text); }
.logo img { width: 52px; height: 52px; display: block; flex: none; }
.logo b { display: block; font-size: 1.45rem; letter-spacing: -0.02em; line-height: 1.05; }
.logo small {
  font-family: var(--mono);
  letter-spacing: 0.32em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
}
.links { text-align: center; margin: 14px 0 0; }

.swatch { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.swatch i { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); display: block; flex: none; }
.swatch b { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 0.93rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Plant HMI */
body.hmi {
  background: var(--hmi);
  color: var(--hmi-text);
  padding-bottom: 0;
}
body.hmi h1, body.hmi h2, body.hmi h3 { color: var(--hmi-text); }
body.hmi .meta, body.hmi .hint, body.hmi label { color: var(--hmi-muted); }
body.hmi .group { color: var(--amber); }
body.hmi .wrap { max-width: 1100px; }
body.hmi .sub { margin: 0 0 12px; color: var(--hmi-muted); font-size: 0.9rem; }

.runbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  margin: 0 0 12px;
  font-size: 0.92rem;
}
.runbar strong { font-weight: 650; }

.safety { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; }
.chip {
  background: var(--hmi-card);
  border: 1px solid var(--hmi-line);
  border-radius: var(--r);
  padding: 8px 8px 10px;
  min-width: 0;
}
.chip .k {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hmi-muted);
  margin-bottom: 6px;
  line-height: 1.2;
}
.case, .panel, .mod, .ret, .ha, .tools {
  background: var(--hmi-card);
  border: 1px solid var(--hmi-line);
  border-radius: var(--r);
}
.case, .panel { padding: 12px; margin: 0 0 12px; }
.flow { display: grid; gap: 8px; }
.mod { padding: 10px; border-top: 2px solid transparent; min-width: 0; }
.mod.is-on { border-top-color: var(--amber); }
.mod.is-alarm { border-top-color: var(--bad); }
.mod .k {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hmi-muted);
}
.mod .v, .ret .v, .ha-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.mod .v { font-size: 1.45rem; line-height: 1.15; margin: 2px 0; }
.mod .v small, .unit { font-size: 0.75rem; color: var(--hmi-muted); margin-left: 2px; font-weight: 400; }
.pair { display: flex; gap: 14px; margin: 4px 0; }
.pair span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pair i { font-style: normal; font-size: 0.75rem; color: var(--hmi-muted); }
body.hmi b.bad { color: #f0b4ae; }
body.hmi b.ok { color: #b7e4c7; }
.sym { width: 100%; height: 36px; margin-bottom: 4px; color: var(--hmi-muted); }
.mod.is-on .sym { color: var(--amber); }
.mod.is-alarm .sym { color: var(--bad); }
.sym svg { width: 72px; height: 36px; display: block; }
.return { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ret { padding: 10px; min-width: 0; }
.ret .k { display: block; font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--hmi-muted); }
.ret .v { font-size: 1.15rem; }

.alarm { padding: 2px 0 10px; border-bottom: 1px solid var(--hmi-line); margin-bottom: 10px; }
.alarm:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.alarm h3 { margin: 8px 0 2px; }
.empty { color: var(--hmi-muted); margin: 8px 0; }

.spin { display: flex; gap: 8px; align-items: center; }
.spin input { max-width: 7rem; text-align: right; font-family: var(--mono); }
body.hmi .spin input {
  background: var(--hmi);
  color: var(--hmi-text);
  border-color: var(--hmi-line);
}
.seg {
  display: flex;
  background: #0c1730;
  border-radius: 10px;
  padding: 3px;
  margin: 0;
  gap: 0;
}
.seg button {
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--hmi-muted);
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  min-height: 34px;
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--navy); }

.hand-grid { display: grid; gap: 8px; }
.ha {
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name val" "seg seg" "hand hand";
  gap: 6px 8px;
  align-items: center;
}
.ha-name { grid-area: name; font-weight: 650; font-size: 0.92rem; }
.ha-val { grid-area: val; justify-self: end; font-size: 1rem; }
.ha .seg { grid-area: seg; }
.hand-row { grid-area: hand; display: none; }
.ha[data-mode="hand"] .hand-row { display: block; }
.ha .force { display: none; font-style: normal; margin-left: 6px; color: var(--amber); font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.ha.forced .force { display: inline; }
.ha.forced .ha-val b { color: var(--amber); }
input[type="range"] { width: 100%; accent-color: var(--amber); }

.tools { padding: 0; margin: 0 0 12px; }
.tools summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 650;
  color: var(--amber);
  list-style: none;
}
.tools summary::-webkit-details-marker { display: none; }
.tools summary::before { content: "▸ "; font-family: var(--mono); }
.tools[open] summary::before { content: "▾ "; }
.tools .inner { padding: 0 12px 12px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.hmi .tool-grid .btn.sec { background: transparent; color: var(--paper); border-color: var(--hmi-line); }
.note { min-height: 1.2em; margin: 8px 0 0; color: var(--amber); font-size: 0.85rem; }

.foot {
  color: var(--hmi-muted);
  font-size: 0.75rem;
  margin: 4px 2px 8px;
}

@media (min-width: 1100px) {
  .desk { display: flex; gap: 16px; margin-left: 22px; align-items: center; }
  .desk a { color: #fff; text-decoration: none; font-size: 0.92rem; opacity: 0.78; }
  .desk a[aria-current="page"] { opacity: 1; font-weight: 650; box-shadow: inset 0 -2px 0 var(--amber); padding-bottom: 2px; }
  .tabs { display: none; }
  body.paper { padding-bottom: 28px; }
  body.paper .wrap { max-width: 980px; }
  .about-grid, .guide-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 12px; align-items: start; }
  .safety { gap: 8px; }
  .chip { padding: 8px 10px; }
  .chip .k { font-size: 0.72rem; }
  .case, .panel { padding: 10px; margin-bottom: 8px; }
  .mod { padding: 8px; }
  .mod .v { font-size: 1.25rem; }
  .sym { height: 28px; }
  .sym svg { height: 28px; }
  .ha { padding: 8px; gap: 4px; }
  .seg button { min-height: 30px; padding: 4px 4px; font-size: 0.78rem; }
  .stage { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
  .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .return { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hand-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: repeat(4, 1fr); }
  html.shot body.hmi { height: 100vh; overflow: hidden; }
  html.shot body.hmi .wrap {
    height: calc(100vh - 54px);
    max-width: none;
    display: flex;
    flex-direction: column;
    padding: 12px 16px 10px;
    overflow: hidden;
  }
  html.shot .stage { flex: 1; min-height: 0; }
  html.shot .case { margin-bottom: 0; }
  html.shot .side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
  html.shot .side .panel { margin: 0; }
  html.shot .side .panel.alarms { flex: 1; overflow: auto; }
  html.shot .hand-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html.shot .tools, html.shot .foot, html.shot .tabs { display: none; }
}

@media (max-width: 420px) {
  .brand small { letter-spacing: 0.22em; }
  .who .pill { font-size: 0.65rem; padding: 2px 6px; }
}
html.shot .top, html.shot .tabs { position: static; }
html.shot * { animation: none !important; transition: none !important; }

.who { display: flex; align-items: center; gap: 8px; }
.menu-btn {
  appearance: none;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  min-height: 28px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
}
.menu-sheet {
  position: fixed;
  top: 62px;
  right: 12px;
  z-index: 30;
  width: min(280px, calc(100vw - 24px));
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 8px;
}
.menu-sheet[hidden] { display: none !important; }
.menu-sheet .btn { min-height: 42px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 550; margin: 14px 0 4px; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; }
.login input[type="password"],
.login input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid #cfcabd;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.mono { font-family: var(--mono); }

.coach { position: fixed; inset: 0; z-index: 40; }
.coach-hole {
  position: fixed;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(8, 14, 28, 0.72);
  outline: 2px solid var(--amber);
  pointer-events: none;
}
.coach-card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  margin: 0 auto;
  max-width: 440px;
  max-height: 48vh;
  overflow: auto;
  background: var(--paper);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.coach-logo { margin: 0 0 8px; }
.coach-logo img { width: 36px; height: 36px; }
.coach-logo b { font-size: 1.05rem; }
body.hmi .coach-card h2,
.coach-card h2 { font-size: 1.12rem; color: var(--text); }
body.hmi .coach-card,
body.hmi .coach-card p { color: var(--text); }
.coach-card p { margin: 6px 0 0; font-size: 0.95rem; }
.dots { display: flex; gap: 6px; justify-content: center; align-items: center; margin: 12px 0; }
.dots button {
  width: 8px;
  height: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: #d5cfc3;
  cursor: pointer;
}
.dots button[aria-current="true"] { width: 18px; background: var(--navy); }
.coach-actions { display: flex; justify-content: space-between; gap: 8px; }
.coach-actions .btn { min-height: 44px; min-width: 108px; }
body.coaching .tabs { display: none; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
