/* ============================================================================
   Dispatch — layout
   Shopfloor board, by machine: each station is an sds-card whose NEXT job gets
   the hero treatment, queue listed below. Brand-restrained — neutral surfaces;
   colour is feedback only: a status LED (running = success, idle = neutral),
   an error-token due chip when at risk, and warning/success readiness checks.
   The one primary CTA is "Start" on the idle station that's ready to load.
   ========================================================================== */

/* ---- App grid + rail + pagehead (shared shell) -------------------------- */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: calc(100vh - 34px); }
.rail {
  border-right: 1px solid var(--sds-color-border); background: var(--sds-color-surface);
  position: sticky; top: 34px; height: calc(100vh - 34px);
  display: flex; flex-direction: column; padding: var(--sds-space-400) var(--sds-space-300);
  gap: var(--sds-space-200); overflow: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: var(--sds-space-200) var(--sds-space-200) var(--sds-space-300); }
.brand sds-logo { --sds-logo-height: 22px; height: 22px; display: inline-flex; }
.brand .product { font-family: var(--sds-font-family-headline); font-weight: var(--sds-font-weight-bold); font-size: 16px; letter-spacing: .01em; }
.brand .product .sub { color: var(--sds-color-text-muted); font-weight: var(--sds-font-weight-regular); }
.rail sds-sidenav { width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }
.pagehead {
  display: flex; align-items: flex-end; gap: var(--sds-space-400);
  padding: var(--sds-space-500) var(--sds-space-600) var(--sds-space-400);
  border-bottom: 1px solid var(--sds-color-border);
}
.pagehead .title { font-family: var(--sds-font-family-headline); font-size: var(--sds-type-headline-4-size); line-height: var(--sds-type-headline-4-line); font-weight: var(--sds-type-headline-4-weight); margin: 0; }
.pagehead .sub { color: var(--sds-color-text-muted); font-size: var(--sds-type-body-small-size); margin-top: var(--sds-space-100); }
.pagehead .sub b { color: var(--sds-color-text); font-variant-numeric: tabular-nums; }
.pagehead .actions { margin-left: auto; display: flex; align-items: center; gap: var(--sds-space-400); }
.pagehead .actions sds-search { width: 300px; }
.floor-toggle { display: inline-flex; align-items: center; color: var(--sds-color-text-muted); font-size: var(--sds-type-body-small-size); }

.viewseg {
  display: inline-flex; gap: 2px; margin: var(--sds-space-400) var(--sds-space-600) 0;
  padding: 3px; align-self: flex-start; background: var(--sds-color-surface-strong);
  border: 1px solid var(--sds-color-border); border-radius: var(--sds-radius-pill);
}
.viewseg .seg { font-size: var(--sds-type-body-small-size); font-weight: var(--sds-font-weight-bold); color: var(--sds-color-text-muted); padding: 6px 14px; border-radius: var(--sds-radius-pill); cursor: pointer; white-space: nowrap; }
.viewseg a.seg:hover { color: var(--sds-color-text); background: var(--sds-color-surface-hover); }
.viewseg .seg.on { background: var(--sds-color-surface); color: var(--sds-color-text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* ---- Floor: responsive grid of station cards --------------------------- */
.floor {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sds-space-400);
  padding: var(--sds-space-500) var(--sds-space-600) var(--sds-space-700);
  align-items: start;
}

.station { --sds-card-corner-radius: var(--sds-radius-l); display: block; }
.station-in { display: flex; flex-direction: column; }
.station.empty { opacity: .72; }

/* station header */
.st-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sds-space-300); padding-bottom: var(--sds-space-300); border-bottom: 1px solid var(--sds-color-border); }
.st-id { display: flex; align-items: center; gap: var(--sds-space-200); font-family: var(--sds-font-family-headline); font-weight: var(--sds-font-weight-bold); font-size: var(--sds-type-body-large-size); }
.st-id .led { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.led.idle { background: var(--sds-color-border-strong); }
.led.run  { background: var(--sds-color-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sds-color-success) 18%, transparent); }
.st-state { font-size: var(--sds-type-body-small-size); color: var(--sds-color-text-muted); white-space: nowrap; }

/* NEXT hero block */
.next { padding: var(--sds-space-400) 0 var(--sds-space-300); display: grid; gap: var(--sds-space-300); }
.nx-tag {
  font-size: var(--sds-type-footnote-size); font-weight: var(--sds-font-weight-bold);
  letter-spacing: .1em; color: var(--sds-color-text-muted);
}
.nx-tag.run { color: var(--sds-color-success); }
.next h3 { margin: 0; font-family: var(--sds-font-family-headline); font-size: var(--sds-type-headline-5-size); line-height: 1.2; }
.nx-sub { font-size: var(--sds-type-body-small-size); color: var(--sds-color-text-muted); }

.chips { display: flex; align-items: center; gap: var(--sds-space-200); flex-wrap: wrap; }
.chips .due { font-size: var(--sds-type-footnote-size); font-weight: var(--sds-font-weight-bold); padding: 2px 8px; border-radius: var(--sds-radius-pill); background: var(--sds-color-surface-strong); color: var(--sds-color-text-muted); }
.chips .due.crit { background: color-mix(in srgb, var(--sds-color-error) 14%, transparent); color: var(--sds-color-error); }

/* readiness checks — neutral marks coloured only by state */
.ready { display: flex; flex-wrap: wrap; gap: var(--sds-space-300); font-size: var(--sds-type-body-small-size); }
.rk { display: inline-flex; align-items: center; gap: 6px; color: var(--sds-color-text-muted); }
.rk::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sds-color-border-strong); }
.rk.ok { color: var(--sds-color-text); } .rk.ok::before { background: var(--sds-color-success); }
.rk.warn { color: var(--sds-color-warning); } .rk.warn::before { background: var(--sds-color-warning); }

.runbar { display: block; width: 100%; }
.start { justify-self: start; margin-top: var(--sds-space-100); }

/* queue list */
.queue { list-style: none; margin: 0; padding: var(--sds-space-300) 0 0; border-top: 1px solid var(--sds-color-border); display: grid; gap: 2px; }
.queue li {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: var(--sds-space-200);
  padding: var(--sds-space-200) var(--sds-space-200);
  border-radius: var(--sds-radius-m); font-size: var(--sds-type-body-small-size);
}
.queue li:hover { background: var(--sds-color-surface-hover); }
.queue .qpos { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--sds-color-surface-strong); font-size: var(--sds-type-footnote-size); font-weight: var(--sds-font-weight-bold); color: var(--sds-color-text-muted); }
.queue .qn { font-weight: var(--sds-font-weight-bold); }
.queue .qmeta { grid-column: 2; color: var(--sds-color-text-muted); font-size: var(--sds-type-footnote-size); }
.queue .qstat { grid-row: 1 / span 2; grid-column: 3; color: var(--sds-color-text-muted); font-size: var(--sds-type-footnote-size); }

/* empty station */
.next-empty { padding: var(--sds-space-600) 0; text-align: center; }
.next-empty p { margin: 0; }
.next-empty p:first-child { font-weight: var(--sds-font-weight-bold); }

@media (max-width: 900px) { .app { grid-template-columns: 1fr; } .rail { display: none; } }
