/* =========================================================
   OasisInvoice — site theme (dark default, light alt)
   ========================================================= */
:root {
  --bg: #0a0b14;
  --bg2: #10121f;
  --card: rgba(22, 25, 44, .72);
  --card-solid: #161a2c;
  --line: rgba(148, 163, 255, .14);
  --line2: rgba(148, 163, 255, .26);
  --text: #e8eaf7;
  --muted: #9aa0c3;
  --field: rgba(10, 12, 24, .7);
  --a1: #8b5cf6;
  --a2: #22d3ee;
  --a3: #ec4899;
  --danger: #f87171;
  --ok: #34d399;
  --grad: linear-gradient(120deg, var(--a1), var(--a2));
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6);
  --r: 16px;
  --focus: 0 0 0 3px rgba(139, 92, 246, .45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6fc;
  --bg2: #ffffff;
  --card: rgba(255, 255, 255, .82);
  --card-solid: #ffffff;
  --line: rgba(76, 81, 140, .14);
  --line2: rgba(76, 81, 140, .26);
  --text: #141631;
  --muted: #5b6087;
  --field: #ffffff;
  --a1: #7c3aed;
  --a2: #0891b2;
  --shadow: 0 10px 40px -18px rgba(40, 40, 90, .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow-x: hidden; min-height: 100vh;
}
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -.02em; line-height: 1.15; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; }
.ta-r { text-align: right; }

/* background fx */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .45; animation: float 18s ease-in-out infinite alternate; }
.o1 { width: 520px; height: 520px; background: var(--a1); top: -160px; left: -120px; }
.o2 { width: 460px; height: 460px; background: var(--a2); top: 20%; right: -160px; animation-delay: -6s; opacity: .3; }
.o3 { width: 380px; height: 380px; background: var(--a3); bottom: -160px; left: 30%; animation-delay: -12s; opacity: .22; }
:root[data-theme="light"] .orb { opacity: .18; }
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%); opacity: .5;
}
@keyframes float { to { transform: translate(60px, 40px) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } html { scroll-behavior: auto; } }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 40; backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); background: color-mix(in srgb, var(--bg) 72%, transparent); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; font-family: "Space Grotesk"; font-weight: 700; box-shadow: 0 0 24px -4px var(--a1); }
.brand-name { font-family: "Space Grotesk"; font-size: 19px; }
.brand-name b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { white-space: nowrap; text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--line); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line2); background: var(--card); padding: 11px 18px; border-radius: 12px; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .15s, box-shadow .2s, background .2s, border-color .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); border-color: var(--a1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn-glow { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 30px -10px var(--a1); }
.btn-glow:hover { box-shadow: 0 10px 34px -8px var(--a1); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn.danger:hover, .mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn { position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); cursor: pointer; transition: border-color .2s, background .2s; flex: none; }
.icon-btn:hover { border-color: var(--a1); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; border-radius: 9px; background: var(--a3); color: #fff; display: grid; place-items: center; font-weight: 700; }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="light"]) .i-moon { display: none; }
:root[data-theme="light"] .i-sun { display: none; }
:root[data-theme="light"] .i-moon { display: block; }
.mini { border: 1px solid var(--line2); background: transparent; border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.mini:hover { border-color: var(--a1); }
.link { background: none; border: 0; padding: 0; color: var(--a2); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, label.upload-drop:focus-within { outline: none; box-shadow: var(--focus); }

/* hero */
.hero { text-align: center; padding: 72px 20px 40px; }
.pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line2); background: var(--card); padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.hero h1 { font-size: clamp(36px, 6vw, 68px); margin: 22px auto 18px; max-width: 900px; }
.grad { background: linear-gradient(110deg, var(--a1), var(--a2) 50%, var(--a3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); max-width: 720px; margin: 0 auto; }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.hero-stats { list-style: none; padding: 0; margin: 40px auto 0; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.hero-stats li { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 18px; min-width: 120px; }
.hero-stats b { display: block; font-family: "Space Grotesk"; font-size: 24px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow); }

/* smart fill */
.generator { padding-bottom: 40px; }
.smart { padding: 20px; position: relative; overflow: hidden; margin-bottom: 20px; }
.smart::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: linear-gradient(120deg, var(--a1), transparent 40%, var(--a2)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.smart-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.smart-title { display: flex; gap: 12px; align-items: center; }
.smart-title h2 { font-size: 20px; }
.smart-title p { margin: 2px 0 0; font-size: 13px; }
.spark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; color: #fff; font-size: 20px; box-shadow: 0 0 30px -6px var(--a1); }
.smart-meter { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { width: 140px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s; }
.smart-input { display: flex; gap: 10px; align-items: stretch; }
.smart-input textarea { flex: 1; resize: vertical; min-height: 52px; }
.smart-btns { display: flex; gap: 8px; align-items: flex-start; }
.smart-btns .btn { height: 40px; }
#sfMic.listening { border-color: var(--a3); color: var(--a3); box-shadow: 0 0 0 4px rgba(236, 72, 153, .2); animation: pulse 1.2s infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { border: 1px dashed var(--line2); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--a2); border-style: solid; }
.hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* generator layout */
.gen-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); gap: 20px; align-items: start; }
.form-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sec { padding: 18px 18px 20px; margin: 0; min-width: 0; }
.sec-h { display: flex; align-items: center; gap: 10px; font-family: "Space Grotesk"; font-weight: 600; font-size: 16px; padding: 0; margin-bottom: 14px; float: left; width: 100%; }
.sec > :not(.sec-h) { clear: both; }
.item-row > *, .item-row input, .item-row textarea { min-width: 0; }
.sec-h .num { font-size: 11px; padding: 3px 7px; border-radius: 6px; background: var(--grad); color: #fff; letter-spacing: .05em; }
.sec-total { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--a2); }
.g { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.uae-box { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--line2); border-radius: 12px; background: color-mix(in srgb, var(--a1) 6%, transparent); }
.uae-box .uae-toggle { margin: 0; align-items: flex-start; }
.uae-box .uae-toggle input { margin-top: 2px; flex: none; }
.uae-box #uaeFields { margin-top: 12px; }
.uae-box #uaeFields .check { margin: 0; }
.uae-box .hint { margin-top: 10px; }
.g-logo { grid-template-columns: 150px minmax(0, 1fr); margin-bottom: 12px; align-items: start; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
input:not([type=checkbox]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; background: var(--field); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 11px; min-height: 40px; transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--a1) 50%, var(--line2)); }
input:focus, select:focus, textarea:focus { border-color: var(--a1); }
input.invalid, textarea.invalid { border-color: var(--danger) !important; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0c3' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select option { background: var(--card-solid); color: var(--text); }
input[type=number] { font-variant-numeric: tabular-nums; }
.input-btn { display: flex; gap: 6px; }
.input-btn input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--a1); }

/* uploads */
.upload { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.upload-drop { width: 150px; height: 110px; border: 1.5px dashed var(--line2); border-radius: 12px; display: grid; place-items: center; cursor: pointer; overflow: hidden; background: var(--field); transition: border-color .2s; padding: 6px; }
.upload.small .upload-drop { width: 100%; height: 96px; }
.upload-drop:hover, .upload-drop.drag { border-color: var(--a2); }
.upload-drop img { max-height: 100%; max-width: 100%; object-fit: contain; }
.upload-ph { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.upload-ph svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.media-row { margin-top: 12px; }

/* items */
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 92px 64px 64px 96px 34px; gap: 8px; align-items: start; }
.items-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0 2px 8px; }
.items.no-disc .col-disc, .items-head.no-disc .col-disc, .items.no-tax .col-tax, .items-head.no-tax .col-tax { display: none; }
.items-head.no-disc.no-tax, .items.no-disc.no-tax .item-row { grid-template-columns: minmax(0, 1fr) 64px 92px 96px 34px; }
.items-head.no-disc:not(.no-tax), .items.no-disc:not(.no-tax) .item-row,
.items-head.no-tax:not(.no-disc), .items.no-tax:not(.no-disc) .item-row { grid-template-columns: minmax(0, 1fr) 64px 92px 64px 96px 34px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item-row { padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--field) 50%, transparent); animation: rowIn .25s ease; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } }
.item-row .desc { display: flex; flex-direction: column; gap: 6px; }
.item-row textarea { min-height: 40px; font-size: 13px; }
.item-row .details { min-height: 34px; font-size: 12px; color: var(--muted); }
.item-row input { padding: 9px 8px; }
.item-row .amt { padding-top: 10px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.item-row .rm { width: 34px; height: 40px; border-radius: 10px; }
.item-row .m-lbl { display: none; }
.add-item { margin-top: 12px; width: 100%; border-style: dashed; }
.summary { margin: 18px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-variant-numeric: tabular-nums; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-weight: 600; }
.summary .big { font-size: 18px; color: var(--text); font-weight: 700; padding-top: 6px; border-top: 1px solid var(--line); }
.summary .big + dd { font-size: 18px; padding-top: 6px; border-top: 1px solid var(--line); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-actions .lg { flex: 1; min-width: 240px; }

/* preview */
.preview-col { min-width: 0; }
.preview-sticky { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 12px; }
.preview-bar { padding: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.tpl-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tpl-tabs::-webkit-scrollbar { display: none; }
.tpl-tab { border: 1px solid transparent; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tpl-tab:hover { color: var(--text); }
.tpl-tab[aria-selected="true"] { color: var(--text); border-color: var(--line2); background: var(--line); }
.preview-actions { display: flex; gap: 6px; }
.paper-stage { border-radius: var(--r); border: 1px solid var(--line); background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 22px 22px; padding: 16px; overflow: hidden; max-height: calc(100vh - 170px); overflow-y: auto; }
.paper-sizer { margin: 0 auto; overflow: hidden; border-radius: 4px; box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .55); }
.paper-scale { transform-origin: top left; width: max-content; }

/* blocks */
.block { padding: 72px 20px 0; }
.block.narrow { max-width: 900px; }
.block-head { text-align: center; margin: 0 auto 32px; }
.block-head p { max-width: 720px; margin-left: auto; margin-right: auto; }
.block-head h2 { font-size: clamp(24px, calc(3.6vw - 4px), 40px); margin: 8px 0 10px; }
@media (min-width: 720px) { .block-head h2 { white-space: nowrap; } }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.feat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feat { padding: 22px; transition: transform .2s, border-color .2s; }
.feat:hover { transform: translateY(-3px); border-color: var(--line2); }
.fi { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--a1) 22%, transparent); border: 1px solid var(--line2); margin-bottom: 14px; }
.feat h3 { font-size: 18px; margin-bottom: 6px; }
.feat p { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.tpl-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tpl-card { padding: 12px; cursor: pointer; text-align: left; transition: transform .2s, border-color .2s; color: inherit; }
.tpl-card:hover { transform: translateY(-3px); border-color: var(--a1); }
.tpl-card.active { border-color: var(--a2); box-shadow: 0 0 0 1px var(--a2), var(--shadow); }
.tpl-thumb { height: 260px; overflow: hidden; border-radius: 10px; background: #fff; position: relative; }
.tpl-thumb > div { position: absolute; top: 0; left: 0; width: max-content; transform-origin: top left; pointer-events: none; }
.tpl-card { min-width: 0; width: 100%; }
.tpl-card h3 { font-size: 16px; margin: 12px 4px 2px; }
.tpl-card p { margin: 0 4px 4px; color: var(--muted); font-size: 13px; }
.doc-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.doc-card { padding: 16px; text-align: left; cursor: pointer; color: inherit; transition: border-color .2s, transform .2s; }
.doc-card:hover { border-color: var(--a2); transform: translateY(-2px); }
.doc-card b { display: block; font-family: "Space Grotesk"; font-size: 15px; margin-bottom: 4px; }
.doc-card span { font-size: 13px; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.steps li { padding: 22px; }
.steps b { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; margin-bottom: 14px; font-family: "Space Grotesk"; }
.steps h3 { font-size: 17px; margin-bottom: 6px; }
.steps p { margin: 0; color: var(--muted); font-size: 14px; }
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq details { padding: 0; }
.faq summary { padding: 16px 18px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; border-radius: var(--r); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--a2); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0; padding: 0 18px 16px; color: var(--muted); }
.footer { margin-top: 80px; border-top: 1px solid var(--line); padding: 36px 0; }
.foot-in { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.foot-in p { margin: 0; }

/* drawers / modal */
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-bg { position: absolute; inset: 0; background: rgba(5, 6, 14, .6); backdrop-filter: blur(4px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--card-solid); border-left: 1px solid var(--line2); display: flex; flex-direction: column; animation: slide .25s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 20px; }
.drawer-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal .modal-panel { position: relative; margin: 8vh auto 0; width: min(620px, calc(100% - 32px)); padding: 0 18px 18px; background: var(--card-solid); animation: fade .2s; }
.modal .drawer-head { padding: 16px 0; }
#sigCanvas { width: 100%; height: auto; aspect-ratio: 560 / 200; background: #fff; border-radius: 12px; touch-action: none; cursor: crosshair; margin: 10px 0 12px; display: block; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tpl-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl-pick button { border: 1px solid var(--line2); background: var(--field); border-radius: 10px; padding: 10px 6px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tpl-pick button[aria-pressed="true"] { border-color: var(--a2); box-shadow: 0 0 0 1px var(--a2); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.color-row { display: flex; gap: 8px; margin-top: 8px; }
.color-row input[type=color] { width: 48px; height: 40px; border: 1px solid var(--line2); border-radius: 10px; background: var(--field); padding: 3px; cursor: pointer; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggles label { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.toggles input { accent-color: var(--a1); width: 16px; height: 16px; }
.saved-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.saved-list li { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.saved-list .meta { min-width: 0; }
.saved-list .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-list .meta span { font-size: 12px; color: var(--muted); }
.saved-list .acts { display: flex; gap: 6px; flex: none; }
.saved-empty { color: var(--muted); text-align: center; padding: 30px 0; border: 1px dashed var(--line2) !important; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast { pointer-events: auto; background: var(--card-solid); border: 1px solid var(--line2); border-left: 3px solid var(--a2); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: toastIn .25s ease; width: 100%; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
#pdfHost { position: fixed; left: 0; top: 0; width: 0; height: 0; overflow: hidden; z-index: -10; pointer-events: none; }

/* responsive */
@media (max-width: 1180px) {
  .gen-grid { grid-template-columns: 1fr; }
  .preview-sticky { position: static; }
  .paper-stage { max-height: none; }
  .doc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.icon-btn.menu-btn { display: none; }
@media (max-width: 1120px) {
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--card-solid); border-bottom: 1px solid var(--line); padding: 10px 16px; margin: 0; }
  .nav.open { display: flex; }
  .icon-btn.menu-btn { display: inline-grid; }
}
@media (max-width: 960px) {
  .feat-grid, .tpl-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .hide-sm { display: none; }
  .hero { padding: 44px 16px 28px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .g-logo { grid-template-columns: 1fr; }
  .smart-input { flex-direction: column; }
  .smart-btns { justify-content: flex-end; }
  .meter { width: 90px; }
  .items-head { display: none; }
  #items .item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-row .desc { grid-column: 1 / -1; }
  .item-row .m-lbl { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; font-weight: 600; }
  .item-row .amt { text-align: left; padding-top: 0; }
  .item-row .rm { width: 100%; }
  .feat-grid, .tpl-gallery, .steps { grid-template-columns: minmax(0, 1fr); }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-bar { flex-direction: column; align-items: stretch; }
  .preview-actions { justify-content: stretch; }
  .preview-actions .btn { flex: 1; }
  .paper-stage { padding: 8px; }
  .form-actions .btn { flex: 1; }
  .toggles { grid-template-columns: 1fr; }
}

/* =========================================================
   Invoice document (paper) — always light, print-accurate
   ========================================================= */
.inv {
  --accent: #7c3aed; --accent2: #06b6d4; --ink: #1d2033; --soft: #6b7089; --rule: #e6e8f0; --tint: #f6f7fb;
  width: 794px; min-height: 1123px; background: #fff; color: var(--ink); font-family: var(--inv-font, Inter), Inter, Arial, sans-serif;
  font-size: 13px; line-height: 1.5; position: relative; display: flex; flex-direction: column; text-align: left;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.inv.letter { width: 816px; min-height: 1056px; }
.inv * { box-sizing: border-box; }
.inv .pad { padding: 48px 52px; }
.inv h1 { font-family: inherit; font-size: 34px; letter-spacing: .02em; margin: 0; line-height: 1.1; font-weight: 800; color: var(--accent); }
.inv .logo { max-width: 180px; max-height: 80px; object-fit: contain; display: block; }
.inv .biz-name { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.inv .small { font-size: 12px; color: var(--soft); }
.inv .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--soft); font-weight: 700; margin-bottom: 4px; }
.inv .row { display: flex; gap: 24px; }
.inv .between { justify-content: space-between; }
.inv .meta-tbl { border-collapse: collapse; font-size: 12.5px; }
.inv .meta-tbl td { padding: 3px 0; vertical-align: top; }
.inv .meta-tbl td:first-child { color: var(--soft); padding-right: 18px; white-space: nowrap; }
.inv .meta-tbl td:last-child { text-align: right; font-weight: 600; }
.inv .parties { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 24px; margin: 30px 0; }
.inv .party { font-size: 12.5px; overflow-wrap: anywhere; }
.inv .party b { font-size: 14px; display: block; margin-bottom: 2px; }
.inv table.lines { width: 100%; border-collapse: collapse; margin-top: 6px; table-layout: fixed; }
.inv .lines th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 10px 10px; color: #fff; background: var(--accent); font-weight: 700; }
.inv .lines th.r, .inv .lines td.r { text-align: right; }
.inv .lines td { padding: 11px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.inv .lines tr { page-break-inside: avoid; break-inside: avoid; }
.inv .lines .d-det { font-size: 11.5px; color: var(--soft); margin-top: 2px; white-space: pre-line; }
.inv .lines .no { color: var(--soft); width: 34px; }
.inv .empty-row td { color: var(--soft); text-align: center; font-style: italic; padding: 22px; }
.inv .bottom { display: flex; justify-content: space-between; gap: 30px; margin-top: 22px; align-items: flex-start; }
.inv .totals { width: 290px; flex: none; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.inv .totals td { padding: 6px 0; }
.inv .totals td:last-child { text-align: right; font-weight: 600; }
.inv .totals .grand td { font-size: 15px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 10px; }
.inv .totals .bal td { background: var(--accent); color: #fff; padding: 10px 12px; font-weight: 800; font-size: 15px; }
.inv .totals .bal td:first-child { border-radius: 6px 0 0 6px; }
.inv .totals .bal td:last-child { border-radius: 0 6px 6px 0; }
.inv .totals .aed td { font-size: 12px; color: var(--soft); padding: 3px 0; }
.inv .blk.rc { border-left: 3px solid var(--accent); padding: 6px 10px; background: var(--tint); font-weight: 600; font-size: 12px; }
.inv .left-notes { flex: 1; min-width: 0; font-size: 12px; display: flex; flex-direction: column; gap: 14px; overflow-wrap: anywhere; }
.inv .left-notes .blk div:last-child { white-space: pre-line; }
.inv .qr { width: 96px; height: 96px; object-fit: contain; }
.inv .foot { margin-top: auto; }
.inv .sign { text-align: center; min-width: 190px; }
.inv .sign img { max-width: 190px; max-height: 70px; object-fit: contain; display: block; margin: 0 auto 4px; }
.inv .sign .ln { border-top: 1px solid var(--ink); padding-top: 4px; font-size: 11.5px; color: var(--soft); }
.inv .foot-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 28px; }
.inv .thanks { font-size: 12px; color: var(--soft); }
.inv .status { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .12em; padding: 4px 10px; border-radius: 99px; border: 1.5px solid currentColor; color: #10b981; margin-top: 8px; }
.inv .status.due { color: var(--accent); }

/* --- Aurora (AI gradient) --- */
.inv.t-aurora .hero-band { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #fff; padding: 40px 52px 34px; position: relative; overflow: hidden; }
.inv.t-aurora .hero-band::after { content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .14); }
.inv.t-aurora .hero-band h1 { color: #fff; }
.inv.t-aurora .hero-band .small, .inv.t-aurora .hero-band .meta-tbl td:first-child { color: rgba(255, 255, 255, .8); }
.inv.t-aurora .hero-band .logo { background: #fff; padding: 6px; border-radius: 8px; }
.inv.t-aurora .lines th { background: var(--tint); color: var(--accent); border-bottom: 2px solid var(--accent); }
.inv.t-aurora .totals .bal td { background: linear-gradient(120deg, var(--accent), var(--accent2)); }

/* --- Classic --- */
.inv.t-classic { font-family: var(--inv-font, Merriweather), Georgia, serif; }
.inv.t-classic h1 { color: var(--ink); font-weight: 700; letter-spacing: .12em; font-size: 30px; }
.inv.t-classic .top-rule { height: 6px; background: var(--accent); }
.inv.t-classic .lines th { background: transparent; color: var(--ink); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.inv.t-classic .totals .bal td { background: transparent; color: var(--ink); border-top: 2px double var(--ink); border-bottom: 2px double var(--ink); border-radius: 0; }

/* --- Professional --- */
.inv.t-professional .pro-head { background: #1d2033; color: #fff; padding: 36px 52px; display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.inv.t-professional .pro-head h1 { color: #fff; }
.inv.t-professional .pro-head .small { color: #b9bdd4; }
.inv.t-professional .pro-head .logo { background: #fff; padding: 6px; border-radius: 6px; }
.inv.t-professional .accent-bar { height: 5px; background: var(--accent); }
.inv.t-professional .lines th { background: #1d2033; }
.inv.t-professional .lines tbody tr:nth-child(even) td { background: var(--tint); }

/* --- Minimal ledger --- */
.inv.t-minimal { font-family: var(--inv-font, "IBM Plex Mono"), "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; }
.inv.t-minimal h1 { color: var(--ink); font-weight: 600; font-size: 24px; text-transform: uppercase; letter-spacing: .3em; }
.inv.t-minimal .lines th { background: transparent; color: var(--soft); border-bottom: 1px dashed var(--ink); }
.inv.t-minimal .lines td { border-bottom: 1px dashed var(--rule); }
.inv.t-minimal .totals .grand td { border-top: 1px dashed var(--ink); }
.inv.t-minimal .totals .bal td { background: transparent; color: var(--accent); border-top: 1px dashed var(--ink); border-bottom: 1px dashed var(--ink); border-radius: 0; }
.inv.t-minimal .dot-accent { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 10px; vertical-align: middle; }

/* --- Sleek sidebar --- */
.inv.t-sidebar { flex-direction: row; }
.inv.t-sidebar .side { width: 232px; flex: none; background: var(--accent); color: #fff; padding: 44px 26px; display: flex; flex-direction: column; gap: 24px; overflow-wrap: anywhere; }
.inv.t-sidebar .side .lbl { color: rgba(255, 255, 255, .7); }
.inv.t-sidebar .side .small { color: rgba(255, 255, 255, .85); }
.inv.t-sidebar .side .logo { background: #fff; padding: 6px; border-radius: 8px; max-width: 170px; }
.inv.t-sidebar .main { flex: 1; min-width: 0; padding: 44px 40px; display: flex; flex-direction: column; }
.inv.t-sidebar .lines th { background: transparent; color: var(--accent); border-bottom: 2px solid var(--accent); }
.inv.t-sidebar .totals { width: 260px; }

/* --- Neon grid (bold) --- */
.inv.t-neon .neon-head { background: #0e1024; color: #fff; padding: 40px 52px; position: relative; overflow: hidden; }
.inv.t-neon .neon-head::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 26px 26px; }
.inv.t-neon .neon-head > * { position: relative; }
.inv.t-neon .neon-head h1 { color: #fff; font-size: 42px; text-shadow: 0 0 24px var(--accent); }
.inv.t-neon .neon-head .small, .inv.t-neon .neon-head .meta-tbl td:first-child { color: #aab0d6; }
.inv.t-neon .neon-head .logo { background: #fff; padding: 6px; border-radius: 8px; }
.inv.t-neon .neon-line { height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.inv.t-neon .lines th { background: #0e1024; }
.inv.t-neon .lines th:first-child { border-left: 4px solid var(--accent); }

/* pdf / print mode */
.inv.pdf { min-height: 1118px; }
.inv.letter.pdf { min-height: 1052px; }
@media print {
  @page { margin: 0; }
  body.printing > *:not(#printHost) { display: none !important; }
  body.printing { background: #fff !important; min-height: 0; }
  html { scroll-padding-top: 0; }
  .inv { min-height: 0; box-shadow: none; }
}
