/* Shunt Production additions on top of the shared PML stylesheet (styles.css, same as purchasing / rejections). */
:root {
  --c-ok: #1f8a4c;      /* good production */
  --c-rej: #db241e;     /* rejection – PML red */
  --c-prod: #2a78d6;    /* productivity */
  --c-down: #b7791f;    /* breakdown time */
  --c-neutral: #9a948c;
}

/* ---------- Charts ---------- */
.chart { width: 100%; min-height: 120px; }
svg.viz { display: block; overflow: visible; font-family: var(--font-body); }
svg.viz .grid { stroke: #efebe6; stroke-width: 1; }
svg.viz .grid.base { stroke: #d9d3cb; }
svg.viz .ylab, svg.viz .xlab { font-size: 11px; fill: var(--ink-3); }
svg.viz .ref { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.viz .reflab { font-size: 11px; fill: var(--ink-2); font-weight: 500; }
svg.viz .guide { stroke: var(--ink-3); stroke-width: 1; }
svg.viz .hit { cursor: crosshair; }
.viz-hrow { grid-template-columns: minmax(110px, 30%) 1fr; }
.viz-hlabel a { color: var(--ink); }
.viz-htrack { gap: 10px; }
.viz-hfill { position: relative; flex: 1; height: 14px; }
.viz-hbar { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.viz-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.viz-hval { min-width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.viz-table table th, .viz-table table td { padding: 5px 8px; }
.chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.chart-row > .card { min-width: 0; }
@media (max-width: 1100px) { .chart-row { grid-template-columns: 1fr; } }

/* ---------- Coloured percentages ---------- */
.pct { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pct.good { color: var(--green); }
.pct.warn { color: var(--amber); }
.pct.bad { color: var(--red); }
.pct.bad::before { content: '▲ '; font-size: 9px; vertical-align: 1px; }
.kpi .val.good { color: var(--green); }
.kpi .val.warn { color: var(--amber); }
.kpi .val.bad { color: var(--red); }
.kpi .sub { font-size: 12px; color: var(--ink-3); }
.kpi.blue { border-left-color: var(--c-prod); }
.kpi.green { border-left-color: var(--green); }
.kpi.amber { border-left-color: var(--c-down); }

/* ---------- Filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.filters .field { margin: 0; min-width: 140px; flex: 0 1 170px; }
.filters .field.wide { flex-basis: 220px; }
.filters .presets { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.filters .date-field { min-width: 140px; }

/* ---------- Production sheet ---------- */
.sheet-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.sheet-head .k { font-size: 12px; color: var(--ink-3); }
.sheet-head .v { font-weight: 600; }
.sheet-totals { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; padding: 12px 0 0; margin-top: 12px; border-top: 1px dashed var(--line); }
.sheet-totals b { font: 700 20px var(--font-head); }
.proc-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.proc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: #fbfaf8; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.proc-head h3 { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.proc-head .seq { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--beige-tint); color: var(--beige-text); font-size: 12px; }
.proc-head .norm { font: 500 12px var(--font-body); color: var(--ink-3); }
.tag { display: inline-block; font: 600 11px var(--font-body); padding: 1px 7px; border-radius: 999px; background: var(--beige-tint); color: var(--beige-text); }
.tag.red { background: var(--red-tint); color: var(--red); }
.tag.green { background: var(--green-tint); color: var(--green); }
.tag.blue { background: var(--blue-tint); color: var(--blue); }
/* One compact line per operator; breakdown / remark open below it when needed. */
.op-cols, .op-line { display: grid; grid-template-columns: minmax(170px, 2fr) 76px 110px 170px 96px 100px 36px; gap: 8px; align-items: center; }
.op-cols { padding: 6px 14px 0; font: 600 11px var(--font-body); color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; }
.op-cols span:nth-child(n+2) { text-align: right; }
.op-row { padding: 6px 14px; border-top: 1px solid #f1ede8; }
.op-cols + .op-row { border-top: 0; }
.op-row.dirty { background: #fffaf2; box-shadow: inset 3px 0 0 var(--beige); }
.op-row.saved { animation: savedflash 1.2s ease-out; }
.op-row.remote, .op-row.remote-now { animation: remoteflash 2s ease-out; }
@keyframes savedflash { from { background: var(--green-tint); } to { background: transparent; } }
@keyframes remoteflash { from { background: var(--blue-tint); } to { background: transparent; } }
.op-line input, .op-line select { padding: 6px 8px; }
.op-line input.num { text-align: right; font-variant-numeric: tabular-nums; }
.op-line input[readonly] { background: #fbfaf8; color: var(--ink-2); }
.op-line .calc { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.m-label { display: none; }
.rej-wrap { display: flex; gap: 4px; }
.rej-wrap input { min-width: 0; flex: 1; }
.def-btn { padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.def-btn.has { background: var(--red-tint); border-color: #f5c6c3; color: var(--red); }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; line-height: 1; color: var(--ink-2); }
.icon-btn:hover { border-color: var(--beige); }
.op-extra { display: grid; grid-template-columns: 110px minmax(150px, 1fr) 2fr 2fr auto; gap: 8px; align-items: end; margin: 8px 0 2px; padding: 8px 10px;
  background: #fbfaf8; border-radius: 8px; }
.op-extra .field { margin: 0; }
.op-extra .field label { font-size: 11px; }
.op-extra input, .op-extra select { padding: 6px 8px; }
.op-extra .rm { align-self: center; }
.op-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 18px; }
.op-foot:has(.defect-chips:empty):has(.op-status:empty) { display: none; }
.op-status { margin-left: auto; font-size: 12px; white-space: nowrap; }
.st.ok { color: var(--green); }
.st.bad { color: var(--red); font-weight: 500; white-space: normal; }
.st.saving { color: var(--ink-3); }
.live { align-self: center; }
.sheet-card { padding: 14px 18px; }
.sheet-head { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.defect-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.defect-chips .chip { padding: 1px 8px; font-size: 11px; cursor: default; }
.defect-chips .chip b { margin-left: 4px; }
.warn-line { color: var(--amber); font-size: 11px; margin-top: 2px; }
.defect-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; max-height: 56vh; overflow-y: auto; padding-right: 4px; }
.defect-picker .cat { grid-column: 1 / -1; font: 700 12px var(--font-head); color: var(--beige-text); text-transform: uppercase; letter-spacing: .4px; margin-top: 8px; }
.defect-picker .cat:first-child { margin-top: 0; }
.defect-picker label { display: grid; grid-template-columns: 1fr 86px; gap: 8px; align-items: center; margin: 0; font-size: 13px; color: var(--ink); }
.defect-picker label.has input { border-color: var(--red); background: var(--red-tint); }
.defect-picker input { padding: 5px 8px; text-align: right; }
#dsum { padding: 8px 12px; border-radius: 8px; background: #fbfaf8; font-weight: 700; text-align: right; min-width: 80px; }
.save-all { position: sticky; bottom: 0; z-index: 6; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 14px;
  background: var(--red-tint); border: 1px solid #f5c6c3; border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(0,0,0,.08); margin-top: 8px; color: var(--red); font-weight: 500; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
/* Tablet / phone: each operator row becomes a small card with labelled boxes. */
@media (max-width: 1000px) {
  .op-cols { display: none; }
  .m-label { display: block; font-size: 11px; margin-bottom: 2px; }
  .op-line { grid-template-columns: 1fr 1fr 1fr; align-items: end; }
  .op-line .c-op { grid-column: 1 / 3; }
  .op-line .c-act { grid-column: 3; justify-self: end; }
  .op-line .c-rej { grid-column: span 1; }
  .op-row { padding: 10px 14px; }
  .op-extra { grid-template-columns: 1fr 1fr; }
  .op-extra .field:nth-child(3), .op-extra .field:nth-child(4) { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .op-line { grid-template-columns: 1fr 1fr; }
  .op-line .c-op { grid-column: 1; }
  .op-line .c-act { grid-column: 2; }
  .op-line .c-rej { grid-column: 1 / -1; }
  .save-all { bottom: calc(70px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; }
}

/* ---------- Today on the line ---------- */
.today-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.today-card { border: 1px solid var(--line); border-top: 3px solid var(--beige); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink); display: grid; gap: 4px; }
.today-card:hover { text-decoration: none; border-color: var(--beige); }
.today-card.done { border-top-color: var(--green); }
.today-card.empty-sheet { border-top-color: var(--red); }
.progress { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); }

/* ---------- Processes editor ---------- */
.proc-edit td { padding: 6px 8px; }
.proc-edit input[name=name] { min-width: 220px; }
.proc-edit input[name=norm] { width: 110px; text-align: right; }
.move-btns { display: inline-flex; gap: 2px; }
.move-btns .btn { padding: 2px 8px; min-height: 0; }

/* ---------- Manpower ---------- */
.mp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.mp-calc { font-variant-numeric: tabular-nums; }
.mp-calc td, .mp-calc th { padding: 7px 10px; }
.mp-calc tr.sum td { font-weight: 700; background: #fbfaf8; }
.mp-calc tr.grand td { font-weight: 700; background: var(--red-tint); color: var(--red); font-size: 15px; }
.mp-items input { width: 110px; text-align: right; padding: 5px 8px; }
.mp-items input.remark { width: 160px; text-align: left; }
.mp-items tr.zero td { color: var(--ink-3); }
.mp-items td { padding: 5px 8px; }
.proc-list { font-size: 12px; color: var(--ink-3); }
tr.detail-row td { background: #fbfaf8; }
.gap-bad { color: var(--red); font-weight: 700; }
.gap-ok { color: var(--green); font-weight: 700; }
.warn-list { margin: 0; padding-left: 18px; font-size: 13px; }

.inline-num { width: 100px; text-align: right; }
td .btn.sm + .btn.sm { margin-left: 4px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 8px 0 10px; }
.section-title h2 { margin: 0; }
.badge.sheet { background: #efe7fb; color: #6b46c1; }
.badge.app { background: var(--blue-tint); color: var(--blue); }
.list-check { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 12px; }
.list-check label.check { margin: 0; }

/* ---------- Shared with the Rejection portal: form helpers, sticky bars, dd/mm/yyyy date boxes ---------- */
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); margin-bottom: 6px; }
label.btn { margin: 0; color: var(--ink); }
tr.inactive td { color: var(--ink-3); }
.group-label { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.sticky-bar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0;
  background: linear-gradient(transparent, var(--bg) 30%); }
.sticky-bar .btn.primary { min-width: 200px; }
.sticky-total { margin-right: auto; align-self: center; font-size: 14px; }
.edit-table td { padding: 6px 8px; }
.edit-table input, .edit-table select { min-width: 90px; }
/* dd/mm/yyyy date box with a calendar button (the browser's own picker stays hidden behind it) */
.date-field { position: relative; display: flex; align-items: stretch; gap: 0; width: 100%; }
.date-field .date-text { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; font-variant-numeric: tabular-nums; }
.date-field .date-cal { flex: none; width: 42px; border: 1px solid #d9d3cb; border-left: 0; border-radius: 0 8px 8px 0; background: #fbfaf8; cursor: pointer; font-size: 16px; }
.date-field .date-cal:hover { background: var(--beige-tint); }
.date-field .date-native { position: absolute; right: 0; bottom: 0; width: 42px; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
@media (max-width: 700px) {
  .sticky-bar { bottom: calc(70px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .sticky-bar .btn { flex: 1; min-width: 0; }
  .sticky-total { width: 100%; text-align: center; }
  .edit-table thead { display: none; }
  .edit-table, .edit-table tbody, .edit-table tr, .edit-table td { display: block; width: 100%; }
  .edit-table tbody tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; background: #fff; }
  .edit-table td { border: 0; padding: 4px 0; }
}
input[type=checkbox], input[type=radio] { accent-color: var(--red); }

/* "More" drop-down menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 240px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: flex; flex-direction: column; }
.menu-list a, .menu-list button { text-align: left; padding: 9px 12px; border-radius: 6px; border: 0; background: none; font: 500 14px var(--font-body); color: var(--ink); cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--beige-tint); text-decoration: none; }
@media (max-width: 700px) { .menu-list { right: 0; left: auto; } }
@media (max-width: 600px) {
  .sheet-head { grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
  .sheet-totals { gap: 6px 16px; }
  .sheet-totals b { font-size: 17px; }
  .quick-copy .actions { width: 100%; }
}
