:root {
  /* Warm, friendly palette: cream canvas, periwinkle primary, midnight ink */
  --bg: #fef9ed; --panel: #fff; --ink: #1c1f58; --muted: #56596c; --faint: #9b9caa;
  --line: #ededf5; --line2: #c4c5cf; --soft: #f6f4ee;
  --accent: #545bfe; --accent-dark: #383ca3; --accent-soft: #f1f1ff; --accent-ring: #a3acff;
  --ok: #01744e; --ok-soft: #edfaf4; --warn: #8a5a00; --warn-soft: #fdf3d2; --bad: #b83646; --bad-soft: #fdeceb;
  --sun: #f6c91d; --lime: #aee865; --mint: #41d298; --coral: #fc6350;
  --radius: 16px; --shadow: 0 1px 2px rgba(28,31,88,.05), 0 6px 20px rgba(28,31,88,.06);
  --font: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.nav { background: #0f172a; color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 2px 10px 18px; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: 13px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: inherit; text-decoration: none; white-space: nowrap; }
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: #1e293b; color: #fff; font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav .grow { flex: 1; }
.nav .note { font-size: 11px; color: #64748b; padding: 8px 10px; }
main { min-width: 0; padding: 24px 28px 48px; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .brand, .nav .grow, .nav .note { display: none; }
  main { padding: 16px; }
}

/* ---------- common ---------- */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 700; flex: 1; min-width: 160px; }
.sub-head { color: var(--muted); margin: -10px 0 18px; }
.btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line2); background: #fff; color: var(--ink); cursor: pointer; box-shadow: 0 1px 2px rgba(16,24,40,.05); text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.ent-card { display: flex; flex-direction: column; gap: 4px; }
.ent-card .t { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.ent-card .l { color: var(--muted); font-size: 13px; }
.ent-card .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.empty { text-align: center; padding: 48px 20px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 auto 16px; max-width: 440px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.issued { background: var(--accent-soft); color: var(--accent); }
.pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.pill.green { background: var(--ok-soft); color: var(--ok); }
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.search { min-width: 200px; flex: 1; max-width: 320px; }

/* ---------- forms ---------- */
label.f, div.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; min-width: 0; }
.req { color: var(--bad); font-style: normal; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); padding: 7px 9px; border: 1px solid var(--line2); border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--accent); }
input[disabled] { background: var(--soft); color: var(--muted); }
textarea { resize: vertical; min-height: 60px; }
.f.invalid input, .f.invalid select, .f.invalid textarea { border-color: var(--bad); }
.f .hint { font-size: 12px; font-weight: 400; }
.hint.ok { color: var(--ok); } .hint.bad { color: var(--bad); } .hint.info { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg button { font: inherit; border: 0; border-right: 1px solid var(--line2); background: transparent; padding: 7px 13px; cursor: pointer; color: var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--ink); font-weight: 400; cursor: pointer; }
.check input { width: auto; margin-top: 3px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line2); border-radius: 9px; padding: 9px 11px; cursor: pointer; font-size: 13.5px; }
.radio-card input { width: auto; margin-top: 3px; }
.radio-card.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-card small { display: block; color: var(--muted); }
.code-picker { display: flex; flex-direction: column; gap: 6px; }
.img-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.img-field img { max-height: 44px; max-width: 160px; border: 1px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; }
.img-field input[type=file] { width: auto; border: 0; padding: 0; }
details.help { font-size: 12.5px; color: var(--muted); }
details.help summary { cursor: pointer; color: var(--accent); font-weight: 500; }
details.help p { margin: 6px 0 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.5); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; z-index: 50; }
.modal-card { background: #fff; border-radius: 14px; width: min(620px, 100%); box-shadow: 0 20px 50px rgba(16,24,40,.25); }
.modal-card.narrow { width: min(440px, 100%); }
.modal-card header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-card header h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-card footer { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fcfcfd; border-radius: 0 0 14px 14px; }
.form-err { color: var(--bad); font-size: 13px; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); background: #101828; color: #fff; padding: 10px 16px; border-radius: 9px; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; z-index: 70; font-weight: 500; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

/* ---------- invoice list ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 150px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fcfcfd; white-space: nowrap; }
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f9fafb; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- editor ---------- */
.ed-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ed-top h1 { font-size: 20px; margin-right: 4px; }
.ed-top select { width: auto; }
.editor { display: grid; grid-template-columns: minmax(360px, 470px) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1180px) { .editor { grid-template-columns: 1fr; } }
.sec { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.sec > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.sec > h3 .spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.pick { display: flex; gap: 6px; }
.pick select { flex: 1; }
.summary { font-size: 13px; color: var(--muted); white-space: pre-line; }
.line { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 8px; background: #fcfcfd; display: flex; flex-direction: column; gap: 8px; }
.line-head { display: flex; gap: 6px; align-items: center; }
.line-head .n { font-size: 12px; color: var(--faint); width: 16px; }
.line-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.line-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.checks li { padding: 7px 10px; border-radius: 8px; }
.checks li.err { background: var(--bad-soft); color: var(--bad); }
.checks li.warn { background: var(--warn-soft); color: var(--warn); }
.checks li.tip { background: var(--soft); color: var(--muted); }
.checks li.good { background: var(--ok-soft); color: var(--ok); }
.preview-col { position: sticky; top: 16px; min-width: 0; }
.sheet-wrap { overflow-x: auto; border-radius: 4px; }
.preview-note { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 8px; }

/* ---------- invoice sheet (A4) ---------- */
.sheet { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 13mm 13mm 12mm; box-shadow: 0 4px 18px rgba(16,24,40,.14); font-size: 9.6pt; line-height: 1.4; color: #111; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
.sheet .pre { white-space: pre-line; }
.s-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 8px; }
.s-head .left { display: flex; gap: 12px; align-items: center; }
.s-head img.logo { max-height: 15mm; max-width: 40mm; }
.s-head h2 { font-size: 19pt; letter-spacing: .4px; }
.s-head .sub { font-size: 8.5pt; color: #444; text-transform: uppercase; letter-spacing: .6px; }
.s-copy { font-size: 8pt; border: 1px solid #111; padding: 2px 6px; white-space: nowrap; }
.s-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; margin-top: 10px; }
.s-box h4 { margin: 0 0 3px; font-size: 7.8pt; text-transform: uppercase; color: #555; letter-spacing: .5px; }
.s-box .name { font-weight: 700; font-size: 11pt; }
.s-meta { width: 100%; border-collapse: collapse; }
.s-meta td { padding: 1.5px 0; vertical-align: top; }
.s-meta td:first-child { color: #555; width: 42%; padding-right: 6px; }
table.s-items { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 9pt; }
table.s-items th { background: #f1f1f1; text-align: left; font-size: 7.8pt; text-transform: uppercase; letter-spacing: .3px; }
table.s-items th, table.s-items td { border: 1px solid #bbb; padding: 4.5px 5px; vertical-align: top; }
.s-items .r, .s-totals .r { text-align: right; white-space: nowrap; }
.s-totals { margin-left: auto; width: 60%; border-collapse: collapse; margin-top: 6px; font-size: 9.2pt; }
.s-totals td { padding: 2.5px 5px; }
.s-totals tr.grand td { border-top: 2px solid #111; font-weight: 700; font-size: 10.5pt; padding-top: 4px; }
.s-totals tr.inr td { color: #444; font-size: 8.6pt; }
.s-words { margin-top: 8px; }
.s-endorse { margin-top: 10px; border: 1.5px solid #111; padding: 6px 9px; font-weight: 700; font-size: 9pt; text-align: center; }
.s-lut { text-align: center; font-size: 8.6pt; margin-top: 3px; }
.s-extra { margin-top: 10px; font-size: 8.8pt; }
.s-foot { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-top: 14px; font-size: 8.8pt; break-inside: avoid; }
.s-foot h4 { margin: 0 0 3px; font-size: 7.8pt; text-transform: uppercase; color: #555; letter-spacing: .5px; }
.s-bank td { padding: 0 8px 0 0; vertical-align: top; }
.s-bank td:first-child { color: #555; }
.s-sign { text-align: right; }
.s-sign img { max-height: 16mm; max-width: 55mm; display: block; margin: 5px 0 4px auto; }
.s-sign .space { height: 16mm; }

@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .nav, .ed-top, .ed-form, .preview-note, .toast, .modal { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  .editor { display: block; }
  .preview-col { position: static; }
  .sheet-wrap { overflow: visible; }
  .sheet { box-shadow: none; margin: 0; min-height: auto; zoom: 1 !important; }
}

/* ---------- design controls ---------- */
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tpl-pick button { font: inherit; font-size: 12.5px; border: 1px solid var(--line2); background: #fff; border-radius: 9px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; align-items: stretch; color: var(--ink); }
.tpl-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.tpl-mini { height: 54px; border-radius: 5px; border: 1px solid var(--line); background: #fff; position: relative; overflow: hidden; }
.tpl-mini i { position: absolute; display: block; background: #d0d5dd; border-radius: 2px; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line2); cursor: pointer; padding: 0; }
.swatches button.on { box-shadow: 0 0 0 2px var(--ink); }
.swatches input[type=color] { width: 34px; height: 28px; padding: 0 2px; border-radius: 6px; cursor: pointer; }
.show-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
@media (max-width: 520px) { .show-grid { grid-template-columns: 1fr; } }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 22px; }
.gal-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.gal-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.3); }
.gal-thumb { height: 300px; overflow: hidden; background: #eef0f3; padding: 10px 10px 0; }
.gal-thumb .sheet { box-shadow: 0 2px 8px rgba(0,0,0,.12); pointer-events: none; }
.gal-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.gal-body .t { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.gal-body p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.design-layout { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1100px) { .design-layout { grid-template-columns: 1fr; } }

/* ---------- sheet: shared design knobs ---------- */
.sheet { --accent: #2563eb; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet.paper-letter { width: 215.9mm; min-height: 279.4mm; }
.sheet.font-serif { font-family: Georgia, "Times New Roman", serif; }
.sheet.font-humanist { font-family: Optima, Candara, "Gill Sans", "Segoe UI", sans-serif; }
.sheet.dens-compact { font-size: 8.7pt; }
.sheet.dens-compact table.s-items th, .sheet.dens-compact table.s-items td { padding: 3px 5px; }
.sheet.dens-roomy { font-size: 10.3pt; }
.sheet.dens-roomy table.s-items th, .sheet.dens-roomy table.s-items td { padding: 7px 7px; }
.s-head .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.s-head img.logo.logo-s { max-height: 10mm; max-width: 30mm; }
.s-head img.logo.logo-m { max-height: 15mm; max-width: 42mm; }
.s-head img.logo.logo-l { max-height: 22mm; max-width: 60mm; }
.s-terms { margin-top: 12px; font-size: 8.5pt; color: #333; }
.s-terms h4 { margin: 0 0 2px; font-size: 7.8pt; text-transform: uppercase; color: #555; letter-spacing: .5px; }
.s-footer { margin-top: 12px; text-align: center; font-size: 9pt; color: #444; }

/* Modern */
.sheet.tpl-modern .s-head { background: var(--accent); color: #fff; margin: -13mm -13mm 0; padding: 11mm 13mm 8mm; border-bottom: 0; }
.sheet.tpl-modern .s-head .sub { color: rgba(255,255,255,.85); }
.sheet.tpl-modern .s-copy { border-color: rgba(255,255,255,.8); color: #fff; }
.sheet.tpl-modern .s-head img.logo { background: #fff; padding: 2mm; border-radius: 2mm; }
.sheet.tpl-modern .s-box h4, .sheet.tpl-modern .s-foot h4, .sheet.tpl-modern .s-terms h4 { color: var(--accent); }
.sheet.tpl-modern table.s-items th { background: var(--accent); color: #fff; border-color: var(--accent); }
.sheet.tpl-modern table.s-items td { border-color: #ddd; }
.sheet.tpl-modern .s-totals tr.grand td { border-top-color: var(--accent); color: var(--accent); }
.sheet.tpl-modern .s-endorse { border-color: var(--accent); color: var(--accent); }

/* Minimal */
.sheet.tpl-minimal .s-head { border-bottom: 1px solid #ddd; padding-bottom: 12px; }
.sheet.tpl-minimal .s-head h2 { font-weight: 500; letter-spacing: 3px; font-size: 16pt; color: var(--accent); }
.sheet.tpl-minimal .s-copy { border: 0; color: #888; padding: 0; }
.sheet.tpl-minimal .s-grid { margin-top: 16px; }
.sheet.tpl-minimal table.s-items { margin-top: 18px; }
.sheet.tpl-minimal table.s-items th { background: none; color: #888; border: 0; border-bottom: 1px solid #ccc; }
.sheet.tpl-minimal table.s-items td { border: 0; border-bottom: 1px solid #eee; }
.sheet.tpl-minimal .s-totals tr.grand td { border-top: 1px solid #ccc; color: var(--accent); }
.sheet.tpl-minimal .s-endorse { border: 0; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; font-weight: 600; letter-spacing: .3px; }

/* GST Boxed */
.sheet.tpl-boxed .s-head { border: 1px solid #222; padding: 6px 8px; justify-content: center; text-align: center; position: relative; }
.sheet.tpl-boxed .s-head .left { flex-direction: column; gap: 4px; }
.sheet.tpl-boxed .s-head .right { position: absolute; right: 8px; top: 6px; }
.sheet.tpl-boxed .s-head .right img.logo { display: none; }
.sheet.tpl-boxed .s-grid { margin: 0; gap: 0; border: 1px solid #222; border-top: 0; }
.sheet.tpl-boxed .s-grid > * { padding: 6px 8px; }
.sheet.tpl-boxed .s-grid > * + * { border-left: 1px solid #222; }
.sheet.tpl-boxed table.s-items { margin-top: 0; }
.sheet.tpl-boxed table.s-items th, .sheet.tpl-boxed table.s-items td { border-color: #222; }
.sheet.tpl-boxed table.s-items th { background: #f3f3f3; }
.sheet.tpl-boxed .s-totals { width: 100%; margin: 0; border: 1px solid #222; border-top: 0; }
.sheet.tpl-boxed .s-totals td:first-child { text-align: right; width: 75%; }
.sheet.tpl-boxed .s-totals tr.grand td { border-top: 1px solid #222; }
.sheet.tpl-boxed .s-words, .sheet.tpl-boxed .s-endorse, .sheet.tpl-boxed .s-lut, .sheet.tpl-boxed .s-extra, .sheet.tpl-boxed .s-terms { margin: 0; border: 1px solid #222; border-top: 0; padding: 5px 8px; }
.sheet.tpl-boxed .s-foot { margin: 0; border: 1px solid #222; border-top: 0; padding: 6px 8px; gap: 0; }
.sheet.tpl-boxed .s-footer { margin-top: 8px; }

/* Bold */
.sheet.tpl-bold .s-head { border-bottom: 5px solid var(--accent); padding-bottom: 10px; }
.sheet.tpl-bold .s-head h2 { font-size: 27pt; font-weight: 800; color: var(--accent); letter-spacing: -.5px; }
.sheet.tpl-bold .s-copy { background: var(--accent); color: #fff; border-color: var(--accent); }
.sheet.tpl-bold .s-box h4, .sheet.tpl-bold .s-foot h4, .sheet.tpl-bold .s-terms h4 { color: var(--accent); }
.sheet.tpl-bold table.s-items th { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, white); }
.sheet.tpl-bold table.s-items td { border-color: #e2e2e2; }
.sheet.tpl-bold .s-totals tr.grand td { background: var(--accent); color: #fff; border-top: 0; padding: 6px 7px; }
.sheet.tpl-bold .s-endorse { border-color: var(--accent); }


/* =====================================================================
   App theme: warm cream canvas, pill buttons, soft rounded cards
   ===================================================================== */
body { font-family: var(--font); font-size: 14.5px; }
.page-head h1, .ed-top h1, .empty h2, .brand { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; font-variation-settings: "SOFT" 100, "WONK" 0; }
.page-head h1 { font-size: 30px; }
.ed-top h1 { font-size: 24px; }
.sub-head { font-size: 15px; }

/* sidebar */
.nav { background: var(--ink); color: #c9caf0; }
.brand { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand-mark { background: var(--sun); color: var(--ink); border-radius: 50%; width: 30px; height: 30px; font-family: var(--font); font-weight: 800; font-size: 15px; }
.nav a { border-radius: 100px; padding: 9px 14px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav .note { color: #8f91c7; }
.nav .note::before { content: "✦ "; color: var(--sun); }

/* buttons */
.btn { border-radius: 100px; padding: 8px 18px; font-weight: 600; border-color: var(--line2); box-shadow: none; transition: background .15s, transform .05s, box-shadow .15s; }
.btn:hover { background: var(--accent-soft); border-color: var(--accent-ring); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-dark); }
.btn.primary:hover { background: #474ef0; }
.btn.sm { padding: 5px 13px; }
.btn.ghost { border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #e48585; }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); box-shadow: 0 2px 0 #912333; }
.link { color: var(--accent); font-weight: 600; }

/* cards & sections */
.card, .sec, .stat, .table-wrap, .gal-card { border-radius: var(--radius); border-color: #efe9da; box-shadow: var(--shadow); }
.sec > h3, .group-title { color: var(--accent-dark); letter-spacing: .06em; }
.stat { padding: 14px 18px; }
.stat .v { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.empty { padding: 56px 24px; }
.empty h2 { font-size: 24px; }
.empty h2::after { content: " ✦"; color: var(--sun); }
.line { border-radius: 12px; background: #fdfcf8; border-color: #efe9da; }

/* forms */
input, select, textarea { border-radius: 10px; border-color: var(--line2); padding: 8px 11px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 3px 1px var(--accent-ring); }
.seg { border-radius: 100px; padding: 3px; gap: 2px; background: var(--soft); border-color: #e6e0cf; }
.seg button { border: 0 !important; border-radius: 100px; padding: 6px 14px; font-weight: 500; }
.seg button.on { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(28,31,88,.2); }
.radio-card { border-radius: 12px; }
.radio-card.on { border-color: var(--accent); background: var(--accent-soft); }
.check input, .radio-card input { accent-color: var(--accent); }

/* pills & status */
.pill { background: #f2efe6; color: var(--muted); }
.pill.issued, .pill.blue { background: var(--accent-soft); color: var(--accent-dark); }
.pill.paid, .pill.green { background: var(--ok-soft); color: var(--ok); }
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.checks li { border-radius: 10px; }

/* tables */
table.list th { background: #fdfbf5; color: var(--muted); }
table.list tbody tr:hover { background: #faf8ff; }

/* modal & toast */
.modal { background: rgba(28,31,88,.45); }
.modal-card { border-radius: 22px; }
.modal-card header h3 { font-family: var(--display); font-weight: 600; font-size: 20px; }
.modal-card footer { background: #fdfbf5; border-radius: 0 0 22px 22px; }
.toast { background: var(--ink); border-radius: 100px; padding: 11px 20px; }
.toast.bad { background: var(--bad); }

/* templates */
.tpl-pick button { border-radius: 12px; }
.tpl-pick button.on, .gal-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.gal-thumb { background: #f4efe1; }
.preview-note { color: var(--muted); }
.preview-note::before { content: "✦"; color: var(--sun); }

/* templates page */
.tpl-page { display: grid; grid-template-columns: minmax(340px, 470px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .tpl-page { grid-template-columns: 1fr; } }
.tpl-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tpl-card { font: inherit; color: var(--ink); text-align: left; padding: 0; background: #fff; border: 2px solid #efe9da; border-radius: 14px; overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.tpl-card:hover, .tpl-card:focus-visible { border-color: var(--accent-ring); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(28,31,88,.10); outline: none; }
.tpl-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tpl-card .thumb { height: 170px; overflow: hidden; background: #f4efe1; padding: 8px 8px 0; }
.tpl-card .thumb .sheet { box-shadow: 0 2px 8px rgba(0,0,0,.12); pointer-events: none; }
.tpl-card .meta { display: flex; align-items: center; gap: 8px; padding: 9px 11px; font-weight: 600; font-size: 14px; }
.tpl-card .meta .pill { margin-left: auto; }
.tpl-card .radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line2); flex: none; }
.tpl-card.on .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, #fff 50%); }
.seg { flex-wrap: nowrap; }
.seg button { white-space: nowrap; }

/* colour on every template (black keeps Classic/Boxed black and white) */
.sheet.tpl-classic .s-head { border-bottom-color: var(--accent); }
.sheet.tpl-classic .s-head h2 { color: var(--accent); }
.sheet.tpl-classic .s-box h4, .sheet.tpl-classic .s-foot h4, .sheet.tpl-classic .s-terms h4 { color: var(--accent); }
.sheet.tpl-classic .s-totals tr.grand td { border-top-color: var(--accent); }
.sheet.tpl-boxed .s-head h2 { color: var(--accent); }
.sheet.tpl-boxed table.s-items th { background: color-mix(in srgb, var(--accent) 10%, white); }
.sheet.tpl-boxed .s-box h4, .sheet.tpl-boxed .s-foot h4, .sheet.tpl-boxed .s-terms h4 { color: var(--accent); }

/* ---------- enhancements: invoice extras ---------- */
.sheet { position: relative; }
.s-stamp { position: absolute; top: 58mm; right: 18mm; transform: rotate(-12deg); border: 3px solid; border-radius: 6px; padding: 1.5mm 5mm; font-weight: 800; font-size: 22pt; letter-spacing: 3px; text-align: center; pointer-events: none; line-height: 1.1; z-index: 2; }
.s-stamp small { display: block; font-size: 8pt; letter-spacing: 1px; font-weight: 700; }
.s-stamp.paid { color: #067647; border-color: #067647; opacity: .85; }
.s-stamp.draft { color: #98a2b3; border-color: #98a2b3; opacity: .55; }
table.s-hsn { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 8.4pt; }
table.s-hsn th { background: #f3f3f3; text-align: left; font-size: 7.5pt; text-transform: uppercase; letter-spacing: .3px; }
table.s-hsn th, table.s-hsn td { border: 1px solid #ccc; padding: 3px 5px; }
table.s-hsn .r { text-align: right; white-space: nowrap; }
table.s-hsn .rt { color: #666; font-size: 7.4pt; }
.sheet.tpl-minimal table.s-hsn th, .sheet.tpl-minimal table.s-hsn td { border: 0; border-bottom: 1px solid #e5e5e5; }
.sheet.tpl-modern table.s-hsn th { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); }
.sheet.tpl-boxed table.s-hsn { margin: 0; }
.sheet.tpl-boxed table.s-hsn th, .sheet.tpl-boxed table.s-hsn td { border-color: #222; }
.s-upi { display: flex; gap: 10px; align-items: center; margin-top: 8px; font-size: 8.6pt; }
.s-upi svg { width: 23mm; height: 23mm; flex: none; }

/* ---------- enhancements: app UI ---------- */
.f > .seg { align-self: flex-start; max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12.5px; border: 1px solid var(--line2); background: #fff; border-radius: 100px; padding: 4px 11px; cursor: pointer; color: var(--ink); }
.chip:hover { background: var(--accent-soft); border-color: var(--accent-ring); }
.cf-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.ship-box { border: 1px dashed var(--line2); border-radius: 12px; padding: 10px; background: #fdfcf8; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.ent-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ent-card:hover { border-color: var(--accent-ring); }
.ent-card .acts .btn { padding: 4px 11px; }
.img-field img { order: -1; }

/* ---------- responsive fixes ---------- */
@media (max-width: 1180px) { .editor { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) {
  .tpl-page, .design-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
}
@media (max-width: 700px) {
  .page-head h1 { flex-basis: 100%; font-size: 26px; }
  .filters .search { flex: 1 1 100%; max-width: none; }
  .filters select { flex: 1; }
  .stats { gap: 8px; }
  .stat { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 10px 12px; }
  .stat .v { font-size: 17px; }
  table.list thead { display: none; }
  table.list, table.list tbody { display: block; }
  table.list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.list tr:last-child { border-bottom: 0; }
  table.list td { padding: 0; border: 0; }
  table.list .c-num { grid-row: 1; grid-column: 1; }
  table.list .c-total { grid-row: 1; grid-column: 2; font-weight: 700; }
  table.list .c-client { grid-row: 2; grid-column: 1; }
  table.list .c-status { grid-row: 2; grid-column: 2; text-align: right; }
  table.list .c-date { grid-row: 3; grid-column: 1; font-size: 12.5px; color: var(--muted); }
  table.list .c-type { grid-row: 3; grid-column: 2; text-align: right; }
  table.list .c-biz { display: none; }
  .ed-top h1 { font-size: 20px; flex-basis: 100%; order: -1; }
  .tpl-cards { gap: 8px; }
  .tpl-card .thumb { height: 120px; }
  .modal { padding: 12px 8px; }
  .modal-body { padding: 14px; }
  .modal-card header, .modal-card footer { padding: 12px 14px; }
  .cf-row { grid-template-columns: 1fr 1fr auto; }
}

/* ---------- onboarding wizard ---------- */
body.onboarding .nav { display: none; }
body.onboarding .app { grid-template-columns: 1fr; }
.ob { max-width: 580px; margin: 5vh auto 40px; }
.ob-top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; min-height: 36px; }
.ob-brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 600; font-size: 18px; white-space: nowrap; }
.ob-progress { flex: 1; height: 7px; background: #ece6d6; border-radius: 100px; overflow: hidden; min-width: 60px; }
.ob-progress i { display: block; height: 100%; background: var(--accent); border-radius: 100px; transition: width .3s ease; }
.ob-step { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.ob-card { background: #fff; border-radius: 24px; padding: 34px 34px 28px; box-shadow: 0 1px 2px rgba(28,31,88,.05), 0 16px 40px rgba(28,31,88,.08); border: 1px solid #efe9da; }
.ob-card h1 { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -.01em; }
.ob-card .lead { color: var(--muted); font-size: 15.5px; margin: 0 0 22px; }
.ob-card input.big { font-size: 18px; padding: 13px 15px; border-radius: 12px; }
.ob-card .hint { display: block; margin-top: 8px; font-size: 13px; }
.ob-emoji { font-size: 34px; color: var(--sun); line-height: 1; margin-bottom: 14px; }
.ob-actions { display: flex; align-items: center; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.ob-choice { display: grid; gap: 10px; }
.ob-choice .radio-card { font: inherit; text-align: left; background: #fff; width: 100%; padding: 13px 14px; color: var(--ink); }
.ob-choice .radio-card .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line2); flex: none; margin-top: 2px; }
.ob-choice .radio-card.on .dot { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, #fff 50%); }
.ob-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.ob-logo img { max-height: 80px; max-width: 260px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.ob-logo-empty { width: 260px; height: 80px; border: 2px dashed var(--line2); border-radius: 12px; display: grid; place-items: center; color: var(--faint); }
.ob-tpl { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.ob-tpl .tpl-mini { height: 70px; }
.ob-later { background: var(--soft); border-radius: 14px; padding: 12px 16px; }
.ob-later ul { margin: 6px 0 6px; padding-left: 18px; }
.ob-restore { margin: 18px 0 0; text-align: center; }
@media (max-width: 600px) {
  .ob { margin-top: 12px; }
  .ob-card { padding: 24px 18px 20px; border-radius: 20px; }
  .ob-card h1 { font-size: 25px; }
  .ob-top { flex-wrap: wrap; gap: 8px 12px; }
  .ob-progress { order: 3; flex-basis: 100%; }
}

/* =====================================================================
   Production polish: form controls, focus, banners
   ===================================================================== */
input, select, textarea { min-height: 40px; border: 1px solid #d5d6e0; border-radius: 10px; background-color: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 72px; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #a9abbd; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(84,91,254,.18); }
input::placeholder, textarea::placeholder { color: #a3a4b3; opacity: 1; }
input[disabled], select[disabled], textarea[disabled] { background: #f6f6f9; color: var(--muted); cursor: not-allowed; }
select { -webkit-appearance: none; appearance: none; padding-right: 38px; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2356596c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
select:hover { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%231c1f58' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); }
select::-ms-expand { display: none; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=date] { cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: .9; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; min-height: 0; padding: 0; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex: none; box-shadow: none; }
input[type=color] { min-height: 0; padding: 2px; }
input[type=file] { min-height: 0; }
label.f > span:first-child, div.f > span:first-child { color: #3c3e53; font-weight: 600; font-size: 12.5px; }
.btn { min-height: 38px; justify-content: center; }
.btn.sm { min-height: 32px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:where(button, a, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.tpl-card:focus-visible, .seg button:focus-visible { outline-offset: -2px; }
details > summary { list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; flex: none; }
details[open] > summary::before { transform: rotate(45deg); }
details.help > summary::before { width: 6px; height: 6px; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff8e1; border: 1px solid #f3dc8a; border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; }
.banner-ico { font-size: 22px; line-height: 1; }
.banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1 1 260px; }
.banner-text span { color: var(--muted); font-size: 13px; }
.banner .spacer { display: none; }
.ok-text { color: var(--ok); font-weight: 600; }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.nav-install { font: inherit; font-weight: 600; margin: 0 2px 8px; padding: 9px 14px; border-radius: 100px; border: 1px solid rgba(255,255,255,.22); background: transparent; color: #fff; cursor: pointer; text-align: left; }
.nav-install:hover { background: rgba(255,255,255,.08); }
.nav { scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
@media (max-width: 860px) { .nav-install { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.code-picker .hint { font-size: 12.5px; color: var(--muted); }

/* ---------- returns, notes, help ---------- */
.rsec > summary { cursor: pointer; flex-wrap: wrap; }
.rs-title { font-weight: 700; }
.rs-sub { flex-basis: 100%; padding-left: 22px; font-weight: 400; }
.rs-body { margin-top: 12px; }
.table-wrap.rt { box-shadow: none; border-radius: 10px; }
table.rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rtable th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fdfbf5; white-space: nowrap; }
table.rtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.rtable tfoot td { background: #fdfbf5; border-bottom: 0; }
table.rtable .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.note-sec { border-color: #f3dc8a; background: #fffdf5; }
.s-stamp.cancelled { color: #b42318; border-color: #b42318; opacity: .8; }
.faq details { margin-bottom: 10px; }
.faq summary { cursor: pointer; }
.faq-a { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.snap { padding: 4px 0; border-bottom: 1px solid var(--line); }
.code-search-link { align-self: flex-start; }
@media (max-width: 700px) { .grid2[style*="repeat(3"] { grid-template-columns: 1fr !important; } }
.s-stamp { top: 96mm; right: 20mm; }

/* ---------- customer-walkthrough fixes ---------- */
.ob-trust { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13.5px; color: var(--ink); }
.ob-trust li::before { content: "✓"; color: var(--ok); font-weight: 800; margin-right: 8px; }
@media (max-width: 600px) { .ob-trust { grid-template-columns: 1fr; } }
.ob-preview { margin-top: 14px; height: 300px; overflow: hidden; border-radius: 12px; background: #f4efe1; padding: 10px 10px 0; position: relative; }
.ob-preview::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: linear-gradient(rgba(244,239,225,0), #f4efe1); }
.ob-preview .sheet { box-shadow: 0 2px 10px rgba(0,0,0,.12); pointer-events: none; }
.add-first { align-self: flex-start; border-style: dashed; border-color: var(--accent-ring); color: var(--accent-dark); background: var(--accent-soft); }
.checks li.todo { background: var(--accent-soft); color: var(--accent-dark); }
.checks li.todo::before { content: "○ "; }
.sac-sug { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f1fbe9; border: 1px solid #c2f680; border-radius: 10px; padding: 7px 10px; font-size: 12.5px; color: #3c3e53; }
/* stamps become a faint diagonal watermark that never hides text */
.s-stamp { top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%) rotate(-24deg); font-size: 64pt; border-width: 6px; border-radius: 14px; padding: 1mm 8mm; letter-spacing: 6px; }
.s-stamp small { font-size: 14pt; letter-spacing: 2px; }
.s-stamp.paid { opacity: .13; }
.s-stamp.cancelled { opacity: .15; }
.s-stamp.draft { opacity: .07; color: #1c1f58; border-color: #1c1f58; }
.ob-preview { padding: 10px 0 0; }
.ob-preview .sheet { margin: 0 auto; }
.ob-card h1, .page-head h1, .empty h2 { text-wrap: balance; }
.ob-trust li { display: flex; gap: 8px; align-items: baseline; }
.ob-trust li::before { margin-right: 0; flex: none; }

/* ---------- legal links ---------- */
.nav .legal-links { padding-top: 0; }
.nav .legal-links a { color: #8f91c7; }
.nav .legal-links::before { content: none !important; }
.nav .legal-links { line-height: 1.7; }
.nav .legal-links { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 11.5px; padding: 2px 10px 6px; }
.nav .legal-links a { display: inline; padding: 0; border-radius: 0; background: none; color: #8f91c7; font-weight: 400; white-space: nowrap; }
.nav .legal-links a:hover { background: none; color: #fff; text-decoration: underline; }
.snap { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.snap .snap-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.snap .snap-text b { font-weight: 600; color: var(--ink); }
.snap .snap-text span { color: var(--muted); font-size: 12.5px; }
.snap .btn { flex: none; }

/* =====================================================================
   Navigation (standard app layout)
   ===================================================================== */
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
#view:focus { outline: none; }
.nav { gap: 3px; padding: 14px 12px; overflow-y: auto; }
.nav a, .nav button { font: inherit; }
.nav > a span, .nav-install span { overflow: hidden; text-overflow: ellipsis; }
.biz-switch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin-bottom: 8px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #fff; cursor: pointer; text-align: left; min-height: 56px; }
.biz-switch:hover { background: rgba(255,255,255,.1); }
.bz-logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.bz-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.bz-ini { font-weight: 800; color: var(--ink); font-size: 16px; }
.bz-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.bz-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bz-text small { color: #9b9dd1; font-size: 11.5px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bz-chev { color: #9b9dd1; font-size: 12px; }
.btn-new { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 100px; border: 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; box-shadow: 0 2px 0 #383ca3; margin-bottom: 6px; }
.btn-new:hover { background: #474ef0; }
.btn-new svg, .nav-search svg, .nav-collapse svg { width: 17px; height: 17px; flex: none; }
.nav-search { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 100px; border: 1px solid rgba(255,255,255,.14); background: transparent; color: #c9caf0; cursor: pointer; margin-bottom: 10px; text-align: left; }
.nav-search:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-search span { flex: 1; }
.nav-search kbd { font: 600 10.5px var(--font); color: #9b9dd1; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 1px 6px; }
.nav-group { padding: 16px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8f91c7; font-weight: 700; }
.nav-collapse { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 100px; border: 0; background: transparent; color: #8f91c7; cursor: pointer; margin-top: 2px; text-align: left; }
.nav-collapse:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav .note, .nav .legal-links { display: none !important; }

/* collapsed sidebar: icons only */
body.nav-collapsed .app { grid-template-columns: 76px 1fr; }
body.nav-collapsed .nav { padding: 14px 10px; align-items: center; }
body.nav-collapsed .nav > a, body.nav-collapsed .nav-collapse, body.nav-collapsed .nav-search, body.nav-collapsed .btn-new { justify-content: center; padding: 10px; width: 48px; }
body.nav-collapsed .nav > a span, body.nav-collapsed .nav-search span, body.nav-collapsed .nav-search kbd, body.nav-collapsed .btn-new span,
body.nav-collapsed .nav-collapse span, body.nav-collapsed .bz-text, body.nav-collapsed .bz-chev, body.nav-collapsed .nav-group span { display: none; }
body.nav-collapsed .nav-group { padding: 10px 0 0; width: 32px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 8px; }
body.nav-collapsed .biz-switch { width: 52px; padding: 7px; justify-content: center; }
body.nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
body.nav-collapsed .nav-install { width: 48px; padding: 9px 0; text-align: center; font-size: 0; }
body.nav-collapsed .nav-install::first-letter { font-size: 16px; }

/* menus & sheets */
.menu-back { position: fixed; inset: 0; z-index: 55; }
.menu-back.dim { background: rgba(28,31,88,.45); }
.menu { position: fixed; z-index: 56; min-width: 250px; max-width: 320px; background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(16,24,40,.22), 0 0 0 1px rgba(16,24,40,.06); padding: 6px; color: var(--ink); }
.menu.menu-sheet { width: auto; min-height: 0; top: auto; max-height: 85vh; overflow-y: auto; left: 0; right: 0; bottom: 0; max-width: none; border-radius: 22px 22px 0 0; padding: 8px 10px calc(14px + env(safe-area-inset-bottom)); animation: sheetUp .18s ease-out; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.menu-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 8px 10px 6px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); min-height: 40px; }
.menu.menu-sheet .menu-item { min-height: 50px; font-size: 15.5px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-item.active { font-weight: 700; }
.mi-ic { width: 26px; height: 26px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; color: var(--accent-dark); font-weight: 700; flex: none; font-size: 13px; }
.mi-label { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mi-label small { color: var(--muted); font-size: 12px; font-weight: 400; }
.mi-check { color: var(--accent); font-weight: 800; }
kbd { font: 600 11px var(--font); background: var(--soft); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--muted); }

/* search palette */
.modal-card.pal-card { width: min(620px, 100%); }
.pal input[type=search] { border: 0; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; font-size: 17px; padding: 18px 20px; min-height: 60px; box-shadow: none !important; }
.pal-list { max-height: min(60vh, 440px); overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.pal-item.on { background: var(--accent-soft); }
.pk { flex: none; width: 64px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.pt { display: flex; flex-direction: column; min-width: 0; }
.pt small { color: var(--muted); font-size: 12.5px; }
.pal-empty { padding: 12px 14px; margin: 0; }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: #fdfbf5; border-radius: 0 0 22px 22px; }
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.kbd-table td:first-child { white-space: nowrap; width: 45%; }

/* editor header: breadcrumb, unsaved marker, sticky bar */
.crumbs { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span { color: var(--faint); }
.ed-top { position: sticky; top: 0; z-index: 20; background: rgba(254,249,237,.94); backdrop-filter: blur(8px); margin: -24px -28px 16px; padding: 14px 28px; border-bottom: 1px solid var(--line); }

/* toast with action */
.toast { display: flex; align-items: center; gap: 14px; }
.toast.has-action { pointer-events: auto; }
.toast-btn { font: inherit; font-weight: 700; color: var(--sun); background: none; border: 0; cursor: pointer; padding: 2px 4px; }

/* phone: top bar + bottom tab bar */
.m-top, .m-tabs { display: none; }
@media (max-width: 860px) {
  .nav { display: none !important; }
  .app { grid-template-columns: 1fr !important; grid-template-rows: auto 1fr; align-content: start; }
  .m-top { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; background: var(--ink); padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .m-top .biz-switch { margin: 0; min-height: 48px; flex: 1; min-width: 0; }
  .icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
  .icon-btn svg { width: 20px; height: 20px; }
  .m-tabs { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(28,31,88,.06); }
  .m-tabs a, .m-tabs button:not(.m-new) { display: flex; flex-direction: column; align-items: center; gap: 2px; font: 600 11px var(--font); color: var(--muted); text-decoration: none; background: none; border: 0; padding: 6px 0; cursor: pointer; min-height: 48px; justify-content: center; }
  .m-tabs svg { width: 22px; height: 22px; }
  .m-tabs .active { color: var(--accent); }
  .m-new { justify-self: center; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(84,91,254,.45); transform: translateY(-14px); cursor: pointer; }
  .m-new svg { width: 26px; height: 26px; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .ed-top { margin: -16px -16px 12px; padding: 10px 16px; top: 64px; }
  body.onboarding .m-top, body.onboarding .m-tabs { display: none !important; }
}
@media print { .m-top, .m-tabs, .skip { display: none !important; } .ed-top { position: static; } }
#view h1:focus, #view h1:focus-visible { outline: none; }

/* phone polish: no iOS zoom on focus, comfortable tap targets */
@media (max-width: 860px) {
  input, select, textarea { font-size: 16px !important; }
  .link.small { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 0; }
  .seg button { min-height: 38px; }
}
@media (max-width: 860px) { .swatches { gap: 10px; } .swatches button { width: 34px; height: 34px; } .swatches input[type=color] { height: 34px; } }
@media (max-width: 860px) { .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .seg::-webkit-scrollbar { display: none; } .seg button { white-space: nowrap; flex: none; } }

/* phone: app-like editor and forms */
.ed-cta { display: contents; }
@media (max-width: 860px) {
  /* Editor: actions live in a bottom bar instead of the tab bar */
  body.editing .m-tabs { display: none; }
  body.editing .ed-cta { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(28,31,88,.08); }
  body.editing .ed-cta > .btn, body.editing .ed-cta [data-actions] { flex: 1; }
  body.editing .ed-cta [data-actions] .btn { flex: 1; }
  body.editing .ed-cta .btn { min-height: 46px; justify-content: center; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  body.editing main { padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important; }
  body.editing .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .sec { padding: 14px; border-radius: 16px; }
  /* Forms open as a full-screen sheet with Save always visible */
  .modal { padding: 0; align-items: stretch; }
  .modal-card:not(.narrow):not(.pal-card) { width: 100%; min-height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-card:not(.narrow):not(.pal-card) header { position: sticky; top: 0; z-index: 2; background: #fff; padding-top: calc(12px + env(safe-area-inset-top)); }
  .modal-card:not(.narrow):not(.pal-card) .modal-body { flex: 1; }
  .modal-card:not(.narrow):not(.pal-card) footer { position: sticky; bottom: 0; z-index: 2; border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-card:not(.narrow):not(.pal-card) footer .btn { min-height: 46px; }
  .modal-card.narrow { margin: auto 12px; }
  .modal:has(.modal-card.narrow), .modal:has(.pal-card) { padding: 16px 12px; align-items: center; }
}
@media (max-width: 860px) {
  body.editing .ed-cta > [data-print] { flex: .8; }
  body.editing .ed-cta .btn { font-size: 15px; }
}
@media (max-width: 860px) {
  body.editing .ed-top { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg, #fef9ed); }
  body.editing .ed-cta [data-actions] { flex-wrap: nowrap; }
  .modal-body .link { display: inline-flex; align-items: center; min-height: 36px; }
}
/* Keyboard hints only make sense with a keyboard */
@media (hover: none), (max-width: 860px) { .pal-foot { display: none !important; } }
/* phone editor bar: every button the same width (2 or 3 buttons) */
@media (max-width: 860px) {
  body.editing .ed-cta { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
  body.editing .ed-cta [data-actions] { display: contents; }
  body.editing .ed-cta > [data-print], body.editing .ed-cta .btn { flex: none; width: 100%; min-width: 0; padding-left: 6px; padding-right: 6px; }
}
@media (max-width: 860px) {
  /* full-screen form: grow with its content instead of stopping at screen height */
  .modal { align-items: flex-start; }
  .modal-card:not(.narrow):not(.pal-card) { min-height: 100%; height: auto; }
  /* "See preview" shortcut in the editor */
  .pv-jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 39; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 100px; padding: 9px 16px; background: var(--ink); color: #fff; font: 600 14px var(--font); box-shadow: 0 8px 20px rgba(28,31,88,.25); cursor: pointer; transition: opacity .2s, transform .2s; }
  .pv-jump[hidden] { display: inline-flex; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); }
}
@media (min-width: 861px) { .pv-jump { display: none; } }

/* Quick start: name + GSTIN asked right on the first invoice */
.sec.quick-biz { border: 1.5px solid var(--accent-ring); border-radius: 14px; padding: 14px; background: var(--accent-soft); }
