:root {
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --green: #047857;
  --red: #b91c1c;
  --amber-bg: #fffbeb;
  --calc-bg: #eff6ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Suwannaphum', 'Khmer OS System', serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
:lang(km), .kh { font-family: 'Suwannaphum', 'Khmer OS System', serif; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff; padding: 10px 20px; position: sticky; top: 0; z-index: 50;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar h1 span { font-weight: 400; opacity: .85; font-size: 13px; margin-left: 8px; }
.brand-sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.actions { display: flex; align-items: center; gap: 10px; }
.btn {
  border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn.primary { background: #fff; color: var(--blue-dark); }
.btn.primary:hover { background: #e0e7ff; }
.btn.ghost { background: rgba(255,255,255,.15); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.28); }
.btn.small { padding: 4px 10px; font-size: 12px; background: var(--blue); color: #fff; border-radius: 6px; }
.btn.small.outline { background: #fff; color: var(--blue-dark); border: 1px solid var(--blue); }
.btn.small.outline:hover { background: var(--calc-bg); }
.btn.small.red { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn.small.red:hover { background: #fef2f2; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.danger { background: transparent; color: var(--red); font-size: 15px; padding: 2px 6px; }
.save-status { font-size: 12px; opacity: .9; }
.save-status.dirty { color: #fde68a; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 8px 16px 0; background: var(--card);
  border-bottom: 2px solid var(--border-light); overflow-x: auto;
  position: sticky; top: 52px; z-index: 40;
}
.tabs button {
  border: none; background: transparent; padding: 10px 14px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--blue); }
.tabs button.active { color: var(--blue-dark); border-bottom-color: var(--blue); }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.loading { text-align: center; padding: 60px; color: var(--muted); }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--card); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.card h2 {
  margin: 0 0 14px; font-size: 15px; color: var(--blue-dark);
  border-bottom: 2px solid var(--border-light); padding-bottom: 8px;
}
.grid { display: grid; gap: 12px 18px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.field input, .field select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 7px; font-family: inherit; font-size: 13.5px; background: #fff;
}
.field input:focus, td input:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border-light); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.stat .lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.stat .val { font-size: 19px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat.good .val { color: var(--green); }
.stat.bad .val { color: var(--red); }
.stat.blue .val { color: var(--blue-dark); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.sheet { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.sheet th, table.sheet td { border: 1px solid var(--border); padding: 5px 7px; }
table.sheet thead th {
  background: var(--blue-dark); color: #fff; font-weight: 600; font-size: 11.5px;
  text-align: center; vertical-align: middle;
}
table.sheet thead tr.sub th { background: var(--blue); font-weight: 500; }
table.sheet td.num, table.sheet th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td.ctr { text-align: center; }
table.sheet td.calc { background: var(--calc-bg); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
table.sheet tbody tr:nth-child(even) td:not(.calc) { background: #f8fafc; }
table.sheet tbody tr:hover td { background: #fef9c3 !important; }
table.sheet tfoot td { background: var(--amber-bg); font-weight: 700; border-top: 2px solid var(--blue-dark); }
table.sheet td input {
  width: 100%; min-width: 52px; border: none; background: transparent; padding: 3px 2px;
  font-family: inherit; font-size: 12.5px; border-radius: 4px;
}
table.sheet td input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td input:hover { background: #fff7d6; }
.tbl-actions { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 4px; }
.row-count { font-size: 12px; color: var(--muted); }

/* ---------- Official form (TRS01 / P101 / letter) ---------- */
.form-paper {
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  max-width: 900px; margin: 0 auto 18px; padding: 36px 44px;
  box-shadow: 0 2px 10px rgba(15,23,42,.08);
  font-family: 'Suwannaphum', 'Khmer OS System', serif;
  line-height: 1.65;
}
.form-paper .en { font-family: 'Suwannaphum', serif; }
.fhead { display: flex; justify-content: space-between; font-size: 12.5px; text-align: center; }
.fhead .col b { display: block; }
.fhead .moto { font-size: 13px; font-weight: 700; }
.ftitle { text-align: center; margin: 14px 0; }
.ftitle .t1 { font-size: 17px; font-weight: 700; color: var(--blue-dark); }
.ftitle .t2 { font-size: 13px; color: var(--muted); }
.fnote { text-align: right; font-size: 12px; font-weight: 600; }
.boxes { display: inline-flex; gap: 3px; vertical-align: middle; }
.boxes span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 26px; border: 1.5px solid var(--text); font-weight: 700;
  font-size: 13px; font-family: 'Suwannaphum', serif; background: #fff;
}
.boxes span.dash { border: none; width: 10px; }
.frow { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; margin: 7px 0; font-size: 13px; }
.frow .lbl { font-weight: 600; }
.frow .fill {
  flex: 1; min-width: 120px; border-bottom: 1px dotted var(--muted);
  padding: 0 6px; font-weight: 600; color: var(--blue-dark);
}
table.form-tbl { border-collapse: collapse; width: 100%; font-size: 13px; margin: 10px 0; }
table.form-tbl th, table.form-tbl td { border: 1.4px solid var(--text); padding: 6px 9px; }
table.form-tbl th { background: #f1f5f9; text-align: center; }
table.form-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.form-tbl td.calc { background: var(--calc-bg); font-weight: 700; text-align: right; }
table.form-tbl tr.total td { background: var(--amber-bg); font-weight: 700; }
.fsig { display: flex; justify-content: space-between; margin-top: 30px; font-size: 12.5px; text-align: center; }
.fsig .col { width: 45%; }
.fsig .line { margin-top: 56px; border-top: 1px dotted var(--text); }
.fdecl { font-size: 12px; color: #334155; margin: 12px 0; text-align: justify; }

/* letter */
.letter { font-size: 13.5px; }
.letter p { margin: 9px 0; }
.letter h3 { font-size: 14px; margin: 16px 0 6px; }

.badge { display: inline-block; background: var(--calc-bg); color: var(--blue-dark); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .no-print, .tbl-actions, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .card, .form-paper { box-shadow: none; border: none; margin: 0; padding: 10px; }
  table.sheet thead th { background: #ddd !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  td input { border: none !important; }
}

/* ---------- TRS 01 official header (scoped, additive) ---------- */
.trs-head { display: flex; align-items: flex-start; gap: 14px; }
.trs-col { flex: 1; text-align: center; }
.trs-center { flex: 0 0 190px; }
.trs-logo { width: 175px; height: auto; }
.trs-kh { font-size: 13.5px; font-weight: 700; color: #1f6e63; line-height: 1.9; }
.trs-en { font-size: 11px; font-weight: 700; color: #1f6e63; letter-spacing: .4px; }
.trs-rule { border-bottom: 2.5px solid #e07b2f; padding-bottom: 4px; margin-bottom: 4px; }
.trs-sublbl { font-size: 11px; font-weight: 700; line-height: 1.3; text-align: left; }
.trs-sublbl i, .trs-lbl i, .trs-mbox i { font-style: normal; font-weight: 400; font-size: 9.5px; color: #444; }
.trs-box-fill {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid #333; background: #fff; min-width: 110px; min-height: 32px;
  padding: 2px 12px; font-size: 13px; font-weight: 600;
  box-shadow: 2px 2px 0 rgba(0,0,0,.18);
}
.trs-branch { display: flex; align-items: center; gap: 10px; justify-content: flex-start; margin-top: 8px; text-align: left; }
.trs-branch .trs-box-fill { flex: 1; }
.trs-form-panel { background: #dcdcdc; padding: 8px 10px 10px; margin-top: 8px; box-shadow: 2px 2px 0 rgba(0,0,0,.18); }
.trs-form-no { text-align: center; font-size: 12px; font-weight: 700; padding-bottom: 6px; }
.trs-form-month { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11.5px; font-weight: 700; }
.trs-form-month .trs-mbox { display: inline-flex; flex-direction: column; align-items: flex-end; }
.trs-form-month .trs-box-fill { min-width: 74px; min-height: 28px; }
.trs-form-month .trs-mbox:last-child .trs-box-fill { min-width: 60px; }
.trs-title-row { display: flex; align-items: center; gap: 20px; margin: 14px 0 10px; }
.trs-title { flex: 1; text-align: center; margin-left: 190px; }
.trs-title .t1 { font-size: 15.5px; font-weight: 700; color: #1d3a6e; }
.trs-title .t1.sm { font-size: 12.5px; margin-top: 2px; }
.trs-title .t2 { font-size: 11px; font-weight: 700; color: #1d3a6e; letter-spacing: .5px; }
.trs-barcode {
  flex: 0 0 250px; border: 1.5px solid #333; min-height: 46px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #777;
}
.trs-period-lbls {
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 11px; font-weight: 700;
  border-top: 2.5px solid #e07b2f; padding: 6px 0 4px; margin-top: 6px;
}
.trs-en-inline { font-weight: 400; }
.trs-period-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: nowrap; margin-bottom: 10px; }
.trs-period-row .boxes { gap: 2px; }
.trs-period-row .trs-sublbl { font-size: 9.5px; }
.trs-period-row .trs-sublbl i { font-size: 8.5px; }
.trs-period-row .boxes span { width: 17px; height: 22px; font-size: 10.5px; }
.trs-info { display: flex; flex-direction: column; gap: 7px; }
.trs-row { display: flex; align-items: stretch; gap: 8px; }
.trs-lbl { flex: 0 0 auto; font-size: 11px; font-weight: 700; line-height: 1.3; align-self: center; }
.trs-lbl i { font-style: normal; }
.trs-val {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #333; background: #fff; min-height: 33px;
  padding: 3px 10px; font-size: 13px; font-weight: 600;
  box-shadow: 2px 2px 0 rgba(0,0,0,.18); text-align: center;
}
.trs-val.grow { flex: 1; }
@media print { .trs-form-panel { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- SaaS shell (additive) ---------- */
.user-chip { font-size: 12px; background: rgba(255,255,255,.15); padding: 5px 12px; border-radius: 99px; white-space: nowrap; }
.sub-banner {
  background: #fef2f2; color: var(--red); border-bottom: 1px solid #fecaca;
  padding: 9px 20px; font-size: 13px; font-weight: 700; text-align: center;
}
.abadge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.abadge.ok { background: #d1fae5; color: var(--green); }
.abadge.bad { background: #fee2e2; color: var(--red); }
.abadge.mut { background: var(--border-light); color: var(--muted); }
.modgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px; }
.modchk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: #f8fafc;
  border: 1px solid var(--border-light); border-radius: 7px; padding: 7px 10px; cursor: pointer; }
.modtag { background: var(--calc-bg); color: var(--blue-dark); font-size: 11px; padding: 1px 7px; border-radius: 5px; }
a.btn { text-decoration: none; display: inline-block; }
.np-sel { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 12.5px; background: #fff; }
#npYear { width: 90px; }
[hidden] { display: none !important; }
/* combined print: each tab starts on a new page */
.print-section { break-inside: auto; }
@media print {
  .print-section { page-break-after: always; }
  .print-section:last-child { page-break-after: auto; }
  .print-section .stats, .print-section .hint, .print-section .row-count,
  .print-section .sum-grid, .print-section .sum-section-title { display: none !important; }
}
/* combined print: day books rotate to A4 landscape, forms stay portrait */
@page { size: A4 portrait; }
@page landscape-sheet { size: A4 landscape; }
@media print {
  .print-landscape { page: landscape-sheet; }
}
@media print {
  /* day books: hide the delete-button column left empty in print */
  .print-landscape table.sheet th:last-child, .print-landscape table.sheet td:last-child { display: none; }
}
@media print {
  /* day books: balanced column widths so dates, invoices and Khmer text don't clip */
  .print-landscape table.sheet td:nth-child(2), .print-landscape table.sheet th:nth-child(2) { min-width: 82px; }
  .print-landscape table.sheet td:nth-child(3), .print-landscape table.sheet th:nth-child(3) { min-width: 95px; }
  .print-landscape table.sheet td:nth-child(5), .print-landscape table.sheet th:nth-child(5) { min-width: 150px; }
}

/* ---------- TRS 01: official-style tax calculation table + signature boxes ---------- */
.trs-calc-title { background: #d9c49c; border: 1px solid #b59663; padding: 4px 10px; font-weight: 700; font-size: 13px; margin-top: 14px; }
.trs-turnover { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; }
.trs-turnover .trs-A { font-size: 26px; font-weight: 700; font-family: 'Suwannaphum', serif; }
.trs-turnover .lbl { font-size: 11.5px; font-weight: 700; }
.trs-turnover .trs-K { border: 1.5px solid #333; background: #e7d9bd; padding: 2px 10px; font-weight: 700; box-shadow: 2px 2px 0 rgba(0,0,0,.15); }
.trs-turnover .trs-kval { flex: 1; max-width: 280px; border: 1.5px solid #333; padding: 3px 12px; text-align: right; font-weight: 700; box-shadow: 2px 2px 0 rgba(0,0,0,.15); }
table.trs-calc th, table.trs-calc td { border-color: #b45309; }
table.trs-calc th { background: #faf0dd; position: relative; padding-bottom: 18px; }
table.trs-calc .trs-abcd { position: absolute; left: 0; right: 0; bottom: 0; background: #f3dfba; border-top: 1px solid #b45309; font-weight: 700; }
table.trs-calc .trs-bcode { float: left; font-weight: 700; background: #f3dfba; border: 1px solid #b45309; font-size: 10.5px; padding: 0 5px; border-radius: 2px; }
table.trs-calc .trs-rate { background: #fdf6ea; font-weight: 700; }
table.trs-calc tr.total td { background: #f3dfba; }
.trs-en-sm { font-size: 10.5px; color: #555; }
.trs-decl-h { margin: 12px 0 2px; font-size: 13px; }
.trs-sign { display: flex; gap: 26px; margin-top: 12px; }
.trs-sigbox { flex: 1; border: 1.6px solid #b45309; padding: 8px 12px; }
.trs-sigbox .t { font-size: 11px; font-weight: 700; border-bottom: 1px solid #e3cba0; padding-bottom: 4px; margin-bottom: 8px; }
.trs-sigbox .r { display: flex; align-items: flex-start; gap: 10px; margin: 7px 0; }
.trs-sigarea { flex: 1; border: 1.4px solid #333; min-height: 64px; background: #fff; }
.trs-namearea { flex: 1; border: 1.4px solid #333; min-height: 26px; background: #fff; }
.trs-sigbox .boxes span { width: 20px; height: 24px; }

/* combined print: TRS 01 compact — whole form fits one A4 portrait page */
@media print {
  .print-trs01 .form-paper { padding: 8px 6px; line-height: 1.3; }
  .print-trs01 .trs-logo { width: 110px; }
  .print-trs01 .trs-kh { font-size: 11px; line-height: 1.55; }
  .print-trs01 .trs-en { font-size: 9px; }
  .print-trs01 .trs-box-fill { min-height: 22px; min-width: 84px; font-size: 10.5px; padding: 1px 8px; }
  .print-trs01 .trs-form-panel { padding: 4px 8px 6px; margin-top: 4px; }
  .print-trs01 .trs-form-no { font-size: 10px; padding-bottom: 3px; }
  .print-trs01 .trs-form-month { font-size: 9.5px; }
  .print-trs01 .trs-form-month .trs-box-fill { min-width: 56px; min-height: 20px; }
  .print-trs01 .trs-branch { margin-top: 4px; }
  .print-trs01 .trs-title-row { margin: 6px 0 4px; }
  .print-trs01 .trs-title .t1 { font-size: 12.5px; }
  .print-trs01 .trs-title .t1.sm { font-size: 10.5px; }
  .print-trs01 .trs-title .t2 { font-size: 9px; }
  .print-trs01 .trs-barcode { flex-basis: 190px; min-height: 32px; font-size: 8px; }
  .print-trs01 .trs-period-lbls { font-size: 8.5px; padding: 3px 0 2px; }
  .print-trs01 .trs-period-row { margin-bottom: 4px; }
  .print-trs01 .trs-period-row .boxes span { width: 14px; height: 17px; font-size: 8.5px; }
  .print-trs01 .trs-period-row .trs-sublbl { font-size: 8px; }
  .print-trs01 .trs-period-row .trs-sublbl i { font-size: 7px; }
  .print-trs01 .trs-info { gap: 3px; }
  .print-trs01 .trs-lbl { font-size: 8.5px; }
  .print-trs01 .trs-lbl i { font-size: 7.5px; }
  .print-trs01 .trs-val { min-height: 20px; font-size: 10.5px; padding: 1px 6px; }
  .print-trs01 .trs-calc-title { margin-top: 6px; font-size: 10.5px; padding: 2px 8px; }
  .print-trs01 .trs-turnover { margin: 5px 0 3px; }
  .print-trs01 .trs-turnover .trs-A { font-size: 18px; }
  .print-trs01 .trs-turnover .lbl { font-size: 9px; }
  .print-trs01 .trs-turnover .trs-kval, .print-trs01 .trs-turnover .trs-K { font-size: 10.5px; padding: 1px 8px; }
  .print-trs01 table.form-tbl { font-size: 9.5px; margin: 4px 0; }
  .print-trs01 table.form-tbl th, .print-trs01 table.form-tbl td { padding: 2px 6px; }
  .print-trs01 table.trs-calc th { padding-bottom: 14px; }
  .print-trs01 .trs-en-sm { font-size: 8px; }
  .print-trs01 .trs-bcode { font-size: 8.5px; }
  .print-trs01 .trs-decl-h { margin: 6px 0 1px; font-size: 10px; }
  .print-trs01 .fdecl { font-size: 7.8px; margin: 3px 0; line-height: 1.45; }
  .print-trs01 .trs-sign { margin-top: 6px; gap: 16px; }
  .print-trs01 .trs-sigbox { padding: 5px 8px; }
  .print-trs01 .trs-sigbox .t { font-size: 8.5px; margin-bottom: 4px; }
  .print-trs01 .trs-sigbox .r { margin: 4px 0; gap: 6px; }
  .print-trs01 .trs-sigbox .boxes span { width: 14px; height: 17px; font-size: 8.5px; }
  .print-trs01 .trs-sigarea { min-height: 42px; }
  .print-trs01 .trs-namearea { min-height: 20px; }
  .print-trs01 .trs-sublbl { font-size: 8px; }
  .print-trs01 .trs-sublbl i { font-size: 7px; }
}

/* combined print: client letter compact — fits one A4 portrait page */
@media print {
  .print-letter .form-paper { padding: 14px 24px; line-height: 1.35; }
  .print-letter .letter { font-size: 11.5px; }
  .print-letter .letter p { margin: 5px 0; }
  .print-letter .letter h3 { font-size: 12px; margin: 8px 0 3px; }
  .print-letter table.form-tbl { font-size: 11px; margin: 6px 0; }
  .print-letter table.form-tbl th, .print-letter table.form-tbl td { padding: 3px 8px; }
  .print-letter .fsig { margin-top: 16px; font-size: 10.5px; }
  .print-letter .fsig .line { margin-top: 34px; }
}

/* draggable tabs */
.tabs button { cursor: grab; }
.tabs button.dragging { opacity: .45; cursor: grabbing; background: var(--calc-bg); border-radius: 6px 6px 0 0; }

/* print tab-selector modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 14px; font-size: 15px; color: var(--blue-dark); }
.modal-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.modal-actions { display: flex; align-items: center; gap: 8px; }
@media print { .modal-overlay { display: none !important; } }
.modal-sub { font-size: 12px; font-weight: 700; color: var(--blue-dark); margin: 4px 0 6px; }
.modsize { color: var(--muted); font-size: 11px; margin-left: auto; }
.modchk { justify-content: flex-start; }
/* rasterized attachment pages */
.print-attach { text-align: center; }
.print-attach img { width: 100%; height: auto; display: block; }
@media print {
  /* fit each rasterized page within the printable area (no overflow to a blank page) */
  .print-attach img { width: auto; height: auto; max-width: 100%; max-height: 252mm; margin: 0 auto; }
  .print-landscape.print-attach img { max-height: 180mm; }
}
.modal-hint { font-size: 11.5px; color: var(--muted); margin: -6px 0 12px; }
.modchk[draggable] { cursor: grab; }
.modchk.dragging { opacity: .45; background: var(--calc-bg); }
.draghandle { color: var(--muted); cursor: grab; user-select: none; font-size: 13px; }

/* ---------- summary cards (bottom of Selling/Buying) ---------- */
.sum-section-title { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--blue-dark); }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 16px; }
.sum-card {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  background: #fff; border: 1px solid var(--border-light); border-radius: 14px;
  box-shadow: 0 4px 14px rgba(15,23,42,.06); position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.sum-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.12); }
.sum-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent, #1d4ed8); }
.sum-card.span2 { grid-column: span 2; }
.sum-ic {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--accent-soft, #eff6ff);
}
.sum-body { min-width: 0; }
.sum-lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.sum-val { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.sum-val.sm { font-size: 16px; }
.sum-card.teal   { --accent: #0d9488; --accent-soft: #ccfbf1; }
.sum-card.violet { --accent: #7c3aed; --accent-soft: #ede9fe; }
.sum-card.blue   { --accent: #1d4ed8; --accent-soft: #dbeafe; }
.sum-card.amber  { --accent: #d97706; --accent-soft: #fef3c7; }
.sum-card.red    { --accent: #dc2626; --accent-soft: #fee2e2; }
.sum-card.green  { --accent: #059669; --accent-soft: #d1fae5; }
.sum-card.slate  { --accent: #475569; --accent-soft: #eef2f7; }
.sum-card.red .sum-val { color: var(--red); }
.prevsal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--border-light);
  background: #f8fafc; border-radius: 8px; font-family: inherit; font-size: 13px; cursor: pointer; }
.prevsal-row:hover { background: var(--calc-bg); border-color: var(--blue); }
