:root {
  --brand: #1F5FB0;
  --brand-hover: #174E94;
  --brand-soft: #EEF4FB;
  --ink: #0E2238;
  --ink-2: #21354D;
  --muted: #41546B;
  --muted-2: #56677C;
  --muted-3: #7A8A9D;
  --placeholder: #9AA8B8;
  --line: #E1E8EF;
  --line-2: #D3DDE8;
  --line-3: #C9D5E2;
  --page: #F3F6F9;
  --panel: #F6F9FC;
  --field: #FBFCFD;
  --required: #C2410C;
  --danger: #B42318;
  --ok: #1BA39C;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
a:hover { color: #164784; }
input, textarea, button { font-family: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Header / footer ---------------------------------------------------- */
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.site-header__inner {
  max-width: 1080px; margin: 0 auto;
  padding: 14px clamp(14px, 4vw, 24px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-header__logo { height: clamp(36px, 9vw, 48px); width: auto; display: block; }
.secure-badge { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-2); }
.secure-badge__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

.site-footer { border-top: 1px solid var(--line); background: #fff; }
.site-footer__inner { max-width: 1080px; margin: 0 auto; padding: 18px 24px; font-size: 13px; color: var(--muted-3); }

/* ---- Layout ------------------------------------------------------------- */
.page {
  flex: 1; max-width: 1080px; width: 100%; margin: 0 auto; box-sizing: border-box;
  padding: clamp(24px, 5vw, 40px) clamp(14px, 4vw, 24px) 80px;
  display: flex; flex-direction: column; gap: 28px;
}

.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.intro__text { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.intro__eyebrow { font-size: 13px; font-weight: 600; color: var(--brand); letter-spacing: 0.02em; }
.intro__title { margin: 0; font-size: clamp(28px, 7vw, 36px); font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.intro__lead { margin: 0; font-size: 16px; line-height: 1.8; color: var(--muted); text-wrap: pretty; }
.intro__meta { display: flex; gap: 10px; flex-wrap: wrap; }
.meta-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 120px; box-sizing: border-box;
}
.meta-chip__label { font-size: 12px; color: var(--muted-2); }
.meta-chip__value { font-size: 15px; font-weight: 600; text-align: right; }

.req { color: var(--required); }
.mono { font-family: ui-monospace, Menlo, monospace; }

/* ---- Cards / sections --------------------------------------------------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(18px, 4vw, 28px);
  display: flex; flex-direction: column; gap: 22px;
}
.card--mode { padding: clamp(18px, 4vw, 24px); gap: 16px; }
.card--attachments { gap: 18px; }
.card--declaration { gap: 20px; }

.card__title { margin: 0; font-size: 17px; font-weight: 700; }
.section-head { display: flex; align-items: center; gap: 12px; }
.section-head__num {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.section-head__title { margin: 0; font-size: 20px; font-weight: 700; }
.section-head__hint { font-size: 13px; color: var(--muted-3); }

/* ---- Mode picker -------------------------------------------------------- */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.mode-card {
  text-align: right; cursor: pointer; border-radius: 14px; padding: 18px;
  display: flex; gap: 14px; align-items: flex-start;
  background: #fff; border: 2px solid var(--line);
}
.mode-card[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.mode-card__dot {
  flex: none; margin-top: 3px; width: 18px; height: 18px; border-radius: 50%; box-sizing: border-box;
  border: 2px solid var(--line-3);
}
.mode-card[aria-pressed="true"] .mode-card__dot { border: 5px solid var(--brand); }
.mode-card__body { display: flex; flex-direction: column; gap: 4px; }
.mode-card__title { font-size: 16px; font-weight: 700; color: var(--ink); }
.mode-card__desc { font-size: 14px; line-height: 1.7; color: var(--muted-2); }

.notice {
  background: var(--brand-soft); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.8; color: #21406A;
}
.notice strong { font-weight: 700; }

/* ---- Fields ------------------------------------------------------------- */
.grid { display: grid; gap: 18px; }
.grid--personal { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.grid--prev { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.grid--sign { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); align-items: start; }
.span-all { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 14px; font-weight: 600; }
.field__label-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.field__counter { font-size: 13px; color: var(--muted-3); }
.field__counter.is-near-limit { color: var(--required); }
.field__hint { font-size: 13px; line-height: 1.7; color: var(--muted-3); }

.input {
  width: 100%; box-sizing: border-box; padding: 12px 14px;
  border: 1px solid var(--line-2); border-radius: 10px;
  font-size: 15px; background: var(--field); color: var(--ink); outline: none;
}
.input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px #1F5FB022; }
.input--white { background: #fff; }
.input--ltr { text-align: right; }
textarea.input { line-height: 1.7; resize: vertical; }
textarea.input--facts { padding: 14px; line-height: 1.9; }

.readout {
  padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: 10px;
  font-size: 15px; color: var(--muted-2);
}
.readout--ltr { text-align: right; }

/* Gender pills */
.pills { display: flex; gap: 8px; }
.pill {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
  background: var(--field); color: var(--muted); border: 1px solid var(--line-2);
}
.pill[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* Yes / No segmented toggle */
.panel { background: var(--panel); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.question { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.question--divided { border-top: 1px solid var(--line); padding-top: 16px; }
.question__text { font-size: 15px; font-weight: 600; }
.segmented { display: flex; gap: 6px; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 4px; }
.segmented__btn {
  border: none; padding: 8px 20px; border-radius: 7px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--muted);
}
.segmented__btn[aria-pressed="true"] { background: var(--brand); color: #fff; }
.field--reply-date { max-width: 320px; }

/* ---- Attachments -------------------------------------------------------- */
.dropzone {
  cursor: pointer; border: 1.5px dashed #B9C8D8; border-radius: 14px; padding: clamp(18px, 4vw, 28px);
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--field);
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--brand); background: #F3F7FC; }
.dropzone input { display: none; }
.dropzone__cta { font-size: 15px; font-weight: 600; color: var(--brand); }
.dropzone__hint { font-size: 13px; color: var(--muted-3); }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.file-item__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-item__name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__size { font-size: 12px; color: var(--muted-3); }
.file-item__remove { border: none; background: none; color: var(--danger); font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px; }
.small-note { margin: 0; font-size: 13px; line-height: 1.8; color: var(--muted-2); }

/* ---- Declaration / signature ------------------------------------------- */
.check { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand); cursor: pointer; }
.check__text { font-size: 15px; line-height: 1.8; }
.check--declaration { background: var(--panel); border-radius: 14px; padding: 18px; }
.check--declaration input { width: 20px; height: 20px; margin-top: 4px; }
.check--declaration .check__text { line-height: 1.9; color: var(--ink-2); text-wrap: pretty; }
.field--helper { max-width: 420px; margin-right: clamp(0px, 5vw, 32px); }

.link-btn { border: none; background: none; color: var(--brand); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px; }
.sig-pad {
  position: relative; border: 1px solid var(--line-2); border-radius: 12px; background: var(--field);
  height: 150px; overflow: hidden;
}
.sig-pad canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.sig-pad__placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--placeholder); pointer-events: none;
}
.sig-pad__line { position: absolute; right: 16px; left: 16px; bottom: 32px; border-top: 1px solid var(--line-2); pointer-events: none; }

/* ---- Submit area -------------------------------------------------------- */
.submit-area { display: flex; flex-direction: column; gap: 14px; }
.errors {
  background: #FEF3F2; border: 1px solid #FECDCA; border-radius: 14px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.errors strong { font-size: 15px; color: #912018; }
.errors ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.errors li { font-size: 14px; color: var(--danger); }
.errors li::before { content: '• '; }
.submit-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.submit-row__note { font-size: 13px; color: var(--muted-3); max-width: 520px; line-height: 1.7; }

.btn-primary {
  border: none; background: var(--brand); color: #fff; border-radius: 12px; padding: 15px 36px;
  flex: 1 1 220px; max-width: 100%; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px #1F5FB033;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: progress; }
.btn-secondary {
  border: 1px solid var(--line-3); background: #fff; color: var(--ink); border-radius: 12px;
  padding: 12px 20px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: var(--page); }

/* ---- Success view ------------------------------------------------------- */
.page--success { max-width: 640px; padding: 64px 24px; display: block; }
.success {
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: clamp(22px, 6vw, 40px);
  display: flex; flex-direction: column; gap: 20px; align-items: flex-start;
}
.success__icon {
  width: 52px; height: 52px; border-radius: 50%; background: #E3F5F3;
  display: flex; align-items: center; justify-content: center; color: #138A84; font-size: 26px; font-weight: 700;
}
.success__title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.success__text { margin: 0; font-size: 16px; line-height: 1.8; color: var(--muted); text-wrap: pretty; }
.success__code-box {
  width: 100%; box-sizing: border-box; background: var(--page); border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.success__code-label { font-size: 13px; color: var(--muted-2); }
.success__code {
  font-size: clamp(18px, 5.5vw, 26px); font-weight: 700; letter-spacing: 0.06em;
  word-break: break-all; text-align: right;
}
.success__warning {
  margin: 0; font-size: 14px; line-height: 1.8; color: #8A4B12; background: #FFF5E8; border-radius: 12px; padding: 14px 16px;
}

/* ---- Security additions ------------------------------------------------- */
.meta-chip__value--soft { font-size: 13px; font-weight: 500; color: var(--muted-2); }
.field-error { margin: 0; font-size: 13px; line-height: 1.8; color: var(--danger); }
.turnstile { min-height: 65px; }
