:root {
  --ink: #20252b;
  --muted: #697079;
  --line: #dde1e5;
  --soft: #f3f5f6;
  --paper: #ffffff;
  --accent: #f08a24;
  --accent-dark: #c96610;
  --danger: #b42318;
  --success: #157a46;
  --radius: 14px;
  --shadow: 0 18px 55px rgba(27, 34, 40, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tajawal", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: #e9edef;
  direction: rtl;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: clamp(320px, 34vw, 470px) minmax(0, 1fr);
}
.brand-panel {
  background: linear-gradient(145deg, #252b31, #171b1f);
  color: white;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: clamp(44px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: right;
  gap: 28px;
  overflow: hidden;
}
.brand-panel::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(240, 138, 36, .28);
  transform: rotate(45deg);
  left: -190px;
  bottom: -100px;
}
.brand-mark {
  width: 68px;
  height: 68px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #171b1f;
  font-weight: 800;
  font-size: 20px;
  border: 5px solid rgba(255,255,255,.12);
}
.eyebrow { color: #f5ae67; font-weight: 700; margin: 0 0 8px; }
.brand-panel h1 { max-width: 390px; font-size: clamp(34px, 3vw, 48px); line-height: 1.32; margin: 0 0 16px; }
.brand-copy { color: #c9ced3; line-height: 1.9; max-width: 390px; }
.progress-summary { max-width: 390px; width: 100%; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: #d9dde0; margin-bottom: 8px; }
.progress-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.13); overflow: hidden; }
.progress-fill { height: 100%; width: 8.33%; background: var(--accent); transition: width .35s ease; }

.form-panel {
  background: var(--paper);
  min-height: 100vh;
  width: 100%;
  max-width: 1180px;
  justify-self: center;
  padding: clamp(32px, 4vw, 54px) clamp(28px, 5vw, 74px);
  box-shadow: var(--shadow);
  position: relative;
}
.form-header {
  min-height: 82px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.form-header span { color: var(--accent-dark); font-size: 13px; font-weight: 800; }
.form-header h2 { margin: 5px 0 18px; font-size: clamp(21px, 2.4vw, 29px); }
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}
.icon-button:hover { color: var(--danger); }

.form-step { display: none; animation: enter .28s ease; }
.form-step.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.section-intro { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.section-intro p { margin: 0; color: var(--muted); line-height: 1.8; }
.step-icon {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 50%; display: grid; place-items: center;
  background: #fff4e8; color: var(--accent-dark); font-weight: 800;
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 2px; }
.field.full { grid-column: 1 / -1; }
label, legend { font-size: 14px; font-weight: 700; }
label b, legend b { color: var(--danger); }
label span { color: var(--muted); font-size: 12px; font-weight: 500; }
fieldset { border: 0; padding: 0; margin: 0; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  transition: border .18s, box-shadow .18s;
}
input { height: 46px; }
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,138,36,.13); }
input.invalid, textarea.invalid { border-color: var(--danger); }
.choice-grid, .choice-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.choice-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.choice-grid > .radio-card { min-height: 54px; }
.check-card, .radio-card {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  transition: .18s ease;
}
.check-card input, .radio-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-card span, .radio-card span { line-height: 1.5; }
.check-card:has(input:checked), .radio-card:has(input:checked) {
  border-color: var(--accent);
  background: #fff8ef;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.check-card:has(input:checked)::before, .radio-card:has(input:checked)::before {
  content: "✓";
  color: white;
  background: var(--accent);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  margin-left: 8px;
  font-size: 12px;
}
.conditional { display: none; }
.conditional.visible { display: flex; }
.notice { background: #fff8ef; border: 1px solid #f5d2ac; border-radius: 9px; padding: 12px 14px; color: #8a4c13; }

.dynamic-list { display: grid; gap: 14px; margin: 18px 0; }
.dynamic-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fafbfb; }
.dynamic-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dynamic-card-header strong { font-size: 15px; }
.remove-button { border: 0; background: transparent; color: var(--danger); font-size: 13px; }
.secondary-button {
  min-height: 46px;
  border: 1px dashed #aeb5bb;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  padding: 10px 16px;
  font-weight: 700;
  width: 100%;
}
.secondary-button:hover { border-color: var(--accent); color: var(--accent-dark); background: #fffaf4; }

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 34px;
  padding-top: 22px;
}
.nav-button {
  min-height: 48px;
  border-radius: 9px;
  padding: 11px 22px;
  font-weight: 800;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.4;
  white-space: normal;
}
.previous { background: #eef0f2; color: var(--ink); }
.next, .submit { background: var(--ink); color: white; }
.next:hover, .submit:hover { background: #11161a; }
.submit { display: none; background: var(--accent); color: #171b1f; }
.submit.visible { display: inline-flex; align-items: center; }
.nav-button:disabled { opacity: .55; cursor: wait; }
.form-alert {
  display: none;
  margin-top: 14px;
  border-radius: 9px;
  padding: 12px 14px;
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #f3b9b5;
}
.form-alert.visible { display: block; }

.review-summary { display: grid; gap: 12px; }
.review-section { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.review-heading { display: flex; justify-content: space-between; align-items: center; background: #f7f8f8; padding: 12px 15px; }
.review-heading strong { font-size: 14px; }
.edit-step { border: 0; background: transparent; color: var(--accent-dark); font-weight: 800; }
.review-list { margin: 0; padding: 8px 15px 12px; }
.review-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid #edf0f1; }
.review-row:last-child { border-bottom: 0; }
.review-row dt { color: var(--muted); font-size: 13px; }
.review-row dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.consent-box { display: flex; gap: 10px; align-items: flex-start; background: #fff8ef; border: 1px solid #f2d2b0; border-radius: var(--radius); padding: 15px; margin-top: 18px; }
.consent-box input { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 18px; accent-color: var(--accent); }

.success-screen { min-height: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.success-screen[hidden] { display: none; }
.success-icon { width: 82px; height: 82px; border-radius: 50%; display: grid; place-items: center; background: #daf3e5; color: var(--success); font-size: 42px; margin-bottom: 12px; }
.success-screen h2 { font-size: 34px; margin: 8px 0; }
.success-screen p { color: var(--muted); margin: 5px 0; }
.success-screen .nav-button { margin-top: 24px; }
.arabic-swal { direction: rtl; font-family: "Tajawal", Tahoma, Arial, sans-serif; }
.arabic-swal-button { font-family: "Tajawal", Tahoma, Arial, sans-serif; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .brand-panel { height: 100vh; padding: 28px 22px; }
  .brand-panel h1 { font-size: clamp(21px, 3vw, 28px); }
  .form-panel { min-height: 100vh; padding: 28px 28px 36px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  body { background: var(--paper); }
  .brand-panel {
    position: relative;
    height: auto;
    min-height: 112px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-content: center;
    gap: 10px 12px;
  }
  .brand-mark { width: 52px; height: 52px; border-width: 3px; font-size: 16px; }
  .brand-panel h1 { font-size: clamp(17px, 5vw, 21px); line-height: 1.35; margin: 0; }
  .brand-copy, .eyebrow { display: none; }
  .progress-summary { grid-column: 1 / -1; align-self: end; }
  .progress-label { margin-bottom: 5px; }
  .progress-track { height: 5px; }
  .form-panel {
    min-height: calc(100dvh - 112px);
    padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
  }
  .form-header { min-height: 62px; margin-bottom: 18px; gap: 8px; }
  .form-header h2 { font-size: 20px; line-height: 1.35; margin: 4px 0 10px; }
  .icon-button { max-width: 82px; }
  .section-intro { align-items: flex-start; margin-bottom: 16px; }
  .section-intro p { font-size: 14px; }
  .step-icon { width: 38px; height: 38px; flex-basis: 38px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .field { gap: 6px; }
  label, legend { font-size: 13px; }
  input, textarea {
    font-size: 16px;
    border-radius: 8px;
  }
  input { height: 48px; }
  textarea { min-height: 96px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .choice-row { grid-template-columns: 1fr; }
  .check-card, .radio-card { min-height: 48px; padding: 9px 10px; }
  .check-card span, .radio-card span { font-size: 13px; }
  .dynamic-card { padding: 12px; }
  .dynamic-card-header { gap: 8px; }
  .form-actions {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.98);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(27,34,40,.07);
  }
  .form-actions > .nav-button { min-width: 0; flex: 1 1 0; padding: 10px 12px; font-size: 14px; }
  .form-actions > .submit { flex: 2 1 0; }
  .consent-box { margin-bottom: 8px; }
  .review-row { grid-template-columns: 1fr; gap: 3px; }
  .success-screen { min-height: calc(100dvh - 160px); padding-bottom: 20px; }
}
@media (max-width: 420px) {
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-header h2 { font-size: 18px; }
  .brand-panel { min-height: 108px; }
  .form-panel { min-height: calc(100dvh - 108px); }
  .form-actions > .nav-button { font-size: 13px; padding-inline: 8px; }
}
@media (max-width: 350px) {
  .choice-grid { grid-template-columns: 1fr; }
  .brand-panel { grid-template-columns: 44px minmax(0,1fr); }
  .brand-mark { width: 44px; height: 44px; }
  .form-panel { padding-inline: 10px; }
  .form-actions { padding-inline: 10px; }
}
