/* Workflow view of the Monitor page (BSD-0033, BS-0424 / BS-0438; `public/js/views/monitor/workflow.js`).
   Read-only 12-station map on desktop (> 600 px), vertical station & gate list + Waiting for you screen on phone
   (<= 600 px). Uses existing tokens from `tokens.css` only. */

.mon:not([data-tab='workflow']) .mon-workflow,
.mon[data-tab='workflow'] .mon-layout {
  display: none;
}
@media (max-width: 1023px) {
  .mon[data-tab='design'] .mon-dock,
  .mon[data-tab='workflow'] .mon-dock {
    display: none;
  }
}
@media (min-width: 1024px) {
  .mon[data-tab='workflow'] .mon-summary {
    display: none;
  }
}

/* 5-tab phone bar when Workflow is present; falls back to 4 columns when Design is open on an older Studio without workflow */
.mon-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 0 4px;
  gap: 2px;
}
.mon[data-tab='design']:has(.mon-wf-tab:not(.mon-tab)) .mon-tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 8px;
}
.mon[data-tab='design'] .mon-wf-tab:not(.mon-tab) {
  display: none;
}
.mon-tab,
.mon-wf-tab {
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 550;
  color: var(--text-2);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.mon-wf-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.mon-workflow-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c-review) 18%, var(--surface-2));
  border: 1px solid var(--c-review);
  color: var(--c-review);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mon-workflow-badge:empty {
  display: none;
}

.mon-workflow {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  color: var(--text);
}
@media (min-width: 1024px) {
  .mon-workflow {
    padding: 0;
  }
}

.mon-wf-desktop {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.mon-wf-phone {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
@media (max-width: 600px) {
  .mon-wf-desktop {
    display: none;
  }
  .mon-wf-phone {
    display: flex;
  }
}

/* Diamond SVG mark */
.mon-wf-diamond {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}
.mon-wf-diamond.is-warn polygon {
  fill: color-mix(in srgb, var(--c-review) 20%, var(--surface));
  stroke: var(--c-review);
  stroke-width: 1.5;
}
.mon-wf-diamond.is-muted polygon {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1.4;
}

/* Empty / old Studio / loading state */
.mon-wf-empty-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.mon-wf-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 360px;
  padding: 48px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mon-wf-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.mon-wf-empty-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-empty-text {
  max-width: 440px;
  margin: 0;
  font-size: var(--fs);
  color: var(--text-2);
}

/* Summary strip (desktop) */
.mon-wf-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mon-wf-sum-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.mon-wf-sum-chip.is-warn {
  border-color: var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
}
.mon-wf-sum-chip.is-danger {
  border-color: var(--c-blocked);
  background: color-mix(in srgb, var(--c-blocked) 12%, var(--surface));
}
.mon-wf-sum-badge {
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-2);
}
.mon-wf-sum-badge.is-warn {
  background: color-mix(in srgb, var(--c-review) 20%, var(--surface));
  border: 1px solid var(--c-review);
  color: var(--c-review);
}
.mon-wf-sum-badge.is-danger {
  background: color-mix(in srgb, var(--c-blocked) 18%, var(--surface));
  border: 1px solid var(--c-blocked);
  color: var(--c-blocked);
}
.mon-wf-sum-bottleneck {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
  color: var(--c-review);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.mon-wf-sum-note {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.mon-wf-sum-decisions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

/* Desktop horizontal 12-station map */
.mon-wf-map-scroll {
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mon-wf-map {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 920px;
}
.mon-wf-stations-track {
  position: relative;
  padding-top: 10px;
}
.mon-wf-stations-line {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 36px;
  height: 2px;
  background: var(--border-strong);
  z-index: 0;
}
.mon-wf-stations-grid,
.mon-wf-lane-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 84px 40px 84px 40px 84px 84px 84px 84px 40px 40px 84px 84px;
  gap: 8px;
  align-items: start;
}

.mon-wf-station-col {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mon-wf-bneck-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 7px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c-review) 20%, var(--surface));
  border: 1px solid var(--c-review);
  color: var(--c-review);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 2;
}
.mon-wf-station-box {
  position: relative;
  min-height: 56px;
  padding: 6px 7px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mon-wf-station-col.is-bottleneck .mon-wf-station-box {
  border: 2px solid var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
}
.mon-wf-station-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mon-wf-station-count {
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-station-col.is-bottleneck .mon-wf-station-count {
  color: var(--c-review);
  font-weight: 600;
}
.mon-wf-station-avatars {
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
}
.mon-wf-mini-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--tone, var(--accent)) 22%, var(--surface));
  border: 1.5px solid var(--tone, var(--accent));
  color: var(--tone, var(--accent));
  font-size: 9px;
  font-weight: 700;
}
.mon-wf-mini-avatar + .mon-wf-mini-avatar {
  margin-left: -3px;
}
.mon-wf-station-time {
  display: flex;
  flex-direction: column;
  padding: 0 2px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-station-time .is-muted {
  color: var(--text-3);
}

.mon-wf-gate-col {
  min-height: 54px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.mon-wf-gate-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mon-wf-gate-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}
.mon-wf-gate-col.is-waiting .mon-wf-gate-name {
  color: var(--c-review);
}
.mon-wf-gate-badge {
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--c-review) 20%, var(--surface));
  border: 1px solid var(--c-review);
  color: var(--c-review);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Desktop lanes */
.mon-wf-lanes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mon-wf-lane {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  background: transparent;
}
.mon-wf-lane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-bottom: 2px;
}
.mon-wf-lane-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-lane-meta {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-lane-chip {
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
}
.mon-wf-lane-chip.is-accent {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--link-soft);
}
.mon-wf-lane-chip.is-warn {
  background: color-mix(in srgb, var(--c-review) 18%, var(--surface));
  border: 1px solid var(--c-review);
  color: var(--c-review);
}
.mon-wf-loop {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  height: 20px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c-blocked) 14%, var(--surface));
  border: 1px solid var(--c-blocked);
  color: var(--c-blocked);
  font-size: 11px;
  font-weight: 700;
}

.mon-wf-cell {
  min-height: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 2px 0;
  border-radius: 6px;
}
.mon-wf-cell.is-station {
  background: var(--surface-2);
}
.mon-wf-cell.is-gate {
  justify-content: center;
}
.mon-wf-cell.is-unused {
  justify-content: center;
  opacity: 0.7;
}
.mon-wf-cell-note {
  font-size: 11px;
  color: var(--text-3);
}

/* Ticket pills (84 x 24) */
.mon-wf-pill {
  width: 84px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.mon-wf-pill.is-running {
  border-color: var(--c-doing);
}
.mon-wf-pill.is-slow {
  border-color: var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
  color: var(--c-review);
}
.mon-wf-pill.is-stuck {
  border-width: 1.8px;
  border-color: var(--c-blocked);
  background: color-mix(in srgb, var(--c-blocked) 14%, var(--surface));
  color: var(--c-blocked);
}
.mon-wf-pill.is-waitsForYou {
  border-color: var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
  color: var(--c-review);
}
.mon-wf-pill.is-waitsForTicket {
  border-style: dashed;
  border-color: var(--border-strong);
  color: var(--text-2);
}
.mon-wf-pill.is-done {
  justify-content: center;
  border-color: color-mix(in srgb, var(--c-done) 45%, var(--border));
  background: color-mix(in srgb, var(--c-done) 12%, var(--surface));
  color: var(--c-done);
}
.mon-wf-pill-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.mon-wf-pill-dot.is-running {
  background: var(--c-doing);
}
.mon-wf-pill-dot.is-paused {
  border: 1.5px solid var(--text-3);
}
.mon-wf-pill-mark {
  flex: none;
  font-weight: 800;
  font-size: 11px;
}
.mon-wf-pill-id {
  overflow: hidden;
  text-overflow: ellipsis;
}
.mon-wf-pill-more {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}

.mon-wf-counts-banner {
  padding: 18px 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: center;
}

/* Desktop Machine bar */
.mon-wf-machine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
}
.mon-wf-mach-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mon-wf-mach-label {
  color: var(--text-2);
  font-weight: 600;
}
.mon-wf-mach-val {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mon-wf-meter {
  width: 52px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.mon-wf-meter-fill {
  display: block;
  height: 100%;
  background: var(--c-doing);
}
.mon-wf-meter.is-warn .mon-wf-meter-fill {
  background: var(--c-review);
}
.mon-wf-mach-sub,
.mon-wf-mach-sessions {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-mach-host {
  margin-left: auto;
  color: var(--text-3);
}

/* Phone view (<= 600 px) */
.mon-wf-phone-hero {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--c-review);
  background: color-mix(in srgb, var(--c-review) 14%, var(--surface));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.mon-wf-phone-hero.is-tappable {
  cursor: pointer;
}
.mon-wf-phone-hero-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-phone-hero-counts {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--c-review);
  font-variant-numeric: tabular-nums;
}
.mon-wf-phone-notice {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.mon-wf-phone-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mon-wf-phone-gate {
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.mon-wf-phone-gate.is-waiting {
  border-color: var(--c-review);
  background: color-mix(in srgb, var(--c-review) 12%, var(--surface));
}
.mon-wf-phone-gate-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-phone-gate.is-waiting .mon-wf-phone-gate-name {
  color: var(--c-review);
}
.mon-wf-phone-gate-meta {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.mon-wf-phone-gate.is-waiting .mon-wf-phone-gate-meta {
  color: var(--c-review);
  font-weight: 600;
}

.mon-wf-phone-station {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
}
.mon-wf-phone-station.is-bottleneck {
  border: 1.5px solid var(--c-review);
}
.mon-wf-phone-st-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mon-wf-phone-st-name {
  font-size: var(--fs);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-phone-st-counts {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-phone-st-counts.is-warn {
  color: var(--c-review);
  font-weight: 600;
}
.mon-wf-phone-st-time {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mon-wf-phone-pills {
  display: grid;
  grid-template-columns: repeat(2, 84px);
  gap: 8px;
  padding-top: 4px;
}
.mon-wf-phone-machine {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Phone Waiting for you / station sub-screen */
.mon-wf-sub-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mon-wf-back-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.mon-wf-sub-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-wait-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mon-wf-wait-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.mon-wf-wait-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mon-wf-wait-where {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--c-review);
}
.mon-wf-wait-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}
.mon-wf-wait-detail {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.mon-wf-answer-btn {
  margin-top: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--link-soft);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
}
.mon-wf-wait-none {
  padding: 24px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.mon-wf-wait-foot {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
