:root {
  --bg: #181411;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fff8ef;
  --muted: rgba(255, 248, 239, 0.68);
  --tomato: #e34d36;
  --olive: #9bb86f;
  --steel: #8ca7b7;
  --fire: #f0a34a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(227, 77, 54, 0.18), transparent 32rem), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select {
  font: inherit;
}
.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 16px;
}
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card, .panel, .proofing-panel, .summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
}
.brand-lockup {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}
.brand-logo { width: 132px; height: auto; }
.brand-context { color: var(--muted); }
.eyebrow {
  margin: 0 0 4px;
  color: var(--fire);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: 44px;
  line-height: 0.98;
}
h2 {
  margin-bottom: 0;
  font-size: 24px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
input, select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.24);
}
select option {
  color: #1f130e;
  background: #fff8ef;
}
select option:checked {
  color: #1f130e;
  background: #f0a34a;
}
.primary-button, .ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 950;
  cursor: pointer;
}
.primary-button {
  color: #1f130e;
  background: var(--fire);
}
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}
.ghost-button.dark {
  background: rgba(0, 0, 0, 0.24);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}
.app-view {
  display: grid;
  gap: 16px;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}
.station-pill, .top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--olive);
  box-shadow: 0 0 0 5px rgba(155, 184, 111, 0.18);
}
.nav-link { text-decoration: none; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.summary-card {
  min-height: 118px;
  display: grid;
  gap: 6px;
  padding: 16px;
}
.summary-card span, .summary-card small, .muted {
  color: var(--muted);
  font-weight: 800;
}
.summary-card strong {
  font-size: 34px;
  line-height: 1;
}
.summary-card.steel { border-top: 6px solid var(--steel); }
.summary-card.olive { border-top: 6px solid var(--olive); }
.summary-card.tomato { border-top: 6px solid var(--tomato); }
.summary-card.fire { border-top: 6px solid var(--fire); }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 16px;
}
.workspace.single {
  grid-template-columns: 1fr;
}
.panel, .proofing-panel {
  padding: 16px;
}
.monitor-column {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.result-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.metric-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.metric-grid.tight {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}
.metric small {
  display: block;
  color: var(--muted);
  font-weight: 850;
}
.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}
.stack-list {
  display: grid;
  gap: 8px;
}
.stack-list.contained {
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}
.stack-list.contained.slim {
  max-height: 250px;
}
.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stage-grid .result-card {
  margin-top: 0;
}
.stage-card {
  display: grid;
  align-content: start;
  gap: 12px;
}
.stage-card h3 {
  margin-bottom: 0;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.14;
  min-height: 76px;
}
.section-label {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
}
.queue-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.queue-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) auto auto auto minmax(100px, 0.4fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.queue-row.recommended {
  border-color: rgba(240, 163, 74, 0.58);
  background: rgba(240, 163, 74, 0.11);
}
.queue-row div,
.ingredient-row div {
  display: grid;
  gap: 3px;
}
.queue-row span,
.queue-row small,
.ingredient-row span {
  color: var(--muted);
  font-weight: 850;
}
.queue-row strong,
.ingredient-row strong {
  color: var(--text);
}
.worker-panel {
  min-height: 520px;
}
.placement-panel {
  min-height: 164px;
}
.placement-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
  padding-right: 4px;
}
.placement-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.55fr) minmax(130px, 0.55fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--fire);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}
.placement-row.dough_stack {
  border-left-color: var(--olive);
}
.placement-row span,
.placement-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.placement-row strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.placement-quantity {
  text-align: right;
}
.empty-card.compact {
  padding: 12px;
}
.worker-flow {
  display: grid;
  gap: 12px;
}
.step-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.step-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 950;
}
.step-pill.active {
  color: #1f130e;
  background: var(--fire);
  border-color: transparent;
}
.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.task-card {
  min-height: 154px;
  display: grid;
  gap: 8px;
  align-content: end;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
}
.task-card strong {
  font-size: 24px;
}
.task-card span {
  color: var(--muted);
  font-weight: 800;
}
.worker-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.prep-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(360px, 1.22fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.prep-hero,
.prep-next-card,
.prep-ingredient-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.prep-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(260px, 0.74fr) minmax(0, 1.26fr);
  align-content: start;
  align-items: start;
  gap: 12px;
  padding: 16px;
}

.prep-hero .eyebrow,
.prep-hero h3,
.prep-hero p {
  grid-column: 1;
}

.prep-hero h3 {
  margin: 0;
  font-size: clamp(30px, 2.6vw, 42px);
  line-height: 1.18;
}

.prep-hero p:last-of-type {
  color: var(--muted);
  font-weight: 850;
  line-height: 1.4;
}

.prep-stats {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.prep-stats div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.prep-stats span,
.prep-section-head span,
.availability-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.prep-stats strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.16;
}

.prep-next-card {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.prep-next-card strong {
  font-size: 18px;
}

.prep-step-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-weight: 850;
  line-height: 1.45;
}

.availability-note {
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(240, 163, 74, 0.32);
  border-radius: 8px;
  background: rgba(240, 163, 74, 0.1);
}

.availability-note.ready {
  border-color: rgba(155, 184, 111, 0.34);
  background: rgba(155, 184, 111, 0.1);
}

.prep-ingredient-panel {
  grid-row: 2;
  grid-column: 2;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}

.prep-section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.prep-section-head h4 {
  margin: 2px 0 0;
  font-size: 20px;
}

.prep-ingredient-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.prep-actions {
  grid-row: 3;
  grid-column: 1 / -1;
  justify-content: space-between;
}
.handoff-pill {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  border: 1px solid rgba(242, 155, 61, 0.45);
  border-radius: 8px;
  padding: 0 14px;
  color: #ffe2b9;
  background: rgba(242, 155, 61, 0.12);
  font-size: 13px;
  font-weight: 950;
}
.stack-row, .place-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.stack-row {
  grid-template-columns: 1fr auto auto;
  align-items: center;
}
.ingredient-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, auto) minmax(130px, auto);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.pick-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding-top: 4px;
}
.pick-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.44fr) minmax(180px, 1fr) minmax(96px, 0.45fr) minmax(88px, auto);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}
.proofing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: 610px;
  overflow: auto;
  padding-right: 4px;
}
.queue-panel {
  opacity: 0.9;
}
.queue-panel .result-card {
  margin-top: 0;
}
.place-card.empty {
  opacity: 0.5;
}
.place-card.ready {
  border-color: rgba(155, 184, 111, 0.6);
}
.place-code {
  font-size: 18px;
  font-weight: 950;
}
.pill {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  color: #181411;
  background: var(--steel);
  font-size: 12px;
  font-weight: 950;
}
.pill.ready { background: var(--olive); }
.pill.wait { background: var(--fire); }
.pill.empty { color: var(--muted); background: rgba(255, 255, 255, 0.1); }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 17, 15, 0.96);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .topbar, .workspace, .summary-grid, .stage-grid {
    grid-template-columns: 1fr;
  }

  .prep-workspace,
  .prep-hero {
    grid-template-columns: 1fr;
  }

  .prep-hero .eyebrow,
  .prep-hero h3,
  .prep-hero p,
  .prep-stats,
  .prep-next-card,
  .prep-ingredient-panel,
  .prep-actions {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (min-width: 981px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .shell {
    height: 100vh;
    overflow: hidden;
  }

  .app-view {
    height: calc(100vh - 32px);
    min-height: 0;
    grid-template-rows: auto minmax(0, 0.88fr) minmax(280px, 0.5fr);
  }

  .workspace {
    grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
    min-height: 0;
    overflow: hidden;
  }

  .worker-panel,
  .monitor-column,
  .placement-panel,
  .proofing-panel,
  .queue-panel {
    min-height: 0;
    overflow: hidden;
  }

  .worker-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .worker-flow,
  #productionPlanMount {
    min-height: 0;
    overflow: auto;
    align-content: start;
    padding-right: 4px;
  }

  #productionPlanMount .result-card {
    min-height: 0;
    padding: 14px;
  }

  #productionPlanMount .result-card h3 {
    min-height: 0;
    font-size: clamp(24px, 2.2vw, 34px);
    line-height: 1.05;
  }

  #productionPlanMount .queue-list {
    max-height: 96px;
    overflow: auto;
    padding-right: 4px;
  }

  #productionPlanMount .worker-actions {
    margin-top: 8px;
    margin-bottom: 6px;
  }

  .proofing-panel,
  .queue-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .placement-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .placement-list {
    max-height: none;
    min-height: 0;
  }

  .proofing-grid {
    max-height: none;
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .shell { padding: 10px; }
  .top-actions, .station-pill {
    justify-content: stretch;
  }
  .form-grid, .metric-grid, .stack-row, .task-grid, .queue-row, .ingredient-row, .pick-row, .placement-row {
    grid-template-columns: 1fr;
  }
  .prep-workspace,
  .prep-ingredient-panel,
  .prep-actions {
    grid-template-columns: 1fr;
    grid-column: auto;
    grid-row: auto;
  }
  .placement-quantity {
    text-align: left;
  }
  h1 { font-size: 36px; }
}
