:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #152033;
  --muted: #5b677a;
  --line: #e3e8ef;
  --brand: #0f6e6a;
  --brand-dark: #0a5451;
  --brand-soft: #e7f5f4;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.08);
  --radius: 14px;
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9f3f1 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8eefc 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #7ec7c3;
  box-shadow: 0 0 0 3px rgba(15, 110, 106, 0.12);
}
textarea { resize: vertical; }

.app { max-width: 1180px; margin: 0 auto; padding: 18px 16px 48px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 10px;
  z-index: 20;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), #148f89);
  color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 8px 18px rgba(15,110,106,.28);
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn, .btn-sm, .file-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
}
.btn-sm { padding: 7px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost:hover, .btn-sm:hover { background: var(--brand-soft); border-color: #b7dedc; }
.file-btn { display: inline-flex; align-items: center; }

.layout { display: grid; gap: 14px; margin-top: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel-hd {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-hd h2 { margin: 0; font-size: 16px; }
.chip {
  font-size: 12px; color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px; padding: 4px 10px;
}

.grid-3, .grid-2 { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input, .inline > select { flex: 1; }

.role-toggle { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; background: #eef2f7; border-radius: 999px; padding: 3px; }
.seg-btn {
  border: 0; background: transparent; border-radius: 999px;
  padding: 7px 12px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.seg-btn.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(21,32,51,.08); }

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.party-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.party-hd {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.items-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.items-table th, .items-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}
.items-table th {
  background: #f7fafc;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.items-table tbody tr:last-child td { border-bottom: 0; }
.items-table input, .items-table select {
  padding: 8px 10px;
  border-radius: 8px;
}
.col-idx { width: 42px; text-align: center !important; color: var(--muted); }
.col-num { width: 110px; }
.col-unit { width: 88px; }
.col-act { width: 54px; }
.amount-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  padding-right: 12px !important;
  white-space: nowrap;
}
.btn-icon {
  border: 0; background: transparent; color: var(--danger);
  font-size: 18px; line-height: 1; padding: 4px 8px;
}
.btn-icon:hover { background: #fee2e2; border-radius: 8px; }

.totals {
  margin-top: 14px;
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-end; justify-content: space-between;
}
.totals-note { color: var(--muted); font-size: 12px; }
.totals-box {
  margin: 0; min-width: 240px;
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.totals-box > div {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 4px 0; font-size: 14px;
}
.totals-box dt { margin: 0; color: var(--muted); }
.totals-box dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.totals-box .grand {
  border-top: 1px dashed #b7dedc;
  margin-top: 6px; padding-top: 8px;
  font-size: 16px;
}
.totals-box .grand dd { color: var(--brand-dark); }

.preview-shell { margin-top: 16px; }
.preview-toolbar {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.preview-toolbar .print-tip {
  flex: 1 1 220px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.po-print-brand {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #222;
  margin: 0 0 10px;
  text-align: left;
}
.po-sheet {
  background: #fff;
  width: min(210mm, 100%);
  margin: 0 auto;
  padding: 16mm 14mm;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #111;
}
.po-sheet h1 {
  margin: 0 0 4px;
  text-align: center;
  font-size: 22px;
  letter-spacing: .2em;
}
.po-sheet .doc-sub {
  text-align: center;
  color: #666;
  font-size: 12px;
  margin-bottom: 18px;
}
.po-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-size: 13px;
  margin-bottom: 14px;
}
.po-meta div { display: flex; gap: 6px; }
.po-meta .k { color: #666; min-width: 4.5em; }
.po-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.po-party {
  border: 1px solid #d7dde7;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
}
.po-party h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--brand-dark);
  border-bottom: 1px solid #e8edf4;
  padding-bottom: 4px;
}
.po-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.po-table th, .po-table td {
  border: 1px solid #cfd6e2;
  padding: 7px 8px;
  vertical-align: top;
}
.po-table th { background: #f3f6fa; font-weight: 700; }
.po-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.po-table .center { text-align: center; }
.po-summary {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.po-summary table { border-collapse: collapse; font-size: 13px; min-width: 220px; }
.po-summary td { padding: 4px 0 4px 18px; }
.po-summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.po-summary .grand td { font-size: 15px; padding-top: 8px; border-top: 1px solid #cfd6e2; }
.po-remarks {
  border: 1px dashed #cfd6e2;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 28px;
  white-space: pre-wrap;
}
.po-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  font-size: 13px;
  margin-top: 8px;
}
.po-sign .line { margin-top: 36px; border-top: 1px solid #999; padding-top: 6px; color: #555; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center;
  padding: 16px; z-index: 50;
}
.modal {
  width: min(640px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  overflow: hidden;
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-bd { padding: 14px 16px 18px; max-height: 70vh; overflow: auto; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.drafts-shell { margin-top: 8px; }
.drafts-page-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.drafts-page-hd h2 { margin: 0; font-size: 18px; }
.drafts-list { display: grid; gap: 14px; }
.draft-card { padding: 14px 16px 16px; }
.draft-card-hd {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.draft-card-title { min-width: 0; }
.draft-title-row {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline;
}
.draft-card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.draft-card .actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.draft-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin: 10px 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.draft-card-meta span {
  background: #f4f7fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.draft-items-wrap { margin-top: 4px; }
.draft-items-table { font-size: 13px; }
.draft-img-empty, .draft-img-dot {
  display: grid; place-items: center; color: #9aa7b8; font-size: 10px;
}
.draft-img-dot { color: var(--brand-dark); font-weight: 700; }
.empty-drafts {
  text-align: center; color: var(--muted);
  padding: 40px 12px; border: 1px dashed var(--line); border-radius: 12px;
  background: #fff;
}
@media (max-width: 900px) {
  .draft-card-hd { grid-template-columns: auto 1fr; }
  .draft-card-hd .thumb-mini { display: none; }
  .draft-card-hd .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #152033; color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: 13px; z-index: 80;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.hidden { display: none !important; }

@media (max-width: 900px) {
  .grid-3, .grid-2, .parties, .po-parties, .po-meta, .po-sign { grid-template-columns: 1fr; }
  .topbar { position: static; }
  .brand h1 { font-size: 16px; }
}

@page {
  size: A4;
  margin: 8mm;
}

@media print {
  html, body {
    background: #fff !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .no-print,
  .topbar,
  .preview-toolbar,
  .toast,
  .modal-backdrop,
  #editorView,
  #draftsView,
  #statsView { display: none !important; }
  .app {
    max-width: none;
    padding: 0;
    margin: 0;
    min-height: 0;
  }
  .preview-shell { margin: 0; padding: 0; }
  .po-sheet {
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .po-print-brand {
    display: block !important;
    margin: 0 0 4px;
    font-size: 12px;
  }
  .po-sheet h1 { font-size: 18px; margin: 0 0 2px; letter-spacing: .15em; }
  .po-sheet .doc-sub { margin-bottom: 8px; font-size: 11px; }
  .po-meta { margin-bottom: 8px; gap: 4px 12px; font-size: 12px; }
  .po-parties { margin-bottom: 8px; gap: 8px; }
  .po-party { padding: 6px 8px; font-size: 11.5px; line-height: 1.4; }
  .po-party h3 { margin: 0 0 4px; font-size: 12px; }
  .po-table { font-size: 11.5px; margin-bottom: 8px; }
  .po-table th, .po-table td { padding: 4px 6px; }
  .po-table .po-thumb,
  .po-table .po-thumb-empty { width: 32px; height: 32px; }
  .po-summary { margin-bottom: 8px; }
  .po-summary table { font-size: 12px; }
  .po-summary .grand td { font-size: 13px; padding-top: 6px; }
  .po-remarks { padding: 6px 8px; margin-bottom: 12px; font-size: 11.5px; }
  .po-sign { gap: 16px; margin-top: 0; font-size: 12px; }
  .po-sign .line { margin-top: 20px; }
  /* Keep two columns in print even if viewport is narrow */
  .po-parties, .po-sign, .po-meta { grid-template-columns: 1fr 1fr !important; }
  .item-thumb, .po-thumb {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Compact sheet while capturing PDF (mirrors print density) */
.po-sheet.pdf-capture {
  width: 190mm;
  max-width: 190mm;
  padding: 8mm 8mm;
  box-shadow: none;
  border-radius: 0;
}
.po-sheet.pdf-capture .po-print-brand { margin-bottom: 4px; font-size: 12px; }
.po-sheet.pdf-capture h1 { font-size: 18px; letter-spacing: .15em; }
.po-sheet.pdf-capture .doc-sub { margin-bottom: 8px; font-size: 11px; }
.po-sheet.pdf-capture .po-meta { margin-bottom: 8px; gap: 4px 12px; font-size: 12px; }
.po-sheet.pdf-capture .po-parties { margin-bottom: 8px; gap: 8px; }
.po-sheet.pdf-capture .po-party { padding: 6px 8px; font-size: 11.5px; line-height: 1.4; }
.po-sheet.pdf-capture .po-table { font-size: 11.5px; margin-bottom: 8px; }
.po-sheet.pdf-capture .po-table th,
.po-sheet.pdf-capture .po-table td { padding: 4px 6px; }
.po-sheet.pdf-capture .po-thumb,
.po-sheet.pdf-capture .po-thumb-empty { width: 32px; height: 32px; }
.po-sheet.pdf-capture .po-summary { margin-bottom: 8px; }
.po-sheet.pdf-capture .po-remarks { padding: 6px 8px; margin-bottom: 12px; }
.po-sheet.pdf-capture .po-sign .line { margin-top: 20px; }

/* product image cells */
.col-img { width: 88px; }
.items-table { min-width: 880px; }
.img-cell { vertical-align: middle !important; }
.img-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.item-thumb, .item-thumb-empty {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f7fafc;
  display: block;
}
.item-thumb-empty {
  display: grid;
  place-items: center;
  color: #9aa7b8;
  font-size: 11px;
  user-select: none;
}
.img-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.img-actions .btn-sm { padding: 4px 7px; font-size: 11px; }
.items-hint { margin: 10px 0 0; }
#storageHint { color: var(--warn); font-weight: 600; }
#storageHint.ok { color: var(--muted); font-weight: 500; }

.po-table .po-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #d7dde7;
  display: block;
  margin: 0 auto;
}
.po-table .po-thumb-empty {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 1px dashed #d7dde7;
  border-radius: 4px;
  background: #fafbfd;
}
.po-name-cell {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.po-name-cell .po-thumb,
.po-name-cell .po-thumb-empty { flex-shrink: 0; }
.po-name-text { flex: 1; min-width: 0; word-break: break-word; }



.modal-wide { width: min(760px, 100%); }
.drafts-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 0;
  padding: 10px 14px;
}
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.chk input { width: auto; }
.draft-total {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--brand-dark);
}
.draft-card .thumb-mini {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); background: #f7fafc;
}
.row-active { outline: 2px solid rgba(15,110,106,.35); outline-offset: -2px; background: #f3fbfa; }


.product-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  align-items: start;
}
.products-list { display: grid; gap: 8px; max-height: 58vh; overflow: auto; }
.product-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}
.product-card .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.product-card .actions { display: flex; flex-direction: column; gap: 6px; }
.panel-like {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.product-form h3 { margin: 0 0 10px; font-size: 15px; }
.prod-img-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pick-card { cursor: pointer; }
.pick-card:hover { border-color: #7ec7c3; box-shadow: 0 0 0 3px rgba(15,110,106,.1); }
.row-pick-btn { white-space: nowrap; }

@media (max-width: 900px) {
  .product-layout { grid-template-columns: 1fr; }
}

/* —— Login / multi-user —— */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f766e 0%, #134e4a 45%, #0f172a 100%);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card .brand h1 { font-size: 1.15rem; margin: 0; }
.login-card .brand p { margin: 2px 0 0; color: #64748b; font-size: 12px; }
.user-chip {
  font-size: 12px;
  color: #0f766e;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  align-self: center;
}


/* —— Purchase stats —— */
.stats-filters { margin-bottom: 12px; }
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stats-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stats-card .label { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.stats-card .value {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-dark);
  word-break: break-word;
}
.stats-card .sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.stats-breakdown {
  display: grid;
  gap: 10px;
  margin-bottom: 4px;
}
.stats-break-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stats-break-card h3 { margin: 0 0 8px; font-size: 14px; }
.stats-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stats-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: var(--brand-soft);
  border: 1px solid #b7dedc;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}
.stats-pill strong { font-variant-numeric: tabular-nums; color: var(--brand-dark); }
.stats-table-wrap { overflow: auto; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}
.stats-table th, .stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.stats-table th {
  background: #f7fafc;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-table .group-row td {
  background: linear-gradient(180deg, #eef8f7, #f7fbfb);
  font-weight: 700;
  border-bottom: 1px solid #cfe8e6;
}
.stats-table .group-total { color: var(--brand-dark); }
.stats-table tr.po-row:hover { background: #f8fbfb; }
.stats-lines {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}
.stats-lines li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 2px 0;
}
.stats-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

/* payables / payment status */
.pay-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.pay-unpaid { color: #9a3412; background: #ffedd5; }
.pay-partial { color: #854d0e; background: #fef9c3; }
.pay-paid { color: #166534; background: #dcfce7; }
.payables-table td, .payables-table th { vertical-align: middle; }
.pay-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}
.pay-meta .k { display:block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.pay-balance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.pay-bal-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.pay-bal-card .label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.pay-bal-card .value { margin: 6px 0 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .pay-meta, .pay-balance { grid-template-columns: 1fr; }
}
