/* ============================================================================
   Procurement design system — layered on top of style.css.
   Used by PO / GRN / Invoice / Payment / Cheque pages for a clean, modern look.
   ========================================================================== */
:root {
  --p-ink: #0f172a;
  --p-muted: #64748b;
  --p-faint: #94a3b8;
  --p-line: #e8edf3;
  --p-line-strong: #d6deea;
  --p-bg: #f4f6fb;
  --p-card: #ffffff;
  --p-brand: #2563eb;
  --p-brand-d: #1d4ed8;
  --p-violet: #7c3aed;
  --p-radius: 16px;
  --p-radius-sm: 10px;
  --p-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 30px -12px rgba(15,23,42,.18);
  --p-shadow-sm: 0 1px 2px rgba(15,23,42,.06);
}

body { background:
  radial-gradient(1200px 480px at 100% -10%, #e7edfb 0%, rgba(231,237,251,0) 55%),
  radial-gradient(900px 420px at -10% 0%, #eef2ff 0%, rgba(238,242,255,0) 50%),
  var(--p-bg);
}

/* ---- numbering cache status panel --------------------------------------- */
#numCachePanel { padding: 14px 16px; }
.numhead { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.numhead b { color: var(--p-ink); }
.numdot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:7px; vertical-align:middle; }
.numdot.ok { background:#16a34a; box-shadow:0 0 0 3px rgba(22,163,74,.15); }
.numdot.warn { background:#d97706; box-shadow:0 0 0 3px rgba(217,119,6,.15); }
.numhead .good { color:#16a34a; font-weight:700; }
.numhead .warnTxt { color:#d97706; font-weight:700; }
.numcounts { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.numgrid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:12px; }
@media (max-width:720px){ .numgrid { grid-template-columns:1fr; } }
.numco { border:1px solid var(--p-line); border-radius:var(--p-radius-sm); padding:8px 10px; background:#fbfcfe; }
.numco-h { font-weight:800; font-size:12px; letter-spacing:.04em; color:var(--p-brand-d); margin-bottom:4px; }
.numrow { display:flex; align-items:center; gap:8px; padding:3px 0; font-size:12.5px; border-top:1px dashed var(--p-line); }
.numrow:first-of-type { border-top:none; }
.numlbl { width:62px; color:var(--p-muted); font-weight:700; }
.numval { flex:1; font-variant-numeric:tabular-nums; color:var(--p-ink); }
.numfoot { margin-top:10px; font-size:11.5px; }
.pill { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:700; border:1px solid transparent; }
.pill.prov { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.pill.conf { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }
.pill.warn { background:#fffbeb; color:#b45309; border-color:#fde68a; }
.pill.stale { background:#fff7ed; color:#c2410c; border-color:#fed7aa; }
.pill.muted { background:#f1f5f9; color:#64748b; border-color:#e2e8f0; }
.btn.small { padding:4px 10px; font-size:12px; }

/* ---- master-data mapping page ------------------------------------------- */
#health { padding: 14px 16px; }
.hgrid { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.htile { flex:1; min-width:150px; border:1px solid var(--p-line); border-radius:var(--p-radius-sm); padding:10px 14px; background:#fbfcfe; }
.htile .hv { font-size:24px; font-weight:800; color:var(--p-ink); }
.htile .hv.good { color:#16a34a; } .htile .hv.warnTxt { color:#d97706; }
.htile .hl { font-size:11.5px; color:var(--p-muted); font-weight:600; text-transform:uppercase; letter-spacing:.03em; }
.hco-wrap { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:720px){ .hco-wrap { grid-template-columns:1fr; } }
.hco { border:1px solid var(--p-line); border-radius:var(--p-radius-sm); padding:8px 12px; background:#fff; }
.hco-h { font-weight:800; color:var(--p-brand-d); font-size:12px; margin-bottom:6px; }
.mseg { display:inline-block; margin-right:14px; font-size:12.5px; color:var(--p-ink); }
.mseg b { color:var(--p-muted); font-weight:700; text-transform:capitalize; }
.ptabs { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:12px; }
.ptab { padding:8px 14px; border:1px solid var(--p-line); background:#fff; border-radius:999px; font-weight:700; font-size:13px; color:var(--p-muted); cursor:pointer; }
.ptab.active { background:var(--p-brand); color:#fff; border-color:var(--p-brand); }
.tabbadge { display:inline-block; padding:0 7px; border-radius:999px; font-size:11px; margin-left:4px; }
.tabbadge.warn { background:#fde68a; color:#92400e; }
.ptab.active .tabbadge.warn { background:#fff; }
.actcell { white-space:nowrap; }
.btn.small { padding:4px 10px; font-size:12px; }
.btn.small.ok { background:#16a34a; border-color:#16a34a; }
.btn.small.danger { background:#fff; color:#b91c1c; border:1px solid #fecaca; }
.btn.small.ghost { background:#fff; color:var(--p-muted); border:1px solid var(--p-line); }
.affrow td { background:#f8fafc; font-size:12.5px; }
.sub2 { font-size:11px; color:var(--p-faint); }
.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:50; }
.modal { background:#fff; border-radius:var(--p-radius); width:min(540px,92vw); padding:18px; box-shadow:var(--p-shadow); }
.modal-h { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; font-size:15px; }
.modal-h .x { cursor:pointer; color:var(--p-muted); font-weight:700; }
.modal input { width:100%; padding:9px 12px; border:1px solid var(--p-line-strong); border-radius:var(--p-radius-sm); margin-bottom:10px; }
.picker-results { max-height:340px; overflow:auto; }
.pick-item { padding:8px 10px; border-radius:8px; cursor:pointer; border:1px solid transparent; }
.pick-item:hover { background:#eff6ff; border-color:#bfdbfe; }
.empty-state.good { color:#16a34a; }

/* ---- top bar refinement -------------------------------------------------- */
.topbar { padding: 16px 30px; background: linear-gradient(115deg,#0b1220 0%, #15275e 60%, #1e3a8a 100%); }
.topbar .logo { background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.06)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.topbar nav a { position: relative; padding: 6px 2px; transition: color .15s; }
.topbar nav a:hover { text-decoration: none; }

.container { max-width: 1240px; }

/* ---- read-only / dry-run banner ----------------------------------------- */
.ro-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(100deg, #0b1220, #1e293b);
  color: #e2e8f0; border: 1px solid #2b3a52; border-radius: 14px;
  padding: 11px 18px; font-size: 12.5px; font-weight: 600; letter-spacing: .2px;
  margin-bottom: 18px; box-shadow: var(--p-shadow-sm);
}
.ro-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 0 4px rgba(56,189,248,.18); flex: none; }
.ro-banner b { color: #fff; letter-spacing: .4px; }
.ro-banner .muted { color: #94a3b8; font-weight: 500; }

/* ---- cards / sections ---------------------------------------------------- */
.pcard {
  background: var(--p-card); border: 1px solid var(--p-line);
  border-radius: var(--p-radius); box-shadow: var(--p-shadow);
  padding: 22px 24px; margin-bottom: 18px;
}
.pcard.tight { padding: 16px 18px; }
.pcard-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.pcard-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--p-muted); display: flex; align-items: center; gap: 9px; }
.pcard-title .ic { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; background: #eef2ff; color: var(--p-brand-d); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.page-sub { color: var(--p-muted); font-size: 13px; margin-top: 4px; }

/* ---- buttons ------------------------------------------------------------- */
.btn { border-radius: 11px; font-weight: 650; transition: transform .04s ease, box-shadow .15s, background .15s; box-shadow: var(--p-shadow-sm); }
.btn:hover { box-shadow: 0 4px 14px -4px rgba(37,99,235,.5); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #eef2ff; color: var(--p-brand-d); box-shadow: none; }
.btn.ghost:hover { background: #e0e7ff; box-shadow: none; }
.btn.subtle { background: #fff; color: #334155; border: 1px solid var(--p-line-strong); box-shadow: none; }
.btn.subtle:hover { background: #f8fafc; }
.btn.ok { background: #16a34a; } .btn.ok:hover { background: #15803d; }
.btn.danger { background: #fff; color: #b91c1c; border: 1px solid #fecaca; box-shadow: none; }
.btn.danger:hover { background: #fef2f2; }
.btn.violet { background: var(--p-violet); } .btn.violet:hover { background: #6d28d9; }
.btn[disabled] { opacity: .55; cursor: not-allowed; background: #e2e8f0; color: #64748b; box-shadow: none; }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- pills / badges ------------------------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 11px; border-radius: 999px; line-height: 1.6; white-space: nowrap; }
.pill .pdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.draft   { background: #eef1f6; color: #475569; }
.pill.submitted { background: #dbeafe; color: #1d4ed8; }
.pill.approved  { background: #dcfce7; color: #15803d; }
.pill.dry       { background: #ede9fe; color: #6d28d9; }
.pill.ok   { background: #dcfce7; color: #15803d; }
.pill.warn { background: #fef3c7; color: #b45309; }
.pill.bad  { background: #fee2e2; color: #b91c1c; }
.pill.muted{ background: #eef1f6; color: #475569; }
.pill.info { background: #cffafe; color: #0e7490; }
.pill.issued_internal { background: #dbeafe; color: #1d4ed8; }
.pill.cleared_internal { background: #dcfce7; color: #15803d; }
.pill.bounced_internal { background: #fee2e2; color: #b91c1c; }
.pill.printed_disabled { background: #eef1f6; color: #475569; }

/* ---- key/value grid ------------------------------------------------------ */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 9px 16px; font-size: 14px; }
.kv .k { color: var(--p-muted); font-weight: 600; }
.kv .v { color: var(--p-ink); }
.kv code { background: #0f172a; color: #cbd5e1; padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.muted-text { color: var(--p-faint); }

/* ---- tables -------------------------------------------------------------- */
.ptable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.ptable th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--p-muted);
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--p-line); font-weight: 700; background: #fafbfe; }
.ptable td { padding: 11px 12px; border-bottom: 1px solid var(--p-line); vertical-align: middle; }
.ptable tbody tr:last-child td { border-bottom: none; }
.ptable .num { text-align: right; font-variant-numeric: tabular-nums; }
.ptable.rows tbody tr { transition: background .12s; }
.ptable.rows tbody tr.link { cursor: pointer; }
.ptable.rows tbody tr.link:hover { background: #f5f8ff; }
.ptable .strong { font-weight: 750; }
.t-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--p-line); }

.sub2 { color: var(--p-muted); font-size: 11.5px; margin-top: 3px; line-height: 1.35; }

/* ---- stat cards ---------------------------------------------------------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 18px; }
.statcard { background: var(--p-card); border: 1px solid var(--p-line); border-radius: 14px; padding: 14px 18px; box-shadow: var(--p-shadow-sm); }
.statcard .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--p-muted); }
.statcard .v { font-size: 26px; font-weight: 800; margin-top: 5px; letter-spacing: -.5px; }
.statcard.accent { background: linear-gradient(135deg,#0f172a,#1e293b); border-color: #1e293b; }
.statcard.accent .k { color: #94a3b8; } .statcard.accent .v { color: #fff; }

/* ---- chain stepper ------------------------------------------------------- */
.chain { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.chain .step { flex: 1 1 0; min-width: 150px; position: relative; padding: 14px 16px; background: #fff;
  border: 1px solid var(--p-line); border-radius: 14px; margin-right: 26px; box-shadow: var(--p-shadow-sm); }
.chain .step:last-child { margin-right: 0; }
.chain .step::after { content: "→"; position: absolute; right: -22px; top: 50%; transform: translateY(-50%);
  color: var(--p-faint); font-size: 18px; font-weight: 700; }
.chain .step:last-child::after { display: none; }
.chain .step .lbl { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--p-muted); }
.chain .step .val { font-size: 14px; font-weight: 700; margin-top: 5px; }
.chain .step .meta { font-size: 11.5px; color: var(--p-muted); margin-top: 4px; }
.chain .step.done { border-color: #bbf7d0; background: linear-gradient(180deg,#f0fdf4,#fff); }
.chain .step.active { border-color: #bfdbfe; box-shadow: 0 0 0 3px rgba(191,219,254,.4); }
.chain .step.empty { border-style: dashed; background: #fbfcfe; }
.chain .step.empty .val { color: var(--p-faint); font-weight: 600; }

/* ---- forms --------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px 18px; }
.field label { font-size: 11.5px; font-weight: 700; color: var(--p-muted); display: block; margin-bottom: 5px; letter-spacing: .2px; }
.field .req { color: #dc2626; }
.field input, .field select, .field textarea {
  width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--p-line-strong);
  border-radius: 10px; font-size: 14px; background: #fff; color: var(--p-ink); font-family: inherit; transition: border-color .12s, box-shadow .12s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--p-brand); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.field textarea { min-height: 64px; resize: vertical; }
.field input:disabled { background: #f1f5f9; color: #94a3b8; }

.combo { position: relative; }
.combo-panel { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: #fff;
  border: 1px solid var(--p-line-strong); border-radius: 12px; max-height: 260px; overflow: auto;
  box-shadow: 0 16px 40px -12px rgba(15,23,42,.3); display: none; padding: 4px; }
.combo-panel div { padding: 9px 11px; font-size: 13px; cursor: pointer; border-radius: 8px; }
.combo-panel div:hover { background: #eff4ff; }

/* line-item editor */
.lines-pro { width: 100%; border-collapse: separate; border-spacing: 0; }
.lines-pro th { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--p-muted); padding: 6px 6px; text-align: left; font-weight: 700; }
.lines-pro td { padding: 4px 5px; vertical-align: top; }
.lines-pro input, .lines-pro select { width: 100%; box-sizing: border-box; font-size: 12.5px; padding: 7px 8px; border: 1px solid var(--p-line-strong); border-radius: 8px; }
.lines-pro input:focus, .lines-pro select:focus { outline: none; border-color: var(--p-brand); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.lines-pro .num input { text-align: right; }
.lines-pro input.ro { background: #f1f5f9; color: #475569; font-weight: 600; }
.lines-pro .rowno { color: var(--p-faint); font-weight: 700; font-size: 12px; padding-top: 14px; }
.lines-pro .del { padding: 6px 9px; }

.totbox { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 12px; }
.totbox .t { border: 1px solid var(--p-line); border-radius: 12px; padding: 11px 15px; background: #fafbfe; }
.totbox .t .k { color: var(--p-muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.totbox .t .v { font-size: 19px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.totbox .t.grand { background: linear-gradient(135deg,#0f172a,#1e293b); border-color: #1e293b; }
.totbox .t.grand .k { color: #94a3b8; } .totbox .t.grand .v { color: #fff; }

/* ---- dry-run plan -------------------------------------------------------- */
.dry-badge { display: flex; align-items: center; gap: 10px; background: linear-gradient(100deg,#0b1220,#1e293b);
  color: #fff; border: 1px solid #2b3a52; border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 13px; letter-spacing: .4px; margin-bottom: 14px; }
.dry-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 0 4px rgba(56,189,248,.18); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--p-line); border-radius: 12px; padding: 12px 14px; background: #fff; box-shadow: var(--p-shadow-sm); }
.plan-card .k { color: var(--p-muted); font-size: 11px; font-weight: 700; }
.plan-card .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
.plan-card .note { font-size: 10px; color: var(--p-faint); margin-top: 3px; line-height: 1.3; }
.plan-card.zero { background: #fbfcfe; border-style: dashed; }
.plan-card.zero .v { color: var(--p-faint); }

pre.json { background: #0b1220; color: #d7e0ee; padding: 16px; border-radius: 12px; font-size: 11.5px;
  overflow: auto; max-height: 440px; line-height: 1.55; border: 1px solid #1e293b; }
pre.json .tk { color: #7dd3fc; }

.ban { border-radius: 12px; padding: 12px 16px; font-weight: 700; margin: 4px 0 12px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.ban.ok  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.ban.bad { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.ban.warn{ background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
ul.msgs { margin: 6px 0 0; padding: 0; list-style: none; }
ul.msgs li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--p-line); }
ul.msgs li:last-child { border-bottom: none; }

/* ---- timeline / audit ---------------------------------------------------- */
.audit { display: flex; flex-direction: column; gap: 0; }
.audit .it { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 0 0 14px; position: relative; }
.audit .it::before { content: ""; position: absolute; left: 10px; top: 18px; bottom: -4px; width: 2px; background: var(--p-line); }
.audit .it:last-child::before { display: none; }
.audit .it .node { width: 20px; height: 20px; border-radius: 50%; background: #eff4ff; border: 2px solid var(--p-brand); margin-top: 1px; z-index: 1; }
.audit .it .act { font-weight: 700; font-size: 13.5px; }
.audit .it .when { color: var(--p-muted); font-size: 11.5px; }
.audit .it .det { color: var(--p-faint); font-size: 11.5px; margin-top: 2px; word-break: break-word; }

/* ---- provisional number box --------------------------------------------- */
.numbox { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(120deg,#f8fafc,#eef4ff); border-color: #dbe6fb; }
.numlabel { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--p-muted); }
.numval { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-top: 3px; font-variant-numeric: tabular-nums; color: var(--p-ink); }
.numright { text-align: right; }
.numsub { font-size: 11.5px; color: var(--p-muted); margin-top: 6px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; padding: 4px 11px; border-radius: 999px; letter-spacing: .2px; }
.badge.prov { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge.conflict { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge.final { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.pill.conflict { background: #fee2e2; color: #b91c1c; }
.pill.received, .pill.paid, .pill.allocated, .pill.cleared_internal { background: #dcfce7; color: #15803d; }
.pill.partially_received, .pill.partially_paid, .pill.under_review { background: #fef3c7; color: #b45309; }
.pill.rejected, .pill.bounced_internal, .pill.cancelled, .pill.cancelled_internal { background: #fee2e2; color: #b91c1c; }
.pill.revision_required { background: #ffedd5; color: #c2410c; }
.conflict-banner { display:flex; align-items:center; gap:10px; background:#fef2f2; color:#b91c1c;
  border:1px solid #fecaca; border-radius:12px; padding:11px 16px; font-size:13px; font-weight:700; margin-bottom:16px; }
.badge.mode-legacy { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.badge.mode-modern { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.badge.origin { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }

.legacy-banner { display: flex; align-items: center; gap: 10px; background: linear-gradient(100deg,#fffbeb,#fef9c3);
  color: #854d0e; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 16px; font-size: 13px; margin-bottom: 16px; }

/* ---- section title + form line table ------------------------------------ */
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--p-muted); margin: 0 0 14px; }
table.lines { width: 100%; border-collapse: separate; border-spacing: 0; }
table.lines th { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--p-muted); padding: 6px 6px; text-align: left; font-weight: 700; }
table.lines td { padding: 4px 5px; vertical-align: top; }
table.lines input, table.lines select { width: 100%; box-sizing: border-box; font-size: 12.5px; padding: 7px 8px; border: 1px solid var(--p-line-strong); border-radius: 8px; }
table.lines input:focus, table.lines select:focus { outline: none; border-color: var(--p-brand); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
table.lines .num input { text-align: right; }
table.lines input.ro { background: #f1f5f9; color: #475569; font-weight: 600; }
table.lines .rowno { color: var(--p-faint); font-weight: 700; font-size: 12px; padding-top: 14px; }
.lineadd { margin-top: 10px; }
/* the unit is chosen first and the quantity is then read in it */
table.lines select.unit { font-weight: 700; }
table.lines select.unit:invalid, table.lines select.unit option[value=""] { color: var(--p-muted); }
table.lines .qty-cell { position: relative; }
table.lines .qty-cell .qty { padding-right: 42px; }
table.lines .qty-cell .qty-uom { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px; color: var(--p-muted); pointer-events: none; }

/* A file input that is out of sight but still a working control. Safari on a
   Mac will not open the file dialog for display:none, so it is clipped
   instead of removed. */
.file-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; }

/* ---- where a document stands (register, header, popup) -------------------- */
.stage-tag { display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.35; }
.stage-tag.t-wait { background: #fff7ed; color: #9a5b0b; border: 1px solid #fed7aa; }
.stage-tag.t-act { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.stage-tag.t-ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.stage-tag.t-dead { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

/* ---- the popup that says a purchase was created -------------------------- */
.saved-pop { text-align: center; padding: 4px 2px 2px; }
.saved-tick { width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: linear-gradient(135deg,#16a34a,#15803d);
  box-shadow: 0 8px 24px rgba(21,128,61,.28); }
.saved-tick svg { width: 32px; height: 32px; }
.saved-h { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.saved-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px;
  font-weight: 800; margin: 6px 0 14px; letter-spacing: .5px; }
.saved-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px;
  text-align: left; }
.saved-grid > div { border: 1px solid var(--p-line); border-radius: 10px; padding: 9px 12px; background: #fafbfe; }
.saved-grid span { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; color: var(--p-muted); }
.saved-grid b { font-size: 13.5px; }
.saved-next { margin-top: 14px; text-align: left; border: 1px dashed var(--p-line-strong);
  border-radius: 10px; padding: 11px 13px; background: #f8fafc; font-size: 12.5px; }
.saved-next b { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--p-muted); margin-bottom: 3px; }
.saved-mirror { margin-top: 10px; font-size: 12px; color: var(--p-muted); }

/* ---- document preview (what the LPO will look like) ---------------------- */
.docprev { font-size: 13px; color: #0f172a; }
.docprev .dp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding-bottom: 14px; border-bottom: 2px solid #0f172a; }
.docprev .dp-co { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.docprev .dp-sub { color: var(--p-muted); font-size: 11.5px; margin-top: 3px; }
.docprev .dp-title { text-align: right; }
.docprev .dp-title .t { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.docprev .dp-stamp { display: inline-block; margin-top: 6px; font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px; color: #b45309; background: #fffbeb;
  border: 1px dashed #f59e0b; border-radius: 6px; padding: 3px 8px; }
.docprev .dp-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.docprev .dp-box { border: 1px solid var(--p-line); border-radius: 10px; padding: 11px 13px; background: #fafbfe; }
.docprev .dp-box .lbl { font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; color: var(--p-muted); }
.docprev .dp-box .who { font-weight: 700; font-size: 14px; margin-top: 4px; }
.docprev .mut { color: var(--p-muted); font-size: 11.5px; margin-top: 3px; }
.docprev .dp-miss { color: #b91c1c; font-weight: 700; font-size: 12.5px; }
.docprev .dp-kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin-bottom: 16px; }
.docprev .dp-kv .k { color: var(--p-muted); font-size: 11.5px; font-weight: 700; }
.docprev .dp-kv .v { font-size: 12.5px; font-weight: 600; }
.docprev table.dp-lines { width: 100%; border-collapse: collapse; }
.docprev table.dp-lines th { background: #0f172a; color: #fff; font-size: 10px; text-transform: uppercase;
  letter-spacing: .5px; padding: 8px 9px; text-align: left; font-weight: 700; }
.docprev table.dp-lines td { padding: 8px 9px; border-bottom: 1px solid var(--p-line); font-size: 12.5px; }
.docprev table.dp-lines .r { text-align: right; font-variant-numeric: tabular-nums; }
.docprev table.dp-lines .b { font-weight: 700; }
.docprev table.dp-lines .mut { color: var(--p-faint); }
.docprev .dp-none { border: 1px dashed var(--p-line-strong); border-radius: 10px; padding: 16px;
  text-align: center; color: var(--p-muted); font-size: 12.5px; }
.docprev .dp-foot { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; margin-top: 16px; }
.docprev .dp-words { color: var(--p-muted); font-size: 11.5px; max-width: 340px; }
.docprev .dp-tot { min-width: 290px; }
.docprev .dp-tot > div { display: flex; justify-content: space-between; gap: 20px; padding: 6px 12px;
  font-size: 12.5px; }
.docprev .dp-tot > div span { color: var(--p-muted); font-weight: 600; }
.docprev .dp-tot > div b { font-variant-numeric: tabular-nums; }
.docprev .dp-tot .grand { background: #0f172a; color: #fff; border-radius: 8px; padding: 10px 12px;
  font-size: 15px; margin-top: 4px; }
.docprev .dp-tot .grand span { color: #94a3b8; }
.docprev .dp-tot .dp-adv { border-top: 1px dashed var(--p-line); }

/* ---- totals (form) ------------------------------------------------------- */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 12px; margin-top: 16px; }
.tcard { border: 1px solid var(--p-line); border-radius: 12px; padding: 11px 15px; background: #fafbfe; }
.tcard .k { color: var(--p-muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.tcard .v { font-size: 20px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tcard.dark { background: linear-gradient(135deg,#0f172a,#1e293b); border-color: #1e293b; }
.tcard.dark .k { color: #94a3b8; } .tcard.dark .v { color: #fff; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.muted-note { font-size: 11.5px; color: var(--p-muted); margin-top: 10px; }

/* ---- detail tabs --------------------------------------------------------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--p-line); margin-bottom: 18px; }
.tabs button { background: none; border: none; padding: 11px 16px; font-size: 13.5px; font-weight: 700; color: var(--p-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; transition: color .12s, background .12s; }
.tabs button:hover { color: var(--p-ink); background: #f5f8ff; }
.tabs button.active { color: var(--p-brand-d); border-bottom-color: var(--p-brand); }
.tabpane { display: none; }
.tabpane.active { display: block; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--p-muted); }
.empty-state .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }
.toolbar { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 18px 0; }
.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; margin-top: 12px; display: none; }
.linkish { color: var(--p-brand-d); font-weight: 700; cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* Smart auto-confirmation UI */
.head-actions { display: flex; gap: 8px; align-items: center; }
.btn.primary { background: var(--p-brand-d, #1d4ed8); color: #fff; border-color: var(--p-brand-d, #1d4ed8); }
.btn.primary:hover { filter: brightness(1.06); }
.head-actions .ghost { background: #fff; }
.auto-result { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; background: #f1f5f9; border: 1px solid #e2e8f0; }
.auto-result.good { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.auto-result.bad { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.auto-result .ok-t { color: #047857; }
.hgrid.sub-grid { margin-top: 10px; grid-template-columns: repeat(5, 1fr); }
.hgrid.sub-grid .htile { padding: 8px 10px; }
.hgrid.sub-grid .hv { font-size: 20px; }
label.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--p-muted); white-space: nowrap; cursor: pointer; padding-top: 4px; }
label.chk input { width: auto; }
.pill.prov { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* Mapping Intelligence v2 — batch review + blockers */
.batch-note { padding: 10px 14px; font-size: 12.5px; color: var(--p-muted); background: #f8fafc; border-bottom: 1px solid #eef2f7; font-weight: 600; }
.topblk { margin-top: 10px; padding: 8px 12px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.topblk-h { font-weight: 800; color: #9a3412; }
.blkchip { background: #fff; border: 1px solid #fde0c2; border-radius: 999px; padding: 3px 10px; font-weight: 600; }
.actcell { white-space: nowrap; }

/* ===== Stage C Preflight ===== */
.pcard-h { font-weight: 800; padding: 12px 14px; border-bottom: 1px solid #eef2f7; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px; padding: 12px 14px; }
.gate-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 6px 10px; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 8px; }
.g-on { color: #b91c1c; } .g-off { color: #15803d; }
.chain-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid #eef2f7; border-radius: 10px; margin: 6px 0; cursor: pointer; flex-wrap: wrap; }
.chain-row:hover { background: #f8fafc; }
.chain-row.ready { border-color: #bbf7d0; background: #f0fdf4; }
.chain-group-label { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--p-muted); margin: 12px 0 4px; }
.ne-row { display: flex; gap: 8px; align-items: center; padding: 6px 4px; font-size: 12.5px; border-bottom: 1px dashed #eef2f7; }
.pad { padding: 10px 4px; }
.conflict-warn { margin: 10px 14px; padding: 10px 14px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; font-weight: 700; font-size: 13px; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; padding: 0 14px; }
.pf-cell { border: 1px solid #eef2f7; border-radius: 10px; padding: 10px; }
.pf-l { font-size: 11.5px; font-weight: 800; text-transform: uppercase; color: var(--p-muted); margin-bottom: 6px; }
.pf-sub { font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.stg { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-size: 12.5px; flex-wrap: wrap; }
.pf-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pf-tbl th, .pf-tbl td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #eef2f7; }
.pf-tbl .num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
ul.mini { margin: 4px 0 0; padding-left: 16px; font-size: 12px; }
.plan-badge { margin: 12px 14px 4px; font-weight: 700; font-size: 12px; color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 6px 10px; }
.plan-list { margin: 4px 28px 12px; font-size: 12.5px; }
.plan-list li { padding: 3px 0; }
