:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e7ee;
  --line-strong: #cdd5df;
  --text: #17212e;
  --muted: #5d6b7c;
  --faint: #8c98a7;
  --brand: #173b5f;
  --brand-2: #22507d;
  --accent: #f2b33d;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --ok: #1e7d4f;
  --ok-bg: #e5f5ec;
  --warn: #9a6200;
  --warn-bg: #fff4dc;
  --info: #1f5fa8;
  --info-bg: #e7f0fb;

  --cash: #1e7d4f;   --cash-bg: #e8f5ee;
  --pos: #6b3fb5;    --pos-bg: #f1ebfa;
  --bank_transfer: #1f5fa8; --bank_transfer-bg: #e7f0fb;
  --cheque: #b26a00; --cheque-bg: #fdf1dd;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 4px 14px rgba(16, 30, 54, .06);
  --shadow-lg: 0 10px 40px rgba(16, 30, 54, .22);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 58px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: #0f2b47; display: grid; place-items: center; }
.brand small { display: block; font-weight: 500; font-size: 11px; opacity: .7; letter-spacing: .6px; text-transform: uppercase; }
.nav { display: flex; gap: 2px; overflow-x: auto; }
.nav a { color: #dce6f2; text-decoration: none; padding: 8px 12px; border-radius: 7px; white-space: nowrap; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.user-chip button { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.user-chip button:hover { background: rgba(255,255,255,.18); }
.role-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; background: var(--accent); color: #3a2800; padding: 2px 7px; border-radius: 99px; font-weight: 700; }
main { max-width: 1440px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.2px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong);
  background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px;
  text-decoration: none; color: var(--text); white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: #dd9c22; color: #2d1f00; }
.btn-accent:hover { background: #f5c15e; border-color: #dd9c22; }
.btn-danger { color: var(--danger); border-color: #e9b4ad; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #18663f; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); border-color: transparent; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); min-width: 0; }
.req { color: var(--danger); font-weight: 700; }

/* searchable supplier dropdown */
.combo { position: relative; }
.combo-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.combo-btn > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-caret { color: var(--muted); flex: none; }
.combo-panel { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 8px; }
.combo-list { max-height: 240px; overflow-y: auto; margin: 6px 0; }
.combo-opt { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.combo-opt:hover, .combo-opt.on { background: var(--info-bg); }
.combo-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.combo-add { width: 100%; border: 1px dashed var(--brand-2); background: var(--surface-2); color: var(--brand); font-weight: 700; padding: 8px; border-radius: 6px; cursor: pointer; letter-spacing: .3px; }
.combo-add:hover { background: var(--info-bg); }
.field .hint { font-weight: 400; color: var(--faint); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 8px 10px; color: var(--text);
  font-size: 14px; font-weight: 400; min-height: 38px;
}
.input:focus { outline: 2px solid #9cc1ea; outline-offset: 0; border-color: var(--brand-2); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
.input.err, .err .input { border-color: var(--danger); background: #fff8f7; }
.err-msg { color: var(--danger); font-size: 12px; font-weight: 500; }
textarea.input { min-height: 60px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }

.total-hero {
  background: linear-gradient(120deg, #173b5f, #22507d 70%); color: #fff; border-radius: 14px; padding: 22px 26px;
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); margin-bottom: 20px;
}
.total-hero .label { text-transform: uppercase; letter-spacing: 1.2px; font-size: 13px; opacity: .8; font-weight: 600; }
.total-hero .amount { font-size: 40px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0; }
.total-hero .sub { opacity: .85; font-size: 14px; }
.total-hero .mini { display: flex; gap: 28px; flex-wrap: wrap; }
.total-hero .mini div b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.total-hero .mini div span { font-size: 12px; opacity: .75; text-transform: uppercase; letter-spacing: .6px; }
.total-hero .seg { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); }
.total-hero .seg button { color: #dce6f2; border-right-color: rgba(255,255,255,.15); }
.total-hero .seg button.on { background: #fff; color: var(--brand); }

.sections-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.section-card { border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.section-card .sc-head { padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--m-bg); }
.section-card .sc-icon { width: 44px; height: 44px; border-radius: 11px; background: var(--m); color: #fff; display: grid; place-items: center; flex: none; }
.section-card .sc-title { font-weight: 750; font-size: 17px; color: var(--m); letter-spacing: .3px; text-transform: uppercase; }
.section-card .sc-body { padding: 18px 20px; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 14px; }
.section-card .big { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.4px; line-height: 1.15; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.stat-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.section-card .sc-foot { padding: 12px 20px 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #f1d9a6; }
.pill.info { background: var(--info-bg); color: var(--info); border-color: #c4d8f1; }
.pill.danger { background: var(--danger-bg); color: var(--danger); border-color: #f2c2bc; }

.m-cash { --m: var(--cash); --m-bg: var(--cash-bg); }
.m-pos { --m: var(--pos); --m-bg: var(--pos-bg); }
.m-bank_transfer { --m: var(--bank_transfer); --m-bg: var(--bank_transfer-bg); }
.m-cheque { --m: var(--cheque); --m-bg: var(--cheque-bg); }

.section-banner { border-radius: 14px; padding: 18px 22px; background: var(--m-bg); border: 1px solid var(--line); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section-banner h1 { margin: 0; font-size: 24px; color: var(--m); text-transform: uppercase; letter-spacing: .4px; }
.section-banner .sc-icon { width: 50px; height: 50px; border-radius: 12px; background: var(--m); color: #fff; display: grid; place-items: center; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .stat-val { font-size: 22px; margin-top: 2px; }

/* ---------- filters & tables ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 220px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 650; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.tbl th.num { text-align: right; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: #f6f9fc; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line-strong); }
.tbl .desc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .ref { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.result-bar { display: flex; gap: 16px; align-items: center; padding: 10px 14px; font-size: 14px; color: var(--muted); flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.result-bar b { color: var(--text); font-variant-numeric: tabular-nums; }

.status { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.st-draft { background: #eef1f4; color: #5d6b7c; }
.st-submitted { background: var(--info-bg); color: var(--info); }
.st-approved { background: #e6f3fb; color: #11709f; }
.st-paid { background: var(--ok-bg); color: var(--ok); }
.st-rejected { background: var(--danger-bg); color: var(--danger); }
.st-cancelled { background: #f1f1f1; color: #777; text-decoration: line-through; }
.method-tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--m-bg); color: var(--m); white-space: nowrap; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 1300px; display: flex; flex-direction: column; }
.modal.sm { max-width: 480px; }
.modal.md { max-width: 760px; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 14px 14px; position: sticky; bottom: 0; }
.x-btn { margin-left: auto; border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.x-btn:hover { background: var(--surface-2); }

.form-section { margin-bottom: 22px; }
.form-section > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.form-section > h3 .stepno { background: var(--brand); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

/* items editor */
.items { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.items-head, .item-row { display: grid; gap: 8px; align-items: start; grid-template-columns: 26px minmax(140px, 2.4fr) 150px 64px 64px 100px 150px 90px 80px 100px 32px; padding: 8px 10px; }
.items.with-disc .items-head, .items.with-disc .item-row { grid-template-columns: 26px minmax(140px, 2.4fr) 150px 64px 64px 100px 150px 150px 90px 80px 100px 32px; }
.items:not(.with-disc) .f-disc { display: none; }
.item-row .err-msg:empty { display: none; }
.items-head { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); }
.item-row { border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-row .lineno { color: var(--faint); font-weight: 700; padding-top: 9px; text-align: center; }
.item-row .calc { padding-top: 9px; font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.item-row .calc.final { font-weight: 700; }
.item-row .disc { display: grid; grid-template-columns: 92px 1fr; gap: 6px; }
.item-row .rm { border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 20px; padding: 4px; border-radius: 6px; margin-top: 3px; }
.item-row .rm:hover { color: var(--danger); background: var(--danger-bg); }
.item-row .err-msg { grid-column: 2 / -1; }
.mlabel { display: none; }
.items-foot { padding: 10px; background: var(--surface-2); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.totals-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-width: 300px; background: var(--surface-2); }
.totals-box .tr { display: flex; justify-content: space-between; gap: 20px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals-box .tr.grand { border-top: 2px solid var(--line-strong); margin-top: 6px; padding-top: 10px; font-size: 20px; font-weight: 800; color: var(--brand); }
.below-items { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; margin-top: 14px; }
.disc-box { flex: 1; min-width: 280px; border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; }
.disc-box p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--brand-2); background: var(--info-bg); }
.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file-row { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; flex-wrap: wrap; }
.file-row .fname { flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.file-row select { width: 220px; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { width: 150px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-decoration: none; color: var(--text); background: #fff; display: flex; flex-direction: column; }
.thumb .ti { height: 100px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-weight: 700; }
.thumb .ti img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tn { padding: 6px 8px; font-size: 12px; }
.thumb .tn b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert-err { background: var(--danger-bg); color: #8c2318; border: 1px solid #f2c2bc; }
.alert-warn { background: var(--warn-bg); color: #6d4600; border: 1px solid #f1d9a6; }
.alert-info { background: var(--info-bg); color: #164a85; border: 1px solid #c4d8f1; }

.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.kv > div > span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kv div b { font-weight: 600; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); position: absolute; left: -6px; top: 13px; }
.timeline .when { color: var(--faint); font-size: 12px; }
.timeline pre { margin: 4px 0 0; font-size: 12px; background: var(--surface-2); padding: 6px 8px; border-radius: 6px; white-space: pre-wrap; max-height: 180px; overflow: auto; }
details summary { cursor: pointer; color: var(--brand-2); font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--m, var(--brand-2)); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #173b5f 0%, #0f2b47 100%); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 12px 0 2px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #17212e; color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 14px; max-width: 380px; animation: tin .2s ease-out; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.report-head { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1260px) {
  .items-head { display: none; }
  .items.with-disc .item-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .item-row { grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 12px; gap: 8px 10px; position: relative; }
  .item-row > * { grid-column: span 2; }
  .item-row .lineno { grid-column: span 6; text-align: left; padding: 0; }
  .item-row .f-desc, .item-row .f-cat { grid-column: span 6; }
  .item-row .f-disc { grid-column: span 6; }
  .item-row .rm { position: absolute; top: 4px; right: 6px; }
  .item-row .calc { text-align: left; padding-top: 0; }
  .mlabel { display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .5px; margin-bottom: 2px; }
  .items:not(.with-disc) .f-disc { display: none; }
}
@media (max-width: 900px) {
  .sections-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 8px; }
  .nav { order: 3; width: 100%; }
  .user-chip { margin-left: auto; }
  .user-chip .uname { display: none; }
}
@media (max-width: 560px) {
  main { padding: 16px 12px 50px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .section-card .sc-body { grid-template-columns: 1fr 1fr; }
  .section-card .sc-body > :first-child { grid-column: span 2; }
  .total-hero .amount { font-size: 32px; }
  .item-row > * { grid-column: span 3; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .totals-box { min-width: 0; width: 100%; }
  .modal-foot [data-footnote], .modal-foot [data-again] { display: none; }
  .modal-foot { gap: 8px; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .spacer { display: none; }
}

/* ---------- print (PDF export) ---------- */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .no-print, #toast-root, .filters, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .card, .stat { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .report-head { display: block; margin-bottom: 12px; border-bottom: 2px solid #173b5f; padding-bottom: 8px; }
  .report-head h1 { margin: 0; font-size: 18px; }
  .tbl th { position: static; }
  .tbl td, .tbl th { padding: 4px 6px; }
  .tbl .desc { max-width: none; white-space: normal; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .print-modal-only main { display: none; }
  .print-modal-only .modal-back { position: static; background: none; padding: 0; overflow: visible; }
  .print-modal-only .modal { box-shadow: none; max-width: none; }
  .print-modal-only .modal-foot, .print-modal-only .x-btn { display: none; }
}
