/* STILT.PRO shop stages. Brand navy #2C3E5C, charcoal #2B2B2B, blue-gray #D5E2EC, off-white #F5F5F0.
   Generous, predictable spacing is the point: the paper packet's fab pages were hard to scan. */

:root {
  --navy: #2C3E5C;
  --charcoal: #2B2B2B;
  --bluegray: #D5E2EC;
  --offwhite: #F5F5F0;
  --line: #C6D3DE;
  --warn: #8A4B2A;
  --gap: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--offwhite);
  color: var(--charcoal);
  font: 15px/1.45 Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 6px 14px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; color: #fff; }
.brand span { font-size: 10px; letter-spacing: .16em; opacity: .75; }
.brand strong { font-size: 17px; letter-spacing: .02em; }

/* Progress lives in the sticky banner so it stays on screen while the operator works down the
   list. On the navy bar it needs its own palette: the page's navy-on-blue-gray disappears here. */
.topProgress { flex: 0 1 260px; min-width: 130px; display: flex; flex-direction: column; gap: 5px; }
.topProgress[hidden] { display: none; }
.topProgress b { font-size: 13px; font-weight: 700; color: #fff; letter-spacing: .02em;
  white-space: nowrap; }
.topProgress b span { opacity: .6; font-weight: 400; }
.topBar { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.topBar i { display: block; height: 100%; border-radius: 4px; background: #fff;
  transition: width .18s ease; }
/* The name field is what gives way when a narrow tablet cannot fit all three. */
@media (max-width: 620px) { .topProgress { flex-basis: 150px; } }

.identity { display: flex; align-items: flex-end; gap: 12px; }
.identity label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.identity input {
  display: block; margin-top: 3px; padding: 7px 10px; min-width: 190px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 5px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 15px;
}
.identity input::placeholder { color: rgba(255,255,255,.6); }

/* Re-reads BOMs and product groups from MRPeasy instead of the cached copies, which are otherwise
   up to an hour (groups) and six hours (BOMs) behind an edit made in MRPeasy. */
.refresh-btn {
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 5px;
  background: rgba(255,255,255,.1); color: #fff;
  font: inherit; font-size: 14px; cursor: pointer;
}
.refresh-btn:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.refresh-btn:disabled { opacity: .55; cursor: default; }

main { padding: var(--gap); max-width: 1500px; margin: 0 auto; }
.loading, .empty {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  padding: 56px 20px; text-align: center; color: #5A6672;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.empty strong { font-size: 17px; color: var(--navy); }
.muted { color: #5A6672; font-size: 13px; margin: 2px 0 0; }

/* ----------------------------------------------------------------- MO list */

.jobList { display: flex; flex-direction: column; gap: 12px; }
.jobRow {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.jobIdentity { min-width: 240px; flex: 1 1 320px; }
.jobIdentity h2 {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline;
  margin: 0; font-size: 19px; color: var(--navy);
}
.jobIdentity h2 small { font-size: 13px; font-weight: 400; color: #5A6672; }
.jobIdentity p { margin: 4px 0 0; font-size: 14px; }

.stageButtons { display: flex; flex-wrap: wrap; gap: 10px; }
.stageButton {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 104px; padding: 12px 16px;
  border: 1.5px solid var(--navy); border-radius: 8px;
  background: #fff; color: var(--navy); text-decoration: none;
}
.stageButton strong { font-size: 14px; letter-spacing: .1em; }
.stageButton span { font-size: 12px; color: #5A6672; }
.stageButton:hover { background: var(--bluegray); }
.stageButton.done { background: var(--navy); color: #fff; }
.stageButton.done span { color: rgba(255,255,255,.85); }
.stageButton[aria-disabled="true"] {
  opacity: .4; pointer-events: none; border-style: dashed;
}

/* -------------------------------------------------------------- stage head */

.stageHead {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  padding: 16px 18px; margin-bottom: var(--gap);
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--navy);
  border-radius: 10px;
}
.stageHead > div { flex: 1 1 260px; }
.stageHead span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #5A6672; }
.stageHead h1 { margin: 2px 0 0; font-size: 21px; color: var(--navy); }
.back {
  padding: 8px 14px; border: 1px solid var(--navy); border-radius: 6px;
  color: var(--navy); text-decoration: none; font-size: 13px; white-space: nowrap;
}
.back:hover { background: var(--bluegray); }
.stageProgress {
  display: flex; flex-direction: column; align-items: center;
  font-size: 24px; color: var(--navy); line-height: 1.1;
}
.stageProgress b { display: flex; flex-direction: column; align-items: center; }
.progBar {
  width: 110px; height: 8px; margin-top: 6px; border-radius: 4px;
  background: var(--bluegray); overflow: hidden;
}
.progBar i { display: block; height: 100%; background: var(--navy); border-radius: 4px;
  transition: width .18s ease; }
.stageProgress small { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #5A6672; }

/* ------------------------------------------------------------------- lanes */

.lane { margin-bottom: 26px; }

/* The Assembly stage of an MO: one card across the screen, top-level drawing beside the 3D build guide
   (operator 2026-10-27). Either pane hides; the other takes the width. */
main:has(.asmOne) { max-width: none; padding: 6px; }
.asmOne { display: flex; flex-direction: column; }
.asmBar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.asmTitle { flex: 1 1 320px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.asmTitle h1 { margin: 0; font-size: 17px; color: var(--navy); line-height: 1.2; }
.asmTitle .muted { margin: 0; font-size: 12px; }
.asmViews { display: flex; border: 1.5px solid var(--navy); border-radius: 8px; overflow: hidden; }
.asmViews button { min-height: 40px; padding: 0 16px; border: 0; background: #fff; color: var(--navy); font: 700 14px Roboto, sans-serif; cursor: pointer; }
.asmViews button + button { border-left: 1.5px solid var(--navy); }
.asmViews button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.asmActions.cardActions { flex: 0 1 360px; display: flex; gap: 8px; margin: 0; }
.asmPanes { flex: none; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); grid-template-rows: minmax(0, 1fr); min-height: 0; height: max(420px, calc(100vh - 290px)); }
.asmPanes.noDrawing { grid-template-columns: 1fr; } .asmPanes.noDrawing .asmDrawing { display: none; }
.asmPanes.noModel { grid-template-columns: 1fr; } .asmPanes.noModel .asmModel { display: none; }
.asmDrawing { min-height: 0; border-right: 1px solid var(--line); background: #fff; }
.asmSheet { position: relative; display: flex; align-items: center; justify-content: center; height: 100%; padding: 8px; color: inherit; text-decoration: none; }
.asmSheet img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asmSheet.missing { flex-direction: column; gap: 4px; color: #5A6672; text-align: center; }
.asmSheet.missing strong { color: var(--navy); font-size: 15px; }
.asmModel { min-height: 0; overflow: hidden; background: #1b2536; }
.asmModel .asmGuide, .asmModel .gp { height: 100%; }
.asmModel .gp { border: 0; border-radius: 0; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }
.asmModel > div > span { display: block; padding: 24px; color: #D5E2EC; text-align: center; }
.asmOne .cardDone { padding: 6px 14px; }
@media (max-width: 860px) {
  .asmPanes, .asmPanes.noDrawing, .asmPanes.noModel { grid-template-columns: 1fr; height: auto; }
  .asmDrawing { height: 55vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .asmModel .gp { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; }
  .asmActions.cardActions { flex-basis: 100%; }
}
.laneHead {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 8px 12px;
  background: var(--bluegray); border-radius: 6px;
  font-size: 13px; letter-spacing: .1em; color: var(--navy);
}
.laneHead span {
  padding: 1px 8px; border-radius: 10px;
  background: var(--navy); color: #fff; font-size: 11px; letter-spacing: 0;
}

/* Single-column scrollable tile feed, like the Paperless Picking worker feed: one tile at a time,
   big enough to actually read the drawing rather than squint at a thumbnail grid. */
.cardGrid { display: flex; flex-direction: column; gap: 16px; max-width: 900px; margin: 0 auto; }

/* ------------------------------------------------------------------- cards */

.card {
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.card.done { border-color: var(--navy); background: #FBFCFD; }
.card.done .cardVisual { opacity: .55; }

/* The drawing IS the content, so it gets real height. No fixed aspect ratio: a laser flat is very
   wide (FA04308 is about 6.5:1) while a FAB drawing sheet is landscape, and forcing one ratio wastes
   space on both. min-height keeps short flats from collapsing; max-height keeps tall sheets on
   screen. */
.cardVisual {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 200px; max-height: 62vh; background: #fff;
  border-bottom: 1px solid var(--line); text-decoration: none; padding: 10px;
}
.cardVisual img { max-width: 100%; max-height: 60vh; object-fit: contain; }
.cardVisual.missing { flex-direction: column; gap: 4px; color: #5A6672; text-align: center; padding: 12px; }
.cardVisual.missing strong { color: var(--navy); font-size: 15px; }
.cardVisual.missing span { font-size: 12px; }
/* A finished part at ASSEMBLE: what it is, never its fabrication print. */
.cardVisual.finished { flex-direction: column; gap: 6px; color: #5A6672; text-align: center; padding: 16px; background: #D5E2EC; }
.cardVisual.finished strong { color: var(--navy); font-size: 18px; }
.cardVisual.finished span { font-size: 13px; }
.cardVisual.finishedPic { background: #D5E2EC; }
.cardVisual.finishedPic img { max-height: 320px; }
.cardVisual.finishedCad { display: block; height: 320px; min-height: 320px; overflow: hidden; padding: 0; }
.cardVisual.finishedCad .finishedCadView { position: absolute; inset: 0; }
/* A card's 3D view (guide/panel.js), in place of its drawing: full card width, view and step bar inside. */
.cardVisual.cardGuide { display: block; padding: 0; height: min(62vh, 560px); max-height: none; background: #1b2536; overflow: hidden; }
.cardVisual.cardGuide > div { height: 100%; }
.card.done .cardVisual.cardGuide { opacity: 1; }
.visualHint {
  position: absolute; bottom: 6px; right: 6px;
  padding: 2px 8px; border-radius: 4px;
  background: var(--navy); color: #fff; font-size: 10px; letter-spacing: .08em;
}
.visualHint.warn { background: var(--warn); }

.cardBody { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.cardBody header { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.cardBody h3 {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
  margin: 0; font-size: 16px; color: var(--navy);
}
.rev {
  padding: 1px 6px; border-radius: 4px;
  background: var(--bluegray); color: var(--navy); font-size: 10px; letter-spacing: .06em;
}
.cardQty { display: flex; flex-direction: column; align-items: center; font-size: 19px; color: var(--navy); line-height: 1.1; }
.cardQty small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #5A6672; }
/* Only rendered in the order-scoped view, where a card needs to say which MO it stages with. */
.cardMo { margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em; opacity: .6; }
.cardDesc { margin: 0; font-size: 13.5px; }
.cardFacts { margin: 0; font-size: 12px; color: #5A6672; }
.cardWarn, .cardIssues {
  margin: 0; padding: 6px 8px; border-radius: 5px;
  background: var(--bluegray); color: var(--warn); font-size: 12px;
}
.cardIssues { color: var(--navy); }
.cardDone { margin: 0; font-size: 11.5px; color: #5A6672; }

.cardActions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
/* Bend stage: the bend simulator for this part, the first thing an operator reaches for. The Assembly card's 3D
   button (button.bendSim) is the same big button. */
.cardActions a.bendSim, .cardActions button.bendSim { flex: 1 0 100%; order: -1; display: block; text-align: center; padding: 14px 10px; border-radius: 6px;
  border: 0; background: var(--navy); color: #fff; font-size: 18px; font-weight: 800; letter-spacing: 2px; text-decoration: none; cursor: pointer; }
.cardActions a.bendSim:hover, .cardActions a.bendSim:focus, .cardActions button.bendSim:hover, .cardActions button.bendSim:focus { background: #1f2e46; outline: 3px solid #D5E2EC; }
.cardActions button {
  flex: 1; padding: 11px 12px; border-radius: 6px; border: 1.5px solid var(--navy);
  font: inherit; font-size: 14px; cursor: pointer;
}
.cardActions button.confirm { background: var(--navy); color: #fff; }
.cardActions button.reopen { background: #fff; color: var(--navy); }
.cardActions button[disabled] { opacity: .6; cursor: default; }
/* Done: a green check, lit the instant it is tapped (the save runs behind it). Green is a status
   colour here, not a brand colour. Tapping it again undoes. */
.card.done { border-color: #2E8B57; box-shadow: inset 4px 0 0 #2E8B57; }
.cardActions button.isDone {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #2E8B57; border-color: #2E8B57; color: #fff; font-weight: 700;
}
.cardActions button.isDone .tick { width: 22px; height: 22px; flex: none; }
.tick circle { fill: #fff; }
.tick path { fill: none; stroke: #2E8B57; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.isDone.pop { animation: tick-pop .32s cubic-bezier(.3, 1.6, .5, 1); }
.isDone.pop .tick path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: tick-draw .28s .08s ease-out forwards; }
@keyframes tick-pop { 0% { transform: scale(.92); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .isDone.pop, .isDone.pop .tick path { animation: none; stroke-dashoffset: 0; } }
#saveError {
  position: fixed; left: 50%; bottom: 18px; z-index: 50; max-width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, 140%); transition: transform .2s ease;
  padding: 12px 16px; border-radius: 8px; background: #8A2A2A; color: #fff; font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
#saveError.show { transform: translate(-50%, 0); }
.linkButton {
  padding: 11px 12px; border: 1px solid var(--navy); border-radius: 6px;
  color: var(--navy); text-decoration: none; font-size: 13px;
}
.linkButton:hover { background: var(--bluegray); }

@media (max-width: 620px) {
  :root { --gap: 12px; }
  .topbar { flex-wrap: wrap; }
  .identity input { min-width: 0; width: 100%; }
  .cardGrid { grid-template-columns: 1fr; }
  .stageButton { flex: 1 1 88px; min-width: 88px; }
}

/* Progressive card loading. A real button, sized for a glove on a shop tablet: scrolling to it
   loads the next page automatically, and pressing it does the same when the observer cannot fire
   because the page was backgrounded. */
.moreCards {
  display: block;
  margin: 18px auto 28px;
  padding: 16px 22px;
  min-height: 52px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  border: 2px solid #2C3E5C;
  border-radius: 8px;
  background: #fff;
  color: #2C3E5C;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.moreCards:hover { background: #D5E2EC; }
.moreCards small {
  display: block;
  margin-top: 3px;
  font-weight: 400;
  font-size: 12px;
  color: #5A6E8C;
}

/* Decluttered header (operator 2026-11-09): one line, the signed-in name as text, Refresh as an icon. */
.brand span { display: none; }
.identity { align-items: center; gap: 8px; }
.identity label { display: flex; align-items: center; gap: 6px; }
.identity input { margin-top: 0; padding: 6px 9px; min-width: 150px; }
.identity input[readonly] { min-width: 0; width: auto; border-color: transparent; background: transparent; font-weight: 700; padding-left: 0; }
.identity label:has(input[readonly]) { text-transform: none; letter-spacing: 0; font-size: 0; }
.identity label:has(input[readonly]) input { font-size: 15px; }
.refresh-btn { padding: 6px 10px; font-size: 16px; line-height: 1; }

/* The Assembly card fills the screen down to the bottom bar (fitAssemblyPanes in app.js sets the height). */
.asmOne .asmBar .back { padding: 6px 10px; }
.asmOne .asmActions.cardActions button { min-height: 40px; }
