:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e6e3dd;
  --text: #171614;
  --muted: #6f6b64;
  --accent: #171614;
  --amber: #d98b0a;
  --amber-bg: #fff4de;
  --red: #c93b2e;
  --red-bg: #fde8e5;
  --green: #2f8a4a;
  --green-bg: #e4f4e8;
  --violet: #6b4fd8;
  --violet-bg: #ece8fb;
  --grey-bg: #ecebe8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
a { color: inherit; }

/* Layout */
.boot { padding: 60px 16px; text-align: center; color: var(--muted); }
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px 60px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo-img { height: 42px; width: auto; flex: none; display: block; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 18px; flex: none; }
.brand .eyebrow { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > div { min-width: 0; }
.topbar button { white-space: nowrap; }
.brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Buttons & inputs */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #2a2825; }
.btn-danger { color: var(--red); border-color: #f0c9c4; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { padding: 6px 9px; border-radius: 8px; line-height: 1; }
.qty-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23,22,20,.15); outline-offset: 0; border-color: #bdb8af; }
input:disabled { background: var(--grey-bg); color: var(--muted); }
textarea { resize: vertical; min-height: 72px; }
input[type="file"] { padding: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field .label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-section > .label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 8px; display: block; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; gap: 8px; align-items: center; }
.row-fitment { grid-template-columns: 1.1fr 1.3fr 1fr .8fr .8fr auto; }
.row-component { grid-template-columns: 1fr 90px auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.error { color: var(--red); background: var(--red-bg); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.notice { background: var(--amber-bg); color: #7a4f00; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.success { background: var(--green-bg); color: #1d5e32; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .d { font-size: 12px; color: var(--muted); }
.stat.low .v { color: var(--amber); }
.stat.out .v { color: var(--red); }
.stat.incomplete .v { color: var(--violet); }

/* Filters */
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.search { position: relative; }
.search input { padding-left: 36px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.filter-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.filter-row select, .filter-row input { padding: 8px 10px; font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.check input { width: auto; }

/* Grid */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.card.archived { opacity: .7; }
.card .photo { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .photo .ph { font-size: 40px; opacity: .35; }
.card .badge-wrap { position: absolute; top: 10px; left: 10px; }
.card .body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .eyebrow { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card .name { font-size: 17px; font-weight: 700; }
.card .fit { font-size: 13px; color: var(--muted); }
.card .meta { font-size: 12px; color: var(--muted); }
.card .order { font-size: 12px; color: var(--muted); }
.card .stock-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.card .stock-row .qty { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.card .price { font-weight: 700; font-size: 16px; text-align: right; }
.card .price .k, .card .stock-row .k { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card .actions { display: flex; gap: 8px; padding: 0 16px 14px; }
.card .actions button { flex: 1; }
.card .actions .icon-btn { flex: none; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--grey-bg); color: var(--muted); }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-low { background: var(--amber-bg); color: var(--amber); }
.badge-out { background: var(--red-bg); color: var(--red); }
.badge-incomplete { background: var(--violet-bg); color: var(--violet); }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(20,18,16,.45); display: flex; align-items: flex-start; justify-content: center; padding: calc(24px + env(safe-area-inset-top, 0px)) 12px calc(24px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); margin: auto 0; }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-body { padding: 16px 22px 22px; }

/* Detail */
.detail { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
.detail .photo { aspect-ratio: 4 / 3; background: var(--surface-2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.detail .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 12px; }
.kv .k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kv .v { font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.list-item .sub { font-size: 12px; color: var(--muted); }
.list-item .sub.missing { color: var(--red); }
.list-item .qty { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.section-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
.movement { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.movement:last-child { border-bottom: 0; }
.movement .arrow { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex: none; }
.movement .arrow.up { background: var(--green-bg); color: var(--green); }
.movement .arrow.down { background: var(--red-bg); color: var(--red); }
.movement .arrow.flat { background: var(--grey-bg); color: var(--muted); }
.movement .t { font-weight: 600; }
.movement .s { font-size: 12px; color: var(--muted); }
.movement .reason { margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--grey-bg); color: var(--muted); white-space: nowrap; }

/* Segmented */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card .logo-stacked { width: 190px; max-width: 70%; height: auto; align-self: center; margin: 4px 0 2px; }
.auth-card .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 20px; }
.auth-card .links { display: flex; justify-content: space-between; font-size: 13px; }
.auth-card .links button { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; }
.setup { max-width: 640px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }
.setup ol { padding-left: 20px; }
.setup code { background: var(--grey-bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* Misc */
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--red); }
.photo-pick { display: flex; gap: 14px; align-items: center; }
.photo-pick .thumb { width: 110px; height: 82px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; display: grid; place-items: center; color: var(--muted); flex: none; }
.photo-pick .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .btns { display: flex; flex-direction: column; gap: 6px; }

/* Responsive */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .filter-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 24px; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .row-fitment { grid-template-columns: 1fr 1fr; }
  .row-fitment > :nth-child(6) { grid-column: span 2; }
  .topbar .who { display: none; }
  .topbar-inner { flex-wrap: wrap; row-gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; }
  .brand { flex: 1 1 100%; }
  .brand .logo-img { height: 36px; }
  .topbar .spacer { display: none; }
  .topbar .demo-badge { flex: 1 1 100%; justify-content: center; order: 10; }
  .topbar .btn-sm, .topbar .btn-primary { padding: 7px 10px; font-size: 13px; flex: 1; }
  .brand h1 { font-size: 17px; }
  .stats > :last-child { grid-column: span 2; }
  .grid { grid-template-columns: 1fr; }
  .modal-head, .modal-body { padding-left: 16px; padding-right: 16px; }
  .overlay { padding: 8px; }
}

/* ---------------- Invoicing module ---------------- */
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn { border: 0; background: transparent; padding: 7px 10px; border-radius: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.nav-btn:hover { background: #f1efe9; color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.badge-draft { background: #ececec; color: #555; }
.badge-archived { background: #ececec; color: #777; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats .v { word-break: break-word; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table .nowrap { white-space: nowrap; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #faf9f6; }
.table input, .table select { width: 100%; min-width: 0; }
.table.lines input[type=number] { text-align: right; }
.table .pick { margin-top: 4px; font-size: 12px; color: var(--muted); }
.internal { color: var(--muted); }
.table th.internal, .table td.internal { background: #fbfaf6; }
.row-new td { background: var(--amber-bg); }
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 18px 0 12px; flex-wrap: wrap; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.doc-title { margin: 6px 0 2px; font-size: 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel .section-head { margin: 0 0 8px; }
.lines-panel { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.veh-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 8px; }
.notice.ok { background: var(--green-bg); color: #1f6b38; }
.notice.bad { background: var(--red-bg); color: var(--red); }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.totals .tot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.totals .tot input { width: 130px; }
.totals .grand { font-size: 17px; border-bottom: 2px solid var(--accent); }
.totals .due b { color: var(--red); }
.totals .internal { color: var(--muted); font-size: 13px; }
.pay-list { margin-top: 12px; }
.pay-list .k, .cust-body .k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.pay-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.cust-search { position: relative; margin-bottom: 10px; }
.cust-hits { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; }
.cust-hit { border-bottom: 1px solid var(--border); padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cust-hit button { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 13px; cursor: pointer; }
.cust-hit .cust-main { border: 0; background: transparent; padding: 4px 6px; }
.sig-pad { width: 100%; height: 220px; border: 1px dashed #bbb; border-radius: 12px; background: #fff; touch-action: none; display: block; }
.sig-preview { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.sig-preview img { height: 60px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.cust-list { display: flex; flex-direction: column; gap: 10px; }
.cust-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.cust-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.cust-top .name { font-weight: 600; }
.cust-meta { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.cust-body { border-top: 1px solid var(--border); padding: 14px 16px; }
.cust-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.veh-row, .doc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.doc-row { text-decoration: none; color: inherit; }
.doc-row:hover { background: #faf9f6; }
@media (max-width: 900px) {
  .editor-grid, .cust-cols, .veh-grid { grid-template-columns: 1fr; }
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .nav { order: 5; flex: 1 1 100%; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .stats-4 > :last-child { grid-column: auto; }
}

/* ---------------- Printable document ---------------- */
body.print-mode { background: #777; }
.print-toolbar { position: sticky; top: 0; z-index: 10; background: #222; color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; }
.print-toolbar .btn-link { color: #fff; border-color: #555; margin-left: 8px; }
.print-error { background: #fff; margin: 40px auto; max-width: 480px; padding: 24px; border-radius: 12px; }
.page { position: relative; width: 210mm; min-height: 297mm; margin: 12px auto; background: #fff; color: #111; padding: 8mm 10mm 6mm; box-sizing: border-box; font-family: Arial, Helvetica, sans-serif; font-size: 11px; box-shadow: 0 6px 30px rgba(0,0,0,.35); overflow: hidden; display: flex; flex-direction: column; }
.page .banner { width: 100%; display: block; }
/* Letterhead: crest on the left, company details on the right, gold rule with the three-colour accent */
.letterhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 3px solid #f2c200; position: relative; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.letterhead::after { content: ''; position: absolute; right: 0; bottom: -3px; width: 170px; height: 3px; background: linear-gradient(90deg, #b5b5b5 0 33%, #d71920 33% 66%, #111 66%); }
.lh-logo { height: 72px; margin-left: -6px; display: block; }
.lh-co { text-align: right; line-height: 1.65; font-size: 11px; color: #333; }
.lh-name { font-weight: 700; font-size: 12.5px; letter-spacing: .6px; color: #111; }
.lh-ar { font-weight: 700; font-size: 12px; color: #111; }
.page .brands { margin-top: auto; padding: 0 0 9px; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bs-title { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 8px; letter-spacing: 2.5px; color: #8a8a8a; font-weight: 700; margin-bottom: 6px; }
.bs-title .ar { letter-spacing: 0; font-size: 9px; font-weight: 700; }
.bs-rule { flex: 0 0 60px; height: 1px; background: #d9d9d9; }
.bs-logos { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #f6f6f6; border-radius: 6px; padding: 8px 14px; }
.bs-logos img { height: 32px; width: auto; max-width: 76px; object-fit: contain; filter: drop-shadow(0 1.5px 1.5px rgba(0,0,0,.28)); }
.pfoot { margin-top: 0; padding-top: 8px; border-top: 3px solid #f2c200; position: relative; font-size: 10px; color: #444; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pfoot::before { content: ''; position: absolute; left: 0; top: -3px; width: 170px; height: 3px; background: linear-gradient(90deg, #111 0 33%, #d71920 33% 66%, #b5b5b5 66%); }
.pfoot-row { display: flex; justify-content: space-between; gap: 12px; }
.pfoot-row b { color: #111; }
.pfoot-thanks { text-align: center; margin-top: 5px; color: #777; letter-spacing: .3px; }
.pfoot-thanks .ar { color: #777; }
.page .footer { margin-top: auto; }
.doc-head { display: flex; justify-content: flex-end; align-items: flex-start; gap: 12px; margin: 8px 0 4px; }
.doc-meta { text-align: right; font-size: 11.5px; line-height: 1.6; }
.doc-meta .lbl { color: #555; }
.doc-meta .num { font-size: 14px; }
.doc-meta .ar { font-size: 13px; font-weight: bold; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 8px; }
.party { border: 1px solid #333; border-radius: 4px; padding: 6px 8px; }
.party-title { font-weight: bold; background: #f2c200; margin: -6px -8px 6px; padding: 4px 8px; border-radius: 3px 3px 0 0; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dotted #bbb; }
.kv span { color: #333; }
.kv:last-child { border-bottom: 0; }
.doc-title { text-align: center; font-weight: bold; letter-spacing: 3px; font-size: 14px; background: #111; color: #f2c200; padding: 5px; margin: 4px 0 8px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 11px; }
.ptable th, .ptable td { border: 1px solid #333; padding: 4px 6px; vertical-align: top; }
.ptable th { background: #f2c200; text-align: left; }
.ptable .sn { width: 28px; text-align: center; }
.ptable .n { width: 84px; text-align: right; }
.ptable tr.sec td { background: #e9e9e9; font-weight: bold; }
.ptable tr.sub td { font-weight: bold; text-align: right; background: #fafafa; }
.totals-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 10px; margin-top: 8px; }
.pay-box, .sum-box { border: 1px solid #333; border-radius: 4px; padding: 6px 8px; }
.sum-box .grand { font-size: 13px; background: #f2c200; margin: 4px -8px -6px; padding: 5px 8px; border-radius: 0 0 3px 3px; }
.pay-box .note { margin-top: 6px; font-size: 10.5px; white-space: pre-wrap; }
.notice-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 8px; font-size: 9.5px; line-height: 1.4; border-top: 2px solid #111; padding-top: 6px; }
.notice-box p { margin: 2px 0 0; }
.void-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg); font-size: 110px; font-weight: 900; color: rgba(214,35,42,.22); border: 10px solid rgba(214,35,42,.22); padding: 10px 30px; border-radius: 20px; z-index: 5; }
.terms-page { padding: 6mm 8mm; display: block; }
.terms-wrap { position: relative; }
.terms-wrap .terms { width: 100%; display: block; }
.sig-on-terms { position: absolute; left: 21%; bottom: 4.2%; height: 9%; width: auto; mix-blend-mode: multiply; }
.sig-caption { position: absolute; left: 20%; top: 100%; margin-top: 2px; font-size: 9px; color: #333; }
.adv-caption { position: absolute; left: 56%; top: 100%; margin-top: 2px; font-size: 9px; color: #333; }
@media print {
  @page { size: A4; margin: 0; }
  body.print-mode { background: #fff; }
  .no-print { display: none !important; }
  .page { margin: 0; box-shadow: none; page-break-after: always; height: 297mm; }
  .page:last-child { page-break-after: auto; }
}
/* Netlify's free-plan badge must never appear on printed or shared documents */
#nl-badge-frame { display: none !important; }
.adv-chip { display: inline-block; margin: 4px 10px 4px 0; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.06); font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.dp-sum { margin-top: 12px; }
.totals .tot span { line-height: 1.3; }
/* VAT report page */
.vat-page { font-size: 11px; }
.vat-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 12px; }
.vat-head h1 { margin: 0; font-size: 22px; }
.vat-logo { height: 54px; }
.vat-co { margin-left: auto; text-align: right; line-height: 1.5; }
.vat-page h2 { font-size: 13px; margin: 14px 0 6px; }
.vat-summary td:first-child { font-weight: 600; }
.vat-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid #ccc; }
.invite-link { background: #f6f5f2; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; word-break: break-all; margin: 10px 0 4px; }

/* Payroll grid + Profit & Loss */
.payroll-grid input.cell, .payroll-grid select.cell { min-width: 78px; padding: 5px 6px; font-size: 13px; }
.payroll-grid input.wide { min-width: 170px; }
.payroll-grid td { padding: 6px 6px; }
.table td.neg { color: var(--red); }
.pnl-chart { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px 4px; margin-bottom: 16px; }
.pnl-chart .legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pnl-chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.report-preview { white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fbfaf6; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 0; }

.stats-2 { grid-template-columns: repeat(2, 1fr); }

.status-set select { padding: 6px 8px; font-size: 13px; border-radius: 10px; }

.badge-pending { background: #e3eefb; color: #1f5fa8; }
