/* production.css — production tracking (office lists, dashboard) + station
   tablet screens. Loaded by base.html after style.css; everything namespaced
   under .prod-* / .stn-* so existing pages are untouched. */

/* ---------- shared ---------- */

/* Match the shared <main> width (1400px, set in style.css) so every tab lines
   up at the same content width and nothing forces horizontal page scroll. */
.prod-page, .stn-page { max-width: 1400px; margin: 0 auto; }

/* Station tablet tap targets: resolve a tap straight to a click instead of
   waiting for a double-tap-zoom / pan gesture. Keeps every shop-floor button
   snappy and immune to the "tap eaten inside a scroll area" iOS bug. */
.stn-page button, .stn-page a, .stn-pick-btn, .stn-job-row,
.stn-big-btn, .stn-tab, .stn-next-btn, .stn-ms-btn {
  touch-action: manipulation;
}

.prod-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
  background: #e2e8f0; color: #1e293b; vertical-align: middle;
}
.prod-badge.pc       { background: #ede9fe; color: #5b21b6; }
.prod-badge.pc-out   { background: #7c3aed; color: #fff; }
.prod-badge.pc-back  { background: #d1fae5; color: #065f46; }
.prod-badge.status-awaiting   { background: #fef3c7; color: #92400e; }
.prod-badge.status-live       { background: #dcfce7; color: #166534; }
.prod-badge.status-dispatched { background: #e2e8f0; color: #475569; }

.prod-progress {
  position: relative; display: inline-block; width: 110px; height: 20px;
  background: #e2e8f0; border-radius: 4px; overflow: hidden;
  vertical-align: middle;
}
.prod-progress-fill {
  position: absolute; inset: 0 auto 0 0; background: #22c55e; height: 100%;
}
.prod-progress > span {
  position: relative; display: block; text-align: center; font-size: 0.75rem;
  line-height: 20px; font-weight: 700; color: #0f172a;
}

.prod-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

.prod-card {
  background: rgba(255,255,255,0.92); border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 16px 20px; margin: 16px 0;
}
.prod-form label { display: block; margin: 10px 0; font-weight: 600; }
.prod-form input[type="date"] {
  display: block; margin-top: 4px; padding: 8px; font-size: 1rem;
}
.prod-form label.check { font-weight: 400; }

button.danger, .button.danger { background: #dc2626; color: #fff; }

.logout-form { display: inline; }
button.linklike {
  background: none; border: none; padding: 0; font: inherit; color: inherit;
  text-decoration: underline; cursor: pointer;
}

/* ---------- dashboard ---------- */

.dash-page { max-width: 1400px; }
.dash-suggestions {
  background: #fffbeb; border: 2px solid #fcd34d; border-radius: 12px;
  padding: 12px 18px; margin: 14px 0;
}
.dash-suggestions h2 { margin: 0 0 6px; font-size: 1.1rem; color: #92400e; }
.dash-suggestions ul { margin: 0; padding-left: 22px; line-height: 1.7; }

.dash-grid { border-collapse: collapse; width: 100%; background: rgba(255,255,255,0.95); }
.dash-grid th {
  padding: 10px 8px; border: 1px solid #e2e8f0; background: #0f172a; color: #fff;
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.dash-grid td { border: 1px solid #e2e8f0; padding: 8px; }
.dash-jobcol { text-align: left; min-width: 260px; }
td.dash-jobcol a { font-weight: 700; font-size: 1.05rem; }
.dash-prio {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: #1e293b;
  color: #fff; font-weight: 800; margin-right: 8px;
}
.dash-sub { display: block; color: #64748b; font-size: 0.85rem; margin: 2px 0; }
.dash-cell {
  text-align: center; font-weight: 800; min-width: 76px; font-size: 0.95rem;
}
.dash-cell.red    { background: #dc2626; color: #fff; }
.dash-cell.orange { background: #f59e0b; color: #fff; }
.dash-cell.green  { background: #16a34a; color: #fff; }
.dash-cell.purple { background: #7c3aed; color: #fff; }
.dash-cell.none   { background: #f1f5f9; }
tr.ready-row td.dash-jobcol { box-shadow: inset 4px 0 0 #16a34a; }
.dash-due { text-align: center; white-space: nowrap; }
.dash-due.overdue { color: #b91c1c; font-weight: 800; }
.prod-badge.ready { background: #16a34a; color: #fff; }
.prod-badge.frames-now { background: #dc2626; color: #fff; }
.prod-badge.frames-soon { background: #fbbf24; color: #78350f; }
.dash-legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  color: #475569; font-size: 0.9rem; margin-top: 10px; }
.dash-key {
  display: inline-block; width: 18px; height: 18px; border-radius: 4px;
  vertical-align: middle; margin-right: 4px;
}
.dash-key.red { background: #dc2626; }
.dash-key.orange { background: #f59e0b; }
.dash-key.green { background: #16a34a; }
.dash-key.purple { background: #7c3aed; }
.dash-key.none { background: #f1f5f9; border: 1px solid #e2e8f0; }

/* ---------- live list reorder ---------- */

.drag-cell { white-space: nowrap; width: 90px; }
.drag-handle { cursor: grab; font-size: 1.1rem; padding: 0 6px; user-select: none; }
.move-form { display: inline-block; }
.move-form button {
  padding: 4px 8px; margin: 0 1px; border: 1px solid #cbd5e1; background: #f8fafc;
  border-radius: 4px; cursor: pointer; min-width: 30px;
}
.move-form button:disabled { opacity: 0.3; cursor: default; }
tr.dragging { opacity: 0.4; }
tr.drag-over td { border-top: 3px solid #2563eb; }
.prio-cell { font-weight: 800; font-size: 1.05rem; text-align: center; }

/* ---------- intake buttons on /jobs ---------- */

.intake-cell { white-space: nowrap; }
.intake-cell form { display: inline-block; margin: 0 4px 0 0; }
.intake-hint { font-size: 0.8rem; color: #64748b; }

/* ---------- station screens (tablet-first) ---------- */

.stn-page { padding: 0 8px; }
.stn-title { font-size: 2rem; }

.stn-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-top: 20px;
}
.stn-pick-btn {
  font-size: 1.4rem; font-weight: 800; padding: 34px 10px;
  border-radius: 14px; border: 2px solid #cbd5e1; background: #f8fafc;
  cursor: pointer; min-height: 96px;
}
.stn-pick-btn.current { border-color: #2563eb; background: #dbeafe; }

.stn-job-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.stn-job-row {
  display: flex; align-items: center; gap: 16px; text-decoration: none;
  color: inherit; background: rgba(255,255,255,0.95); border: 2px solid #e2e8f0;
  border-radius: 12px; padding: 16px 18px; min-height: 64px;
}
.stn-job-row:active { background: #eff6ff; }
.stn-job-prio {
  flex: 0 0 44px; height: 44px; border-radius: 50%; background: #1e293b;
  color: #fff; font-weight: 800; font-size: 1.2rem; display: flex;
  align-items: center; justify-content: center;
}
.stn-job-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stn-job-label { font-size: 1.15rem; font-weight: 700; }
.stn-job-sub { color: #475569; font-size: 0.9rem; }
.pc-out-text { color: #7c3aed; }
/* Empty-state message sits directly on the dark backdrop — keep it light. */
.stn-empty { font-size: 1.2rem; color: var(--topbar-fg-soft); margin-top: 30px; }
.stn-back a { font-size: 1.05rem; }
.stn-toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- job hub: the two big buttons ---------- */

.stn-big-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 20px 0;
}
@media (max-width: 640px) { .stn-big-buttons { grid-template-columns: 1fr; } }
.stn-big-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 40px 16px; border-radius: 16px; text-decoration: none;
  background: #2563eb; color: #fff; min-height: 130px; justify-content: center;
}
.stn-big-btn.alt { background: #0f766e; }
.stn-big-btn:active { filter: brightness(1.1); }
.stn-big-btn-title { font-size: 1.7rem; font-weight: 800; }
.stn-big-btn-sub { font-size: 1rem; opacity: 0.85; }

/* ---------- milestone panel ---------- */

.stn-milestones { display: flex; flex-direction: column; gap: 14px; }
.stn-ms-group h3 { margin: 0 0 6px; font-size: 1.05rem; }
.stn-ms-ticks { display: flex; flex-wrap: wrap; gap: 10px; }
.stn-ms-ticks form { margin: 0; }
.stn-ms-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 130px; min-height: 56px; padding: 8px 14px; cursor: pointer;
  border: 2px solid #cbd5e1; border-radius: 10px; background: #f8fafc;
  font: inherit;
}
.stn-ms-btn .stn-ms-shutter { font-weight: 800; font-size: 1.05rem; }
.stn-ms-btn .stn-ms-label { font-size: 0.95rem; }
.stn-ms-btn.done { background: #16a34a; border-color: #15803d; color: #fff; }

/* ---------- job sheets ---------- */

.stn-sheets { padding-bottom: 90px; }   /* room for the fixed tab bar */
.stn-sheet-head { font-size: 1.5rem; }
.stn-section {
  background: rgba(255,255,255,0.95); border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.stn-section h3 { margin: 0 0 8px; color: #1d4ed8; }
.stn-fields { border-collapse: collapse; width: 100%; max-width: 560px; }
.stn-fields th {
  text-align: left; padding: 6px 14px 6px 0; color: #475569; font-weight: 600;
  white-space: nowrap; width: 1%;
}
.stn-fields td { padding: 6px 0; font-weight: 700; font-size: 1.05rem; }
.stn-fields tr { border-bottom: 1px solid #f1f5f9; }
.stn-cuts-table { border-collapse: collapse; width: 100%; max-width: 560px; margin-top: 8px; }
.stn-cuts-table th, .stn-cuts-table td {
  border: 1px solid #e2e8f0; padding: 8px 10px; text-align: left;
}
.stn-cuts-table td.num { text-align: right; font-weight: 700; font-size: 1.05rem; }
.stn-cutlines td.num { text-align: right; }
.stn-cutlines tr.all-cut td { background: #f0fdf4; color: #15803d; }

/* fixed bottom tab bar (shutter numbers) */
.stn-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #0f172a; overflow-x: auto; z-index: 50;
}
.stn-tab {
  flex: 0 0 auto; min-width: 64px; min-height: 48px; font-size: 1.15rem;
  font-weight: 800; border-radius: 10px; border: 2px solid #334155;
  background: #1e293b; color: #cbd5e1; cursor: pointer;
}
.stn-tab.active { background: #2563eb; border-color: #3b82f6; color: #fff; }

/* ---------- cut summary: offcut steppers + plan ---------- */

.stn-startcut-row { margin: 14px 0; }
.stn-startcut-btn {
  display: inline-block; background: #16a34a; color: #fff; font-weight: 800;
  font-size: 1.3rem; padding: 16px 34px; border-radius: 12px;
  text-decoration: none;
}
.offcut-cell { white-space: nowrap; }
.offcut-stepper { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.offcut-stepper button {
  min-width: 48px; min-height: 44px; font-size: 1.3rem; font-weight: 800;
  border: 2px solid #cbd5e1; border-radius: 8px; background: #f8fafc;
  cursor: pointer;
  /* These buttons live inside .table-scroll (a horizontal-scroll region).
     Without this, iOS holds a tap as a possible pan gesture and cancels the
     click, so the form never submits — the "+ does nothing on tablets" bug.
     `manipulation` tells Safari to treat a tap here as an immediate click. */
  touch-action: manipulation;
}
.offcut-stepper button:disabled { opacity: 0.3; cursor: default; }
.offcut-stepper .offcut-all { font-size: 0.95rem; min-width: 54px; }
.offcut-count {
  min-width: 34px; text-align: center; font-size: 1.2rem; font-weight: 800;
  display: inline-block;
}
.offcut-count.active { color: #b45309; }
.stn-plan-group h3 { margin: 18px 0 6px; }
.stn-plan-table td.num { text-align: right; font-weight: 700; }
.plan-cuts { line-height: 1.9; }
.plan-cut {
  display: inline-block; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 1px 8px; margin: 1px 4px 1px 0;
}

/* ---------- cutting mode ---------- */

.stn-cutting { padding-bottom: 40px; }
.stn-now {
  display: flex; gap: 24px; align-items: stretch; flex-wrap: wrap;
  background: #0f172a; color: #fff; border-radius: 18px; padding: 28px 30px;
  margin: 10px 0 18px;
}
.stn-now-main { flex: 1 1 320px; }
.stn-now-length {
  font-size: clamp(64px, 14vw, 150px); font-weight: 900; line-height: 1;
  letter-spacing: -0.02em;
}
.stn-now-length .mm { font-size: 0.35em; font-weight: 700; opacity: 0.7; margin-left: 8px; }
.stn-now-detail { font-size: 1.4rem; margin-top: 10px; }
.stn-now-source { margin-top: 10px; font-size: 1.05rem; opacity: 0.85; }
.stn-now-source.offcut { color: #fbbf24; font-weight: 800; opacity: 1; }
.stn-next-form { display: flex; align-items: center; }
.stn-next-btn {
  background: #16a34a; color: #fff; border: none; border-radius: 16px;
  font-size: 2rem; font-weight: 900; padding: 30px 40px; cursor: pointer;
  min-width: 220px; min-height: 120px;
}
.stn-next-btn:active { background: #15803d; }
.stn-upcoming { max-width: 640px; }
.stn-upcoming h3 {
  margin: 0 0 10px; font-size: 1.15rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: #475569;
}
.stn-upcoming-list { list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px; }
.stn-up-item {
  display: flex; align-items: center; gap: 16px;
  background: #f1f5f9; border: 2px solid #cbd5e1; border-radius: 12px;
  padding: 10px 16px;
}
/* The immediate next cut stands out from the rest of the queue. */
.stn-up-item.is-next {
  background: #e0f2fe; border-color: #0284c7;
}
.stn-up-pos {
  flex: 0 0 34px; height: 34px; border-radius: 50%; background: #334155;
  color: #fff; font-weight: 800; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.stn-up-item.is-next .stn-up-pos { background: #0284c7; }
.stn-up-length {
  font-size: 2.4rem; font-weight: 900; color: #0f172a; line-height: 1;
  min-width: 150px;
}
.stn-up-length .mm { font-size: 0.4em; font-weight: 700; color: #64748b; margin-left: 4px; }
.stn-up-meta { display: flex; flex-direction: column; gap: 4px; }
.stn-up-part { font-size: 1.15rem; font-weight: 600; color: #1e293b; }
.stn-up-bar { font-size: 0.95rem; color: #64748b; }
.up-offcut {
  align-self: flex-start;
  background: #fef3c7; color: #92400e; border-radius: 6px; padding: 1px 10px;
  font-weight: 800; font-size: 0.95rem;
}
.stn-alldone-big { font-size: 2.2rem; font-weight: 900; color: #16a34a; margin: 30px 0 10px; }

/* completed cuts — red-shaded list, bottom-right */
.stn-completed {
  position: fixed; right: 12px; bottom: 12px; width: min(300px, 44vw);
  background: #fef2f2; border: 2px solid #fecaca; border-radius: 12px;
  padding: 10px 14px; max-height: 45vh; overflow-y: auto; z-index: 40;
  font-size: 0.9rem;
}
.stn-completed h3 { margin: 0 0 6px; color: #b91c1c; font-size: 1rem; }
.stn-completed ul { list-style: none; margin: 0; padding: 0; }
.stn-completed li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 3px 0; border-bottom: 1px solid #fee2e2; color: #7f1d1d;
}
.stn-completed form { margin: 0; }
.stn-completed button {
  border: 1px solid #fca5a5; background: #fff; border-radius: 6px;
  min-width: 34px; min-height: 30px; cursor: pointer;
}
