/* Supplier rejection portal additions on top of the shared PML stylesheet */
.badge.reported { background: var(--amber-tint); color: var(--amber); }
.badge.returned { background: var(--red-tint); color: var(--red); }
.badge.dn_raised { background: var(--beige-tint); color: var(--beige-text); }
.badge.accepted { background: var(--blue-tint); color: var(--blue); }
.badge.disputed { background: #efe7fb; color: #6b46c1; }
.badge.recovered { background: var(--green-tint); color: var(--green); }
.badge.waived { background: #eee; color: #555; }
.overdue-text { color: var(--red); font-weight: 500; }

.kpi.green { border-left-color: var(--green); }
.kpi.green .val { color: var(--green); }
.grid.kpis.fy .kpi { background: var(--beige-tint); }

.banner .big-amount { font: 700 26px var(--font-head); color: var(--ink); text-align: right; line-height: 1.1; }
.banner .big-amount span { display: block; font: 500 12px var(--font-body); color: var(--ink-3); }

.viz-col .pair { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 100%; }
.viz-col .pair .viz-seg { width: min(22px, 40%); border-radius: 3px 3px 0 0; min-height: 0; }
tbody td:first-child a, td.nowrap { white-space: nowrap; }

.input-add { display: flex; gap: 6px; }
.input-add select { flex: 1; min-width: 0; }
.edit-table td { padding: 6px 8px; }
.edit-table input, .edit-table select { min-width: 90px; }
.edit-table input.qty { width: 100px; min-width: 0; }
.edit-table select[name=kind] { min-width: 200px; }
.edit-table input[name=description] { min-width: 200px; }
.edit-table input[name=unit] { width: 70px; min-width: 0; }
.edit-table tfoot td { border-bottom: 0; padding-top: 12px; }
tr.total-row td { font-weight: 700; background: #faf6ef; }
.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: 220px; }
.inline-select { width: auto; padding: 3px 6px; font-size: 13px; }
.group-label { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.check-group.invalid { outline: 2px solid var(--red); outline-offset: 4px; border-radius: 6px; }
.check-group { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-top: 4px; }
.check-group label.check { margin: 0; min-height: 32px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); }
tr.inactive td { color: var(--ink-3); }
.chat-preview { white-space: pre-wrap; font: 13px/1.5 var(--font-body); background: #f4f6f8; border-radius: 8px; padding: 12px; margin: 0; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
code { background: var(--beige-tint); padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }

/* Debit note sheet (A4 when printed) */
/* On screen the letterhead strips sit at the top and bottom of the sheet; print rules below repeat them on every page. */
.dn-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-width: 820px; margin: 0 auto; font-size: 13.5px;
  overflow: hidden; display: flex; flex-direction: column; }
.dn-lh-head, .dn-lh-foot { display: block; width: 100%; height: auto; }
.dn-lh-foot { order: 2; margin-top: 8px; }
table.dn-frame, .dn-frame > * > tr > td { border: 0; padding: 0; background: none; }
.dn-frame > tbody > tr:hover { background: none; }
.dn-frame .dn-body { padding: 12px 40px 8px; }
.dn-space-top, .dn-space-bottom { display: none; }
.dn-titlebar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 3px solid var(--red); padding-bottom: 8px; margin-bottom: 14px; }
.dn-title { font: 700 20px var(--font-head); color: var(--red); letter-spacing: 1px; }
.dn-meta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 12px; }
.dn-meta .k, .dn-nums .k { color: var(--ink-3); font-size: 12px; }
.dn-nums { text-align: right; }
.dn-table { margin: 10px 0 14px; }
.dn-table th, .dn-table td { border: 1px solid var(--line); }
.dn-table tbody th { width: 160px; background: #faf6ef; }
.dn-sign { display: flex; justify-content: space-between; margin-top: 36px; font-size: 12.5px; }
.dn-sign > div:last-child { text-align: right; }
@media print {
  .no-print, .tabbar { display: none !important; }
  .main { padding: 0; }
  .dn-sheet { border: 0; padding: 0; max-width: none; border-radius: 0; display: block; overflow: visible; }
  /* Letterhead edge to edge, repeated on every page (A4 is 210 mm wide; the strips are 30.9 and 40.2 mm tall). */
  @page { size: A4; margin: 14mm; }
  @page dn { size: A4; margin: 0; }
  .dn-sheet { page: dn; }
  .dn-lh-head, .dn-lh-foot { position: fixed; left: 0; width: 210mm; margin: 0; }
  .dn-lh-head { top: 0; }
  .dn-lh-foot { bottom: 0; }
  .dn-space-top { display: block; height: 35mm; }
  .dn-space-bottom { display: block; height: 44mm; }
  .dn-frame .dn-body { padding: 0 14mm; }
  .dn-frame thead { display: table-header-group; }
  .dn-frame tfoot { display: table-footer-group; }
  html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 700px) {
  .sticky-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .sticky-bar .btn { flex: 1; min-width: 0; }
  .dn-frame .dn-body { padding: 12px 16px 8px; }
  .dn-meta { flex-direction: column; }
  .dn-nums { text-align: left; }
  .banner .big-amount { text-align: left; }
}

/* ---------- Audit additions ---------- */
.badge.yours { background: var(--red); color: #fff; }
.badge.overdue { background: var(--red-tint); color: var(--red); }
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; }
.photo-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; margin: 0; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #faf6ef; }
.thumb img { width: 100%; height: 100px; object-fit: cover; display: block; }
.thumb .pdf { display: grid; place-items: center; height: 100px; font: 700 18px var(--font-head); color: var(--red); }
.thumb span { display: block; font-size: 11px; padding: 4px 6px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
ul.files { list-style: none; padding: 0; margin: 12px 0 0; }
ul.files li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-form { display: flex; gap: 8px; margin-bottom: 14px; }
.note-form input { flex: 1; }
.timeline li.note { background: var(--beige-tint); border-radius: 0 6px 6px 0; }
.row-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field label { margin: 0; white-space: nowrap; }
.inline-field select { width: auto; }
.sticky-total { margin-right: auto; align-self: center; font-size: 14px; }
.edit-table .unit-cell select { min-width: 110px; }
.dn-total { font-size: 15px; }
.recover-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); padding: 14px 18px; }
.recover-bar .field { margin: 0; min-width: 180px; }
.recover-bar > div:first-child { margin-right: auto; align-self: center; }
.dn-annex { break-before: page; margin-top: 32px; }
.dn-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dn-photos figure { margin: 0; break-inside: avoid; }
.dn-photos img { width: 100%; max-height: 300px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }
.dn-photos figcaption { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
label.check { margin-bottom: 6px; }
label.btn { margin: 0; color: var(--ink); }

/* Phone: lot and cost rows become cards with labelled fields */
@media (max-width: 700px) {
  .edit-table thead { display: none; }
  .edit-table, .edit-table tbody, .edit-table tfoot, .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; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .edit-table td[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--ink-2); flex: none; width: 40%; }
  .edit-table td input, .edit-table td select { flex: 1; min-width: 0 !important; width: auto !important; }
  .edit-table td.right .btn { width: 100%; }
  .edit-table tfoot td { justify-content: flex-end; }
  .edit-table tfoot td:empty { display: none; }
  .table-wrap:has(.edit-table) { overflow: visible; }
  .card-head .actions .btn { flex: 1 1 auto; }
  .sticky-total { width: 100%; text-align: center; }
  .sticky-bar { flex-wrap: wrap; }
  .note-form { flex-direction: column; }
  .dn-photos { grid-template-columns: 1fr; }
  .menu-list { right: auto; left: 0; }
  .recover-bar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* dd/mm/yyyy date box with a calendar button (the browser's 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 #d8cbb8; border-left: 0; border-radius: 0 8px 8px 0; background: #faf6ef; 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; }
.edit-table .date-field { min-width: 150px; }
@media (max-width: 700px) { .edit-table td .date-field { flex: 1; } .edit-table td .date-field .date-text { width: auto !important; } }

/* Supplier rating (F/PURF/10) */
.badge.r-very-good { background: var(--green-tint); color: var(--green); }
.badge.r-good { background: var(--blue-tint); color: var(--blue); }
.badge.r-needs-improvement { background: var(--amber-tint); color: var(--amber); }
.badge.r-poor { background: var(--red-tint, #fde8e7); color: var(--red); }
table.rating th, table.rating td { white-space: nowrap; }
table.rating .grp { text-align: center; border-bottom: 2px solid var(--beige); }
.ppm-table td input { width: 110px; }

/* =================== Alloy Division additions =================== */
.kpi.amber { border-left-color: var(--amber); }
.badge.ok { background: var(--green-tint); color: var(--green); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.charts { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.card h2 .badge { vertical-align: middle; margin-left: 6px; }
.card.tight { padding: 14px 16px; }
.section-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.section-title .spacer { flex: 1; }
.locked-note { background: var(--red-tint); border: 1px solid #f5c6c3; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.locked-note.ok { background: var(--green-tint); border-color: #bfe3cf; }
.locked-note.info { background: var(--beige-tint); border-color: var(--line); }
.locked-note ul { margin: 4px 0 0; padding-left: 18px; }
td.bad, .bad { color: var(--red); font-weight: 500; }
td.good { color: var(--green); }
td.warn-cell { color: var(--red); }
tr.row-bad td { background: #fff7f6; }
.form-row.tight { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.field .hint { margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 2px; margin: 0 0 14px; }
legend { font: 700 13px var(--font-head); color: var(--beige-text); padding: 0 6px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; }

/* Report header: why the report exists and what it enforces */
.report-why { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.report-why h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--beige-text); margin-bottom: 4px; }
.report-why p { margin: 0; }
.report-why ol { margin: 0; padding-left: 18px; }
.report-why .enforced { grid-column: 1 / -1; background: var(--red-tint); border-radius: 8px; padding: 10px 14px; }
.report-why .enforced strong { color: var(--red); }
details.why > summary { cursor: pointer; font: 700 14px var(--font-head); color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.why > summary::-webkit-details-marker { display: none; }
details.why > summary::before { content: '▸'; color: var(--beige-text); }
details.why[open] > summary::before { content: '▾'; }
details.why[open] > summary { margin-bottom: 12px; }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.report-tile { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); box-shadow: var(--shadow); }
.report-tile:hover { border-color: var(--beige); text-decoration: none; }
.report-tile .no { font: 700 12px var(--font-head); color: var(--red); }
.report-tile strong { display: block; font-family: var(--font-head); margin: 2px 0 4px; }
.report-tile span { font-size: 12px; color: var(--ink-3); display: block; }

/* SVG charts */
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-svg text { font: 13px var(--font-body); fill: var(--ink-3); }
.viz-svg .grid { stroke: #efe6d8; stroke-width: 1; }
.viz-svg .limit { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.viz-svg .limit.soft { stroke: var(--warm-grey); stroke-dasharray: 2 4; }
.viz-svg .limit-label { fill: var(--ink); font-weight: 500; }
.viz-svg .limit-label.soft { fill: var(--ink-3); }
.viz-svg .dot { cursor: default; }
.viz-cols { height: 210px; }
.viz-col .cluster { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 100%; }
.viz-col .cluster .viz-seg { width: min(22px, 44%); border-radius: 3px 3px 0 0; min-height: 0; }
.viz-col .cluster .viz-seg[data-zero] { min-height: 0; }
.viz-x { overflow: visible; font-size: 10px; }
.viz-hbar.neg { background: var(--sand) !important; }
.viz-cum { font-size: 11px; color: var(--ink-3); margin-left: 4px; }
.viz-progress { height: 14px; background: #efe6d8; border-radius: 7px; overflow: hidden; flex: 1; }
.viz-progress div { height: 100%; border-radius: 7px; }
.viz-hrow.prog { grid-template-columns: minmax(80px, 22%) 1fr; }

/* Charge table and heat page */
.heat-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.lot-rows { display: grid; gap: 6px; }
.lot-row { display: grid; grid-template-columns: 1fr 110px 34px; gap: 6px; align-items: center; }
.lot-row .btn { padding: 4px 0; }
.chem-table td.num.bad { background: var(--red-tint); }
.chem-table th small { display: block; font-weight: 400; color: var(--ink-3); font-family: var(--font-body); }
.tabs .count { background: var(--red); color: #fff; border-radius: 999px; font: 600 10px var(--font-body); padding: 1px 6px; margin-left: 4px; }

/* MTC certificate sheet */
.cert { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-width: 860px; margin: 0 auto; padding: 32px 40px; font-size: 13.5px; }
.cert-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid var(--red); padding-bottom: 10px; margin-bottom: 16px; }
.cert-head .co { font: 700 20px var(--font-head); }
.cert-head .title { font: 700 16px var(--font-head); color: var(--red); letter-spacing: .5px; text-align: right; }
.cert table th, .cert table td { border: 1px solid var(--line); padding: 6px 9px; }
.cert .watermark { color: var(--red); font: 700 14px var(--font-head); border: 2px solid var(--red); display: inline-block; padding: 2px 10px; border-radius: 6px; }
@media print {
  .cert { border: 0; padding: 0; max-width: none; }
  .report-why, details.why, #filters { display: none !important; }
}
@media (max-width: 700px) {
  .report-why { grid-template-columns: 1fr; }
  .cert { padding: 16px; }
  .lot-row { grid-template-columns: 1fr 44px; } .lot-row select { grid-column: 1 / -1; } .lot-row input { font-size: 18px; }
}

.form-row.tight { align-items: end; }
.datetime-field { display: flex; gap: 6px; }
.datetime-field .date-field { flex: 1 1 60%; }
.datetime-field .time-text { flex: 0 0 82px; width: 82px; text-align: center; }
input.time-text { font-variant-numeric: tabular-nums; }

/* =================== PML brand guidelines (03 · Colour) =================== */
/* Light theme: white and beige carry everything, ink is for text, red is kept for accents and the one main action. */
.sidebar { background: #fff; border-right: 1px solid var(--line); }
.brand { border-bottom: 3px solid var(--red); }
.brand .sub { color: var(--warm-grey); }
.nav .group { color: var(--warm-grey); }
.nav a { color: var(--ink-2); }
.nav a:hover { background: var(--beige-tint); color: var(--ink); }
.nav a.active { background: var(--red-tint); color: var(--red); }
.userbox { border-top-color: var(--line); }
.userbox .role { color: var(--warm-grey); }
/* Sign-in (cover) screen: same as rejections / purchasing – PML Red panel on the left, white logo tile, sign-in card on beige. */
.login-hero { background-image: radial-gradient(circle at 85% 15%, rgba(255,255,255,.12) 0, transparent 40%), radial-gradient(circle at 10% 90%, rgba(201,179,146,.45) 0, transparent 45%); }
.btn.secondary { background: var(--ink); border-color: var(--ink); color: #fff; }
.banner { background: #fff; border-color: var(--line); border-left: 4px solid var(--sand); }
.banner.red { background: #fff; border-color: var(--line); border-left-color: var(--red); }
.kpi { border-left-color: var(--sand); }
.kpi.red .val { color: var(--red); }
.attention li { background: var(--beige-tint); border-left-color: var(--sand); }
.attention li.red { background: var(--red-tint); border-left-color: var(--red); }
.badge.kind { background: var(--line); color: var(--ink-2); }
/* Next steps and normal waiting states are green; red is kept for something missing or wrong. */
.locked-note.info { background: var(--green-tint); border-color: #bfe3cf; border-left: 4px solid var(--green); }
.report-tile .no, .report-why h3, legend { color: var(--warm-grey); }
.report-tile .no { color: var(--red); }
.tabbar a.active { color: var(--red); background: var(--beige-tint); }
.cert-head { border-bottom-color: var(--red); }
.toast { background: var(--green); }
.toast.error { background: var(--red); }
th { color: var(--ink-2); }

/* ---------- Data-entry comfort ---------- */
.next-step { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 14px 0 4px; padding: 12px 16px;
  border-radius: 10px; background: var(--beige-tint); border-left: 4px solid var(--red); }
.next-step .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 2px; }
.next-step ul { margin: 4px 0 0; padding-left: 18px; }
.next-step li { margin: 4px 0; }
.next-step li .btn { margin-left: 6px; }
.time-field, .datetime-field { display: flex; gap: 6px; align-items: center; }
.time-field .time-text { flex: 1 1 auto; min-width: 0; }
.now-btn { flex: 0 0 auto; padding-left: 10px; padding-right: 10px; }
.select-filter { width: 100%; margin-bottom: 4px; font-size: 13px; padding: 6px 10px; }
.weigh-sum { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.weigh-sum:empty { display: none; }
.weigh-sum.ok { background: var(--green-tint); color: var(--green); }
.weigh-sum.bad { background: var(--red-tint); color: var(--red-dark); }
input.oos { border-color: var(--red) !important; background: var(--red-tint); }
textarea.invalid, .date-text.invalid, .time-text.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(219,36,30,.15); }
.draft-note { margin-bottom: 12px; }
@media (max-width: 600px) {
  /* All five heat stages fit across a phone, so the current one is always in view. */
  .steps .step { min-width: 0; font-size: 10.5px; line-height: 1.25; padding-left: 2px; padding-right: 2px; }
}

/* Test mode: shown on every screen while the administrator may act for every role. */
.test-banner { background: #fff4d6; border-bottom: 1px solid #e8c56a; color: #6b4e00; font-size: 13px; padding: 8px 16px; text-align: center; }

/* ---------- Documents: customer order, dispatch sheet (laid out like the Tally voucher) ---------- */
.doc-title { font-family: Quicksand, sans-serif; font-weight: 700; font-size: 18px; text-align: center; margin-bottom: 12px; letter-spacing: .02em; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.doc-grid > * { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.doc-grid > :nth-child(odd) { border-right: 1px solid var(--line); }
.doc-grid .k, .doc-refs .k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.doc-refs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0 !important; }
.doc-refs > div { padding: 8px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 44px; }
.doc-refs > div:nth-child(even) { border-right: 0; }
.card > .doc-grid:only-child, .doc-grid:not(.card .doc-grid) { margin-bottom: 0; }
form .doc-grid { border: 0; overflow: visible; grid-template-columns: 1fr 1fr; gap: 16px; }
form .doc-grid > * { padding: 16px; border: 1px solid var(--line); }
.doc-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-lines th, .doc-lines td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.doc-lines .num, .doc-totals .num { text-align: right; white-space: nowrap; }
.doc-totals { margin: 12px 0 4px auto; min-width: 300px; border-collapse: collapse; font-size: 13px; }
.doc-totals td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
input.short { width: 70px; }
td.amount { white-space: nowrap; }

/* Attached files */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.file { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.file img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; }
.file .pdf { width: 64px; height: 64px; display: grid; place-items: center; background: var(--red-tint); color: var(--red); font-weight: 700; border-radius: 6px; }
.file .small { word-break: break-word; }

@media screen and (max-width: 760px) {
  .doc-grid, form .doc-grid, .doc-refs { grid-template-columns: 1fr; }
  .doc-grid > :nth-child(odd), .doc-refs > div { border-right: 0; }
}
@media print {
  .doc { border: 0; box-shadow: none; padding: 0; }
  .doc-grid { break-inside: avoid; }
}
@media print { .no-print, .test-banner, .tabbar, .crumbs, .files-card { display: none !important; } }

h2.sub { margin: 20px 0 8px; font-size: 16px; }

/* A date-and-time pair wraps rather than squeezing the date out of sight. */
.datetime-field { flex-wrap: wrap; }
.datetime-field .date-field { flex: 1 1 150px; min-width: 150px; }
.weigh-sum .lot-short { margin-top: 6px; padding-top: 6px; border-top: 1px solid #f5c6c3; color: var(--red); }

/* ---------- Letterhead printing (quotation, order acknowledgement, certificate) ---------- */
.lh-bg { display: none; }
.lh-frame { width: 100%; border-collapse: collapse; }
.lh-frame > thead, .lh-frame > tfoot { display: none; }
.lh-frame td { padding: 0; }
@media print {
  .lh-doc .doc-lines { font-size: 11px; }
  .lh-doc .doc-lines th { white-space: normal; }
  .lh-doc .doc-lines th, .lh-doc .doc-lines td { padding: 6px 5px; }
  .lh-doc .lh-bg { display: block; position: fixed; top: 0; left: 0; width: 210mm; height: 297mm; z-index: -1; }
  .lh-doc .lh-frame > thead { display: table-header-group; }
  .lh-doc .lh-frame > tfoot { display: table-footer-group; }
  .lh-doc .lh-top { height: 36mm; }
  .lh-doc .lh-bottom { height: 44mm; }
  .lh-doc .lh-body { padding: 0 15mm; }
  .lh-doc .card, .lh-doc .doc, .lh-doc .cert { border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; background: transparent !important; }
  .lh-doc .lh-hide { display: none !important; }
  body:has(.lh-doc) .main { padding: 0 !important; }
  body:has(.lh-doc) .page-head, body:has(.lh-doc) .no-print { display: none !important; }
}
.thread { list-style: none; margin: 0; padding: 0; }
.thread li { border-left: 3px solid var(--line); padding: 8px 12px; margin-bottom: 10px; }
.thread li.in { border-left-color: var(--sand); }
.thread li.out { border-left-color: var(--green); }
.thread li.internal { border-left-color: var(--ink-3, #888); background: #faf6ef; }
.thread .meta { font-size: 12px; color: var(--muted); }
.thread .kp { font-weight: 600; margin: 2px 0; }
.thread details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.thread pre { white-space: pre-wrap; font-family: inherit; font-size: 13px; margin: 6px 0 0; max-height: 360px; overflow: auto; }

.doc-terms { border-collapse: collapse; font-size: 13px; width: 100%; }
.doc-terms th { text-align: left; width: 170px; vertical-align: top; padding: 4px 8px 4px 0; color: var(--muted); font-weight: 500; }
.doc-terms td { padding: 4px 0; }
.lh-frame > thead > tr > td, .lh-frame > tfoot > tr > td, .lh-frame > tbody > tr > td.lh-body { border: 0 !important; background: none !important; }
@media print { .lh-doc .doc-terms th, .lh-doc .doc-terms td { padding-top: 3px; padding-bottom: 3px; } }
/* A next step is normal work, not a problem: green (red stays for something missing or wrong). */
.next-step { background: var(--green-tint) !important; border-color: #bfe3cf !important; border-left: 4px solid var(--green) !important; }
a.kpi-link { color: inherit; text-decoration: none; display: block; }
a.kpi-link:hover { box-shadow: 0 0 0 2px var(--line); }
.good { color: var(--green); }
#give-bar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
#give-bar[hidden] { display: none; }

/* On screen: the document sits on a sheet with the letterhead's header and footer (the same image the print uses). */
.lh-paper { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.lh-screen-top, .lh-screen-bottom { background: url(/img/letterhead.jpg) no-repeat; background-size: 100% auto; }
.lh-screen-top { aspect-ratio: 1755 / 260; background-position: top; }
.lh-screen-bottom { aspect-ratio: 1755 / 320; background-position: bottom; }
.lh-paper .lh-body { padding: 4px 4% 8px; }
.lh-paper .card, .lh-paper .doc, .lh-paper .cert { border: 0; box-shadow: none; margin: 0; }
@media print {
  .lh-paper { border: 0; border-radius: 0; overflow: visible; margin: 0; background: transparent; }
  .lh-screen-top, .lh-screen-bottom { display: none !important; }
  .lh-paper .lh-body { padding: 0 15mm; }
  .cert .watermark { font-size: 22px; }
}
.lh-paper .lh-hide { display: none; }
.lh-paper .cert-head { justify-content: flex-end; }

.setup { list-style: none; padding: 0; margin: 0; }
.setup li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.setup li.done { color: var(--muted); }
.setup li.done a { color: var(--muted); text-decoration: line-through; }
.paste-spec { margin: 8px 0 12px; }
.paste-spec summary { cursor: pointer; color: var(--red); font-weight: 600; font-size: 13px; }

.line-hint { margin-top: 4px; line-height: 1.35; white-space: normal; max-width: 340px; }
.ok-text { color: var(--green, #1a7f37); font-weight: 600; }

.clock-banner { background: #fdecea; border-color: #e3a19a; color: #8a1c12; }
.tasks li.bad a, li.bad a { color: var(--red); font-weight: 600; }

/* Tappable task rows (home screen) */
.tasks { display: flex; flex-direction: column; gap: 8px; }
.tasks .task { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--card, #fff); color: inherit; text-decoration: none; }
.tasks .task:hover, .tasks .task:focus-visible { border-color: var(--red); box-shadow: 0 1px 0 var(--line); }
.tasks .task > span:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tasks .task .count { background: var(--red); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.tasks .task .go { font-size: 22px; color: var(--muted); line-height: 1; }
.tasks .task.bad { border-color: #e3a19a; background: #fdf3f1; }
.tasks .task.bad > span:first-child { color: #8a1c12; font-weight: 600; }

/* Search in the menu */
.nav-search { position: relative; padding: 0 14px 10px; }
.nav-search input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; }
.search-results { position: absolute; left: 14px; right: -260px; top: 42px; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; }
.search-results a { display: block; padding: 8px 12px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--beige-tint); }
@media (max-width: 760px) { .search-results { right: 14px; } }
/* Shop-floor tablet sign-in */
.floor-login { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.floor-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.floor-head h1 { margin: 0; }
.floor-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.floor-name { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px 16px; min-height: 80px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 18px; cursor: pointer; text-align: left; }
.floor-name span { font-size: 13px; color: var(--muted); }
.floor-name:active, .floor-name:focus-visible { border-color: var(--red); }
.pin-input { font-size: 28px; letter-spacing: 8px; text-align: center; }

/* Consignment lots: room for each control (the table scrolls sideways on a phone instead of squeezing) */
.dispatch-lots { min-width: 900px; }
.dispatch-lots td:nth-child(1) select { min-width: 240px; }
.dispatch-lots td:nth-child(2) select { min-width: 200px; }
.dispatch-lots td:nth-child(3) select { min-width: 140px; }
.grn-lines { min-width: 980px; }
.grn-lines td:nth-child(1) select { min-width: 170px; }

/* OK / Not OK: two buttons, one tap */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; min-width: 76px; padding: 10px 14px; text-align: center; font-weight: 600; background: #fff; }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line); }
.seg-opt.yes input:checked + span { background: #e6f4ea; color: #1a7f37; }
.seg-opt.no input:checked + span { background: #fdecea; color: #8a1c12; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--red); outline-offset: -2px; }
.seg-opt input:disabled + span { opacity: .6; cursor: default; }
.form-row.checks { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
/* Heat page: parts that fold, and a strip to jump between them */
.stage-jump { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 10px; position: sticky; top: 0; z-index: 5; background: var(--bg, #f3ece2); padding: 6px 0; }
.stage-jump a { white-space: nowrap; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: inherit; text-decoration: none; font-size: 14px; }
.stage-jump a.on { border-color: var(--red); color: var(--red); font-weight: 600; }
details.stage-sec { margin-bottom: 12px; }
details.stage-sec > summary { cursor: pointer; list-style: none; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; font: 600 16px var(--font-head, inherit); }
details.stage-sec > summary::-webkit-details-marker { display: none; }
details.stage-sec > summary::after { content: '▸'; float: right; color: var(--muted); }
details.stage-sec[open] > summary { margin-bottom: 8px; }
details.stage-sec[open] > summary::after { content: '▾'; }
/* Heat list: cards on a phone, the table on a computer */
.heat-cards { display: none; }
.more-filters > summary { cursor: pointer; font-size: 14px; color: var(--muted); padding: 8px 0; }
.more-filters[open] > .toolbar { margin-top: 6px; }
@media (max-width: 700px) {
  .heat-table { display: none; }
  .heat-cards { display: flex; flex-direction: column; gap: 8px; }
  .heat-card { display: block; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; }
  .heat-card .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
  /* The charge table keeps only what the operator needs on a phone */
  .charge-table th:nth-child(6), .charge-table td:nth-child(6), .charge-table th:nth-child(8), .charge-table td:nth-child(8),
  .charge-table th:nth-child(10), .charge-table td:nth-child(10), .charge-table th:nth-child(11), .charge-table td:nth-child(11) { display: none; }
  .charge-table td, .charge-table th { padding: 8px 6px; font-size: 14px; }
  .meta-grid { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .meta-grid .v { font-size: 14px; }
}
@media (max-width: 700px) {
  .form-row.checks { grid-template-columns: 1fr; gap: 6px; }
  .form-row.checks .field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .form-row.checks .field > label { margin: 0; flex: 1; font-size: 14px; }
  .form-row.checks .seg-opt span { min-width: 64px; padding: 9px 10px; }
}
@media (max-width: 700px) { #filters:not(.show-filters) > .more-filters { display: none; } }
.floor-head .logo { width: 52px; height: 52px; border-radius: 12px; background: var(--red); color: #fff; display: grid; place-items: center; font: 700 16px var(--font-head, inherit); flex: none; }
