:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel2: #1b1b1e;
  --line: #2a2a2e;
  --text: #ecebe7;
  --muted: #8f8c85;
  --gold: #d4a94f;
  --gold2: #f1d58a;
  --gold-dim: #d4a94f22;
  --green: #5fc48a;
  --red: #ef6b5e;
  --blue: #6aa8ff;
  --amber: #e9b44c;
  --radius: 10px;
  --serif: Arial, Helvetica, sans-serif;
  --sans: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--gold2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font: 700 26px/1.2 var(--serif); color: #fff; }
h2 { font-size: 15px; margin-bottom: 12px; letter-spacing: .2px; }
h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: 14px 16px; margin: 0; }

/* ---------- layout ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: 236px; background: #070708; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30; overflow-y: auto; }
.logo { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.logo:hover { text-decoration: none; }
.logo img { width: 42px; height: 42px; object-fit: contain; }
.logo b { display: block; font: 700 15px/1.2 var(--serif); color: var(--gold2); }
.logo small { color: var(--muted); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; }
.side nav { padding: 8px 8px 16px; flex: 1; }
.nav-h { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: #5f5d58; padding: 14px 10px 4px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: #c9c6bf; font-size: 13.5px; }
.side nav a i { font-style: normal; width: 18px; text-align: center; color: var(--muted); }
.side nav a:hover { background: var(--panel2); text-decoration: none; }
.side nav a.on { background: var(--gold-dim); color: var(--gold2); }
.side nav a.on i { color: var(--gold); }
.side-foot { padding: 12px; border-top: 1px solid var(--line); }
.main { margin-left: 236px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px 24px; background: #0b0b0cee; backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar #menu { display: none; }
#gsearch { width: min(460px, 100%); }
#gres { position: absolute; top: 52px; left: 24px; width: min(560px, calc(100% - 48px)); }
.gres { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: 0 12px 40px #000a; }
.gres a, .gres span { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); cursor: pointer; }
.gres a:hover { background: var(--gold-dim); text-decoration: none; }
#view { padding: 22px 24px 60px; max-width: 1500px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.left { justify-content: flex-start; margin-top: 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.grid2 > .card { margin-bottom: 0; min-width: 0; overflow-x: auto; }
section.card:not(.flush) > .tbl { min-width: 100%; }
#view > section.card { overflow-x: auto; }
.grid2 + .card, .grid2 + section { margin-top: 16px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(auto-fill, minmax(200px, 260px)); }
.kpi { background: linear-gradient(160deg, #18181b, #111113); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi b { display: block; font: 700 21px/1.3 var(--serif); color: #fff; margin: 4px 0 2px; }
.kpi small { color: var(--muted); font-size: 11.5px; }

/* ---------- controls ---------- */
input, select, textarea { background: #0e0e10; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font: inherit; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
input[readonly] { color: var(--muted); }
textarea { resize: vertical; width: 100%; }
input[type=date] { color-scheme: dark; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: 400 13px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #444; text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1a1406; border-color: var(--gold); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #ef6b5e55; background: transparent; }
.btn.danger:hover { background: #ef6b5e18; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.file { position: relative; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--panel2); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { flex: 0 1 auto; }
.ctrange { display: inline-flex; gap: 4px; }
.ctrange input { width: 82px; }
.filters .mm-filter { width: 120px; flex: 0 0 auto; border-color: var(--gold); }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.form-grid label.chk { flex-direction: row; align-items: center; }
.form-grid .span2 { grid-column: span 2; }
.with-btn { display: flex; gap: 6px; }
.with-btn select { flex: 1; }
.head-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.logo-row { display: flex; gap: 8px; align-items: center; }
.logo-row img { width: 44px; height: 44px; object-fit: contain; background: #000; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.tbl th.r { text-align: right; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #202023; vertical-align: middle; white-space: nowrap; }
.paper-tbl td, .tbl td.wrap { white-space: normal; }
.tbl tbody tr:hover td { background: #19191c; }
.tbl.click tbody tr { cursor: pointer; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; background: #111113; }
.tbl.sticky thead th { position: sticky; top: 0; z-index: 1; }
.tbl.sticky td { white-space: nowrap; }
.card.flush .tbl-wrap { max-height: calc(100vh - 250px); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--gold2); }
.sumbar { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 0 4px 12px; color: var(--muted); }
.sumbar b { color: var(--text); }

.tbl.lines td { padding: 5px 5px; }
.tbl.lines input { width: 100%; min-width: 80px; padding: 6px 7px; }
.tbl.lines input.w-s { min-width: 60px; width: 70px; }
.tbl.lines input.w-m { min-width: 88px; width: 100px; }
.tbl.lines input.r { text-align: right; }
.tbl.lines input[data-k=gemType] { min-width: 170px; }
.tbl.lines input[data-k=stockId] { min-width: 110px; }
.tbl.lines tr.over input[data-f=ct] { border-color: var(--red); }
.tbl.lines tr.topup td { background: #5fc48a0a; }
.lines-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lines-head h2 { margin: 0; }
.scan { width: 230px; }

.totals-grid { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.tsum { display: flex; gap: 28px; flex-wrap: wrap; }
.tsum span { display: block; color: var(--muted); font-size: 12px; }
.tsum b { font: 700 19px var(--serif); }
.tcalc { min-width: 300px; }
.trow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.trow input { width: 130px; text-align: right; }
.trow.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-size: 16px; }
.trow.grand b { color: var(--gold2); font: 700 21px var(--serif); }

/* ---------- pills & badges ---------- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.pill.green { background: #5fc48a1f; color: var(--green); }
.pill.blue { background: #6aa8ff1f; color: var(--blue); }
.pill.amber { background: #e9b44c22; color: var(--amber); }
.pill.red { background: #ef6b5e22; color: var(--red); }
.pill.grey { background: #ffffff12; color: var(--muted); }
.badge { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .4px; padding: 2px 7px; border-radius: 5px; background: #ffffff10; color: var(--muted); white-space: nowrap; }
.badge.b-PUR, .badge.b-OPN { color: var(--green); background: #5fc48a18; }
.badge.b-MI { color: #b99cff; background: #b99cff18; }
.badge.b-MO { color: var(--blue); background: #6aa8ff18; }
.badge.b-INV { color: var(--gold2); background: var(--gold-dim); }
.badge.b-PRR, .badge.b-MIR { color: #f0a46b; background: #f0a46b18; }
.sel-bar { position: sticky; top: 58px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--gold); border-radius: var(--radius); background: #1c1708; }
.renum-bar, .merge-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; }
.merge-bar { justify-content: flex-start; }
.merge-bar label.inline { color: var(--text); font-size: 13.5px; }
.tbl th.chk, .tbl td.chk { width: 34px; text-align: center; cursor: default; }
.tbl tr.picked td { background: #d4a94f14; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--gold2); border-color: var(--gold); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.related { padding: 10px 16px; }

.empty { text-align: center; padding: 40px 16px; }
.empty img { width: 70px; opacity: .8; }
.empty h3 { font: 700 19px var(--serif); margin: 8px 0 4px; }
.empty p { margin: 0 0 14px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: #000b; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(560px, 100%); box-shadow: 0 30px 80px #000; }
.modal.wide { width: min(1040px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font: 700 18px var(--serif); }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-body p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.picker { max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.picker tbody tr { cursor: pointer; }
.picker-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.picker-bar input[type=search] { flex: 1; }

.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.buckets div { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.buckets div.hl { border-color: var(--gold); background: var(--gold-dim); }
.buckets span, .detail-grid span { display: block; color: var(--muted); font-size: 11.5px; }
.buckets b { font: 700 18px var(--serif); }
.buckets small { display: block; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.detail-grid b { font-weight: 500; }
.note { background: var(--panel2); padding: 10px 12px; border-radius: 8px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #222225; border: 1px solid var(--line); border-left: 3px solid var(--green); color: var(--text); padding: 10px 14px; border-radius: 8px; box-shadow: 0 10px 30px #0008; max-width: 380px; transition: opacity .4s, transform .4s; }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- sync status ---------- */
.sync { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync:hover { text-decoration: none; border-color: #444; }
.sync::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync.s-synced::before { background: var(--green); }
.sync.s-saving::before { background: var(--gold); animation: pulse 1s infinite; }
.sync.s-offline::before { background: var(--amber); }
.sync.s-offline { color: var(--amber); }
.sync.s-error::before { background: var(--red); }
.sync.s-error { color: var(--red); }
.sync.stale { color: var(--gold2); border-color: var(--gold); cursor: pointer; }
@keyframes pulse { 50% { opacity: .3; } }
.who { font-size: 12px; color: var(--text); margin-bottom: 8px; word-break: break-all; }
.who small { display: block; color: var(--muted); text-transform: capitalize; }
.team-add { margin-top: 14px; align-items: end; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at top, #2a2210 0%, var(--bg) 60%); }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 30px 80px #000c; }
.auth-card img { width: 110px; margin: 0 auto 4px; }
.auth-card h1 { color: var(--gold2); }
.auth-card p { margin: 0; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; text-align: left; font-size: 12px; color: var(--muted); }
.auth-card .btn { margin-top: 6px; padding: 10px; }
.err { color: var(--red); min-height: 18px; }
.ok-msg { color: var(--green); background: #5fc48a14; border-radius: 8px; padding: 8px 10px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.seg { display: flex; background: #0e0e10; border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); padding: 7px; border-radius: 7px; font: 400 13px var(--sans); cursor: pointer; }
.seg button.on { background: var(--gold-dim); color: var(--gold2); }
label.radio { flex-direction: row !important; align-items: flex-start; gap: 8px !important; color: var(--text) !important; font-size: 13px !important; }
label.radio small { display: block; color: var(--muted); }

/* ---------- printable document (same layout for every document type) ---------- */
.paper { background: #fff; color: #111; max-width: 860px; box-shadow: 0 10px 40px #0008; }
.paper a { color: inherit; }
.pp { padding: 36px 40px 40px; font-size: 13px; line-height: 1.4; color: #111; }
.pp b { font-weight: 700; }
.pp p { margin: 0; }
.pp-head { display: grid; grid-template-columns: 1fr 340px; border: 1.5px solid #9a9a9a; }
.pp-us { display: flex; gap: 34px; align-items: center; padding: 18px 24px; border-right: 1.5px solid #9a9a9a; }
.pp-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.pp-logo img { width: 112px; height: auto; object-fit: contain; }
.pp-logo img.mono { filter: brightness(0); }
.pp-logo span { font: 300 27px/1 var(--sans); letter-spacing: 6px; padding-left: 6px; color: #111; }
.pp-us h1 { font: 700 21px/1.2 var(--sans); color: #111; margin: 0 0 6px; }
.pp-us p { font-size: 15px; line-height: 1.45; }
.pp-meta { display: flex; flex-direction: column; }
.pp-title { font: 700 23px var(--sans); letter-spacing: 2px; text-align: right; padding: 18px 24px 16px; border-bottom: 1.5px solid #9a9a9a; }
.pp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; padding: 12px 24px 16px; text-align: right; }
.pp-grid span { font-size: 13px; font-weight: 700; color: #444; padding-top: 4px; }
.pp-grid b { font-weight: 400; font-size: 16px; padding: 8px 0 14px; }
.pp-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin: 30px 0 30px; }
.pp-lbl { color: #555; font-size: 15px; }
.pp-party h2 { font: 700 24px/1.2 var(--sans); margin: 2px 0 6px; color: #111; }
.pp-party p { font-size: 15px; line-height: 1.3; margin-bottom: 3px !important; }
.pp-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pp-tbl th { text-align: left; font-weight: 700; font-size: 12.5px; padding: 6px 6px 8px; border-bottom: 2px solid #9a9a9a; white-space: nowrap; }
.pp-tbl td { padding: 6px; border-bottom: 1px solid #e3e3e3; vertical-align: top; white-space: nowrap; }
.pp-tbl td.wrap { white-space: normal; }
.pp-tbl .r { text-align: right; }
.pp-tbl .pp-total td { font-weight: 700; }
.pp-summary { margin-top: 34px; }
.pp-summary h3 { font: 400 18px var(--sans); text-align: center; margin: 0; padding-bottom: 8px; border-bottom: 2px solid #ddd; }
.pp-row { display: flex; justify-content: space-between; padding: 10px 0; font-size: 16px; border-bottom: 1px solid #e3e3e3; }
.pp-net { font-weight: 700; border-top: 2px solid #bbb; }
.pp-note { font-weight: 700; font-size: 13px; line-height: 1.45; margin-top: 12px !important; }
.pp-bank { margin-top: 34px; }
.pp-bank h3 { font: 700 16px var(--sans); padding-bottom: 8px; border-bottom: 2px solid #111; margin: 0 0 12px; }
.pp-brow { display: grid; grid-template-columns: 160px 1fr; gap: 10px; padding: 2px 0; font-size: 15px; }
.pp-notes { margin: 20px 0 0 !important; }
.pp-terms { margin-top: 40px; font-size: 13px; line-height: 1.6; color: #222; }
.pp-terms h3 { font: 700 13.5px var(--sans); text-decoration: underline; margin: 0 0 8px; color: #111; }
.pp-terms p { margin: 0 0 10px; }
.pp-sign { display: flex; flex-direction: column; align-items: flex-end; gap: 28px; margin-top: 36px; font-size: 16px; }

/* statement of account */
.st-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.st-bar .seg { min-width: 480px; }
.st-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.st-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin: 0 0 26px; }
.st-box { border: 1.5px solid #111; padding: 10px 12px 12px; text-align: center; color: #111; }
.st-box span { display: block; font-size: 12px; letter-spacing: .3px; margin-bottom: 8px; }
.st-box b { font: 400 20px var(--sans); }
.st-box.over { border-color: #d0021b; color: #d0021b; }
.st-box.today { border-color: #e6a01a; color: #e6a01a; }
.st-box.up { border-color: #1c8a2e; color: #1c8a2e; }
.st-h { font: 700 15px var(--sans); margin: 0 0 6px; color: #111; }
.pp-tbl + .st-h { margin-top: 26px; }
.st-tag { font-weight: 700; font-size: 12px; }
.st-tag.over { color: #d0021b; } .st-tag.today { color: #c98a0c; } .st-tag.up { color: #1c8a2e; } .st-tag.paid { color: #777; }
/* rendered wider, then scaled onto A4, so the PDF has the same proportions as the printed page */
.st-list { table-layout: fixed; }
.st-list th:nth-child(1) { width: 14%; } .st-list th:nth-child(2) { width: 16%; } .st-list th:nth-child(3) { width: 14%; }
.st-list th:nth-child(4) { width: 11%; } .st-list th:nth-child(5), .st-list th:nth-child(6), .st-list th:nth-child(7) { width: 12%; }
.st-inv { margin-bottom: 16px; break-inside: avoid; }
.st-band { display: grid; grid-template-columns: 1.25fr 1.15fr 1.15fr .9fr 1fr .9fr 1fr 1.2fr; gap: 10px; align-items: end;
  background: #f2f2f2; border-top: 2px solid #9a9a9a; padding: 8px 10px; }
.st-band span { display: block; font-size: 10.5px; font-weight: 700; color: #666; margin-bottom: 2px; }
.st-band b { display: block; font-weight: 400; font-size: 14px; color: #111; white-space: nowrap; }
.st-band .st-no b { font-weight: 700; }
.st-band .r { text-align: right; }
.st-goods { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12.5px; color: #222; }
.st-goods th { text-align: left; font-weight: 700; font-size: 11px; color: #666; padding: 6px 8px 4px; border-bottom: 1px solid #cfcfcf; }
.st-goods td { padding: 5px 8px; border-bottom: 1px solid #ececec; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-goods .r { text-align: right; }
.st-goods tr.st-adj td { color: #555; font-style: italic; }
.st-totals { width: 340px; margin: 6px 0 0 auto; }
.st-totals .pp-row { font-size: 14px; padding: 7px 0; }
.st-totals .pp-net { font-size: 15px; }
.st-band .st-tag { font-size: 13px; }
.print-only { display: none; }
.pdf-capture { width: 1000px; max-width: none; box-shadow: none; }

@media print {
  body { background: #fff; color: #111; }
  .side, .topbar, .no-print, #toasts, .tabs, .filters, .page-head .actions { display: none !important; }
  .main { margin: 0; }
  #view { padding: 0; max-width: none; }
  /* no page margin → the browser has no room for its date / title / URL / page-number lines */
  @page { size: A4; margin: 0; }
  .paper { box-shadow: none; max-width: none; }
  .pp { padding: 12mm 12mm; font-size: 11px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .pp-head { grid-template-columns: 1fr 66mm; }
  .pp-us { padding: 4mm 5mm; gap: 9mm; }
  .pp-logo img { width: 84px; }
  .pp-logo span { font-size: 20px; letter-spacing: 5px; }
  .pp-us h1 { font-size: 16px; margin-bottom: 4px; }
  .pp-us p, .pp-party p { font-size: 12px; }
  .pp-title { font-size: 18px; padding: 4mm 5mm 3.5mm; }
  .pp-grid { padding: 2.5mm 5mm 3mm; }
  .pp-grid span { font-size: 10.5px; }
  .pp-grid b { font-size: 12.5px; padding: 5px 0 10px; }
  .pp-parties { margin: 7mm 0 6mm; gap: 24px; }
  .pp-lbl { font-size: 12px; }
  .pp-party h2 { font-size: 18px; margin-bottom: 4px; }
  .pp-party p { margin-bottom: 2px !important; }
  .pp-tbl { font-size: 11px; }
  .pp-tbl th { font-size: 10.5px; padding: 4px 5px 6px; }
  .pp-tbl td { padding: 5px; }
  .pp-summary { margin-top: 8mm; }
  .pp-summary h3 { font-size: 14.5px; padding-bottom: 6px; }
  .pp-row { padding: 7px 0; font-size: 13px; }
  .pp-note { font-size: 10.5px; }
  .pp-bank { margin-top: 8mm; }
  .pp-bank h3 { font-size: 13px; padding-bottom: 6px; margin-bottom: 8px; }
  .pp-brow { font-size: 12px; padding: 1px 0; grid-template-columns: 130px 1fr; }
  .pp-terms { margin-top: 9mm; font-size: 10.5px; line-height: 1.55; }
  .pp-terms h3 { font-size: 11px; margin-bottom: 6px; }
  .pp-terms p { margin-bottom: 7px; }
  .pp-notes { margin-top: 12px !important; }
  .pp-sign { margin-top: 9mm; gap: 20px; font-size: 13px; }
  .pp-head, .pp-parties, .pp-summary, .pp-bank, .pp-sign { break-inside: avoid; }
  .pp-tbl tr { break-inside: avoid; }
  .print-only { display: block; }
  .rep-print { padding: 12mm; }
  .rep-print > .pp { padding: 0 0 6mm; }
  .rep-print .card { border: 0; border-radius: 0; box-shadow: none; }
  .rep-print .tbl-wrap { overflow: visible !important; max-height: none !important; }
  .rep-print .tbl { width: 100%; font-size: 9px; }
  .rep-print .tbl th, .rep-print .tbl td { padding: 4px 5px; white-space: normal; letter-spacing: 0; }
  .rep-print .tbl th { font-size: 8.5px; }
  .rep-print a { color: #111 !important; }
  .st-boxes { gap: 5mm; margin-bottom: 7mm; break-inside: avoid; }
  .st-box { padding: 2.5mm 3mm 3mm; }
  .st-box span { font-size: 10px; margin-bottom: 5px; }
  .st-box b { font-size: 16px; }
  .st-h { font-size: 12.5px; }
  .pp-tbl + .st-h { margin-top: 7mm; }
  .st-tag { font-size: 10.5px; }
  .st-inv { margin-bottom: 4mm; }
  .st-band { padding: 2mm 2.5mm; gap: 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .st-band span { font-size: 8.5px; }
  .st-band b { font-size: 11px; }
  .st-goods { font-size: 10px; }
  .st-goods th { font-size: 9px; padding: 3px 5px 2px; }
  .st-goods td { padding: 3px 5px; }
  .st-totals { width: 70mm; }
  .st-totals .pp-row { font-size: 11.5px; padding: 4px 0; }
  .st-totals .pp-net { font-size: 12.5px; }
  .st-band .st-tag { font-size: 10.5px; }
  .st-box, .st-tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { background: #fff; border-color: #ccc; color: #111; }
  .card.flush .tbl-wrap { max-height: none; overflow: visible; }
  .tbl th { background: #f3f3f3; color: #333; }
  .tbl td { color: #111; border-color: #ddd; }
  .tbl tfoot td { background: #f7f7f7; }
  h1 { color: #111; }
  .pp-logo img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- small screens ---------- */
@media screen and (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 60px #000; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 16px; }
  .topbar #menu { display: block; }
  #gres { left: 16px; width: calc(100% - 32px); }
  #view { padding: 16px 16px 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .paper { padding: 20px 16px; overflow-x: auto; }
  /* phone layout for the page on screen; a PDF being made keeps the full A4 layout (.pdf-capture) */
  .pp:not(.pdf-capture) { padding: 18px 14px; }
  .pp:not(.pdf-capture) :is(.pp-head, .pp-parties) { grid-template-columns: 1fr; }
  .pp:not(.pdf-capture) .st-boxes { grid-template-columns: 1fr 1fr; }
  .pp:not(.pdf-capture) .st-band { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .pp:not(.pdf-capture) .st-goods { table-layout: auto; } .pp:not(.pdf-capture) .st-goods td { white-space: normal; }
  .pp:not(.pdf-capture) .st-totals { width: 100%; }
  .st-bar .seg { min-width: 0; width: 100%; }
  .pp:not(.pdf-capture) .pp-us { flex-wrap: wrap; gap: 14px; border-right: 0; border-bottom: 1.5px solid #9a9a9a; }
  .tcalc { min-width: 0; width: 100%; }
}
