/* ================= Tokens ================= */
:root {
  --paper: #f4f6f5;      /* cool off-white page */
  --sheet: #ffffff;
  --ink: #16222e;        /* body text */
  --muted: #5b6874;
  --rule: #d6dddb;
  --ledger: #0e6b57;     /* brand: ledger green */
  --ledger-dk: #0a5444;
  --mark: #f2df4f;       /* highlighter: selection and focus only */
  --danger: #b4232f;
  --r-sm: 6px; --r-md: 10px;
  --shadow-sheet: 0 1px 2px rgba(22,34,46,.06), 0 8px 28px rgba(22,34,46,.08);
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --wrap: 1200px;
  color-scheme: light;
}
html[lang="ar"] { --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; }
html[lang="hi"] { --font: "Noto Sans Devanagari", "Schibsted Grotesk", system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--font); }
img { max-width: 100%; }
a { color: var(--ledger-dk); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--mark); color: var(--ink); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 99; }
.skip:focus { inset-inline-start: 8px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ================= Buttons ================= */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r-sm); padding: 9px 16px; font: 600 15px/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--ledger); color: #fff; }
.btn-primary:hover { background: var(--ledger-dk); color: #fff; }
.btn-ghost { background: var(--sheet); border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.btn[disabled], .btn.busy { opacity: .6; cursor: progress; }
.btn-link { background: none; border: 0; padding: 4px 0; color: var(--ledger-dk); font: 500 14px var(--font); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-link.danger { color: var(--danger); }
.btn-icon { background: none; border: 1px solid transparent; border-radius: var(--r-sm); width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.btn-icon:hover { color: var(--danger); border-color: var(--rule); }

/* ================= Header ================= */
.site-head { background: var(--sheet); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 30; }
.site-head .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand svg { flex: none; }
.head-nav { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.head-nav > a, .pd-menu > summary { padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; cursor: pointer; }
.head-nav > a:hover, .pd-menu > summary:hover { background: var(--paper); }
.pd-menu { position: relative; }
.pd-menu > summary { list-style: none; display: flex; align-items: center; gap: 6px; }
.pd-menu > summary::-webkit-details-marker { display: none; }
.pd-menu > summary::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.pd-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--shadow-sheet); padding: 8px; min-width: 220px; z-index: 40; }
.pd-pop a, .pd-pop button { display: block; width: 100%; text-align: start; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font: 500 15px var(--font); background: none; border: 0; cursor: pointer; }
.pd-pop a:hover, .pd-pop button:hover { background: var(--paper); }
.pd-pop a[aria-current] { background: var(--mark); }
.pop-docs { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 4px 16px; width: min(760px, 92vw); padding: 14px; }
.pop-docs h4 { margin: 6px 10px 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.nav-toggle { display: none; }
@media (max-width: 860px) {
  .head-nav { display: none; position: absolute; top: 60px; inset-inline: 0; background: var(--sheet); border-bottom: 1px solid var(--rule); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .head-nav.open { display: flex; }
  .nav-toggle { display: grid; margin-inline-start: auto; }
  .pd-pop { position: static; box-shadow: none; border: 0; padding: 0 0 0 8px; }
  .pop-docs { grid-template-columns: 1fr; width: auto; }
}

/* ================= Home ================= */
.hero { padding: 56px 0 40px; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(36px, 5.2vw, 62px); font-weight: 800; letter-spacing: -.035em; line-height: 1.02; max-width: 12ch; }
.hero .lead { font-size: 19px; color: var(--muted); max-width: 46ch; margin-bottom: 28px; }
.hero .ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn { padding: 13px 22px; font-size: 16px; }
.privacy-line { display: flex; align-items: center; gap: 8px; margin-top: 22px; font-size: 14px; color: var(--muted); }
/* the fanned stack of real documents */
.stack { position: relative; height: 470px; }
.stack .sheet { position: absolute; width: 340px; height: 440px; background: var(--sheet); border-radius: 3px; box-shadow: var(--shadow-sheet); overflow: hidden; top: 10px; inset-inline-start: 50%; transform-origin: 50% 100%; }
.stack .sheet .pd-doc { transform: scale(.428); transform-origin: top left; width: 794px; min-height: 1028px; pointer-events: none; }
[dir="rtl"] .stack .sheet .pd-doc { transform-origin: top right; }
.stack .s1 { transform: translateX(-74%) rotate(-7deg); }
.stack .s2 { transform: translateX(-50%) rotate(1.5deg); }
.stack .s3 { transform: translateX(-26%) rotate(8deg) translateY(14px); }
[dir="rtl"] .stack .s1 { transform: translateX(74%) rotate(7deg); }
[dir="rtl"] .stack .s2 { transform: translateX(50%) rotate(-1.5deg); }
[dir="rtl"] .stack .s3 { transform: translateX(26%) rotate(-8deg) translateY(14px); }
@media (prefers-reduced-motion: no-preference) {
  .stack .sheet { animation: deal .9s cubic-bezier(.2,.8,.2,1) both; }
  .stack .s1 { animation-delay: .05s; } .stack .s2 { animation-delay: .15s; } .stack .s3 { animation-delay: .25s; }
  @keyframes deal { from { opacity: 0; translate: 0 40px; } to { opacity: 1; translate: 0 0; } }
}
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .stack { height: 330px; }
  .stack .sheet { width: 240px; height: 310px; }
  .stack .sheet .pd-doc { transform: scale(.302); }
}

/* Document index: a filing cabinet, grouped by purpose */
.index { padding: 40px 0 24px; }
.index > .wrap > h2, .section-title { font-size: 30px; letter-spacing: -.02em; margin-bottom: 20px; }
.drawers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 28px 32px; }
.drawer h3 { font-size: 15px; font-weight: 700; color: var(--ledger-dk); border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 0; }
.drawer ul { list-style: none; margin: 0; padding: 0; }
.drawer li { border-bottom: 1px solid var(--rule); }
.drawer a { display: block; padding: 12px 0; text-decoration: none; color: var(--ink); }
.drawer a strong { display: block; font-size: 17px; font-weight: 600; }
.drawer a span { display: block; font-size: 14px; color: var(--muted); line-height: 1.4; }
.drawer a:hover strong { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.steps { padding: 48px 0; }
.steps ol { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; counter-reset: s; }
.steps li { counter-increment: s; border-top: 2px solid var(--ink); padding-top: 14px; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--mark); font-weight: 800; margin-bottom: 10px; }
.steps h3 { font-size: 19px; }
.steps p { color: var(--muted); }
@media (max-width: 760px) { .steps ol { grid-template-columns: 1fr; } }

.features { padding: 24px 0 48px; }
.features dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 40px; margin: 0; }
.features dl > div { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.features dt { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.features dd { margin: 0; color: var(--muted); }

/* ================= Prose / FAQ ================= */
.prose { max-width: 72ch; }
.prose h2 { font-size: 26px; margin-top: 1.6em; }
.prose ol { padding-inline-start: 1.3em; } .prose li { margin-bottom: .6em; }
.faq { max-width: 72ch; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 600; font-size: 17px; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 400; font-size: 22px; line-height: 1; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { color: var(--muted); padding-bottom: 8px; }
.page-sec { padding: 40px 0; }
.page-sec + .page-sec { border-top: 1px solid var(--rule); }

/* ================= Tool page ================= */
.tool-head { padding: 28px 0 18px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.tool-head h1 { font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -.025em; margin-bottom: 6px; }
.tool-head p { color: var(--muted); margin: 0; max-width: 70ch; }
.pd-app { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 28px; align-items: start; padding-bottom: 48px; }
.pd-tabs { display: none; }
@media (max-width: 1000px) {
  .pd-app { grid-template-columns: 1fr; }
  .pd-tabs { display: flex; position: sticky; top: 60px; z-index: 20; background: var(--paper); padding: 8px 0; gap: 6px; }
  .pd-tabs button { flex: 1; padding: 10px; border: 1px solid var(--rule); background: var(--sheet); border-radius: var(--r-sm); font: 600 15px var(--font); color: var(--ink); cursor: pointer; }
  .pd-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  .pd-app[data-view="edit"] .pd-view { display: none; }
  .pd-app[data-view="preview"] .pd-form-col { display: none; }
}

/* form */
.f-sec { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); margin-bottom: 12px; }
.f-sec > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; }
.f-sec > summary::-webkit-details-marker { display: none; }
.f-sec > summary::after { content: ""; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
.f-sec[open] > summary::after { transform: rotate(-135deg); }
.f-sec h2 { font-size: 17px; margin: 0; }
.f-body { padding: 0 18px 18px; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f-field.wide { grid-column: 1 / -1; }
.f-field label, .f-lab { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: 15px/1.4 var(--font); color: var(--ink); background: #fff; border: 1px solid #c5cecb; border-radius: var(--r-sm); padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ledger); outline-offset: -1px; border-color: var(--ledger); }
input[type="color"] { padding: 2px; width: 40px; height: 34px; }
.f-join { display: flex; } .f-join input { border-start-end-radius: 0; border-end-end-radius: 0; } .f-join select { width: auto; border-start-start-radius: 0; border-end-start-radius: 0; margin-inline-start: -1px; }
.f-check { display: flex; align-items: center; gap: 8px; font-size: 15px; grid-column: 1 / -1; cursor: pointer; }
.f-check input { width: 18px; height: 18px; accent-color: var(--ledger); }
.f-sub { font-size: 15px; margin: 18px 0 10px; }
.f-pick { margin-bottom: 12px; }
.f-hint { font-size: 13px; color: var(--muted); margin: 8px 0; }
.f-privacy { display: flex; gap: 6px; align-items: center; }
.f-row { display: flex; gap: 16px; align-items: center; margin-top: 6px; }
.f-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.f-logo img { max-height: 48px; max-width: 140px; border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 4px; background: #fff; }
.f-logo .btn { cursor: pointer; }
.f-sec .btn-link { margin-top: 10px; margin-inline-end: 18px; display: inline-block; }
.f-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; background: var(--sw); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rule); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 2px var(--ink); }
#sig-pad { width: 100%; aspect-ratio: 3 / 1; border: 1px dashed #b6c0bd; border-radius: var(--r-sm); background: #fff; touch-action: none; cursor: crosshair; }
/* item rows */
.f-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.f-item { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 10px; background: #fbfcfc; }
.f-item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.m-priced .f-item-grid, .m-timesheet .f-item-grid { grid-template-columns: repeat(3, 1fr); }
.m-timesheet .f-item-grid .c-date { grid-column: 1 / -1; }
.m-statement .f-item-grid { grid-template-columns: 1fr 1fr; }
.m-packing .f-item-grid { grid-template-columns: 1fr 1fr 1fr; }
.f-item-grid .f-field.wide { grid-column: 1 / -1; }
.f-item-grid textarea { resize: none; overflow: hidden; min-height: 38px; }
.f-item-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.f-line { font-weight: 700; font-variant-numeric: tabular-nums; }
.f-item-foot .btn-icon { margin-inline-start: auto; }

/* preview column */
.pd-view { position: sticky; top: 76px; }
.pd-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.pd-bar .spacer { flex: 1; }
.pd-bar .pd-menu > summary { border: 1px solid var(--rule); background: var(--sheet); font-weight: 600; }
.pd-stage { position: relative; overflow: hidden; }
.pd-paper { transform-origin: top left; background: #fff; box-shadow: var(--shadow-sheet); }
[dir="rtl"] .pd-paper { transform-origin: top right; }
.pd-paper .pd-doc.size-a4 { min-height: 1123px; } .pd-paper .pd-doc.size-letter { min-height: 1056px; }
@media (max-width: 1000px) { .pd-view { position: static; } }
#pd-export { position: fixed; left: -10000px; top: 0; }
#print-root { display: none; }
.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); font-size: 15px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
[dir="rtl"] .toast { transform: translate(50%, 20px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } [dir="rtl"] .toast.show { transform: translate(50%, 0); }

.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { padding: 8px 14px; border: 1px solid var(--rule); background: var(--sheet); border-radius: 999px; text-decoration: none; color: var(--ink); font-size: 15px; }
.related a:hover { border-color: var(--ink); }

/* calculators */
.calc { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 24px; max-width: 640px; display: grid; gap: 16px; }
.calc .f-grid { gap: 16px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; }
.seg label { padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 15px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--mark); }
.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 2px solid var(--ink); }
.results div { padding: 12px 0; }
.results span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.results output { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* my documents */
.docs-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.docs-tools input, .docs-tools select { width: auto; flex: 1 1 200px; }
.docs-table { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); }
.docs-row { display: grid; grid-template-columns: 1fr 140px 170px auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.docs-row:last-child { border-bottom: 0; }
.dr-main a { color: var(--ink); text-decoration: none; } .dr-main span { display: block; font-size: 14px; color: var(--muted); }
.dr-total { font-weight: 700; font-variant-numeric: tabular-nums; text-align: end; }
.dr-when { font-size: 14px; color: var(--muted); }
.dr-act { display: flex; gap: 8px; align-items: center; }
.empty { padding: 32px; background: var(--sheet); border: 1px dashed var(--rule); border-radius: var(--r-md); color: var(--muted); }
@media (max-width: 760px) { .docs-row { grid-template-columns: 1fr auto; } .dr-when { display: none; } .dr-act { grid-column: 1 / -1; } }

/* ================= Footer ================= */
.site-foot { border-top: 1px solid var(--rule); background: var(--sheet); padding: 36px 0 28px; margin-top: 40px; font-size: 15px; }
.foot-grid { display: grid; grid-template-columns: 1.2fr 2fr; gap: 32px; }
.foot-grid p { color: var(--muted); max-width: 34ch; }
.foot-links { columns: 3 180px; column-gap: 24px; }
.foot-links a { display: block; padding: 3px 0; color: var(--ink); text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }
.foot-base { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; border-top: 1px solid var(--rule); margin-top: 24px; padding-top: 16px; color: var(--muted); }
.foot-base nav { display: flex; gap: 16px; flex-wrap: wrap; } .foot-base a { color: var(--muted); }
.foot-langs { display: flex; flex-wrap: wrap; gap: 4px 14px; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr; } }

/* ================= The document (preview, PDF, print) ================= */
.pd-doc { --c: #1d5c7a; position: relative; background: #fff; color: #1b2128; font: 13px/1.45 "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", Tahoma, sans-serif; padding: 52px 56px 48px; text-align: start; overflow: hidden; }
.pd-doc[lang="ar"] { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; font-size: 13.5px; }
.pd-doc h1, .pd-doc h3, .pd-doc .d-title { margin: 0; letter-spacing: 0; }
.pd-doc p { margin: 0; }
.d-head { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; margin-bottom: 30px; }
.d-brand { display: flex; flex-direction: column; gap: 12px; min-width: 0; max-width: 55%; }
.d-logo { max-width: 180px; max-height: 80px; object-fit: contain; align-self: flex-start; }
.d-titlebox { text-align: end; flex: none; max-width: 45%; }
.d-title { font-size: 30px; font-weight: 700; color: var(--c); line-height: 1.1; margin-bottom: 12px !important; }
.d-meta { margin: 0; display: grid; gap: 3px; }
.d-meta div { display: flex; justify-content: flex-end; gap: 12px; }
.d-meta dt { color: #6a737d; } .d-meta dd { margin: 0; font-weight: 600; min-width: 90px; }
.d-party { display: flex; flex-direction: column; gap: 3px; color: #3c4650; }
.d-party h3 { font-size: 11px; color: var(--c); font-weight: 700; margin-bottom: 4px !important; letter-spacing: .04em; }
.d-pname { color: #1b2128; font-size: 15px; }
.d-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 26px; padding: 16px 0; border-top: 1px solid #e3e7ea; border-bottom: 1px solid #e3e7ea; }
.d-items { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
.d-items th { text-align: start; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--c); padding: 9px 10px; }
.d-items td { padding: 9px 10px; border-bottom: 1px solid #e8ecef; vertical-align: top; }
.d-items .n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.d-items tr { page-break-inside: avoid; }
.d-items .c-desc, .d-items .c-task { width: 99%; white-space: normal; }
.d-bf td { color: #6a737d; font-style: italic; background: #f7f9fa; }
.d-bottom { display: flex; gap: 32px; justify-content: space-between; align-items: flex-start; page-break-inside: avoid; }
.d-notes { flex: 1; display: grid; gap: 14px; color: #3c4650; min-width: 0; }
.d-notes h3 { font-size: 11px; font-weight: 700; color: var(--c); margin-bottom: 3px !important; letter-spacing: .04em; }
.d-totals { border-collapse: collapse; min-width: 260px; font-variant-numeric: tabular-nums; }
.d-totals th { text-align: start; font-weight: 500; color: #4b555f; padding: 5px 14px 5px 0; }
.d-totals td { text-align: end; padding: 5px 0; white-space: nowrap; }
[dir="rtl"] .d-totals th { padding: 5px 0 5px 14px; }
.d-totals .d-grand th, .d-totals .d-grand td { font-size: 16px; font-weight: 700; color: #1b2128; border-top: 2px solid var(--c); padding-top: 9px; }
.d-totals .d-due th, .d-totals .d-due td { font-weight: 700; color: var(--c); font-size: 15px; }
.d-signs { display: flex; gap: 40px; margin-top: 48px; page-break-inside: avoid; }
.d-sign { flex: 1; max-width: 240px; }
.d-sigimg { height: 64px; border-bottom: 1px solid #8a939b; display: flex; align-items: flex-end; }
.d-sigimg img { max-height: 60px; max-width: 100%; }
.d-sign span { display: block; font-size: 11.5px; color: #6a737d; margin-top: 6px; }
.d-stamp { position: absolute; top: 210px; inset-inline-end: 70px; transform: rotate(-14deg); border: 4px solid; border-radius: 8px; padding: 6px 18px; font-size: 34px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .7; z-index: 2; }
.d-stamp-paid { color: #1f8a4c; } .d-stamp-unpaid { color: #c22a33; } .d-stamp-draft { color: #8a939b; }

/* modern template: coloured band header */
.tpl-modern { padding-top: 0; }
.tpl-modern .d-head { margin: 0 -56px 30px; padding: 40px 56px 30px; background: var(--c); color: #fff; }
.tpl-modern .d-head .d-title, .tpl-modern .d-head .d-pname, .tpl-modern .d-head .d-party, .tpl-modern .d-head dt, .tpl-modern .d-head dd, .tpl-modern .d-head .d-party h3 { color: #fff; }
.tpl-modern .d-head dt { opacity: .78; }
.tpl-modern .d-logo { background: #fff; padding: 6px; border-radius: 6px; }
.tpl-modern .d-parties { border: 0; padding: 0; }
.tpl-modern .d-items th { background: #f1f4f6; color: #1b2128; border-bottom: 2px solid var(--c); }
.tpl-modern .d-stamp { top: 250px; }

/* minimal template: type and rules only */
.tpl-minimal .d-title { color: #1b2128; font-weight: 300; font-size: 38px; }
.tpl-minimal .d-items th { background: none; color: #6a737d; border-bottom: 1.5px solid #1b2128; padding-inline: 0 10px; }
.tpl-minimal .d-items td { padding-inline: 0 10px; }
.tpl-minimal .d-parties { border: 0; padding: 0; }
.tpl-minimal .d-party h3, .tpl-minimal .d-notes h3 { color: #6a737d; }
.tpl-minimal .d-totals .d-grand th, .tpl-minimal .d-totals .d-grand td { border-top-color: #1b2128; color: var(--c); }

/* classic template: rule under header */
.tpl-classic { border-top: 8px solid var(--c); }

/* ================= Print ================= */
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .pd-doc { width: 100%; padding: 14mm 15mm; }
  #print-root .tpl-modern { padding-top: 0; } #print-root .tpl-modern .d-head { margin: 0 -15mm 24px; padding: 12mm 15mm 8mm; }
  .pd-doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pd-doc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* fixes: grid children must be allowed to shrink below the paper width */
.pd-app > * { min-width: 0; }
.pd-stage { width: 100%; }
/* Arabic letters must stay joined: no tracking anywhere in an Arabic document */
.pd-doc[lang="ar"], .pd-doc[lang="ar"] * { letter-spacing: 0 !important; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; }
.d-items .c-date, .d-items .c-ref, .d-items .c-sku, .d-items .c-unit { white-space: nowrap; }

/* ===== Script-specific typography ===== */
html[lang="ru"] { --font: "Onest", "Segoe UI", Roboto, Arial, sans-serif; }
/* Arabic and Devanagari are joined scripts: tracking breaks the letter shapes */
html[lang="ar"] *, html[lang="hi"] * { letter-spacing: 0 !important; }
html[lang="ar"] body, html[lang="hi"] body { line-height: 1.7; }
html[lang="ar"] .hero h1, html[lang="hi"] .hero h1 { line-height: 1.25; }
/* long compound words (German, Russian, Turkish) must wrap instead of overflowing */
h1, h2, h3, .drawer a strong, .related a { overflow-wrap: break-word; hyphens: manual; }
.pd-doc[lang="hi"] { font-family: "Noto Sans Devanagari", "Nirmala UI", "Mangal", sans-serif; line-height: 1.6; }
.pd-doc[lang="ru"] { font-family: "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; }

/* ===== Preview placeholders (never printed) ===== */
.d-ph { color: #b3bcc4; font-style: italic; font-weight: 400; }
strong.d-ph { font-weight: 600; }

/* ===== Layout: give the document preview more room ===== */
.pd-app { grid-template-columns: minmax(320px, 390px) 1fr; }
@media (max-width: 1000px) { .pd-app { grid-template-columns: 1fr; } }

/* ===== Item details, extra party info, photos ===== */
.d-idet { display: block; color: #6a737d; font-size: 11.5px; margin-top: 2px; white-space: pre-line; }
.d-extra { color: #6a737d; font-size: 11.5px; }
.d-photos { margin-top: 32px; }
.d-photos h3 { font-size: 11px; font-weight: 700; color: var(--c); margin-bottom: 10px !important; }
.d-pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.d-photo { margin: 0; border: 1px solid #e3e7ea; border-radius: 4px; overflow: hidden; aspect-ratio: 4 / 3; background: #f7f9fa; page-break-inside: avoid; }
.d-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.f-idet { margin-top: 6px; font-size: 14px; color: var(--muted); }
.f-adds { display: flex; gap: 20px; grid-column: 1 / -1; }
.f-adds .btn-link { margin-top: 0; }
.f-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.f-photo { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--rule); }
.f-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.f-photo .btn-icon { position: absolute; top: 4px; inset-inline-end: 4px; background: rgba(255,255,255,.92); width: 28px; height: 28px; }
.f-sec label.btn { cursor: pointer; }

/* ===== Compact layout (used automatically to fit one page) ===== */
.pd-doc.compact { padding: 34px 42px 30px; font-size: 12px; line-height: 1.38; }
.compact .d-head { margin-bottom: 16px; gap: 24px; }
.compact .d-brand { gap: 8px; }
.compact .d-logo { max-height: 60px; }
.compact .d-title { font-size: 26px; margin-bottom: 8px !important; }
.compact .d-meta { gap: 1px; }
.compact .d-parties { padding: 10px 0; margin-bottom: 14px; gap: 18px; }
.compact .d-pname { font-size: 13.5px; }
.compact .d-items { margin-bottom: 14px; }
.compact .d-items th { padding: 6px 8px; }
.compact .d-items td { padding: 5px 8px; }
.compact .d-idet { margin-top: 0; }
.compact .d-notes { gap: 8px; }
.compact .d-totals th, .compact .d-totals td { padding-block: 3px; }
.compact .d-totals .d-grand th, .compact .d-totals .d-grand td { padding-top: 6px; font-size: 15px; }
.compact .d-photos { margin-top: 16px; }
.compact .d-pgrid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.compact .d-signs { margin-top: 22px; }
.compact .d-sigimg { height: 50px; }
.compact .d-sigimg img { max-height: 46px; }
.compact.tpl-modern { padding-top: 0; }
.compact.tpl-modern .d-head { margin: 0 -42px 16px; padding: 26px 42px 18px; }
@media print {
  #print-root .pd-doc.compact { padding: 10mm 12mm; }
  #print-root .compact.tpl-modern { padding-top: 0; }
  #print-root .compact.tpl-modern .d-head { margin: 0 -12mm 14px; padding: 8mm 12mm 5mm; }
  #print-root .pd-doc { margin: 0 auto; }
}

/* ===== Page-break markers in the preview (not exported) ===== */
.pd-paper { position: relative; }
.pd-pbreak { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed #9aa5ad; z-index: 3; pointer-events: none; }
.pd-pbreak span { position: absolute; top: -12px; inset-inline-end: 10px; background: #8a959e; color: #fff; font: 600 12px/1 var(--font); padding: 5px 10px; border-radius: 12px; }
/* photos drawn as backgrounds: the PDF renderer supports background-size but not object-fit */
.d-photo { background-size: cover; background-position: center; background-repeat: no-repeat; }
/* photos are cropped to 4:3 on upload, so a plain full-width image fills the frame */
.d-photo { aspect-ratio: auto; line-height: 0; }
.d-photo img { width: 100%; height: auto; object-fit: initial; }
/* html2canvas mis-draws images inside rounded, overflow-clipped boxes: keep the photo frame square-cornered and unclipped */
.d-photo { border-radius: 0; overflow: visible; border: 0; background: none; }
.d-photo img { border: 1px solid #e3e7ea; box-sizing: border-box; }

/* ===== Legal pages ===== */
.tool-head .updated { color: var(--muted); font-size: 14px; margin-top: 6px; }
.prose.legal { padding-bottom: 24px; }
.prose.legal h2 { font-size: 21px; margin-top: 1.5em; }
.prose.legal p { overflow-wrap: anywhere; }
.foot-base nav { gap: 6px 16px; }
.d-totals .d-incl th, .d-totals .d-incl td { color: #6a737d; font-size: 11.5px; padding-top: 2px; }

/* ===== Guides ===== */
.g-wrap { max-width: 860px; }
.g-article { padding-bottom: 16px; }
.g-head { padding: 24px 0 8px; }
.g-head h1 { font-size: clamp(30px, 4.4vw, 46px); letter-spacing: -.03em; text-wrap: balance; }
.g-lead { font-size: 19px; color: var(--muted); max-width: 62ch; }
.g-meta { font-size: 14px; color: var(--muted); }
.g-meta a { color: var(--muted); }
.g-toc { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 16px 20px; margin: 16px 0 8px; max-width: 62ch; }
.g-toc h2 { font-size: 15px; margin-bottom: 6px; }
.g-toc ol { margin: 0; padding-inline-start: 1.2em; }
.g-toc li { margin: 4px 0; }
.g-body { max-width: 68ch; font-size: 17.5px; line-height: 1.7; }
.g-body h2 { font-size: 26px; margin: 1.6em 0 .5em; scroll-margin-top: 80px; text-wrap: balance; }
.g-body h3 { font-size: 20px; margin: 1.3em 0 .4em; }
.g-body ul, .g-body ol { padding-inline-start: 1.3em; margin: 0 0 1em; }
.g-body li { margin-bottom: .45em; }
.g-tip { border-inline-start: 4px solid var(--ledger); background: #e9f3f0; padding: 12px 16px; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin: 1.2em 0; font-size: 16px; }
[dir="rtl"] .g-tip { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.g-tip p { margin: 0; }
.g-table { overflow-x: auto; margin: 1em 0 1.4em; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sheet); }
.g-table table { border-collapse: collapse; width: 100%; font-size: 15.5px; line-height: 1.45; }
.g-table th, .g-table td { padding: 10px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--rule); }
.g-table thead th { background: #eef2f1; font-weight: 700; }
.g-table tbody th { font-weight: 600; }
.g-table tr:last-child > * { border-bottom: 0; }
.g-figure { margin: 1.6em 0; }
.g-sheet { background: #fff; box-shadow: var(--shadow-sheet); border-radius: 3px; overflow: hidden; width: fit-content; max-width: 100%; }
.g-sheet .pd-doc { zoom: .78; width: 794px; pointer-events: none; }
.g-figure figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; }
.g-cta { display: flex; gap: 16px 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 18px 20px; margin: 1.2em 0; }
.g-cta p { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.g-cta > div { flex: 1 1 280px; min-width: 0; }
.g-cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 32px; }
.g-cards li { border-top: 2px solid var(--ink); }
.g-cards a { display: block; padding: 14px 0 18px; text-decoration: none; color: var(--ink); }
.g-cards strong { display: block; font-size: 18px; line-height: 1.3; margin-bottom: 6px; text-wrap: balance; }
.g-cards span { display: block; color: var(--muted); font-size: 15px; }
.g-cards small { display: block; margin-top: 8px; color: var(--ledger-dk); font-weight: 600; font-size: 13px; }
.g-cards a:hover strong { text-decoration: underline; text-underline-offset: 4px; }
.g-all { margin-top: 8px; font-weight: 600; }
.g-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.g-links a { font-weight: 600; }
@media (max-width: 860px) { .g-sheet .pd-doc { zoom: .5; } .g-body { font-size: 17px; } }
@media (max-width: 480px) { .g-sheet .pd-doc { zoom: .4; } }
html[lang="ar"] .g-body, html[lang="hi"] .g-body { line-height: 1.85; }
/* keep article typography out of the embedded sample document */
.g-sheet .pd-doc h3 { font-size: 11px; margin: 0 0 4px; line-height: 1.3; }
.g-sheet .pd-doc p { margin: 0; }

/* ===== Feedback ===== */
.fb-card { position: fixed; z-index: 50; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); inset-inline-end: 16px; width: min(360px, calc(100vw - 32px));
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 10px 40px rgba(22,34,46,.18); padding: 16px 18px; }
.fb-card .fb-x { position: absolute; top: 8px; inset-inline-end: 8px; }
.fb-card .fb-body { padding-inline-end: 24px; }
@media (prefers-reduced-motion: no-preference) {
  .fb-card { animation: fbIn .35s cubic-bezier(.2,.8,.2,1) both; }
  .fb-card.fb-out { animation: fbOut .25s ease-in both; }
  @keyframes fbIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  @keyframes fbOut { to { opacity: 0; transform: translateY(16px); } }
}
.fb-q { font-weight: 600; margin: 0 0 10px; line-height: 1.4; }
.fb-votes { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-votes .btn { min-width: 84px; justify-content: center; }
.fb-form { display: grid; gap: 8px; }
.fb-form textarea, .fb-form input { font-size: 15px; }
.fb-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.fb-row small { color: var(--muted); font-size: 13px; }
.fb-done { color: var(--ledger-dk); font-weight: 600; margin: 0; }
.fb-err { color: var(--danger); margin: 0; }
.fb-hp { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; inset-inline-start: -9999px; }
.fb-inline { max-width: 68ch; margin: 32px 0 8px; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); }
.fb-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; align-items: start; padding-bottom: 40px; }
.fb-pform { max-width: none; }
.fb-changes h2 { font-size: 18px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.fb-changes ul { list-style: none; padding: 0; margin: 0; }
.fb-changes li { padding: 12px 0 12px 22px; border-bottom: 1px solid var(--rule); position: relative; color: var(--ink); }
[dir="rtl"] .fb-changes li { padding: 12px 22px 12px 0; }
.fb-changes li::before { content: ""; position: absolute; inset-inline-start: 0; top: 19px; width: 10px; height: 10px; border-radius: 50%; background: var(--ledger); }
.foot-fb { font-weight: 600; color: var(--ledger-dk) !important; }
@media (max-width: 800px) { .fb-grid { grid-template-columns: 1fr; } }

/* ===== Clear / restore ===== */
.btn-clear svg { flex: none; }
.f-restored { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; background: #fff8dc; border: 1px solid #ecd98a; border-radius: var(--r-md); padding: 10px 12px 10px 16px; margin-bottom: 12px; font-size: 14.5px; }
[dir="rtl"] .f-restored { padding: 10px 16px 10px 12px; }
.f-restored span { flex: 1 1 200px; }
.f-restored .btn-link { margin: 0; font-weight: 600; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast-act { background: none; border: 0; color: var(--mark); font: 700 15px var(--font); cursor: pointer; padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
.toast.show { pointer-events: auto; }

/* ===== Generator page content ===== */
.inc-list, .mis-list { padding-inline-start: 1.2em; }
.inc-list li, .mis-list li { margin-bottom: .55em; }
.mis-list li::marker { color: var(--danger); }
.tpl-link { margin-top: 1.4em; padding: 12px 16px; background: var(--sheet); border: 1px dashed var(--rule); border-radius: var(--r-sm); }
.tpl-home p { color: var(--muted); max-width: 70ch; margin-bottom: 18px; }

/* ===== Template pages ===== */
.tpl-app { display: grid; gap: 14px; }
.tpl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; }
.tpl-paper { display: inline-flex; align-items: center; gap: 8px; }
.tpl-paper .f-lab { margin: 0; white-space: nowrap; }
.tpl-paper select { padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sheet); font: 500 15px var(--font); color: var(--ink); }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-stage { max-width: 820px; }
.tpl-checks { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 20px; }
.tpl-checks li { position: relative; padding-inline-start: 28px; margin: 0; }
.tpl-checks li::before { content: ""; position: absolute; inset-inline-start: 0; top: 4px; width: 16px; height: 16px; border-radius: 4px; background: var(--ledger); }
.tpl-checks li::after { content: ""; position: absolute; inset-inline-start: 5px; top: 6px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tpl-cta { background: var(--sheet); border: 1px solid var(--rule) !important; border-radius: var(--r); padding: 28px; margin: 24px 0; }
.tpl-cta p { color: var(--muted); }

/* blank printable template: writing lines */
.pd-doc .d-ln { display: block; min-height: 20px; border-bottom: 1px solid #b8c0c8; margin-top: 4px; }
.pd-doc.blank .d-party { min-width: 46%; }
.pd-doc.blank .d-brand { flex: 1; } .pd-doc.blank .d-brand .d-party { max-width: 300px; }
.pd-doc.blank .d-meta dd { min-width: 130px; } .pd-doc.blank .d-meta dd .d-ln { margin-top: 0; min-height: 18px; }
.pd-doc.blank .d-items td { height: 30px; }
.pd-doc.blank .d-totals td { min-width: 120px; border-bottom: 1px solid #b8c0c8; }
.pd-doc.blank .d-notes > div { margin-bottom: 10px; }
.tpl-modern.blank .d-head .d-ln { border-color: rgba(255, 255, 255, .55); }

/* ===== Ad slots: fixed reserved height, clearly labelled, away from buttons ===== */
.ad-slot { margin: 32px auto; min-height: 280px; text-align: center; }
.ad-label { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
@media (max-width: 700px) { .ad-slot { min-height: 250px; margin: 24px auto; } }
.tpl-app > * { min-width: 0; }
.tpl-bar .seg { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 480px) { .tpl-bar .seg label { padding: 8px 11px; font-size: 14px; } }
.tpl-cta .btn, .tpl-actions .btn { white-space: normal; text-align: center; max-width: 100%; }
