.app-body { min-height: 100vh; background:
  radial-gradient(1000px 420px at 100% 0, rgba(224,154,37,.10), transparent 60%), var(--canvas); }

/* ---------- top bar + stepper ---------- */
.app-top {
  position: sticky; top: 0; z-index: 15;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 12px clamp(16px, 3vw, 36px);
  background: var(--green-900); color: #fff;
}
.app-top .seg { justify-self: end; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; }
.stepper li { display: flex; align-items: center; }
.stepper li + li::before { content: ""; width: clamp(14px, 3vw, 44px); height: 2px; background: rgba(255,255,255,.2); margin-inline: 6px; border-radius: 2px; }
.stepper li.done + li::before, .stepper li.done + li.active::before { background: var(--amber); }
.stepper button { display: flex; align-items: center; gap: 9px; border: 0; background: none; color: rgba(255,255,255,.62); padding: 4px; font-weight: 600; font-size: 14.5px; border-radius: 999px; }
.stepper .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; box-shadow: inset 0 0 0 2px rgba(255,255,255,.28); transition: background-color .2s ease, color .2s ease; }
.stepper li.active button { color: #fff; }
.stepper li.active .dot { background: var(--amber); color: var(--green-900); box-shadow: 0 0 0 4px rgba(224,154,37,.25); }
.stepper li.done .dot { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; font-size: 0; }
.stepper li.done .dot::after { content: "✓"; font-size: 15px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: minmax(0, 620px) minmax(0, 1fr); gap: clamp(20px, 3vw, 44px); max-width: 1280px; margin: 0 auto; padding: clamp(18px, 3vw, 36px) clamp(16px, 3vw, 36px) 64px; align-items: start; }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-2); overflow: clip; }
.card-head { padding: 30px 32px 6px; }
.kicker { color: var(--amber-700); font-weight: 700; font-size: 13.5px; text-transform: uppercase; letter-spacing: .08em; }
:lang(ar) .kicker { letter-spacing: 0; font-size: 14.5px; }
.card-head h1 { font-size: clamp(26px, 3vw, 32px); font-weight: 800; margin-top: 6px; }
.card-head .sub { color: var(--muted); margin-top: 6px; }
#editor { padding: 14px 32px 28px; }
.step { animation: stepIn .22s ease; }
.step[hidden] { display: none; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .step { animation: none; } }

/* step 4 */
.ready { margin-top: 8px; padding: 22px 24px; border-radius: 18px; color: #fff; background: radial-gradient(420px 200px at 100% 0, rgba(224,154,37,.30), transparent 65%), var(--green-900); }
.ready p { opacity: .82; font-size: 15px; overflow-wrap: anywhere; }
.ready strong { display: block; font-size: clamp(30px, 5vw, 40px); font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; color: var(--amber); white-space: nowrap; }
.checks { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; font-size: 15px; }
.checks li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.checks .warn { background: var(--amber-50); } .checks .warn::before { background: var(--amber); }
.checks .ok { background: var(--green-50); color: var(--green-900); font-weight: 600; } .checks .ok::before { background: var(--green); }
.checks .hint-row { color: var(--muted); padding-block: 4px; } .checks .hint-row::before { background: #cfc9bb; }
.checks button { margin-inline-start: auto; border: 0; background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13.5px; font-weight: 700; color: var(--amber-700); box-shadow: var(--sh-1); white-space: nowrap; }
.send { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.keep { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 14px 16px; border-radius: 16px; background: var(--amber-50); box-shadow: inset 0 0 0 1px #f1dfb6; text-decoration: none; }
.keep span { display: grid; flex: 1; } .keep small { color: #5f563f; font-size: 14px; } .keep .ico { color: var(--amber-700); }
:root[dir="rtl"] .keep .ico { transform: scaleX(-1); }
.after { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin-top: 14px; }
.privacy { color: var(--muted); font-size: 13.5px; }

/* card footer */
.card-nav { display: flex; align-items: center; gap: 12px; padding: 16px 32px; border-top: 1px solid var(--line); background: #fcfbf8; }
.card-nav .btn { min-width: 132px; }
.card-nav [hidden] { display: none; }
.nav-total { margin-inline: auto 4px; text-align: end; line-height: 1.2; }
.nav-total span { display: block; font-size: 12.5px; color: var(--muted); }
.nav-total strong { font-size: 18px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
:root[dir="rtl"] .flip, :root[dir="rtl"] #btnNext .ico { transform: scaleX(-1); }
:root[dir="ltr"] .flip { transform: scaleX(-1); }
:root[dir="rtl"] .flip { transform: none; }

/* ---------- preview ---------- */
.preview { position: sticky; top: 84px; min-width: 0; max-width: 600px; width: 100%; justify-self: center; }
.preview-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.preview-bar b { font-size: 15px; margin-inline-end: auto; }
.swatches { display: flex; gap: 7px; }
.swatches button { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--c); box-shadow: 0 0 0 2px var(--canvas), 0 0 0 3px transparent; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--c); }
.preview-close { display: none; }
.peek { display: none; }

.toast { position: fixed; inset-inline: 16px; bottom: 28px; margin: 0 auto; max-width: 420px; background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 14px; text-align: center; z-index: 60; box-shadow: var(--sh-2); }
.toast[hidden] { display: none; }

/* ---------- small screens ---------- */
@media (max-width: 1020px) {
  .app { grid-template-columns: minmax(0, 1fr); max-width: 680px; padding-bottom: 110px; }
  .app-top { grid-template-columns: auto 1fr auto; }
  .stepper { justify-self: center; }
  .stepper .lbl { display: none; }
  .stepper li.active .lbl { display: inline; }
  .card { overflow: visible; }
  .card-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -10px 30px -14px rgba(20,32,28,.3); }
  .card-nav .btn { min-width: 0; padding-inline: 18px; }
  .preview { display: none; }
  .preview.open { display: block; position: fixed; inset: 0; z-index: 40; max-width: none; overflow: auto; padding: 14px 14px 32px; background: var(--canvas); }
  .preview.open .preview-close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: #fff; box-shadow: var(--sh-1); }
  .peek { display: inline-flex; align-items: center; gap: 8px; position: fixed; inset-inline-end: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 19; border: 0; border-radius: 999px; padding: 11px 18px; background: var(--ink); color: #fff; font-weight: 700; box-shadow: var(--sh-2); }
}
@media (max-width: 560px) {
  .app-top .logo span:last-child { display: none; }
  .app-top { padding: 10px 12px; gap: 8px; }
  .stepper li + li::before { width: 10px; margin-inline: 3px; }
  .stepper .dot { width: 27px; height: 27px; font-size: 13px; }
  .app-top .seg button { padding: 5px 9px; font-size: 13px; }
  .card-head { padding: 22px 20px 4px; } #editor { padding: 10px 20px 22px; }
  .grid, .grid.three, .choices, .send { grid-template-columns: minmax(0, 1fr); }
  .item-row { grid-template-columns: 1fr 1.3fr; }
  .item-row .f-vat { grid-column: 1 / -1; }
  .card-nav .btn-ghost span { display: none; }
  .stepper li.active .lbl { display: none; }
}

/* ---------- printing: only the invoice ---------- */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff !important; }
  .app-top, .card, .preview-bar, .peek, .toast { display: none !important; }
  .app { display: block; padding: 0; max-width: none; }
  .preview { display: block !important; position: static !important; max-width: none; padding: 0 !important; }
  .stage { box-shadow: none; height: auto !important; overflow: visible; border-radius: 0; }
  .scaler { transform: none !important; }
  .paper { min-height: 0; }
}

/* invoice or pro forma */
.pf-note { margin: 10px 0 0; }
