﻿/* ==========================================================================
   PVTech Bundle Verification Station
   --------------------------------------------------------------------------
   Extends the PV Tech design system (pvtech.css) with the shop-floor terminal.

   Designed against how this screen is actually used:
     - Touched with gloved hands, so every target is at least 64 px.
     - Read from a metre away, so live weight is 96 px and the verdict is
       unmissable by colour AND by text.
     - Two decisions to sign in (who, then PIN), three to work: capture,
       confirm, log out.

   LIGHT, deliberately. An extrusion hall is lit like a workshop, not like an
   office: daylight through roof panels plus high-bay lamps. A dark panel under
   that becomes a mirror of the ceiling and of whoever is standing at it, and the
   operator ends up tilting their head to read a weight. White ground with near
   black text is the one combination that survives glare, so the terminal is
   light even though the back office offers both.
   ========================================================================== */

:root {
  --stn-bg: #eef2f7;
  --stn-panel: #ffffff;
  --stn-panel-2: #f5f8fc;
  --stn-line: #d8e1ec;
  --stn-line-2: #e8eef5;
  --stn-ink: #0d1723;
  --stn-ink-2: #4a5b72;
  --stn-ink-3: #7b8ba1;
  --stn-shadow: 0 1px 2px rgba(13,23,35,.05), 0 8px 24px rgba(13,23,35,.06);
  --stn-shadow-lg: 0 24px 60px rgba(13,23,35,.18);
}

body { background: var(--stn-bg); color: var(--stn-ink); }

/* ============================ SIGN IN =============================
   The whole sign-in fits the panel. Nothing here scrolls except the tile grid,
   and that only when a crew is genuinely too large: a terminal you have to
   scroll to reach the confirm key is a terminal that gets pressed twice. */
.stn-login {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--stn-bg); color: var(--stn-ink);
}

/* Three columns so the instruction is centred on the panel, not on whatever is left
   after the brand — a heading that shifts when the logo loads reads as a wobble. */
.stn-login-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 16px; padding: 0 clamp(16px, 2vw, 26px);
  height: clamp(62px, 8vh, 84px); flex: none;
  background: var(--stn-panel); border-bottom: 1px solid var(--stn-line);
}
.stn-login-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.stn-brand { display: inline-flex; align-items: center; }
.stn-brand img { height: clamp(26px, 3.6vh, 34px); display: block; }
.stn-login-title b { display: block; font-size: clamp(14px, 2vh, 18px); font-weight: 800;
  letter-spacing: -.01em; white-space: nowrap; }
.stn-login-title small { font-size: clamp(10.5px, 1.5vh, 12.5px); color: var(--stn-ink-3);
  white-space: nowrap; }
.stn-login-h1 { margin: 0; text-align: center; white-space: nowrap;
  font-size: clamp(19px, 2.9vh, 30px); font-weight: 800; letter-spacing: -.02em; }
.stn-login-h1[hidden] { display: none; }
.stn-top .grow { flex: 1; }

.stn-step { flex: 1; min-height: 0; overflow: hidden;
  padding: clamp(12px, 2.4vh, 28px) clamp(18px, 2.4vw, 34px);
  display: flex; flex-direction: column; align-items: center; }

/* Operator tiles. A face is faster to find than a number, and tapping one is
   what turns the PIN from an identifier into a personal secret.

   The photograph is the tile: full bleed, with the name laid over it under a
   scrim. From two metres a face reads before any text does, so the picture gets
   the space and the name confirms it. */
/* Centred while the crew fits, scrolled from the top once it does not. `safe`
   is what stops centring from pushing the first row above the scroll origin. */
.stn-tiles-wrap { flex: 1; min-height: 0; width: 100%; overflow-y: auto;
  display: flex; align-items: safe center; }
/* auto-fit with a fixed tile width collapses the empty tracks, so the tiles sit
   in the middle of the screen however few operators there are. */
.stn-tiles {
  display: grid; align-content: start; justify-content: center; width: 100%;
  /* Half the old size (150-230px), so a crew of twenty-odd fits on one screen
     without scrolling. */
  grid-template-columns: repeat(auto-fit, clamp(104px, 8vw, 132px));
  gap: clamp(8px, .8vw, 14px);
}
.stn-tiles-loading { grid-column: 1 / -1; text-align: center; color: var(--stn-ink-3);
  font-size: 16px; padding: 40px 0; }

.stn-tile {
  position: relative; overflow: hidden;
  padding: 7px 5px 6px; gap: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--stn-panel); border: 2px solid var(--stn-line); border-radius: 12px;
  box-shadow: var(--stn-shadow); cursor: pointer;
  transition: border-color .12s, transform .07s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.stn-tile:hover { border-color: var(--blue); box-shadow: var(--stn-shadow-lg); }
.stn-tile:active { transform: scale(.975); }
.stn-tile:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* A circle crops to the face and throws away the corners, which on a staff photo
   is where the office furniture lives. It also makes a mixed grid — some
   photographed, some still on initials — read as one set rather than two. */
/* 90% of the tile: the face is the tile, with only a thin margin of white round it. */
.stn-tile-photo { width: 90%; aspect-ratio: 1; flex: none;
  border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(150deg, #dcebf7, #b9d4ea); color: #16496b;
  font-weight: 800; letter-spacing: .02em; font-size: clamp(24px, 2.4vw, 36px);
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(13,23,35,.16); }
.stn-tile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.stn-tile-name { max-width: 100%; padding: 0 2px;
  font-size: clamp(13px, .95vw, 16px); font-weight: 900; line-height: 1.15;
  color: var(--stn-ink); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stn-tile-code { font-family: var(--mono, Consolas, monospace); font-size: clamp(11px, .8vw, 13px);
  font-weight: 700; line-height: 1; color: var(--stn-ink-3); letter-spacing: .03em; }

.stn-tile-flag { position: absolute; top: 4px; right: 4px; font-size: 8.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; border-radius: 20px; padding: 2px 6px;
  background: var(--crit-bg); color: var(--crit-ink); }
.stn-tile.locked { cursor: not-allowed; }
.stn-tile.locked .stn-tile-photo { filter: grayscale(1); opacity: .5; }
.stn-tile.locked .stn-tile-name { color: var(--stn-ink-3); }
.stn-tile.locked:hover { border-color: var(--stn-line); box-shadow: var(--stn-shadow); }

/* Circular avatar, still used in the header and the supervisor picker where a
   full-bleed tile would be absurd. */
.stn-avatar {
  width: 86px; height: 86px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 800; letter-spacing: .02em;
  background: linear-gradient(150deg, #dcebf7, #c6dcef); color: #16496b;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(13,23,35,.12); font-size: 30px;
}
.stn-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stn-avatar.sm { width: 44px; height: 44px; font-size: 16px; }

/* --- step 2: the keypad, beside the person rather than under them --- */
#pinStep {
  display: grid; grid-template-columns: auto auto;
  gap: clamp(22px, 4vw, 72px); align-items: center; justify-content: center; align-content: center;
  position: relative;
}
/* Offsets, not zero: an absolutely positioned child is placed against the padding
   box, so left:0 sits it on the border edge and clips half the button away. */
.stn-back { position: absolute; top: clamp(12px, 2.4vh, 28px); left: clamp(18px, 2.4vw, 34px);
  border: 1px solid var(--stn-line); background: var(--stn-panel);
  color: var(--stn-ink-2); border-radius: 12px; height: 52px; padding: 0 20px;
  font: inherit; font-size: 16px; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; }
.stn-back:hover { border-color: var(--blue); color: var(--blue-2); }
.stn-back span { font-size: 22px; line-height: 1; }

.stn-pin-side { display: flex; flex-direction: column; align-items: center; text-align: center; }

/* The photograph gets room here — this is the one moment the operator is looking
   at their own face rather than at a bundle. */
.stn-chosen-photo { width: clamp(150px, 30vh, 320px); aspect-ratio: 1; border-radius: 50%;
  overflow: hidden; display: grid; place-items: center; flex: none;
  background: linear-gradient(150deg, #dcebf7, #b9d4ea); color: #16496b;
  font-weight: 800; font-size: clamp(48px, 9vh, 96px); letter-spacing: .02em;
  box-shadow: var(--stn-shadow-lg); border: 3px solid #fff; }
.stn-chosen-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.stn-chosen-name { display: block; margin-top: clamp(10px, 1.8vh, 18px);
  font-size: clamp(24px, 4vh, 40px); font-weight: 900; letter-spacing: -.02em; line-height: 1.15; }
.stn-chosen-code { display: block; font-size: 14px; color: var(--stn-ink-3); font-family: var(--mono); }
.stn-pad-sub { color: var(--stn-ink-2); font-size: clamp(13px, 1.7vh, 16px);
  margin: clamp(8px, 1.6vh, 16px) 0 clamp(10px, 1.8vh, 18px); }

/* PIN display: dots, not digits. Somebody is always standing behind you. */
.stn-pin { display: flex; gap: 10px; align-items: center; justify-content: center; }
.stn-pin i { width: clamp(38px, 3.4vw, 52px); height: clamp(48px, 6vh, 64px); border-radius: 12px;
  background: var(--stn-panel); border: 2px solid var(--stn-line);
  display: grid; place-items: center; font-style: normal; }
.stn-pin i.filled { border-color: var(--blue); background: var(--blue-weak); }
.stn-pin i.filled::after { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--blue); }

.stn-keypad { display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(9px, 1.2vh, 14px); width: clamp(268px, 30vh, 350px); }
/* Never below 64 px: this is pressed with a gloved hand. */
.stn-key { height: clamp(64px, 9.4vh, 88px); border-radius: 14px; border: 1px solid var(--stn-line);
  background: var(--stn-panel); color: var(--stn-ink);
  font-size: clamp(24px, 3.4vh, 32px); font-weight: 700;
  box-shadow: var(--stn-shadow); cursor: pointer;
  transition: transform .06s, background .12s; -webkit-tap-highlight-color: transparent; }
.stn-key:hover { background: var(--stn-panel-2); border-color: var(--blue); }
.stn-key:active { transform: scale(.96); background: var(--blue); color: #fff; }
.stn-key.wide { grid-column: span 1; font-size: clamp(13px, 1.7vh, 16px); font-weight: 700; }
.stn-key.clear { background: var(--red-weak); border-color: rgba(225,31,38,.35); color: var(--crit-ink); }
.stn-key.ok { background: var(--good); border-color: var(--good); color: #fff; }
.stn-key.ok:disabled { opacity: .35; }

.stn-login-error { margin-top: clamp(10px, 1.8vh, 18px); padding: 12px 16px; border-radius: 12px;
  background: var(--crit-bg); border: 1px solid var(--crit); color: var(--crit-ink);
  font-size: 15px; font-weight: 650; max-width: 320px; }

/* ============================== MAIN SCREEN ============================== */
.stn { position: fixed; inset: 0; display: flex; flex-direction: column;
  background: var(--stn-bg); color: var(--stn-ink); overflow: hidden; }

.stn-top { display: flex; align-items: center; gap: clamp(12px, 1.6vw, 20px);
  padding: 0 clamp(14px, 1.6vw, 26px); height: clamp(60px, 8.4vh, 88px);
  background: var(--stn-panel); border-bottom: 1px solid var(--stn-line); flex: none; }
.stn-top .logo { display: flex; }
.stn-top .logo img { height: clamp(22px, 3vh, 30px); display: block; }
.stn-welcome b { display: block; font-size: clamp(16px, 2.4vh, 22px); font-weight: 800; line-height: 1.1;
  white-space: nowrap; }
.stn-welcome small { font-size: clamp(11px, 1.5vh, 13px); color: var(--stn-ink-3); }
.stn-top .sep { width: 1px; height: clamp(30px, 4.6vh, 44px); background: var(--stn-line); }
.stn-fact { display: flex; flex-direction: column; gap: 2px; }
.stn-fact .k { font-size: clamp(9.5px, 1.2vh, 11px); text-transform: uppercase; letter-spacing: .09em;
  color: var(--stn-ink-3); }
.stn-fact .v { font-size: clamp(15px, 2vh, 18px); font-weight: 700; white-space: nowrap; }
/* A company name is as long as it likes, and the header cannot grow, so this one
   truncates and carries the full name in its tooltip. The order reference is a code and
   is read digit by digit, so it gets the mono face the rest of the system uses for one. */
.stn-fact.wide { min-width: 0; max-width: clamp(140px, 16vw, 260px); }
.stn-fact.wide .v { overflow: hidden; text-overflow: ellipsis; }
.stn-fact .v.mono { font-family: var(--mono); font-size: clamp(13px, 1.8vh, 16px); }
.stn-scale-state { display: inline-flex; align-items: center; gap: 8px;
  font-size: clamp(11px, 1.6vh, 13px); font-weight: 700; padding: 6px 13px; border-radius: 20px;
  white-space: nowrap; }
.stn-scale-state.on { background: var(--good-bg); color: var(--good-ink); }
.stn-scale-state.off { background: var(--crit-bg); color: var(--crit-ink); }
.stn-scale-state .d { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.stn-logout { height: clamp(44px, 6.4vh, 56px); padding: 0 clamp(16px, 2vw, 26px); border-radius: 12px;
  border: 1px solid rgba(225,31,38,.4); background: var(--crit-bg); color: var(--crit-ink);
  font-size: clamp(14px, 1.9vh, 16px); font-weight: 700; cursor: pointer; white-space: nowrap; }
.stn-logout:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* The working screen fits the panel. Ten operators pass through this in a shift and
   none of them should have to scroll to find the button that ends their turn — so
   everything is sized against the viewport and only the bundle history may scroll. */
.stn-body { flex: 1; min-height: 0; overflow: hidden;
  display: grid; grid-template-columns: 1.05fr 1fr;
  gap: clamp(12px, 1.5vw, 22px); padding: clamp(12px, 1.8vh, 22px); }

.stn-card { background: var(--stn-panel); border: 1px solid var(--stn-line);
  border-radius: 18px; box-shadow: var(--stn-shadow);
  padding: clamp(14px, 2vh, 22px) clamp(14px, 1.4vw, 24px);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  gap: clamp(10px, 1.6vh, 18px); }
.stn-card h2 { margin: 0; flex: none; font-size: clamp(11px, 1.5vh, 13px); font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--stn-ink-3); }
.hl { color: var(--blue-2); }

/* --- The article check ---------------------------------------------------
   A weight proves the bundle is the right mass. Only looking at it proves the
   right profile is running. This panel is the operator's second check, so it
   sits above the numbers rather than beside them. */
.stn-die { flex: none; display: flex; gap: clamp(12px, 1.4vw, 18px); align-items: stretch;
  border: 2px solid var(--blue-ring); border-radius: 16px; background: var(--blue-weak);
  padding: clamp(10px, 1.4vh, 14px); }
.stn-die-img { width: clamp(104px, 10vw, 172px); flex: none; border: 0; padding: 0;
  border-radius: 12px; overflow: hidden; background: var(--stn-panel);
  display: grid; place-items: center; cursor: zoom-in; box-shadow: var(--stn-shadow); }
.stn-die-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stn-die-none { display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--stn-ink-3); padding: 12px 10px; text-align: center; }
.stn-die-none svg { width: clamp(22px, 3.2vh, 32px); height: clamp(22px, 3.2vh, 32px); opacity: .6; }
.stn-die-none b { font-size: clamp(11.5px, 1.6vh, 13.5px); color: var(--stn-ink-2); font-weight: 700; }
.stn-die-none small { font-size: clamp(10px, 1.4vh, 11.5px); line-height: 1.35; }
.stn-die-meta { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center;
  gap: 2px; min-width: 0; }
/* Tight tracking so the instruction holds one line at 1366 wide, where wrapping it
   would steal the room the die number needs. */
.stn-die-meta .k { font-size: clamp(9.5px, 1.3vh, 11px); font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--blue-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.stn-die-meta .v { font-size: clamp(22px, 4vh, 36px); font-weight: 800; letter-spacing: -.02em;
  font-family: var(--mono); line-height: 1.1; }
.stn-die-meta .prod { font-size: clamp(14px, 2vh, 18px); font-weight: 650; color: var(--stn-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stn-die-meta .sub { font-size: clamp(11px, 1.5vh, 13px); color: var(--stn-ink-2); }

.stn-die-zoomwrap { border-radius: 14px; overflow: hidden; background: var(--stn-panel-2);
  border: 1px solid var(--stn-line); margin-bottom: 20px; display: grid; place-items: center; min-height: 220px; }
.stn-die-zoomwrap img { max-width: 100%; max-height: 62vh; display: block; }

/* The four numbers that decide the verdict, sitting beside the article inside the
   same panel. Two by two rather than in a strip: four across would squeeze the die
   number and the article name into a column too narrow to read them in. */
.stn-job { flex: none; align-self: stretch;
  display: grid; grid-template-columns: repeat(3, minmax(clamp(70px, 6.6vw, 118px), auto));
  gap: 1px; background: var(--stn-line); border: 1px solid var(--stn-line);
  border-radius: 12px; overflow: hidden; }
.stn-job .c { background: var(--stn-panel); display: flex; flex-direction: column; justify-content: center;
  padding: clamp(6px, 1vh, 11px) clamp(9px, .8vw, 14px); }
.stn-job .k { font-size: clamp(9px, 1.2vh, 10.5px); text-transform: uppercase; letter-spacing: .06em;
  color: var(--stn-ink-3); white-space: nowrap; }
.stn-job .v { font-size: clamp(14px, 2.1vh, 19px); font-weight: 700; margin-top: 1px; white-space: nowrap; }

/* Progress */
.stn-progress { flex: none; }
.stn-progress-head { display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: clamp(6px, .9vh, 10px); }
.stn-progress-head .n { font-size: clamp(21px, 3.4vh, 30px); font-weight: 800; }
.stn-progress-head .n small { font-size: clamp(12px, 1.8vh, 16px); color: var(--stn-ink-2); font-weight: 600; }
.stn-progress-head .p { font-size: clamp(16px, 2.5vh, 22px); font-weight: 800; color: var(--blue-2); }
.stn-track { height: clamp(12px, 2.1vh, 20px); border-radius: 12px; background: var(--stn-panel-2);
  border: 1px solid var(--stn-line); overflow: hidden; }
.stn-fill { height: 100%; border-radius: 12px; background: linear-gradient(90deg, var(--blue-2), var(--blue));
  transition: width .35s ease; }
.stn-progress-foot { display: flex; justify-content: space-between; margin-top: clamp(6px, .9vh, 10px);
  font-size: clamp(12px, 1.7vh, 14px); color: var(--stn-ink-2); }
.stn-progress-foot b { color: var(--stn-ink); }

/* Live weight. Takes whatever the panel has left after the fixed rows, so it is
   biggest on a big screen and still legible on a tablet. */
.stn-weight { flex: 1 0 auto; min-height: clamp(120px, 20vh, 240px); display: flex; flex-direction: column; justify-content: center;
  align-items: center; text-align: center; border-radius: 16px; padding: clamp(14px, 2.4vh, 26px) 20px;
  background: var(--stn-panel-2); border: 3px solid var(--stn-line); transition: all .25s; }
.stn-weight .num { font-size: clamp(48px, min(10vh, 6.4vw), 96px); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stn-weight .unit { font-size: clamp(20px, 3.2vh, 30px); color: var(--stn-ink-3); font-weight: 700; margin-left: 8px; }
.stn-weight .expect { margin-top: clamp(8px, 1.6vh, 14px); font-size: clamp(13px, 1.9vh, 16px);
  color: var(--stn-ink-2); }
.stn-weight .expect b { color: var(--stn-ink); }
.stn-weight.ok { border-color: var(--good); background: var(--good-bg); }
.stn-weight.ok .num { color: var(--good-ink); }
.stn-weight.bad { border-color: var(--red); background: var(--crit-bg); animation: stnPulse 1.1s ease-in-out 3; }
.stn-weight.bad .num { color: var(--crit-ink); }
@keyframes stnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(225,31,38,0); } 50% { box-shadow: 0 0 0 14px rgba(225,31,38,.16); } }

/* Live reading, still moving. Dimmed rather than coloured: green and red already
   mean pass and fail on this box, and a settling load is neither. The operator
   waits for the number to go solid before pressing Capture. */
.stn-weight.live-motion .num { color: var(--stn-ink-3); }
.stn-weight.live-motion .unit { opacity: .6; }

/* Verdict banner - colour is never the only signal */
.stn-verdict { flex: none; border-radius: 14px; padding: clamp(12px, 1.8vh, 18px) 18px;
  font-size: clamp(15px, 2.2vh, 20px); font-weight: 700; display: flex; align-items: center;
  gap: 14px; min-height: clamp(56px, 8vh, 72px); }
.stn-verdict .ic { width: clamp(32px, 4.4vh, 40px); height: clamp(32px, 4.4vh, 40px); border-radius: 10px;
  display: grid; place-items: center; font-size: clamp(17px, 2.4vh, 22px); flex: none; }
.stn-verdict.idle { background: var(--stn-panel-2); color: var(--stn-ink-2); border: 1px solid var(--stn-line); }
.stn-verdict.idle .ic { background: var(--stn-line); color: var(--stn-ink-2); }
.stn-verdict.ok { background: var(--good-bg); color: var(--good-ink); border: 1px solid var(--good); }
.stn-verdict.ok .ic { background: var(--good); color: #fff; }
.stn-verdict.bad { background: var(--crit-bg); color: var(--crit-ink); border: 1px solid var(--red); }
.stn-verdict.bad .ic { background: var(--red); color: #fff; }
.stn-verdict .sub { display: block; font-size: clamp(12px, 1.7vh, 14px); font-weight: 600;
  opacity: .9; margin-top: 3px; }

/* Actions */
.stn-actions { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 1.4vw, 16px); }
/* Never under 64 px: gloved hand, metre's distance. */
.stn-btn { height: clamp(68px, 11vh, 96px); border-radius: 16px; border: none;
  font-size: clamp(17px, 2.7vh, 24px); font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 14px; cursor: pointer;
  transition: transform .07s, filter .15s; -webkit-tap-highlight-color: transparent; }
.stn-btn:active:not(:disabled) { transform: scale(.975); }
.stn-btn:disabled { opacity: .35; cursor: not-allowed; }
.stn-btn.capture { background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(21,145,209,.28); }
.stn-btn.capture:hover:not(:disabled) { filter: brightness(1.06); }
.stn-btn.confirm { background: var(--good); color: #fff; box-shadow: 0 8px 20px rgba(12,163,90,.26); }
.stn-btn.confirm:hover:not(:disabled) { filter: brightness(1.06); }
.stn-btn.span { grid-column: 1 / -1; }
.stn-btn.ghost { background: var(--stn-panel); color: var(--stn-ink-2); border: 1px solid var(--stn-line);
  font-size: clamp(14px, 2vh, 18px); height: clamp(52px, 8vh, 68px); }
.stn-btn.ghost:hover:not(:disabled) { color: var(--blue-2); border-color: var(--blue); }
.stn-btn.ghost.sm { height: 58px; font-size: 16px; padding: 0 22px; }
.stn-btn .spin { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: stnSpin .7s linear infinite; }
@keyframes stnSpin { to { transform: rotate(360deg); } }

/* Recent bundles — the one flexible region, and the only thing on the screen that
   is allowed to scroll. */
.stn-recent { flex: 1; min-height: 0; overflow-y: auto; }
.stn-recent table { width: 100%; border-collapse: collapse; font-size: clamp(12.5px, 1.9vh, 15px); }
.stn-recent th { text-align: left; font-size: clamp(9.5px, 1.3vh, 11px); text-transform: uppercase;
  letter-spacing: .07em; color: var(--stn-ink-3); padding: 6px 10px;
  border-bottom: 1px solid var(--stn-line);
  position: sticky; top: 0; background: var(--stn-panel); }
.stn-recent td { padding: clamp(7px, 1.2vh, 11px) 10px; border-bottom: 1px solid var(--stn-line-2); }
.stn-recent tr:last-child td { border-bottom: none; }
.stn-recent .pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.stn-recent .pill.ok { background: var(--good-bg); color: var(--good-ink); }
.stn-recent .pill.bad { background: var(--crit-bg); color: var(--crit-ink); }
/* Reprint a missed label from its row. */
.stn-recent .stn-reprint { height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--stn-line);
  background: var(--stn-panel); color: var(--stn-ink-2); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.stn-recent .stn-reprint:hover { color: var(--stn-ink); border-color: var(--blue); }
.stn-empty { text-align: center; color: var(--stn-ink-3); padding: 30px 10px; font-size: 15px; }

/* Simulated-scale panel. Present only while no real indicator is wired up; it is
   styled as clearly auxiliary so nobody mistakes it for part of the operator's job. */
.stn-sim { flex: none; border: 1px dashed var(--stn-line); border-radius: 12px;
  padding: clamp(9px, 1.3vh, 14px) 14px; background: var(--stn-panel-2); }
.stn-sim-head { display: flex; align-items: center; gap: 10px; margin-bottom: clamp(7px, 1.1vh, 12px);
  font-size: clamp(11px, 1.6vh, 13px); color: var(--stn-ink-3); }
.stn-sim-head .tag { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--warn-ink); background: var(--warn-bg); border: 1px solid rgba(201,133,0,.3);
  padding: 3px 9px; border-radius: 20px; }
.stn-sim-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stn-sim-btns button { height: clamp(36px, 5.2vh, 44px); padding: 0 clamp(11px, 1.2vw, 16px);
  border-radius: 10px; border: 1px solid var(--stn-line); background: var(--stn-panel);
  color: var(--stn-ink-2); font-size: clamp(12px, 1.7vh, 14px); font-weight: 650; cursor: pointer; }
.stn-sim-btns button:hover { color: var(--blue-2); border-color: var(--blue); }
.stn-sim-manual { display: inline-flex; gap: 8px; align-items: center; margin-left: auto; }
.stn-sim-manual input { width: 100px; height: clamp(36px, 5.2vh, 44px); border-radius: 10px; padding: 0 12px;
  border: 1px solid var(--stn-line); background: var(--stn-panel); color: var(--stn-ink);
  font: inherit; font-size: 15px; }
.stn-sim-manual input:focus { outline: none; border-color: var(--blue); }

/* Dialogs */
.stn-overlay { position: fixed; inset: 0; background: rgba(13,23,35,.5); z-index: 70;
  display: none; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px); }
.stn-overlay.show { display: flex; }
.stn-modal { background: var(--stn-panel); border: 1px solid var(--stn-line); border-radius: 20px;
  width: 560px; max-width: 96vw; max-height: 92vh; overflow-y: auto; padding: 30px;
  box-shadow: var(--stn-shadow-lg); }
.stn-modal.wide { width: 860px; }
.stn-modal h3 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.stn-modal p { color: var(--stn-ink-2); font-size: 16px; margin: 0 0 22px; line-height: 1.55; }
.stn-modal label { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--stn-ink-3); margin-bottom: 8px; }
.stn-modal input, .stn-modal textarea { width: 100%; background: var(--stn-panel);
  border: 2px solid var(--stn-line); border-radius: 12px; color: var(--stn-ink); font: inherit;
  font-size: 20px; padding: 16px; margin-bottom: 18px; }
.stn-modal input:focus, .stn-modal textarea:focus { outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-ring); }
.stn-modal textarea { font-size: 16px; min-height: 92px; resize: vertical; }
.stn-modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stn-modal.wide .stn-modal-actions { grid-template-columns: 1fr; }

/* Supervisor picker inside the override dialog */
.stn-sup-tiles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.stn-sup-tile { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px;
  border: 2px solid var(--stn-line); border-radius: 40px; background: var(--stn-panel);
  cursor: pointer; font: inherit; font-size: 15px; font-weight: 650; color: var(--stn-ink); }
.stn-sup-tile .stn-avatar { width: 40px; height: 40px; font-size: 15px; }
.stn-sup-tile:hover { border-color: var(--blue); }
.stn-sup-tile.on { border-color: var(--blue); background: var(--blue-weak); color: var(--blue-2); }
.stn-sup-tile.locked { opacity: .45; cursor: not-allowed; }

/* Toast */
.stn-toasts { position: fixed; top: 104px; right: 26px; z-index: 90;
  display: flex; flex-direction: column; gap: 12px; }
.stn-toast { background: var(--stn-panel); border: 1px solid var(--stn-line); border-left: 5px solid var(--good);
  border-radius: 12px; padding: 16px 22px; font-size: 16px; font-weight: 600; color: var(--stn-ink);
  box-shadow: var(--stn-shadow-lg); animation: stnToast .22s ease; max-width: 460px; }
.stn-toast.err { border-left-color: var(--red); }
@keyframes stnToast { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; } }

@media (max-width: 1200px) {
  .stn-body { grid-template-columns: 1fr; overflow-y: auto; }
  .stn-weight .num { font-size: 72px; }
  .stn-die { flex-direction: column; }
  .stn-die-img { width: 100%; }
}
/* A short panel — 768-high industrial displays are common — stacks the sign-in and
   lets the whole step scroll rather than clipping the confirm key. */
@media (max-height: 560px), (max-width: 700px) {
  #pinStep { grid-template-columns: 1fr; gap: 16px; align-content: start;
    overflow-y: auto; padding-top: 64px; }
  .stn-chosen-photo { width: 120px; }
}
@media (max-width: 720px) {
  .stn-step-head h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition: none !important; } }

/* ===========================================================================
   SIZING THE TAIL BUNDLE BY HAND
   =========================================================================== */

.stn-next-h { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.stn-count-btn {
    display: inline-flex; align-items: center; gap: 9px;
    height: clamp(40px, 5.4vh, 48px); padding: 0 clamp(14px, 1.6vw, 20px);
    border: 1.5px solid var(--blue); border-radius: 11px;
    background: var(--stn-panel); color: var(--blue);
    font: inherit; font-size: clamp(13px, 1.7vh, 15px); font-weight: 700;
    letter-spacing: 0; text-transform: none; cursor: pointer;
}
.stn-count-btn svg { width: 19px; height: 19px; }
.stn-count-btn:hover { background: var(--blue); color: #fff; }

.stn-cnt-sub { font-size: 15px; color: var(--stn-ink-2); margin: 0 0 18px; }

/* One row, three targets: take one off, read it, put one on. The display between the
   steppers is the only thing on this screen an operator has to read precisely. */
.stn-cnt-row { display: flex; align-items: stretch; gap: 14px; margin-bottom: 16px; }
.stn-cnt-step {
    flex: 0 0 clamp(64px, 9vh, 84px);
    border: 1.5px solid var(--stn-line); border-radius: 14px; background: var(--stn-panel);
    font-size: clamp(30px, 4.4vh, 40px); font-weight: 700; line-height: 1;
    color: var(--stn-ink); cursor: pointer;
}
.stn-cnt-step:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.stn-cnt-step:disabled { opacity: .35; cursor: not-allowed; }

.stn-cnt-display {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 1.5px solid var(--stn-line); border-radius: 14px; background: var(--stn-bg);
    padding: clamp(8px, 1.4vh, 16px) 0;
}
.stn-cnt-display span {
    font-size: clamp(40px, 7vh, 64px); font-weight: 800; line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stn-cnt-display small { font-size: 13px; color: var(--stn-ink-3); margin-top: 4px; }

.stn-cnt-target {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    background: var(--stn-bg); border-radius: 12px; padding: 13px 16px; margin-bottom: 16px;
    font-size: 15px;
}
.stn-cnt-target .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--stn-ink-3); }
.stn-cnt-target b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stn-cnt-target #cntBand { font-variant-numeric: tabular-nums; color: var(--stn-ink-2); }

.stn-cnt-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 16px; }
.stn-cnt-keys button {
    height: clamp(50px, 7vh, 64px);
    border: 1.5px solid var(--stn-line); border-radius: 12px; background: var(--stn-panel);
    font: inherit; font-size: clamp(20px, 2.8vh, 26px); font-weight: 700; color: var(--stn-ink);
    cursor: pointer;
}
.stn-cnt-keys button:hover { border-color: var(--blue); color: var(--blue); }
.stn-cnt-keys button.wide { font-size: clamp(14px, 1.9vh, 17px); }
.stn-cnt-keys button.all { font-size: clamp(14px, 1.9vh, 17px); border-color: var(--blue); color: var(--blue); }

.stn-cnt-err {
    background: var(--crit-bg); color: var(--crit-ink);
    border-radius: 11px; padding: 12px 15px; margin-bottom: 16px;
    font-size: 15px; font-weight: 600;
}

/* The tag that says a bundle was sized by hand rather than derived. */
.stn-tag-custom {
    font-size: 11px; background: var(--blue); color: #fff;
    padding: 3px 10px; border-radius: 20px; letter-spacing: 0; margin-left: 8px;
    vertical-align: middle;
}

/* ===========================================================================
   THE BUNDLE LABEL

   Sized for the plant's 50x25mm roll: 50mm wide, one label every 25mm. Change the
   @page size and the .stn-label width and height together if the plant runs
   different stock (reports.css has the reprint copy); everything inside is in
   millimetres so it scales with them.

   Layout: the facts in a column on the left, bundle number on top, the QR square
   on the right taking the full height.
   =========================================================================== */

.stn-label-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px; border: 1px solid var(--stn-line); border-radius: 12px;
    margin-top: 12px;
}
.stn-label-auto { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.stn-label-auto input { width: 20px; height: 20px; }

/* Off-screen rather than display:none. A hidden element cannot be measured, and some
   browsers will not lay out its contents in time for the print it was built for. */
/* Its own font stack rather than an inherited one. What a thermal printer has loaded
   is not what the terminal has, and a label that silently falls back to a serif face
   prints narrower digits than the layout was measured for. */
.stn-label {
    position: absolute; left: -10000px; top: 0; width: 50mm; z-index: 0;
    /* The margin is inside the label, not the page: Chrome's "Margins: None" removes
       a page margin, and the text then prints against the edge of the sticker. */
    box-sizing: border-box; padding: 1mm 1mm 1mm 1.4mm;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #000;
}

.lbl-ref { display: block; font-size: 3.3mm; line-height: 1.08; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The operator line is normal weight: a code, not a figure. */
.lbl-op { font-weight: 400; }
.lbl-ref b { font-weight: 800; }
/* Nine monospaced characters (J27260001) across the ~29mm beside the QR. */
.lbl-no { font-family: var(--mono, Consolas, "Courier New", monospace); font-size: 5mm; font-weight: 800; line-height: 1; letter-spacing: -.03em; white-space: nowrap; }
.lbl-body { display: flex; align-items: center; gap: 1.2mm; height: 100%; }
.lbl-facts { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .3mm; }
/* 17mm still scans easily: without the weight the code is only about 25 modules across. */
.lbl-qr { width: 17mm; height: 17mm; flex: none; }
.lbl-qr svg { display: block; width: 100%; height: 100%; }
.lbl-cell { display: contents; }
.lbl-k { display: block; font-size: 2mm; text-transform: uppercase; letter-spacing: .1em; opacity: .75; line-height: 1.2; }
.lbl-v { display: block; font-size: 3.4mm; line-height: 1; white-space: nowrap; }
.lbl-v b { font-size: 5mm; font-weight: 800; }
.lbl-v { overflow: hidden; }
.lbl-cut { font-size: 3.3mm; }
/* The plan no: small, but bold so it prints clearly - the floor sorts bundles by it. */
.lbl-plan { font-family: Verdana, Geneva, sans-serif; font-size: 1.5mm; font-weight: 700; }
.lbl-cut b { font-size: 3.6mm; }
/* A short bundle on a pallet of full ones invites the question "is one missing?".
   This answers it on the label rather than in a phone call. */
.lbl-flag {
    font-size: 2.2mm; letter-spacing: .06em; text-transform: uppercase;
    border: .25mm solid currentColor; border-radius: .8mm;
    padding: .2mm .8mm; margin-left: 1mm; vertical-align: middle;
}

@media print {
    /* The stock is the page. Margins are the printer's own. */
    @page { size: 50mm 25mm; margin: 0; }

    /* Everything that is not the label goes, including the two full-screen panels,
       so a stray background cannot cost a whole label's worth of ribbon. */
    body > * { display: none !important; }

    /* No browser margin on top of the @page one, or the label is pushed past the stock. */
    html, body { background: #fff; margin: 0 !important; padding: 0 !important; height: auto !important; }

    /* One label, one page: never let it run on to the next label on the roll. The
       height is the stock, with a hair spare for rounding. */
    .stn-label {
        display: block !important;
        position: relative; left: auto; width: 50mm; z-index: 0;
        height: 24.6mm; overflow: hidden; break-inside: avoid; page-break-inside: avoid;
        color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}

/* Scale on this PC - the browser reads the COM port when the site runs in the cloud */
.stn-scale-setup { height: clamp(44px, 6.4vh, 56px); padding: 0 clamp(14px, 1.6vw, 20px); border-radius: 12px;
  border: 1px solid var(--stn-line); background: var(--stn-panel); color: var(--stn-ink-2);
  font-size: clamp(14px, 1.9vh, 16px); font-weight: 700; cursor: pointer; white-space: nowrap; }
.stn-scale-setup:hover { color: var(--blue-2); border-color: var(--blue); }
.stn-bsc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.stn-modal select { width: 100%; background: var(--stn-panel); border: 2px solid var(--stn-line);
  border-radius: 12px; color: var(--stn-ink); font: inherit; font-size: 18px; padding: 12px; margin-bottom: 18px; }

/* Compact: the whole dialog fits a 1080p terminal without scrolling. */
.stn-modal.stn-bsc { width: 620px; padding: 20px 22px; }
.stn-modal.stn-bsc h3 { font-size: 20px; margin-bottom: 4px; }
.stn-modal.stn-bsc p { font-size: 14px; margin-bottom: 14px; line-height: 1.4; }
.stn-modal.stn-bsc label { font-size: 11px; margin-bottom: 4px; }
.stn-modal.stn-bsc select,
.stn-modal.stn-bsc input:not([type=checkbox]) { height: 42px; font-size: 16px; padding: 0 10px;
  border-radius: 10px; margin-bottom: 12px; }
.stn-modal label.stn-bsc-check { display: flex; align-items: center; gap: 8px; text-transform: none;
  letter-spacing: 0; font-size: 15px; color: var(--stn-ink); margin-bottom: 12px; cursor: pointer; }
.stn-modal label.stn-bsc-check input { width: 20px; height: 20px; margin: 0; }
.stn-bsc-live { font-family: ui-monospace, Consolas, monospace; font-size: 14px; padding: 10px 12px;
  border-radius: 10px; background: var(--crit-bg); color: var(--crit-ink); margin-bottom: 14px;
  word-break: break-all; }
.stn-bsc-live.on { background: var(--good-bg); color: var(--good-ink); }
.stn-bsc .stn-modal-actions .stn-btn { height: 50px; font-size: 16px; border-radius: 12px; }

@media (max-width: 560px) {
  .stn-bsc-grid { grid-template-columns: 1fr 1fr; }
}

/* Refresh icon on the weight box */
.stn-weight { position: relative; }
.stn-weight-reset { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 1px solid var(--stn-line); background: var(--stn-panel); color: var(--stn-ink-2); cursor: pointer; }
.stn-weight-reset svg { width: 22px; height: 22px; }
.stn-weight-reset:hover { color: var(--blue-2); border-color: var(--blue); }
.stn-weight-reset:active { transform: rotate(-90deg); transition: transform .15s; }


/* The weighing side holds the weight, verdict, buttons, label options and test loads.
   The weight box takes what is left but never less than its number needs; on a short
   panel the card scrolls rather than letting the number spill out of its box. */
.stn-body > .stn-card:last-child { overflow-y: auto; }
.stn-card > .stn-label-bar { margin-top: 0; flex: none; }

/* Recent bundles: three across, one compact line each, newest first. The whole
   line is the reprint button. */
.stn-rb-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; align-content: start; }
.stn-rb { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  height: clamp(28px, 3.6vh, 36px); padding: 0 10px; border: 1px solid var(--stn-line); border-radius: 6px;
  background: var(--stn-panel); color: var(--stn-ink); font: inherit; font-size: clamp(12px, 1.6vh, 14px);
  text-align: left; cursor: pointer; white-space: nowrap; min-width: 0; }
.stn-rb:hover { border-color: var(--blue); background: var(--blue-weak); }
.stn-rb:active { transform: scale(.99); }
.stn-rb .no { font-family: var(--mono); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.stn-rb .q { color: var(--stn-ink-2); }
.stn-rb .w { font-weight: 700; font-variant-numeric: tabular-nums; }
.stn-rb-h { font-size: clamp(10px, 1.4vh, 12px); font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--stn-ink-3); }
.stn-rb-h small { font-size: inherit; text-transform: none; letter-spacing: 0; font-weight: 600; }
@media (max-width: 1200px) { .stn-rb-list { grid-template-columns: repeat(2, 1fr); } }

/* Progress on one line: 32 / 1085 pcs [=====    ] 2.9%  RECENT BUNDLES */
.stn-progress-line { display: flex; align-items: center; gap: clamp(10px, 1.2vw, 16px); }
.stn-progress-line .n { font-size: clamp(18px, 2.8vh, 26px); font-weight: 800; white-space: nowrap; }
.stn-progress-line .n small { font-size: clamp(12px, 1.7vh, 15px); color: var(--stn-ink-2); font-weight: 600; }
.stn-progress-line .stn-track { flex: 1; min-width: 60px; }
.stn-progress-line .p { font-size: clamp(15px, 2.2vh, 20px); font-weight: 800; color: var(--blue-2); white-space: nowrap; }
.stn-progress-line .stn-rb-h { white-space: nowrap; padding-left: clamp(8px, 1vw, 14px); border-left: 1px solid var(--stn-line); }
