/* ═══════════════════════════════════════════════════════════
   WIZARD PAGE
═══════════════════════════════════════════════════════════ */
.wizard { padding: 40px 0 80px; }

.stepper {
  display: flex; align-items: center;
  max-width: 900px; margin: 0 auto 40px;
  gap: 8px;
}
.step-dot {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex: 0 0 auto;
  transition: all 0.3s;
}
.step-dot span {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: var(--text-dim);
  transition: all 0.3s;
}
.step-dot em { font-style: normal; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.step-dot.active span {
  background: var(--grad-btn);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}
.step-dot.active em { color: var(--text); font-weight: 600; }
.step-dot.done span { background: rgba(34, 197, 94, 0.2); color: #4ade80; border-color: rgba(34, 197, 94, 0.4); }
.step-line { flex: 1; height: 2px; background: var(--border); border-radius: 2px; }

/* Steps animation */
.wiz-step { display: none; animation: step-in 0.4s ease; }
.wiz-step.active { display: block; }
@keyframes step-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.wiz-card {
  max-width: 820px; margin: 0 auto;
  padding: 48px 44px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
}
.wiz-card-wide { max-width: 1100px; }
.wiz-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.15;
}
.wiz-sub { color: var(--text-soft); margin-bottom: 32px; font-size: 16px; }
.wiz-section-title {
  font-size: 18px; font-weight: 700;
  margin: 32px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ─── Compact biz card ─── */
.biz-compact {
  padding: 18px 22px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  border: 1px solid var(--accent-1);
  border-radius: 16px;
  margin-bottom: 10px;
}
.biz-compact-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.biz-compact-icon { font-size: 22px; }
.biz-compact-title { font-size: 16px; font-weight: 700; flex: 1; }
.biz-compact-edit {
  color: var(--accent-1);
  font-size: 13px; font-weight: 600;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.biz-compact-edit:hover {
  background: rgba(139, 92, 246, 0.3);
}
.biz-compact-body {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--text-soft);
}
.biz-compact-body div { padding: 2px 0; }
.biz-compact-body strong { color: var(--text); font-weight: 600; }
@media (max-width: 600px) {
  .biz-compact-body { grid-template-columns: 1fr; }
}

/* ─── Doctype grid ─── */
.doctype-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}
.doctype input { position: absolute; opacity: 0; pointer-events: none; }
.doctype {
  cursor: pointer;
  border-radius: var(--radius);
}
.doctype-inner {
  padding: 26px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  text-align: center;
  transition: all 0.25s;
}
.doctype:hover .doctype-inner { border-color: var(--border-strong); transform: translateY(-3px); }
.doctype input:checked + .doctype-inner {
  border-color: var(--accent-1);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.15), rgba(34, 211, 238, 0.05));
  box-shadow: 0 12px 30px -12px rgba(139, 92, 246, 0.6);
}
.doctype-icon { font-size: 38px; margin-bottom: 10px; }
.doctype-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.doctype-desc { font-size: 12px; color: var(--text-dim); }
.doctype-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 100px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.doctype-disabled { cursor: not-allowed !important; opacity: 0.55; }
.doctype-disabled .doctype-inner { background: rgba(0,0,0,0.4); }
.doctype-disabled:hover .doctype-inner { transform: none; border-color: var(--border); }

@media (max-width: 700px) { .doctype-grid { grid-template-columns: repeat(2, 1fr); } }

/* ─── Form ─── */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field input, .field textarea, .field select {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent-1);
  background: rgba(0, 0, 0, 0.45);
}
.field textarea { resize: vertical; min-height: 90px; }

.logo-upload { position: relative; }
.logo-upload input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.logo-preview {
  height: 100px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.2);
  transition: border-color 0.2s;
  overflow: hidden;
}
.logo-preview:hover { border-color: var(--accent-1); }
.logo-preview img { max-height: 100%; max-width: 200px; object-fit: contain; }
.logo-placeholder { color: var(--text-dim); font-size: 14px; font-weight: 500; }

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .wiz-card { padding: 32px 24px; }
}

/* ─── Saved clients chips ─── */
.saved-clients { margin-bottom: 24px; }
.saved-clients label { font-size: 13px; color: var(--text-soft); display: block; margin-bottom: 10px; }
.client-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.client-chip {
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 8px;
}
.client-chip:hover { border-color: var(--accent-1); background: var(--surface-strong); }
.client-chip .x {
  color: var(--text-dim);
  margin-right: 4px;
}
.client-chip .x:hover { color: #f87171; }

/* ─── Common items (chips above the list) ─── */
.common-items {
  background: linear-gradient(135deg, rgba(139,92,246,0.10), rgba(236,72,153,0.06));
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 14px;
  padding: 12px 14px 12px;
  margin-bottom: 14px;
}
.common-items-head {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
}
.common-items-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.common-item-chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.common-item-chip:hover {
  background: rgba(139,92,246,0.18);
  border-color: rgba(167,139,250,0.5);
  transform: translateY(-1px);
}
.common-item-chip .chip-price {
  color: #c4b5fd;
  font-weight: 800;
  font-size: 12.5px;
}
.common-item-chip .chip-meta {
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  font-size: 11.5px;
  margin-right: 4px;
}

/* ─── Template chip with delete button ─── */
.tpl-chip-wrap {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  transition: all .15s ease;
}
.tpl-chip-wrap:hover {
  background: rgba(139,92,246,0.18);
  border-color: rgba(167,139,250,0.5);
  transform: translateY(-1px);
}
.tpl-chip-wrap .common-item-chip {
  background: transparent;
  border: none;
  padding-left: 8px;
}
.tpl-chip-wrap .common-item-chip:hover {
  background: transparent;
  border-color: transparent;
  transform: none;
}
.tpl-chip-del {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
  line-height: 1;
}
.tpl-chip-del:hover {
  background: rgba(239,68,68,0.25);
  color: #f87171;
}

/* ─── Save-as-template button (under items list) ─── */
.save-tpl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(139, 92, 246, 0.10);
  border: 1px dashed rgba(139, 92, 246, 0.4);
  border-radius: 12px;
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  transition: all .2s ease;
}
.save-tpl-btn:hover {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.7);
  color: #ddd6fe;
}
.save-tpl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── Save-template modal preview list ─── */
.tpl-save-items-list {
  max-height: 220px;
  overflow-y: auto;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.tpl-save-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.tpl-save-item:last-child { border-bottom: none; }
.tpl-save-item span {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-save-item strong {
  color: var(--accent-1);
  font-weight: 700;
  white-space: nowrap;
}
.tpl-name-input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  text-align: right;
}
.tpl-name-input:focus { border-color: var(--accent-1); }

/* ─── Items ─── */
.items-wrap { margin-bottom: 24px; }
.items-head {
  display: grid; grid-template-columns: 2.5fr 1.6fr 1.2fr 40px;
  gap: 12px;
  padding: 0 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.item-row {
  display: grid; grid-template-columns: 2.5fr 1.6fr 1.2fr 40px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.materials-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.20), rgba(245, 158, 11, 0.08));
  border: 2.5px dashed rgba(245, 158, 11, 0.85);
  border-radius: 12px;
  color: #fcd34d;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: pulse-attention 2.4s ease-in-out infinite;
}
.materials-toggle .mt-box {
  font-size: 22px;
  line-height: 1;
  display: inline-block;
}
.materials-toggle .mt-text { line-height: 1.1; }
.materials-toggle.on {
  background: rgba(34, 197, 94, 0.18);
  border-style: solid;
  border-color: rgba(34, 197, 94, 0.7);
  color: #4ade80;
  animation: none;
  box-shadow: none;
}
.materials-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}
.materials-toggle.on:hover {
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}
@keyframes pulse-attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
.item-row input {
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.item-row input:focus { border-color: var(--accent-1); }
.item-total {
  padding: 10px 14px;
  color: var(--accent-1);
  font-weight: 700;
}
.item-remove {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.item-remove:hover { background: rgba(239, 68, 68, 0.25); }
.add-item-btn { margin-top: 10px; width: 100%; }

.totals-row {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap; gap: 20px;
}
.vat-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}
.vat-toggle input { accent-color: var(--accent-1); transform: scale(1.2); }
.totals-box { min-width: 280px; }
.total-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 14px;
}
.total-line strong { font-weight: 700; font-size: 16px; }
.total-line.grand {
  font-size: 16px;
  padding-top: 12px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.total-line.grand strong { font-size: 26px; font-weight: 800; }

@media (max-width: 700px) {
  .items-head { display: none; }
  .item-row {
    grid-template-columns: 1fr 40px;
    gap: 8px;
    padding: 14px; background: var(--surface); border-radius: 12px;
    border: 1px solid var(--border);
  }
  .item-row > *:not(.item-remove) { grid-column: 1 / 2; }
  .item-remove { grid-column: 2 / 3; grid-row: 1; }
}

/* ─── Actions ─── */
.wiz-actions {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
/* First step has only one button — in RTL, flex-end = left side */
.wiz-actions-first { justify-content: flex-end; }
.wiz-actions-final { justify-content: space-between; }
.wiz-actions button { min-width: 150px; }

/* Top placement — used in steps 1-4 so phone users find "הבא" without
   scrolling. Just sits at the top of the card; no sticky / background
   overlay, so it blends naturally with the card and the page behind it. */
.wiz-actions-top {
  margin-top: 0;
  margin-bottom: 28px;
  padding-top: 0;
  padding-bottom: 22px;
  border-top: none;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 700px) {
  .wiz-actions { flex-direction: column-reverse; }
  .wiz-actions button { min-width: unset; }
  /* Keep the top bar compact — two buttons side by side, not stacked,
     so the form below isn't pushed too far down. */
  .wiz-actions-top {
    flex-direction: row;
    margin-bottom: 20px;
    padding-bottom: 14px;
    gap: 10px;
  }
  .wiz-actions-top button {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    font-size: 14px;
  }
  /* The single "הבא" button on step 1 fills the full width on phones. */
  .wiz-actions-top.wiz-actions-first button { flex: 1 1 auto; width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   TEMPLATE PICKER + PREVIEW
═══════════════════════════════════════════════════════════ */
.template-picker {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.tmpl input { position: absolute; opacity: 0; pointer-events: none; }
.tmpl { cursor: pointer; }
.tmpl-preview {
  height: 120px;
  border-radius: 12px;
  border: 2px solid var(--border);
  margin-bottom: 10px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.tmpl:hover .tmpl-preview { transform: translateY(-3px); border-color: var(--border-strong); }
.tmpl input:checked + .tmpl-preview {
  border-color: var(--accent-1);
  box-shadow: 0 12px 30px -12px rgba(139, 92, 246, 0.6);
}
.tmpl-name { text-align: center; font-size: 14px; font-weight: 600; }

/* Preview thumbnails */
.tmpl-preview-classic {
  background:
    linear-gradient(180deg, transparent 18%, white 18%, white 92%, transparent 92%),
    #1e293b;
}
.tmpl-preview-classic::before {
  content: ""; position: absolute;
  top: 26%; right: 10%; width: 50%; height: 4px;
  background: #0ea5e9;
}
.tmpl-preview-classic::after {
  content: ""; position: absolute;
  top: 40%; right: 10%; width: 80%; height: 4px;
  background: #cbd5e1;
  box-shadow: 0 8px 0 #cbd5e1, 0 16px 0 #cbd5e1;
}

.tmpl-preview-modern {
  background: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
}
.tmpl-preview-modern::before {
  content: ""; position: absolute;
  inset: 18% 10% 10%;
  background: white;
  border-radius: 6px;
}

.tmpl-preview-minimal {
  background: #ffffff;
  border: 2px solid #e2e8f0 !important;
}
.tmpl-preview-minimal::before {
  content: ""; position: absolute;
  top: 25%; right: 10%; width: 40%; height: 3px;
  background: #000;
  box-shadow: 0 20px 0 #cbd5e1, 0 30px 0 #cbd5e1, 0 40px 0 #cbd5e1;
}

.tmpl-preview-bold {
  background: #0a0a24;
}
.tmpl-preview-bold::before {
  content: ""; position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(244, 114, 182, 0.5), transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(34, 211, 238, 0.5), transparent 50%);
}
.tmpl-preview-bold::after {
  content: ""; position: absolute;
  top: 35%; right: 15%; width: 70%; height: 4px;
  background: white;
  box-shadow: 0 10px 0 rgba(255,255,255,0.5), 0 20px 0 rgba(255,255,255,0.5);
}

@media (max-width: 700px) {
  .template-picker { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Preview frame ─── */
.preview-wrap {
  display: flex; justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.3);
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.preview-frame {
  transform-origin: center top;
}
.pdf-page {
  width: 794px;  /* A4 at 96dpi = 794 */
  min-height: 1123px;
  padding: 60px 56px;
  background: white;
  color: #1e293b;
  font-family: 'Heebo', 'Rubik', sans-serif;
  font-size: 14px;
  direction: rtl;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  position: relative;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .preview-frame { transform: scale(0.6); margin-bottom: -300px; }
}
@media (max-width: 500px) {
  .preview-frame { transform: scale(0.4); margin-bottom: -500px; }
}

/* ═══════════════════════════════════════════════════════════
   PDF TEMPLATES
═══════════════════════════════════════════════════════════ */
/* Common for all templates */
.pdf-page .p-hdr { display: flex; justify-content: space-between; align-items: center; }
.pdf-page .p-biz-name { font-size: 26px; font-weight: 800; }
.pdf-page .p-biz-line { font-size: 12px; color: #64748b; margin-top: 2px; }
.pdf-page .p-logo { width: 80px; height: 80px; object-fit: contain; }
.pdf-page .p-title {
  font-size: 22px; font-weight: 800;
  margin: 30px 0;
  text-align: center;
}
.pdf-page .p-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 12px;
}
.pdf-page .p-meta-stack {
  display: block;
  margin-bottom: 24px;
}
.pdf-page .p-meta-stack .m {
  display: block;
  background: transparent;
  padding: 4px 0;
  border: none;
  font-size: 13px;
}
.pdf-page .p-meta .m { background: #f1f5f9; padding: 8px 14px; border-radius: 6px; }
.pdf-page .p-meta strong { font-weight: 700; margin-left: 6px; }
.pdf-page .p-dates {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  color: #475569;
}
.pdf-page .p-dates strong { font-weight: 700; margin-left: 4px; color: #0f172a; }
.pdf-page table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.pdf-page table th, .pdf-page table td { padding: 10px 12px; text-align: right; font-size: 13px; }
.pdf-page table tfoot td { font-weight: 700; }
.pdf-page .p-totals {
  margin: 20px 0 30px; display: flex; justify-content: flex-start;
}
.pdf-page .p-totals table { width: auto; min-width: 260px; }
.pdf-page .p-totals td:first-child { color: #64748b; }
.pdf-page .p-totals td:last-child { text-align: left; font-weight: 700; }
.pdf-page .p-notes {
  margin-top: 20px; padding: 14px 18px;
  background: #f8fafc; border-right: 3px solid #e2e8f0;
  font-size: 12px; line-height: 1.6; color: #475569;
  border-radius: 4px;
}
.pdf-page .p-foot {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  font-size: 11px; color: #94a3b8;
  text-align: center;
}

/* ─── Signature in PDF ─── */
.pdf-page .p-signature {
  margin-top: 28px;
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 200px;
}
.pdf-page .p-sig-label { font-size: 12px; font-weight: 600; color: #64748b; }
.pdf-page .p-sig-img {
  max-height: 60px;
  background: transparent;
  align-self: flex-start;
  border-bottom: 1px solid #475569;
  padding-bottom: 2px;
}
.pdf-bold .p-sig-label { color: #cbd5e1; }
.pdf-bold .p-sig-img { border-bottom-color: rgba(255,255,255,0.5); }

/* ─── Template: classic ─── */
.pdf-classic .p-hdr { padding-bottom: 14px; border-bottom: 3px solid #2563eb; }
.pdf-classic .p-biz-name { color: #2563eb; }
.pdf-classic .p-title {
  color: #2563eb; background: #dbeafe; padding: 12px; border-radius: 8px;
}
.pdf-classic table thead { background: #2563eb; color: white; }
.pdf-classic table tbody tr:nth-child(even) { background: #f8fafc; }
.pdf-classic table tbody tr { border-bottom: 1px solid #e2e8f0; }

/* ─── Template: modern (gradient) ─── */
.pdf-modern { padding: 0; overflow: hidden; }
.pdf-modern .p-hdr {
  padding: 40px 56px;
  background: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
  color: white;
  align-items: flex-start;
}
.pdf-modern .p-biz-name { color: white; font-size: 28px; }
.pdf-modern .p-biz-line { color: rgba(255,255,255,0.85); }
.pdf-modern .p-logo { background: rgba(255,255,255,0.15); padding: 8px; border-radius: 12px; }
.pdf-modern .p-body { padding: 0 56px 60px; }
.pdf-modern .p-title {
  color: #8b5cf6;
  text-align: right;
  margin: 28px 0 20px;
  font-size: 20px;
  border-bottom: 2px solid #8b5cf6;
  padding-bottom: 10px;
  display: inline-block;
}
.pdf-modern table thead {
  background: linear-gradient(135deg, #8b5cf6, #22d3ee); color: white;
}
.pdf-modern table thead th { padding: 12px; }
.pdf-modern table tbody td { border-bottom: 1px solid #f1f5f9; }
.pdf-modern .p-meta .m {
  background: linear-gradient(135deg, #faf5ff, #ecfeff);
  border: 1px solid #e9d5ff;
}
.pdf-modern .p-grand {
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  color: white; padding: 16px 24px;
  border-radius: 12px;
  font-size: 18px; font-weight: 800;
  display: flex; justify-content: space-between;
  margin-top: 10px;
}

/* ─── Template: minimal ─── */
.pdf-minimal { font-family: 'Rubik', sans-serif; }
.pdf-minimal .p-hdr { border: none; padding-bottom: 0; align-items: baseline; }
.pdf-minimal .p-biz-name { color: #000; font-weight: 900; font-size: 28px; letter-spacing: -0.02em; }
.pdf-minimal .p-biz-line { color: #64748b; }
.pdf-minimal .p-title {
  background: none; color: #000; text-align: right;
  font-size: 40px; font-weight: 900; letter-spacing: -0.02em;
  margin: 24px 0;
}
.pdf-minimal .p-meta .m {
  background: none; padding: 0; border-bottom: 1px solid #e2e8f0;
  border-radius: 0; padding-bottom: 6px;
}
.pdf-minimal table thead { background: none; border-bottom: 2px solid #000; }
.pdf-minimal table thead th { color: #000; font-weight: 700; }
.pdf-minimal table tbody tr { border-bottom: 1px solid #e2e8f0; }
.pdf-minimal .p-grand {
  font-size: 22px; font-weight: 900;
  border-top: 3px solid #000;
  padding-top: 14px;
  display: flex; justify-content: space-between;
}

/* ─── Template: bold (dark) ─── */
.pdf-bold {
  background: linear-gradient(135deg, #0a0a24 0%, #1a1040 100%);
  color: #f8fafc;
}
.pdf-bold .p-hdr {
  padding-bottom: 22px;
  border-bottom: 2px solid #8b5cf6;
}
.pdf-bold .p-biz-name {
  color: #a78bfa;
  font-size: 32px;
  text-shadow: 0 0 20px rgba(139, 92, 246, 0.35);
}
.pdf-bold .p-biz-line { color: #cbd5e1; }
.pdf-bold .p-title {
  text-align: right;
  font-size: 26px;
  background: none;
  color: #f8fafc;
  padding: 0;
  margin: 30px 0 20px;
}
.pdf-bold .p-meta .m {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #e9d5ff;
}
.pdf-bold table { color: #f8fafc; }
.pdf-bold table thead {
  background: linear-gradient(135deg, rgba(139,92,246,0.4), rgba(34,211,238,0.3));
}
.pdf-bold table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.1); }
.pdf-bold .p-notes {
  background: rgba(255,255,255,0.05);
  border-right-color: #8b5cf6;
  color: #cbd5e1;
}
.pdf-bold .p-grand {
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  color: white; padding: 16px 24px;
  border-radius: 12px;
  font-size: 18px; font-weight: 800;
  display: flex; justify-content: space-between;
  margin-top: 10px;
}
.pdf-bold .p-foot { color: #94a3b8; border-top-color: rgba(255,255,255,0.1); }

/* ═══════════════════════════════════════════════════════════
   MODAL (validation / success)
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 20, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: modal-fade 0.25s ease;
}
.modal-overlay.open { display: flex; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 32px 32px;
  background: linear-gradient(180deg, #1a1a40 0%, #0f0f2e 100%);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 40px 100px -20px rgba(139, 92, 246, 0.5);
  animation: modal-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* When modal is open, lock the page from scrolling */
body.modal-open { overflow: hidden; }
@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-soft);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.modal-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  position: relative;
}
.modal-icon::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.25;
  animation: modal-ring 1.6s ease-in-out infinite;
}
@keyframes modal-ring {
  0%, 100% { transform: scale(1); opacity: 0.25; }
  50% { transform: scale(1.12); opacity: 0.05; }
}
.modal-icon.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.modal-icon.success {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.modal-icon.warning {
  background: rgba(234, 179, 8, 0.18);
  color: #facc15;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 10px;
}
.modal-message {
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.modal-actions .btn { min-width: 120px; }

/* ═══════════════════════════════════════════════════════════
   Nav right + settings
═══════════════════════════════════════════════════════════ */
.nav-right { display: flex; gap: 10px; align-items: center; }
@media (max-width: 700px) {
  .nav-right .btn:not(#settingsBtn) { display: none; }
}
/* user-chip removed — email is shown only inside Settings now */
.user-chip { display: none !important; }

.trial-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 100px;
  font-size: 12px; font-weight: 700;
  color: #fcd34d;
  white-space: nowrap;
}
.trial-chip.expired {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

/* ═══════════════════════════════════════════════════════════
   Biz details view modal
═══════════════════════════════════════════════════════════ */
.biz-view { text-align: right; }
.biz-view-logo {
  max-width: 110px; max-height: 110px;
  border-radius: 14px;
  display: block; margin: 0 auto 18px;
  background: rgba(255,255,255,0.05); padding: 8px;
}
.biz-view-row {
  display: grid; grid-template-columns: 1fr 2fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.biz-view-row:last-child { border: none; }
.biz-view-row span { color: var(--text-dim); }
.biz-view-row strong { color: var(--text); font-weight: 600; }

/* Biz edit form (inside settings) */
.biz-edit { text-align: right; }
.biz-edit-row {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.biz-edit-row label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.biz-edit-row input,
.biz-edit-row select {
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.biz-edit-row input:focus,
.biz-edit-row select:focus {
  outline: none;
  border-color: var(--accent-1);
}
.biz-edit-logo {
  text-align: center;
  margin-bottom: 18px;
}
.biz-edit-logo img {
  max-width: 110px; max-height: 110px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  padding: 8px;
  display: block;
  margin: 0 auto;
}
.biz-logo-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--accent-1);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.biz-logo-btn:hover { background: rgba(139, 92, 246, 0.3); }
.biz-logo-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}
.biz-logo-btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

/* First-time template picker (modal) */
.tmpl-pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tmpl-pick {
  position: relative;
  display: block;
  padding: 14px 12px;
  background: rgba(0,0,0,0.3);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  text-align: right;
  cursor: pointer;
  transition: all 0.15s;
}
.tmpl-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tmpl-pick:hover { border-color: var(--accent-1); }
.tmpl-pick:has(input:checked) {
  border-color: var(--accent-1);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.08));
}
.tmpl-pick-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.tmpl-pick-desc { font-size: 11px; color: var(--text-soft); }

/* ═══════════════════════════════════════════════════════════
   Settings modal
═══════════════════════════════════════════════════════════ */
.settings-body { text-align: right; }
.settings-userline {
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.settings-userline strong { color: var(--text); font-weight: 700; }
.settings-label {
  font-size: 13px; color: var(--text-dim); font-weight: 600;
  margin-bottom: 12px; letter-spacing: 0.3px;
}
.acc-list-scroll {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 18px;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
}
.acc-list-scroll::-webkit-scrollbar { width: 8px; }
.acc-list-scroll::-webkit-scrollbar-track { background: transparent; }
.acc-list-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.acc-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  transition: all 0.2s;
}
.acc-row.current {
  border-color: var(--accent-1);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(34, 211, 238, 0.06));
}
.acc-info { flex: 1; min-width: 0; text-align: right; }
.acc-label { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.acc-current-badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--grad-btn);
  color: white;
  white-space: nowrap;
}
.acc-enter {
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid var(--accent-1);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.acc-enter:hover { background: var(--accent-1); }
.acc-delete {
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.acc-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}
.settings-divider {
  height: 1px; background: var(--border);
  margin: 14px 0;
}

/* ─── Account tiles ─── */
.acc-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
}
.acc-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 16px 12px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  transition: all 0.15s;
}
.acc-tile.current {
  border-color: var(--accent-1);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.08));
}
.acc-tile-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-btn);
  color: white;
  font-weight: 700; font-size: 20px;
  margin-bottom: 8px;
}
.acc-tile-name {
  font-size: 13px; font-weight: 600;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 2px;
}
.acc-tile-mail {
  font-size: 10px; color: var(--text-soft);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 10px;
}
.acc-tile-enter {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid var(--accent-1);
  color: var(--text);
  cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
}
.acc-tile-enter:hover { background: var(--accent-1); }
.acc-tile-badge {
  font-size: 11px; font-weight: 700;
  color: #4ade80;
  padding: 6px 0;
}
.acc-tile-forget {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  border: 1px solid transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  padding: 0;
}
.acc-tile-forget:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

/* ─── Feedback modal ─── */
.fb-form { text-align: right; }
.fb-stars-input {
  display: flex; gap: 6px;
  justify-content: center;
  margin-bottom: 16px;
}
.fb-star {
  font-size: 32px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.15s, color 0.15s;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}
.fb-star:hover { transform: scale(1.18); color: #fcd34d; }
.fb-star.on { color: #fbbf24; }
.fb-textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
.fb-textarea:focus { outline: none; border-color: var(--accent-1); }
.fb-divider { height: 1px; background: var(--border); margin: 18px 0 12px; }
.fb-section-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.fb-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.fb-row {
  position: relative;
  padding: 10px 36px 10px 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}
.fb-stars { color: #fbbf24; font-size: 14px; margin-bottom: 4px; }
.fb-text { color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.fb-meta { color: var(--text-dim); font-size: 11px; }
.fb-del {
  position: absolute;
  top: 8px; left: 8px;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  padding: 0;
}
.fb-del:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

/* ═══════════════════════════════════════════════════════════
   Signature section (step 4) + signature modal
═══════════════════════════════════════════════════════════ */
.signature-section {
  margin-top: 24px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
}
.signature-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.signature-title { font-size: 15px; font-weight: 700; }
.signature-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.signature-preview {
  margin-top: 14px;
  padding: 10px;
  background: white;
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.signature-preview img { max-width: 100%; max-height: 120px; }

.sig-modal { max-width: 640px; padding: 30px 24px; }
.sig-canvas-wrap {
  margin: 0 0 20px;
  background: white;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}
#sigCanvas {
  display: block;
  width: 100%;
  height: 220px;
  cursor: crosshair;
}

/* ═══════════════════════════════════════════════════════════
   PHONE-SIZE TIGHTENING (≤500px)
   Cuts paddings, title sizes and step-dot sizes so the wizard
   doesn't feel "big and spread out" on narrow phones.
═══════════════════════════════════════════════════════════ */
@media (max-width: 500px) {
  .wizard { padding: 22px 0 90px; }
  .wiz-card { padding: 20px 14px; border-radius: 14px; }
  .wiz-title { font-size: clamp(22px, 6vw, 28px); margin-bottom: 6px; }
  .wiz-sub { font-size: 13.5px; margin-bottom: 18px; line-height: 1.5; }
  .wiz-section-title { font-size: 16px; margin: 18px 0 10px; }

  /* Stepper — keep all 5 dots visible without horizontal scroll */
  .stepper { gap: 4px; margin-bottom: 20px; }
  .step-dot span { width: 26px; height: 26px; font-size: 13px; }
  .step-dot em { font-size: 10px; }

  /* Forms */
  .form-grid { gap: 12px; }
  .field label { font-size: 12.5px; margin-bottom: 4px; }
  .field input, .field textarea, .field select {
    padding: 10px 12px; font-size: 14.5px;
  }

  /* Doctype tiles + items */
  .doctype-inner { padding: 14px 10px; }
  .doctype-icon { font-size: 26px; }
  .doctype-name { font-size: 14.5px; }
  .doctype-desc { font-size: 11.5px; }
  .item-row { padding: 10px 12px; }
}
