/* Refine ERP shop-floor styles. Plain CSS, no framework. Readable at 1.5 m, big touch targets.
   Shared classes other screens may reuse: .page, .btn (.btn-primary .btn-warn .btn-danger
   .btn-quiet), .table (.num .nowrap), .banner (.banner-ok .banner-error .banner-warn),
   .badge (.badge-late .badge-paused .badge-tier .badge-stock .badge-priority .badge-expedite), .muted, .late, .field, .pin-fields,
   .action-bar, .section, .count-grid, .card, .check-cell, .empty, .check-field, .component-of,
   .artwork-link, .depth-1 to .depth-3, .sub (muted second line in a cell). */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #5a5a5a;
  --line: #c9c6bf;
  --accent: #1d5e3a;
  --accent-text: #ffffff;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --danger: #8b1e1e;
  --danger-bg: #fbe3e3;
  --ok-bg: #e6f2ea;
  --row-hover: #eef4f0;
  --focus: #1f5fbf;
  --radius: 6px;
  --tap: 3.25rem;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Header: row 1 is the dark module bar, row 2 the active module's views */
.site-header { background: var(--text); color: #fff; }
.site-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem 1rem;
  min-height: 56px;
  padding: 6px 16px;
}
.site-header .brand { font-weight: 700; font-size: 1.2rem; color: #fff; text-decoration: none; }
.site-nav { display: flex; gap: .25rem; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .75rem;
  border-radius: var(--radius);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.site-nav a:hover { background: #333; }
.site-nav a[aria-current="page"] { background: var(--accent); }
/* Fills row 1 after the tabs. When the status block does not fit beside it, the block wraps
   to a second row, right-aligned. */
.site-search { flex: 1 1 8rem; min-width: 8rem; max-width: 24rem; display: flex; align-items: center; gap: .35rem; margin: 0; }
.operator-none { display: none; } /* the Sign in person button says it */
.site-search-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 .6rem;
  font-size: .95rem;
  border: 1px solid #777;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
.site-search-button {
  min-height: 44px;
  padding: 0 .8rem;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: transparent;
  border: 1px solid #777;
  border-radius: var(--radius);
  cursor: pointer;
}
.site-search-button:hover { background: #333; }
/* Enter submits the search; the button is for touch screens and only fits on a wide bar */
@media (max-width: 1599px) { .site-search-button { display: none; } }
.site-user {
  margin-left: auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .25rem .75rem;
  font-size: .85rem;
  color: #ddd;
}
.site-user .import-status { white-space: nowrap; cursor: default; }
.site-user .import-status.late { color: #ff9b9b; }
.operator-group { display: inline-flex; align-items: center; gap: .5rem; }
.operator strong { color: #fff; }
.site-user a.operator-change, .station-menu > summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 .7rem;
  color: #fff; border: 1px solid #777; border-radius: var(--radius);
  font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.site-user a.operator-change:hover, .station-menu > summary:hover { background: #333; }
.station-menu { position: relative; }
.station-menu > summary { list-style: none; }
.station-menu > summary::-webkit-details-marker { display: none; }
.station-menu > summary::after { content: "\25BE"; margin-left: .4rem; }
.station-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 13rem;
  padding: .4rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  font-size: .95rem;
}
.station-menu-list .station-name { padding: .5rem .6rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.station-menu-list a, .station-menu-list button {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 .6rem;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text);
  font: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
}
.station-menu-list a:hover, .station-menu-list button:hover { background: var(--row-hover); }
.station-menu-list form { margin: 0; }

.sub-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  min-height: 44px;
  padding: 0 16px;
  background: #ecebe7;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sub-nav a, .sub-nav .sub-current {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.sub-nav a:hover { text-decoration: underline; }
.sub-nav [aria-current="page"] { font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }
.sub-actions { margin-left: auto; display: inline-flex; align-items: center; gap: .25rem; padding-left: .75rem; }
.sub-nav a.sub-primary {
  /* 44px tap target, 36px visible button: the transparent border is outside the background */
  min-height: 44px; padding: 0 1rem; border: 4px solid transparent; border-radius: 10px;
  background: var(--accent) padding-box; color: var(--accent-text); font-weight: 700;
}
.sub-nav a.sub-primary:hover { text-decoration: none; filter: brightness(1.1); }
.sub-nav a.sub-primary[aria-current="page"] { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .35); }
.sub-nav a.sub-secondary { color: var(--accent); font-weight: 600; }
.operator-page form { display: flex; flex-direction: column; gap: 1rem; max-width: 24rem; margin-bottom: 1rem; }

.page { padding: 1rem 16px 7rem; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 1.9rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.4rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.late { color: var(--danger); font-weight: 700; }
.empty { color: var(--muted); padding: .75rem 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: 7rem;
  padding: .6rem 1.3rem;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid var(--text);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-quiet { border-color: var(--line); font-weight: 600; }
/* Complete is dark with a check and sits apart from the green Start, so a running operation is never finished by a slip. */
.btn-complete { background: #2b2b2b; border-color: #2b2b2b; color: #fff; margin-left: auto; }
.btn-complete::before { content: "\2713\00a0"; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .2rem; font-weight: 700; }
.field input, .field select, input.input {
  font-size: 1.25rem;
  min-height: var(--tap);
  padding: .4rem .6rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.pin-fields { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.pin-fields input { width: 9rem; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td {
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.table th {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  background: var(--bg);
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table tbody tr:hover { background: var(--row-hover); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.check-cell { width: 3.5rem; }
.check-cell label { display: flex; align-items: center; justify-content: center; min-height: var(--tap); cursor: pointer; }
.check-cell input[type=checkbox] { width: 2rem; height: 2rem; cursor: pointer; }
.unit-text { font-weight: 700; font-size: 1.15rem; white-space: nowrap; }

/* Badges */
.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-late { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.badge-paused { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.badge-tier { background: var(--surface); }
.badge-stock { background: var(--surface); }
.badge-ok { background: var(--ok-bg); border-color: var(--accent); color: var(--accent); }
/* Priority and Expedite in the traveler band's vocabulary (D109): Priority black with white
   text, Expedite a diagonal hatch with the text on white. Separate from progress colors. */
.badge-priority { background: #000; border-color: #000; color: #fff; }
.badge-expedite { background: repeating-linear-gradient(45deg, #000 0 2px, #fff 2px 6px); border: 2px solid #000; padding: .1rem .3rem; color: #000; }
.badge-expedite > span { background: #fff; padding: 0 .3rem; border-radius: 999px; }

/* Banners */
.banner { padding: .75rem 1rem; margin: 1rem 0; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.banner-ok { background: var(--ok-bg); border-color: var(--accent); }
.banner-error { background: var(--danger-bg); border-color: var(--danger); }
.banner-warn { background: var(--warn-bg); border-color: var(--warn); }
.banner ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.banner li { margin: .2rem 0; }

/* Sections and cards */
.section { margin: 1.25rem 0 2rem; }
/* Work in process: the same amber "running" look as the Scan page's Now box, so WIP stands out. */
.section-wip.is-running { border: 3px solid var(--warn); background: var(--warn-bg); border-radius: var(--radius); padding: .5rem 1rem 1rem; }
.section-wip.is-running > details > summary { color: var(--warn); }
.scan-state { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .9rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; margin-left: .5rem; vertical-align: middle; }
.scan-state-ready { background: var(--ok-bg); color: var(--accent); border: 2px solid var(--accent); }
.scan-state-active { background: var(--warn); color: #fff; border: 2px solid var(--warn); }
.scan-state-paused { background: #fff; color: var(--warn); border: 2px solid var(--warn); }
.section-title { display: flex; align-items: baseline; gap: .75rem; }
.section-title .count { font-size: 1.1rem; color: var(--muted); }
.count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.card {
  display: block;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card .card-title { font-size: 1.4rem; font-weight: 700; }
.card .card-counts { display: flex; gap: 1.5rem; margin-top: .5rem; font-size: 1.1rem; }
.card .card-counts strong { font-size: 1.6rem; display: block; }

/* Sticky action bar at the bottom of a station */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  padding: .75rem 16px;
  margin: 0 -16px;
  background: var(--surface);
  border-top: 3px solid var(--text);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, .08);
}
.action-bar .actions { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 auto; }
.check-field { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); font-weight: 700; cursor: pointer; }
.check-field input[type=checkbox] { width: 2rem; height: 2rem; flex: 0 0 auto; cursor: pointer; }

/* Station lists: one-line rows, only Operation wraps; detail lives on the unit page */
.station-table td { white-space: nowrap; }
.station-table .op-cell { white-space: normal; min-width: 12rem; }
.station-table .wrap { white-space: normal; }
.sub { display: block; color: var(--muted); font-weight: 400; }
.blocked-list > summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; list-style: none; }
.blocked-list > summary::-webkit-details-marker { display: none; }
.blocked-list > summary::before { content: "\25B8"; font-size: 1.4rem; margin-right: .5rem; color: var(--muted); }
.blocked-list[open] > summary::before { content: "\25BE"; }

/* Components, artwork and skip-ahead */
.component-of { font-size: .9rem; font-weight: 400; white-space: normal; }
.artwork-link { font-weight: 700; }
.closed-ops { font-size: .95rem; color: var(--warn); font-weight: 700; }
.depth-1 { padding-left: 1.5rem !important; }
.depth-2 { padding-left: 3rem !important; }
.depth-3 { padding-left: 4.5rem !important; }

/* Order progress */
.op-list { margin: 0; padding: 0; list-style: none; }
.op-list li { padding: .2rem 0; }
.status-complete { color: var(--accent); font-weight: 700; }
.status-active, .status-paused { color: var(--warn); font-weight: 700; }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }

@media (max-width: 700px) {
  html { font-size: 16px; }
  .btn { min-width: 0; flex: 1 1 auto; }
  .action-bar .actions { width: 100%; }
  /* Row 1 at phone width: brand and Station menu, then the five tabs, then import and person */
  .site-bar { gap: 0 .5rem; padding-bottom: 4px; }
  .site-user { display: contents; }
  .station-menu { order: 1; margin-left: auto; }
  .site-nav { order: 2; width: 100%; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .site-nav a { flex: 1 0 auto; justify-content: center; padding: 0 .4rem; font-size: .92rem; }
  .site-user .import-status { order: 3; font-size: .8rem; color: #ccc; }
  .operator-group { order: 4; margin-left: auto; font-size: .8rem; color: #ccc; }
  .operator-none { display: none; } /* the Sign in person button says it */
  .site-search { order: 5; width: 100%; padding-top: 4px; }
  .site-search-input { font-size: 1rem; }
  .site-user a.operator-change, .station-menu > summary { padding: 0 .55rem; font-size: .9rem; }
}

/* Environment banner: sandbox and development copies (D4, D127) */
.env-banner {
  width: 100%;
  padding: .3rem 16px;
  font-size: .85rem;
  font-weight: 700;
  border-bottom: 2px solid #000;
}
.env-banner-sandbox { background: #ffb000; color: #000; }
.env-banner-development { background: #5a5a5a; color: #fff; }
.env-banner-production { background: var(--warn-bg); color: var(--warn); border-bottom-color: var(--warn); }

@media print {
  .site-header, .action-bar, .env-banner { display: none; }
  body { background: #fff; }
}

/* This order's operation instructions (D85, Q173): white on black so a non-standard step is
   impossible to miss on any screen or printout. */
.instr-changed {
  display: inline-block;
  background: #000;
  color: #fff;
  font-size: 1.15em;
  font-weight: 700;
  padding: .15em .45em;
  margin: .2em 0;
  white-space: pre-wrap;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Order priority box on the Scan card and the order page (ADR-0006). */
.priority-box { border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .5rem .75rem; margin: .75rem 0; }
.priority-box > summary { cursor: pointer; font-size: 1.1rem; min-height: 2.4rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.priority-box.priority-expedited { border-color: #000; }
.priority-box.priority-expedited > summary strong { background: #000; color: #fff; padding: .05em .4em; }
.priority-form label { display: block; font-weight: 700; margin: .4rem 0; }
.priority-form input { display: block; width: 100%; box-sizing: border-box; font-size: 1.1rem; min-height: 2.6rem; margin-top: .2rem; }
.priority-buttons { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.priority-buttons .btn { min-height: 2.8rem; }
