:root {
  --ink: #151518;
  --ink-soft: #232329;
  --gold: #d4aa45;
  --gold-dark: #ad8127;
  --gold-pale: #f5ead1;
  --paper: #f5f2ec;
  --white: #ffffff;
  --text: #1c1d22;
  --muted: #6e7380;
  --line: #e5e2dc;
  --danger: #b82e2e;
  --success: #18864a;
  --radius-xl: 28px;
  --radius-lg: 19px;
  --radius-md: 14px;
  --shadow: 0 24px 70px rgba(43, 35, 22, .15);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Tajawal", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(212, 170, 69, .17), transparent 25%),
    linear-gradient(180deg, #eae5dc 0, #f8f6f2 30%, #f2efe9 100%);
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 12px auto 0;
}

.app-header {
  direction: ltr;
  min-height: 112px;
  padding: 18px 28px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-radius: 25px 25px 17px 17px;
  color: #fff;
  background:
    radial-gradient(circle at 8% 20%, rgba(212, 170, 69, .21), transparent 27%),
    linear-gradient(135deg, #0e0e10, #222226);
  box-shadow: 0 17px 42px rgba(0, 0, 0, .18);
  position: relative;
  overflow: hidden;
}
.app-header::after {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  border: 1px solid rgba(212, 170, 69, .16);
  border-radius: 50%;
  right: -80px;
  bottom: -175px;
}
.app-title {
  direction: rtl;
  text-align: right;
  position: relative;
  z-index: 1;
  margin-left: auto;
}
.app-eyebrow {
  color: var(--gold);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .75rem;
  font-weight: 800;
}
.app-title h1 {
  margin: 5px 0 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 800;
}
.app-title p { margin: 7px 0 0; color: rgba(255,255,255,.68); }
.brand-logo {
  width: min(230px, 36vw);
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
}

.registration-card {
  position: relative;
  margin: -16px 13px 0;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 25px 18px;
  border-bottom: 1px solid #efede8;
}
.card-kicker {
  color: var(--gold-dark);
  font-weight: 800;
  font-size: .72rem;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.card-topline h2 { margin: 5px 0 0; font-size: 1.7rem; }
.card-topline p { margin: 6px 0 0; color: var(--muted); }
.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #e7e5df;
  color: #4d5360;
  background: #fbfaf8;
  white-space: nowrap;
}
.connection-dot { width: 9px; height: 9px; border-radius: 50%; background: #aaa; }
.connection-dot.online { background: #20a259; box-shadow: 0 0 0 5px rgba(32,162,89,.12); }
.connection-dot.offline { background: #d34343; box-shadow: 0 0 0 5px rgba(211,67,67,.12); }

#leadForm { padding: 23px 25px 27px; }
.form-section {
  position: relative;
  padding: 21px;
  border: 1px solid #ece8e0;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff, #fcfbf8);
  box-shadow: 0 10px 28px rgba(37,31,20,.055);
  animation: sectionEnter .45s ease both;
}
.form-section + .form-section { margin-top: 18px; }
.form-section:nth-of-type(2) { animation-delay: .06s; }
.form-section:nth-of-type(3) { animation-delay: .12s; }
@keyframes sectionEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.form-section::before {
  content: "";
  position: absolute;
  top: 0;
  right: 20px;
  left: 20px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(212,170,69,.45), transparent);
}
.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 19px;
}
.section-number {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--ink-soft), #09090a);
  box-shadow: 0 9px 20px rgba(0,0,0,.13);
  font-weight: 800;
  direction: ltr;
}
.section-heading h3 { margin: 0; font-size: 1.25rem; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; color: #25262c; }
.field label b { color: var(--danger); }
.control, .phone-control, textarea {
  border: 1px solid #dedbd5;
  background: #fff;
  border-radius: var(--radius-md);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.control:focus-within, .phone-control:focus-within, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(212,170,69,.12);
  transform: translateY(-1px);
}
.control { display: flex; align-items: center; gap: 9px; padding: 0 13px; }
.control-icon { color: #898e98; flex-shrink: 0; }
.control input, .control select, .phone-control input, .phone-control select {
  width: 100%;
  min-height: 52px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.select-control select { appearance: none; }
.phone-control { display: grid; grid-template-columns: 140px 1fr; overflow: hidden; }
.phone-control select { padding: 0 11px; border-left: 1px solid #ebe8e2; background: #faf9f7; }
.phone-control input { padding: 0 14px; }
textarea { width: 100%; min-height: 112px; padding: 14px 15px; outline: 0; resize: vertical; }
.hint, .error { display: block; margin-top: 6px; font-size: .82rem; }
.hint { color: #777d89; }
.error { min-height: 16px; color: var(--danger); }
.field.invalid .control, .field.invalid .phone-control, .field.invalid textarea { border-color: rgba(184,46,46,.62); }
.counter { text-align: left; color: #858a94; font-size: .8rem; margin-top: 5px; }

.choice-row {
  width: max-content;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 5px;
  border: 1px solid #e1ded7;
  background: #f7f5f1;
  border-radius: var(--radius-md);
}
.choice { position: relative; margin: 0 !important; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  min-width: 95px;
  min-height: 42px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #676c76;
  font-weight: 700;
  cursor: pointer;
  transition: .2s ease;
}
.choice input:checked + span { background: linear-gradient(135deg, var(--ink-soft), #0b0b0c); color: #fff; box-shadow: 0 8px 17px rgba(0,0,0,.15); }
.choice input:checked + span::after { content: ""; width: 6px; height: 6px; border-radius: 50%; margin-right: 8px; background: var(--gold); }
.compact .choice span { min-width: 70px; }
.language-row .choice input:checked + span { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); }
.sales-box { padding: 14px; border-radius: 16px; border: 1px dashed #d6d0c4; background: #faf8f4; }
.sales-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }

.consent-box {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 17px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid #e5e1d8;
  background: #faf8f4;
  cursor: pointer;
}
.consent-box input { position: absolute; opacity: 0; }
.custom-check {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid #d7d2c9;
  background: #fff;
  color: transparent;
}
.consent-box input:checked + .custom-check { color: #fff; border-color: var(--gold); background: var(--gold); }

.form-alert {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 13px;
  border: 1px solid rgba(184,46,46,.16);
  background: rgba(184,46,46,.08);
  color: #962626;
  font-weight: 700;
}
.submit-area { margin-top: 20px; text-align: center; }
.submit-btn {
  width: min(420px, 100%);
  min-height: 58px;
  border-radius: 16px;
  border: 0;
  padding: 0 24px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  box-shadow: 0 13px 25px rgba(173,129,39,.24);
  transition: .18s ease;
}
.submit-btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.submit-btn:disabled { opacity: .7; cursor: wait; transform: none; }
.submit-area p { margin: 9px 0 0; color: var(--muted); font-size: .86rem; }
.loader { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-footer { padding: 18px 8px 24px; text-align: center; color: #666b75; }
.app-footer span { display: block; font-size: .88rem; }
.app-footer strong { display: block; margin-top: 4px; color: #292b30; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(13,13,15,.65);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: min(455px, 100%);
  padding: 27px;
  border-radius: 24px;
  background: #fff;
  text-align: center;
  position: relative;
  box-shadow: 0 30px 90px rgba(0,0,0,.28);
  animation: modalIn .25s ease both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.close-modal { position: absolute; top: 13px; left: 13px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1efeb; font-size: 1.35rem; cursor: pointer; }
.success-icon { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 50%; color: var(--success); background: rgba(24,134,74,.11); font-size: 2rem; font-weight: 800; }
.modal-card h3 { margin: 0; font-size: 1.55rem; }
.modal-card > p { color: var(--muted); }
.lead-box { margin: 16px 0; padding: 14px; border: 1px solid #e6e2da; border-radius: 15px; background: #faf9f6; }
.lead-box span { display: block; color: #777d87; font-size: .84rem; }
.lead-box strong { display: block; margin-top: 4px; font-size: 1.2rem; direction: ltr; }
.modal-actions { display: flex; gap: 10px; }
.primary-btn, .secondary-btn { flex: 1; min-height: 48px; border-radius: 13px; border: 0; font-weight: 800; cursor: pointer; }
.primary-btn { color: #fff; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); }
.secondary-btn { color: #33363d; background: #efede9; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 14px, 1180px); margin-top: 7px; }
  .app-header { min-height: 96px; padding: 13px 16px 24px; border-radius: 20px 20px 13px 13px; gap: 14px; }
  .brand-logo { width: min(160px, 42vw); }
  .app-title h1 { font-size: 1.18rem; }
  .app-title p { font-size: .8rem; }
  .registration-card { margin: -12px 4px 0; border-radius: 19px; }
  .card-topline { padding: 18px 16px 14px; flex-direction: column; }
  .connection-state { align-self: flex-start; }
  #leadForm { padding: 16px 13px 20px; }
  .form-section { padding: 17px 14px; border-radius: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .phone-control { grid-template-columns: 120px 1fr; }
  .sales-row { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column; }
}

@media (max-width: 430px) {
  .app-header { align-items: center; }
  .brand-logo { width: 132px; }
  .app-title h1 { font-size: 1rem; }
  .app-title p, .app-eyebrow { font-size: .68rem; }
  .section-heading p { font-size: .82rem; }
  .phone-control { grid-template-columns: 108px 1fr; }
  .choice-row { width: 100%; }
  .choice { flex: 1; }
  .choice span { min-width: 0; }
}

/* V7: preserve the approved palette, cards and one-page structure. */
.card-actions { display:flex; flex-direction:column; align-items:flex-end; gap:10px; flex-shrink:0; }
.language-toggle { min-height:44px; padding:0 20px; border:1px solid #d4aa45; border-radius:999px; color:#292b30; background:#faf7ef; font-weight:800; cursor:pointer; display:flex; align-items:center; gap:16px; }
.language-toggle:hover { background:#f5ead1; }
.language-toggle:focus-visible, button:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
.choice input:focus-visible + span, .consent-box input:focus-visible + .custom-check { outline:3px solid var(--gold); outline-offset:3px; }
.sales-details { margin-top:16px; }
.preview-banner, .queue-banner { margin:16px 25px 0; padding:11px 15px; font-size:.9rem; line-height:1.55; border-radius:12px; color:#75551c; border:1px solid #e7d8b4; background:#fcf8ed; }
.queue-banner { color:#76491d; background:#fff5e7; }
[dir="ltr"] .app-title { direction:ltr; text-align:right; }
[dir="ltr"] .counter { text-align:right; }
[dir="ltr"] .choice input:checked + span::after { margin-right:0; margin-left:8px; }
[dir="ltr"] .close-modal { left:auto; right:13px; }
.control input,.phone-control input,.control select { min-width:0; }
.phone-control select { border-left:0; border-right:1px solid #ebe8e2; }
.success-icon.pending { background:#fcf2da; color:#9a7021; }
.modal-card { max-height:calc(100dvh - 36px); overflow-y:auto; }
.modal-card > p, .consent-box { line-height:1.55; }
.app-footer strong { direction:ltr; }
@media (max-width:720px) {
 .card-topline { flex-direction:row; flex-wrap:wrap; }
 .card-actions { flex-direction:row; align-items:center; flex-wrap:wrap; }
 .preview-banner,.queue-banner { margin-inline:13px; }
 .language-toggle,.connection-state { font-size:.88rem; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } }
.app-title { min-width:0; }
@media (max-width:430px) { .brand-logo { width:clamp(104px,32vw,132px); } .card-topline h2 { font-size:1.45rem; } }
.field label b { margin-inline-start:4px; }

/* International phone picker and truthful registration feedback. */
.phone-control { grid-template-columns:minmax(150px, 230px) minmax(0,1fr); }
.phone-control select { width:100%; min-width:0; text-overflow:ellipsis; }
@media(max-width:600px) { .phone-control { grid-template-columns:145px minmax(0,1fr); } }
.status-dots { display:none; align-items:center; gap:6px; }
.status-dots i { width:9px; height:9px; border-radius:50%; background:currentColor; animation:waitingDot 1.1s ease-in-out infinite; }
.status-dots i:nth-child(2) { animation-delay:.16s; }
.status-dots i:nth-child(3) { animation-delay:.32s; }
@keyframes waitingDot { 0%,70%,100% { transform:translateY(0); opacity:.4; } 35% { transform:translateY(-6px); opacity:1; } }
.status-check { display:none; width:48px; height:48px; }
.status-static { display:none; }
.success-icon[data-state="pending"] .status-dots { display:flex; }
.success-icon[data-state="saved"] .status-check,.success-icon[data-state="preview"] .status-check { display:block; }
.success-icon[data-state="saved"] { animation:successPop .32s ease-out both; }
.success-icon[data-state="saved"] .status-check path { stroke-dasharray:1; animation:drawCheck .4s ease-out both; }
.success-icon[data-state="offline"] .status-static,.success-icon[data-state="review"] .status-static,.success-icon[data-state="configuration"] .status-static { display:block; }
@keyframes drawCheck { from { stroke-dashoffset:1; } to { stroke-dashoffset:0; } }
@keyframes successPop { from { transform:scale(.8); opacity:.5; } to { transform:scale(1); opacity:1; } }
.whatsapp-notice { padding:10px 12px; border-radius:10px; background:#f7f3e9; font-size:.9rem; line-height:1.6; }
@media(prefers-reduced-motion:reduce) { .status-dots i,.success-icon[data-state="saved"],.success-icon[data-state="saved"] .status-check path,.modal-card { animation:none; } }
