/* Invoice Generator: same look as the irvinPH tool apps (Sound Mixer, Pixelate, QR Code, PDF Rebrander). */
:root {
  --ink-950: #040b16;
  --ink-900: #07111f;
  --ink-850: #0a1728;
  --ink-800: #0e1e33;
  --ink-700: #16283f;
  --brand-200: #a8e6ff;
  --brand-300: #6fd4ff;
  --brand-400: #3fbef7;
  --brand-500: #1fa3e6;
  --white: #fff;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --line: rgb(255 255 255 / .06);
  --line-2: rgb(255 255 255 / .1);
  --danger: #fda4af;
  font-family: "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--slate-300); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
::selection { background: rgb(63 190 247 / .3); }

.app-bg {
  background:
    radial-gradient(60rem 40rem at 72% -10%, rgb(30 110 190 / .22), transparent 65%),
    radial-gradient(50rem 35rem at 110% 110%, rgb(20 90 170 / .18), transparent 60%),
    radial-gradient(40rem 30rem at -10% 40%, rgb(20 70 140 / .12), transparent 60%),
    #050c18;
  background-attachment: fixed;
}
.preview-bg {
  background:
    radial-gradient(ellipse at 50% 35%, rgb(24 70 120 / .45), transparent 70%),
    #060f1c;
}

svg { width: 20px; height: 20px; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; }

kbd {
  display: inline-flex; min-width: 24px; align-items: center; justify-content: center;
  padding: 1px 6px; border-radius: 6px; border: 1px solid rgb(255 255 255 / .15);
  background: rgb(255 255 255 / .06); font: 700 11px/1.6 inherit; color: var(--slate-200);
}

/* ---------- Type ---------- */
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--brand-400); }
.sub-title { font-size: 19px; font-weight: 900; color: var(--white); letter-spacing: -.01em; }
.sec-title { font-size: 17px; font-weight: 900; color: var(--white); letter-spacing: -.01em; }
.sec-copy { margin: 2px 0 14px; font-size: 13.5px; line-height: 1.5; color: var(--slate-400); }

/* ---------- Buttons ---------- */
.btn-primary, .primary-btn, .btn-outline, .btn-ghost, .chip-btn, .tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; text-decoration: none; border: 0; white-space: nowrap;
  transition: filter .15s, background-color .15s, border-color .15s, opacity .15s, color .15s;
}
.btn-primary, .primary-btn {
  height: 48px; padding: 0 20px; border-radius: .75rem; font-size: 15px; color: var(--ink-950);
  background-image: linear-gradient(to right, var(--brand-300), var(--brand-400));
  box-shadow: 0 10px 24px -8px rgb(63 190 247 / .45);
}
.btn-primary:hover:not(:disabled), .primary-btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled, .primary-btn:disabled {
  color: var(--slate-400); background-image: none; background-color: rgb(71 85 105 / .45); box-shadow: none;
}
.btn-outline {
  height: 44px; padding: 0 18px; border-radius: .75rem; border: 1px solid var(--line-2);
  background: rgb(255 255 255 / .02); font-size: 15px; color: var(--slate-200);
}
.btn-outline:hover:not(:disabled) { border-color: rgb(255 255 255 / .2); background: rgb(255 255 255 / .06); }
.btn-outline svg { width: 18px; height: 18px; }
.btn-ghost {
  height: 40px; padding: 0 16px; gap: 8px; border-radius: .75rem; font-size: 14px; color: var(--brand-200);
  border: 1px solid rgb(63 190 247 / .4); background: rgb(63 190 247 / .1);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-400); background: rgb(63 190 247 / .2); }
.btn-ghost svg { width: 16px; height: 16px; }
.chip-btn {
  gap: 7px; height: 32px; padding: 0 12px; border-radius: .6rem; font-size: 13px; color: var(--slate-200);
  border: 1px solid var(--line-2); background: rgb(7 17 31 / .85);
}
.chip-btn:hover:not(:disabled) { border-color: rgb(255 255 255 / .25); background: var(--ink-800); }
.chip-btn svg { width: 15px; height: 15px; }
.tool-btn {
  width: 44px; height: 44px; border-radius: .75rem; color: var(--white);
  border: 1px solid var(--line-2); background: rgb(7 17 31 / .7);
}
.tool-btn:hover { border-color: var(--brand-400); color: var(--brand-300); }
.danger-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; background: none; border: 0; color: #fb7185; font-size: 14px; font-weight: 700; }
.danger-btn:hover { color: var(--danger); }
.danger-btn svg { width: 18px; height: 18px; }
.icon-del { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: .5rem; background: none; color: var(--slate-400); }
.icon-del:hover { color: #fb7185; background: rgb(251 113 133 / .1); }
.icon-del svg { width: 17px; height: 17px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  flex: none; width: 20rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 24px 24px;
  background: rgb(4 11 22 / .5); border-right: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .1) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; transition: opacity .2s; }
.brand:hover { opacity: .85; }
.brand-icon { width: 56px; height: 56px; object-fit: contain; }
.brand-logo { height: 60px; width: auto; }

.hero h1 { margin-top: 8px; font-size: 2rem; line-height: 1.12; font-weight: 900; letter-spacing: -.025em; color: var(--white); }
.hero h1 span { color: var(--brand-400); }
.hero-copy { margin-top: 12px; font-size: 14px; line-height: 1.6; color: var(--slate-400); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps button {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 12px; border: 0; border-radius: .75rem;
  background: none; text-align: left; transition: background .25s, box-shadow .25s;
}
.steps button:hover { background: rgb(255 255 255 / .04); }
.steps b { display: block; font-size: 15px; font-weight: 800; color: var(--white); }
.steps small { display: block; font-size: 13px; color: var(--slate-400); }
.step-num {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid rgb(255 255 255 / .25); color: var(--white); font-size: 14px; font-weight: 800;
}
.step-num svg { display: none; width: 16px; height: 16px; }
.steps li.is-active button { background-image: linear-gradient(to right, var(--brand-300), var(--brand-400)); box-shadow: 0 10px 15px -3px rgb(63 190 247 / .2); }
.steps li.is-active b { color: var(--ink-950); }
.steps li.is-active small { color: rgb(7 17 31 / .7); }
.steps li.is-active .step-num { border-color: transparent; background: var(--ink-900); color: var(--white); }
.steps li.is-done:not(.is-active) .step-num { border-color: var(--brand-400); background: rgb(63 190 247 / .15); color: var(--brand-300); }
.steps li.is-done:not(.is-active) .step-num span { display: none; }
.steps li.is-done:not(.is-active) .step-num svg { display: block; }

.card { border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07); background-color: rgb(10 23 40 / .6); }
.tip-card { display: flex; gap: 12px; padding: 16px; }
.tip-card > svg { width: 22px; height: 22px; color: var(--brand-400); margin-top: 1px; }
.tip-title { font-size: 14px; font-weight: 800; color: var(--brand-300); }
.tip-card p + p { margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--slate-400); }

.sidebar-bottom { margin-top: auto; }
.keys-card { padding: 14px 16px; }
.keys-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 800; color: var(--white); }
.keys-title svg { color: var(--brand-400); }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.key-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-300); }
.key-list li > span:last-child { display: inline-flex; gap: 4px; }

/* ---------- Workspace ---------- */
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 20px 20px 16px; }
.workspace-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-left: 6px; }
.page-title { font-size: 1.75rem; line-height: 1.2; font-weight: 900; letter-spacing: -.02em; color: var(--white); }
.draft-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--slate-300); }
.draft-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-400); box-shadow: 0 0 0 3px rgb(63 190 247 / .18); }
.draft-status.is-dirty i { background: #fbbf24; box-shadow: 0 0 0 3px rgb(251 191 36 / .18); }
.draft-status.is-saved i { background: #34d399; box-shadow: 0 0 0 3px rgb(52 211 153 / .18); }
.howto-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: .75rem;
  border: 1px solid rgb(63 190 247 / .4); background: rgb(7 17 31 / .6); color: var(--white); font-size: 14px; font-weight: 700;
  transition: border-color .15s, background .15s;
}
.howto-btn:hover { border-color: var(--brand-400); background: rgb(63 190 247 / .1); }
.howto-btn svg { width: 18px; height: 18px; }

.workspace-card { flex: 1; margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 40rem); background-color: rgb(7 17 31 / .4); }

/* ---------- Preview ---------- */
.stage { position: sticky; top: 0; align-self: start; height: 100vh; max-height: 100%; min-width: 0; display: flex; flex-direction: column; padding: 22px 24px 24px; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.stage-copy { margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--slate-400); }
.stage-tools { display: flex; gap: 8px; flex: none; }

.select-wrap { position: relative; display: flex; align-items: center; height: 44px; border: 1px solid var(--line-2); border-radius: .75rem; background: rgb(7 17 31 / .7); transition: border-color .15s; }
.select-wrap:focus-within, .select-wrap:hover { border-color: rgb(255 255 255 / .2); }
.select-wrap select {
  -webkit-appearance: none; appearance: none; width: 100%; height: 100%; padding: 0 36px 0 14px; border: 0; background: none;
  outline: none; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--white);
}
.select-wrap select option { background: var(--ink-850); color: var(--white); }
.select-wrap svg { position: absolute; right: 12px; width: 16px; height: 16px; color: var(--slate-300); pointer-events: none; }
.select-wrap.sm select { padding-right: 34px; font-size: 14px; }
.select-wrap.sm { min-width: 84px; }

.preview {
  position: relative; flex: 1; margin-top: 18px; min-height: 480px; padding: 24px; overflow: auto;
  border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07);
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .15) transparent;
}
.paper-wrap { position: relative; margin: 0 auto; }
.paper-wrap .paper { position: absolute; top: 0; left: 0; transform-origin: 0 0; box-shadow: 0 30px 60px -20px rgb(0 0 0 / .6), 0 0 0 1px rgb(0 0 0 / .05); }

/* ---------- Editor panel ---------- */
.panel { min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.panel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 14px 18px 0; border-bottom: 1px solid var(--line); }
.panel-tabs button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; border-radius: .6rem .6rem 0 0; background: none;
  color: var(--slate-400); font-size: 14.5px; font-weight: 700; transition: color .15s, background .15s;
}
.panel-tabs button svg { width: 18px; height: 18px; }
.panel-tabs button:hover { color: var(--white); }
.panel-tabs button[aria-selected="true"] { color: var(--brand-300); background: rgb(63 190 247 / .1); border-bottom-color: var(--brand-400); }

.pane { flex: 1; padding: 6px 24px 8px; }
.pane > section { padding: 20px 0 22px; }
.pane > section + section { border-top: 1px solid var(--line); }

.stack { display: grid; gap: 12px; align-content: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr .8fr 1fr 1fr; gap: 12px; }
.span-2 { grid-column: 1 / -1; }
.mt { margin-top: 12px; }

.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--slate-300); }
.field-label em { font-style: normal; color: var(--slate-500); font-weight: 500; }
.input-wrap { position: relative; display: flex; align-items: center; height: 44px; border: 1px solid var(--line-2); border-radius: .75rem; background: rgb(7 17 31 / .7); transition: border-color .15s; }
.input-wrap:focus-within { border-color: var(--brand-400); }
.input-wrap input, .input-wrap textarea {
  flex: 1; min-width: 0; width: 100%; padding: 0 12px; border: 0; background: none; outline: none;
  font-size: 15px; font-weight: 600; color: var(--white); font-variant-numeric: tabular-nums; color-scheme: dark;
}
.input-wrap input::placeholder, .input-wrap textarea::placeholder { color: var(--slate-500); font-weight: 500; }
.input-wrap input[type="number"] { -moz-appearance: textfield; }
.input-wrap input::-webkit-inner-spin-button { opacity: .35; }
.input-wrap input[type="date"]::-webkit-calendar-picker-indicator { opacity: .7; cursor: pointer; }
.input-wrap.area { height: auto; align-items: stretch; }
.input-wrap textarea { padding: 10px 12px; resize: vertical; min-height: 44px; line-height: 1.45; font-size: 14.5px; }

/* Logo dropzone */
.biz-grid { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 16px; }
.logo-drop {
  position: relative; display: grid; place-items: center; min-height: 128px; padding: 14px; cursor: pointer; text-align: center;
  border-radius: 1rem; border: 2px dashed rgb(63 190 247 / .45); background: rgb(63 190 247 / .02);
  transition: border-color .2s, background .2s;
}
.logo-drop:hover { border-color: rgb(63 190 247 / .8); background: rgb(63 190 247 / .05); }
.logo-drop.is-over { border-color: var(--brand-300); background: rgb(63 190 247 / .1); }
.logo-empty { display: flex; flex-direction: column; align-items: center; }
.logo-empty b { margin-top: 10px; font-size: 14px; font-weight: 800; color: var(--white); }
.logo-empty small { margin-top: 4px; font-size: 11.5px; line-height: 1.45; font-weight: 600; color: var(--slate-400); }
.drop-icon {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: .65rem; color: var(--ink-950);
  background-image: linear-gradient(to bottom, var(--brand-300), var(--brand-400)); box-shadow: 0 10px 15px -3px rgb(63 190 247 / .3);
}
.drop-icon svg { width: 20px; height: 20px; }
.logo-filled { display: none; width: 100%; height: 100%; }
.logo-drop.has-logo { border-style: solid; border-color: rgb(63 190 247 / .3); background: rgb(255 255 255 / .96); }
.logo-drop.has-logo .logo-empty { display: none; }
.logo-drop.has-logo .logo-filled { display: grid; place-items: center; }
.logo-filled img { max-width: 100%; max-height: 92px; object-fit: contain; }
.logo-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.logo-drop:hover .logo-actions, .logo-drop:focus-within .logo-actions { opacity: 1; }
.logo-actions .chip-btn { height: 28px; padding: 0 10px; font-size: 12px; }

/* Items */
.items { border: 1px solid var(--line); border-radius: .9rem; background: rgb(4 11 22 / .35); overflow: hidden; }
.items-head, .item-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 70px 104px 108px 34px; gap: 8px; align-items: center; }
.items-head { padding: 9px 10px; background: rgb(255 255 255 / .03); border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--slate-300); }
.items-head b { font-weight: 700; }
.items-list { list-style: none; margin: 0; padding: 4px 10px; }
.item-row { padding: 5px 0; }
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-num { text-align: center; font-size: 13px; font-weight: 700; color: var(--slate-400); font-variant-numeric: tabular-nums; }
.item-row .input-wrap { height: 38px; border-radius: .6rem; }
.item-row .input-wrap input { font-size: 14px; padding: 0 10px; }
.item-amount { text-align: right; font-size: 14px; font-weight: 700; color: var(--slate-200); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-r { text-align: right; }
.add-item { margin-top: 12px; }

.grid-totals { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 12px 16px; }

/* Panel footer */
.panel-foot {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-top: 1px solid var(--line); border-radius: 0 0 1rem 0;
  background: rgb(8 18 33 / .92); backdrop-filter: blur(8px);
}
.panel-foot .btn-primary { min-width: 12rem; }
.panel-foot .confirm { flex: 1 0 100%; }
.confirm {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; cursor: pointer;
  border-radius: .75rem; border: 1px solid rgb(255 255 255 / .07); background: rgb(255 255 255 / .02);
  font-size: 13px; line-height: 1.6; color: var(--slate-300); transition: border-color .15s, background .15s;
}
.confirm:hover { border-color: rgb(255 255 255 / .15); }
.confirm:has(:checked) { border-color: rgb(63 190 247 / .4); background: rgb(63 190 247 / .06); }
.confirm input { flex: none; width: 16px; height: 16px; margin: 3px 0 0; cursor: pointer; accent-color: var(--brand-400); }
.link { display: inline; padding: 0; border: 0; background: none; font-weight: 700; color: var(--brand-300); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--brand-200); }
.panel-foot .btn-primary svg { width: 19px; height: 19px; }
.panel-foot.flash .btn-primary { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 100% { box-shadow: 0 10px 24px -8px rgb(63 190 247 / .45); } 30% { box-shadow: 0 0 0 6px rgb(63 190 247 / .35), 0 10px 30px -4px rgb(63 190 247 / .7); } }

/* Design tab */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tpl-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: .9rem; border: 1px solid var(--line-2); background: rgb(255 255 255 / .02); cursor: pointer; transition: border-color .15s, background .15s; }
.tpl-card:hover { border-color: rgb(255 255 255 / .22); }
.tpl-card:has(:checked) { border-color: var(--brand-400); background: rgb(63 190 247 / .08); box-shadow: 0 0 0 1px var(--brand-400); }
.tpl-card:has(:focus-visible) { outline: 2px solid var(--brand-300); outline-offset: 2px; }
.tpl-card input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card b { margin-top: 8px; font-size: 14px; font-weight: 800; color: var(--white); }
.tpl-card small { font-size: 12px; color: var(--slate-400); line-height: 1.4; }
.tpl-thumb { --a: var(--brand-400); position: relative; display: block; aspect-ratio: 1 / 1.15; border-radius: .5rem; background: #fff; overflow: hidden; }
.tpl-thumb i { position: absolute; display: block; border-radius: 2px; }
.tpl-thumb .t-logo { left: 10%; top: 9%; width: 16%; height: 12%; background: var(--a); border-radius: 3px; }
.tpl-thumb .t-title { right: 10%; top: 11%; width: 34%; height: 7%; background: #0f172a; }
.tpl-thumb .t-band { left: 0; right: 0; top: 0; height: 26%; background: var(--a); border-radius: 0; }
.tpl-thumb .t-lines { left: 10%; top: 31%; width: 40%; height: 14%; background: repeating-linear-gradient(#cbd5e1 0 2px, transparent 2px 6px); }
.tpl-thumb .t-table { left: 10%; right: 10%; top: 52%; height: 22%; background: linear-gradient(var(--tbl-head, #e0f2fe) 0 22%, transparent 22%), repeating-linear-gradient(transparent 0 7px, #e2e8f0 7px 8px); }
.tpl-thumb .t-total { right: 10%; top: 79%; width: 38%; height: 8%; background: var(--tbl-head, #e0f2fe); }
.tpl-thumb--classic { --tbl-head: var(--a); }
.tpl-thumb--classic .t-lines { top: 34%; }
.tpl-thumb--minimal .t-title { left: 10%; right: auto; top: 10%; width: 30%; height: 6%; background: var(--a); }
.tpl-thumb--minimal .t-table { background: linear-gradient(#0f172a 0 2px, transparent 2px), repeating-linear-gradient(transparent 0 7px, #e2e8f0 7px 8px); }
.tpl-thumb--minimal .t-total { background: transparent; border-top: 2px solid #0f172a; border-radius: 0; height: 6%; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { position: relative; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .15); transition: transform .15s; }
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ink-900), 0 0 0 4px var(--white); }
.swatch[aria-checked="true"]::after { content: ""; position: absolute; inset: 0; background: center / 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.swatch-custom { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; font-weight: 700; color: var(--slate-200); cursor: pointer; }
.swatch-custom:hover { border-color: rgb(255 255 255 / .22); }
.swatch-custom input { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.swatch-custom input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-custom input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatch-custom input::-moz-color-swatch { border: 0; border-radius: 50%; }
.swatch-custom.is-on { border-color: var(--brand-400); color: var(--brand-300); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 12px; padding: 4px; border-radius: .75rem; background: rgb(255 255 255 / .03); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; height: 38px; border-radius: .5rem; font-size: 15px; font-weight: 600; color: var(--slate-300); cursor: pointer; transition: background .15s, color .15s; }
.seg span:hover { color: var(--white); }
.seg input:checked + span { background: rgb(63 190 247 / .15); color: var(--brand-300); box-shadow: inset 0 0 0 1px rgb(63 190 247 / .35); }
.seg input:focus-visible + span { outline: 2px solid var(--brand-300); }

.slider-field { display: grid; gap: 10px; margin-top: 12px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; }
.slider-top output { font-size: 14px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.range {
  --p: 0%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; margin: 0; border-radius: 999px; cursor: pointer; outline: none;
  background: linear-gradient(to right, var(--brand-400) var(--p), rgb(255 255 255 / .14) var(--p));
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-400); box-shadow: 0 0 0 4px rgb(63 190 247 / .2); }
.range::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-400); box-shadow: 0 0 0 4px rgb(63 190 247 / .2); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgb(63 190 247 / .35); }

.toggles { margin-top: 16px; display: grid; gap: 6px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; font-weight: 600; color: var(--slate-200); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 38px; height: 22px; flex: none; border-radius: 999px; background: rgb(255 255 255 / .14); transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cbd5e1; transition: transform .2s; }
.toggle input:checked + i { background: var(--brand-400); }
.toggle input:checked + i::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + i { outline: 2px solid var(--brand-300); outline-offset: 2px; }

.action-list { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.action-list .danger-btn { margin-left: auto; }

.credit { padding-top: 16px; text-align: center; font-size: 13px; color: var(--slate-500); display: grid; gap: 6px; }
.credit a { font-weight: 700; color: var(--brand-400); text-decoration: none; text-underline-offset: 4px; }
.credit a:hover { color: var(--brand-300); text-decoration: underline; }
.credit .link { font-weight: 600; color: var(--slate-400); }
.credit .link:hover { color: var(--white); }

/* ---------- Dialogs ---------- */
.modal {
  width: min(32rem, calc(100vw - 32px)); max-height: 90vh; overflow-y: auto; padding: 28px; border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07);
  background: var(--ink-900); color: var(--slate-300); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .5);
}
.modal::backdrop { background: rgb(4 11 22 / .8); backdrop-filter: blur(4px); }
.modal h2 { font-size: 1.5rem; font-weight: 900; letter-spacing: -.02em; color: var(--white); }
.modal .sub { margin-top: 6px; font-size: 15px; line-height: 1.6; color: var(--slate-300); }
.modal .icon-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: .5rem; background: none; color: var(--slate-300); }
.modal .icon-btn:hover { background: rgb(255 255 255 / .1); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal h3 { margin: 20px 0 8px; font-size: 15px; font-weight: 800; color: var(--white); }
.modal-copy { display: grid; gap: 12px; font-size: 14px; line-height: 1.6; color: var(--slate-300); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.modal-actions .btn-outline { height: 48px; }
.primary-btn.is-danger { color: var(--white); background-image: linear-gradient(to right, #f43f5e, #e11d48); box-shadow: 0 10px 24px -8px rgb(244 63 94 / .45); }
.howto-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.howto-steps li { display: flex; gap: 12px; font-size: 15px; line-height: 1.6; color: var(--slate-300); }
.howto-steps li > span { width: 24px; height: 24px; flex: none; margin-top: 2px; display: grid; place-items: center; border-radius: 50%; background: rgb(63 190 247 / .15); color: var(--brand-300); font-size: 12px; font-weight: 800; }
.howto-steps b { display: block; color: var(--white); }
.howto em, .howto-notes em { font-style: normal; font-weight: 700; color: var(--brand-300); }
.howto-notes { margin: 0; padding: 12px 12px 12px 30px; border-radius: .75rem; border: 1px solid rgb(63 190 247 / .2); background: rgb(63 190 247 / .06); font-size: 13px; line-height: 1.6; color: var(--slate-300); }
.howto-ok { width: 100%; margin-top: 20px; }

.busy { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 16px; background: rgb(4 11 22 / .75); backdrop-filter: blur(4px); color: var(--white); font-size: 15px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgb(255 255 255 / .15); border-top-color: var(--brand-400); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: .75rem;
  background: var(--ink-850); border: 1px solid var(--line-2); box-shadow: 0 12px 40px rgb(0 0 0 / .5);
  font-size: 14px; font-weight: 600; color: var(--white); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgb(251 113 133 / .6); }

#print-root { display: none; }

/* =====================================================================
   The invoice paper. Plain colours only (no color-mix), so html2canvas
   renders the PDF exactly like the preview.
   ===================================================================== */
.paper {
  --accent: #1fa3e6; --accent-tint: #e4f4fc; --accent-ink: #fff; --accent-dark: #0f6d9e;
  --ink: #0f1b33; --muted: #475569; --soft: #64748b; --rule: #e2e8f0;
  width: 794px; min-height: 1123px; display: flex; flex-direction: column; padding: 52px 56px 48px;
  background: #fff; color: var(--ink); font-size: 13.5px; line-height: 1.5; font-family: "Nunito Sans", sans-serif;
  -webkit-font-smoothing: antialiased; print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.paper * { box-sizing: border-box; }
.paper p { margin: 0; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.inv-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.inv-logo { display: block; width: auto; max-width: 260px; object-fit: contain; }
.inv-mono { display: grid; place-items: center; flex: none; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.inv-biz { font-size: 22px; line-height: 1.2; font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.inv-tag { margin-top: 2px; font-size: 15px; color: var(--soft); }
.inv-title { flex: none; max-width: 50%; text-align: right; font-size: 44px; line-height: 1; font-weight: 900; letter-spacing: -.01em; color: var(--ink); overflow-wrap: anywhere; }

.inv-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 30px; }
.inv-from { color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.inv-facts { flex: none; border-collapse: collapse; }
.inv-facts td { padding: 1px 0; }
.inv-facts td:first-child { padding-right: 36px; color: var(--muted); }
.inv-facts td:last-child { text-align: right; color: var(--ink); }
.inv-facts tr:first-child td:last-child { font-weight: 800; }

.inv-rule { height: 1px; margin: 26px 0 22px; background: var(--rule); }
.inv-label { font-size: 13px; font-weight: 800; color: var(--ink); }
.inv-client { margin-top: 2px; font-size: 17px; font-weight: 800; color: var(--ink); }
.inv-bill p:not(.inv-label):not(.inv-client) { white-space: pre-line; overflow-wrap: anywhere; }

.inv-items { width: 100%; margin-top: 22px; border-collapse: collapse; }
.inv-items th { padding: 11px 14px; background: var(--accent-tint); color: var(--ink); font-size: 13px; font-weight: 800; text-align: left; white-space: nowrap; }
.inv-items td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.inv-items .n { width: 44px; text-align: center; }
.inv-items .q { width: 70px; text-align: center; }
.inv-items .r, .inv-items .a { width: 130px; text-align: right; white-space: nowrap; }
.inv-items tr { break-inside: avoid; }
.inv-items .empty td { color: var(--soft); text-align: center; font-style: italic; }

.inv-totals { display: flex; justify-content: flex-end; margin-top: 18px; break-inside: avoid; }
.inv-totals table { width: 290px; border-collapse: collapse; }
.inv-totals td { padding: 4px 18px; }
.inv-totals td:last-child { text-align: right; white-space: nowrap; }
.inv-totals .tot td { padding: 13px 18px; background: var(--accent-tint); font-size: 17px; font-weight: 800; color: var(--ink); }
.inv-totals .tot td:first-child { border-radius: 6px 0 0 6px; }
.inv-totals .tot td:last-child { border-radius: 0 6px 6px 0; }
.inv-totals .gap td { padding: 3px; }

.inv-pay { margin-top: 30px; break-inside: avoid; }
.inv-pay p:last-child { margin-top: 3px; white-space: pre-line; color: var(--muted); overflow-wrap: anywhere; }
.inv-foot { margin-top: auto; padding-top: 34px; break-inside: avoid; }
.inv-foot .inv-rule { margin: 0 0 18px; }
.inv-notes { white-space: pre-line; color: var(--ink); overflow-wrap: anywhere; }
.inv-small { margin-top: 6px; font-size: 12px; color: var(--soft); white-space: pre-line; overflow-wrap: anywhere; }

/* Bold: colour band header */
.tpl-classic .inv-head { margin: -52px -56px 0; padding: 40px 56px 34px; background: var(--accent); align-items: center; }
.tpl-classic .inv-biz, .tpl-classic .inv-title { color: var(--accent-ink); }
.tpl-classic .inv-tag { color: var(--accent-ink); opacity: .82; }
.tpl-classic .inv-mono { background: var(--accent-ink); color: var(--accent); }
.tpl-classic .inv-logo-box { padding: 8px; border-radius: 10px; background: #fff; }
.tpl-classic .inv-items th { background: var(--accent); color: var(--accent-ink); }
.tpl-classic .inv-label { color: var(--accent-dark); text-transform: uppercase; letter-spacing: .1em; font-size: 11.5px; }
.tpl-classic .inv-totals .tot td { background: var(--accent); color: var(--accent-ink); }

/* Minimal: rules, accent title */
.tpl-minimal .inv-title { font-size: 30px; font-weight: 800; letter-spacing: .14em; color: var(--accent-dark); }
.tpl-minimal .inv-items th { background: none; border-bottom: 2px solid var(--ink); padding-left: 0; padding-right: 0; }
.tpl-minimal .inv-items td { padding-left: 0; padding-right: 0; }
.tpl-minimal .inv-items .n { text-align: left; }
.tpl-minimal .inv-label { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--soft); }
.tpl-minimal .inv-totals td { padding-left: 0; padding-right: 0; }
.tpl-minimal .inv-totals .tot td { background: none; border-top: 2px solid var(--ink); border-radius: 0; padding-left: 0; padding-right: 0; color: var(--accent-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 1439px) {
  .workspace-card { grid-template-columns: minmax(0, 1fr) minmax(0, 34rem); }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-totals { grid-template-columns: 1fr 1fr; }
  .notes-field { grid-column: 1 / -1; }
}

@media (max-width: 1199px) {
  .workspace-card { grid-template-columns: minmax(0, 1fr); }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .stage { position: static; height: auto; max-height: none; }
  .preview { flex: none; min-height: 0; max-height: 80vh; }
  .panel-foot { border-radius: 0 0 1rem 1rem; }
}

@media (max-width: 1023px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: auto; height: auto; overflow: visible; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .hero h1 br { display: none; }
  .steps-nav, .tip-card, .sidebar-bottom { display: none; }
  .workspace { padding: 16px; }
}

@media (max-width: 640px) {
  .stage { padding: 18px 14px; }
  .stage-head { flex-direction: column; }
  .preview { padding: 12px; }
  .pane { padding: 4px 16px 8px; }
  .panel-tabs { padding: 10px 10px 0; }
  .panel-tabs button { font-size: 13.5px; gap: 6px; }
  .panel-foot { padding: 12px 16px; }
  .panel-foot .btn-primary { min-width: 0; flex: 1; }
  .biz-grid, .grid-2, .grid-4, .grid-totals { grid-template-columns: 1fr; }
  .logo-drop { min-height: 110px; }
  .tpl-grid { gap: 8px; }
  .tpl-card small { display: none; }
  .page-title { font-size: 1.4rem; }
  .items-head { display: none; }
  .items-list { padding: 4px 10px; }
  .item-row { grid-template-columns: 22px 1fr 1fr 34px; grid-template-areas: "n d d x" ". q r r" ". a a a"; row-gap: 6px; padding: 10px 0; }
  .item-row > :nth-child(1) { grid-area: n; }
  .item-row > :nth-child(2) { grid-area: d; }
  .item-row > :nth-child(3) { grid-area: q; }
  .item-row > :nth-child(4) { grid-area: r; }
  .item-row > :nth-child(5) { grid-area: a; }
  .item-row > :nth-child(6) { grid-area: x; }
  .item-row .input-wrap[data-ph]::before { content: attr(data-ph); padding-left: 10px; font-size: 12px; color: var(--slate-500); font-weight: 600; }
}

@media (max-width: 480px) {
  .brand-icon { width: 44px; height: 44px; }
  .brand-logo { height: 48px; }
  .hero h1 { font-size: 1.7rem; }
}

/* ---------- Print: only the invoice ---------- */
@media print {
  html, body { background: #fff !important; min-height: 0; }
  body > :not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .paper { width: 100%; min-height: var(--print-h, 296mm); box-shadow: none; }
}
