/* CPRM Forms — public styles */
:root {
  --brand: #4A2C6D;
  --brand-dark: #36204F;
  --brand-soft: #F3EEF9;
  --bg: #F6F3FA;
  --card: #FFFFFF;
  --ink: #1F1A2E;
  --muted: #5E5670;
  --line: #E3DDEC;
  --line-strong: #CFC6DC;
  --ok: #1F7A4D;
  --ok-soft: #E5F3EC;
  --bad: #B3261E;
  --bad-soft: #FCE8E6;
  --warn: #8A5A00;
  --warn-soft: #FFF3DC;
  --radius: 12px;
  --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; }
[dir="rtl"] { font-family: 'IBM Plex Sans Arabic', var(--font); }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.25; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.h3 { font-size: 18px; margin: 8px 0 4px; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.wrap.narrow { max-width: 820px; }
@media (min-width: 640px) { .wrap { padding-left: 24px; padding-right: 24px; } }
.page { padding-top: 32px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 24px; }

/* Header / footer */
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-logo { height: 48px; width: auto; display: block; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; letter-spacing: .5px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 600; font-size: 18px; }
.brand-sub { font-size: 13px; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 500; font-size: 14px; text-decoration: none; }
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; font-size: 14px; color: var(--muted); text-align: center; }
.site-footer p { margin: 4px 0; }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
@media (min-width: 640px) { .card { padding: 28px 32px; } }
.empty { text-align: center; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; }
.page-head h1 { margin: 0; font-size: 32px; }
.page-head h2 { margin: 0; font-size: 26px; }
.page-head .lead { margin: 6px 0 0; }
.page-head-ar { text-align: right; }
.lead { color: var(--muted); font-size: 17px; }
.survey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.survey-card { display: flex; flex-direction: column; gap: 12px; }
.survey-card-top { display: flex; justify-content: space-between; align-items: center; }
.survey-title { margin: 0; font-size: 21px; }
.survey-title-ar { margin: 0; color: var(--muted); }
.survey-card .btn { margin-top: auto; }
.clamp { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-off { background: #ECE9F0; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-primary:disabled { opacity: .7; cursor: wait; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); font-weight: 500; }
.btn-ghost:hover { border-color: var(--brand); color: var(--ink); }
.btn-block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--brand-soft); color: var(--ink); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

/* Alerts */
.alert { padding: 14px 16px; border-radius: 12px; font-size: 15px; border: 1px solid transparent; margin: 0; }
.alert.ok { background: var(--ok-soft); color: #145336; border-color: #B9DCC8; }
.alert.bad { background: var(--bad-soft); color: #8C1D18; border-color: #F0C2BD; }
.alert.warn { background: var(--warn-soft); color: #6B4600; border-color: #F0D9A8; }

/* Hero */
.hero { background: var(--brand); color: #fff; border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 640px) { .hero { padding: 32px; } }
.hero h1 { margin: 0; font-size: 28px; }
.hero p { margin: 0; color: rgba(255,255,255,.88); line-height: 1.65; }
.hero .hero-ar-title { font-size: 19px; font-weight: 500; color: #fff; }

/* Progress */
.progress-wrap { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.progress-text { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: 14px; color: var(--muted); }
.progress-en { font-weight: 600; color: var(--ink); }
.progress { display: grid; gap: 6px; }
.progress span { height: 6px; border-radius: 3px; background: #DCD3E8; }
.progress span.on { background: var(--brand); }

/* Steps: without JS every step is shown */
.step + .step { margin-top: 32px; }
.js .step { display: none; margin-top: 0; }
.js .step.active { display: block; }

/* Fields */
.form-card { display: flex; flex-direction: column; gap: 28px; }
.questions { display: flex; flex-direction: column; gap: 26px; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.lbl { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; width: 100%; padding: 0; font-size: 15px; font-weight: 500; }
legend.lbl { margin-bottom: 8px; float: left; }
legend.lbl + * { clear: both; }
.lbl-ar { color: var(--muted); font-weight: 400; }
.req { color: var(--bad); }
.sublbl { font-size: 13px; color: var(--muted); }
.help { margin: -2px 0 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
.inp { width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 14px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; }
textarea.inp { min-height: 110px; resize: vertical; }
.inp:focus { border-color: var(--brand); outline: 3px solid color-mix(in srgb, var(--brand) 18%, transparent); outline-offset: 0; }
.inp::placeholder { color: #8A8299; }
.inp.center { text-align: center; }
select.inp { appearance: auto; }
.has-error .inp, .has-error .dropzone { border-color: var(--bad); }
.field-error { margin: 0; font-size: 14px; color: var(--bad); font-weight: 500; }
.info-block { background: var(--bg); border-radius: 12px; padding: 14px 16px; color: var(--muted); font-size: 15px; }
.info-block p { margin: 0; }
.info-block p + p { margin-top: 4px; }

.date-row { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 12px; max-width: 420px; }
.date-part { display: flex; flex-direction: column; gap: 4px; }

.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.choice { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 15px; cursor: pointer; background: #fff; }
.choice:hover { border-color: var(--brand); }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.choice:has(input:checked) { border: 2px solid var(--brand); background: var(--brand-soft); padding: 9px 13px; }
.other-box { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

/* File upload */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px dashed #B7A9CC; background: #FAF8FC; border-radius: 12px; padding: 26px 16px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.file-input:focus-visible + .file-chosen, .file-input:focus-visible ~ .dropzone { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); }
.dz-icon { color: var(--brand); }
.dz-title { font-weight: 500; }
.dz-link { color: var(--brand); text-decoration: underline; }
.dz-ar { font-size: 14px; color: var(--muted); }
.dz-hint { font-size: 13px; color: var(--muted); }
.file-chosen { display: flex; align-items: center; gap: 14px; border: 1px solid #B9DCC8; background: #F2F9F5; border-radius: 12px; padding: 12px 12px 12px 16px; }
.file-chosen.too-big { border-color: #F0C2BD; background: var(--bad-soft); }
.fc-badge { width: 44px; height: 44px; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--brand); flex-shrink: 0; }
.fc-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fc-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-size { font-size: 13px; color: var(--ok); }
.too-big .fc-size { color: var(--bad); }

.consent { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; background: var(--bg); border-radius: 12px; padding: 16px; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.consent-ar { display: block; color: var(--muted); margin-top: 4px; }

.form-nav { border-top: 1px solid var(--line); padding-top: 22px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.form-nav-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.privacy-note { margin: 0; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.privacy-note > span { flex: 1; }
.privacy-note .icon { color: var(--brand); margin-top: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.thanks { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 40px; padding-bottom: 40px; }
.thanks h1 { margin: 8px 0 0; font-size: 24px; max-width: 34ch; }
.thanks-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; justify-content: center; }

/* Installer bits */
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.checks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--bad); font-weight: 600; }
.steps-list li { margin-bottom: 6px; }

@media (max-width: 480px) {
  .page-head-ar { text-align: right; width: 100%; }
  .form-nav-btns { width: 100%; }
  .form-nav-btns .btn { flex: 1; }
}

/* Year, grid, show-if */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.year-inp { max-width: 160px; text-align: center; }
.questions > .q-wrap { display: block; }
.grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.grid-table th, .grid-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.grid-table tbody tr:last-child th, .grid-table tbody tr:last-child td { border-bottom: 0; }
.grid-table thead th { font-weight: 500; color: var(--muted); font-size: 13px; background: #FAF8FC; }
.grid-table thead th span { display: block; }
.grid-table tbody th { text-align: left; font-weight: 500; padding-left: 14px; white-space: nowrap; }
.grid-table tbody th span { display: block; color: var(--muted); font-weight: 400; font-size: 13px; text-align: left; }
.grid-table tbody tr:hover { background: #FAF8FC; }
.grid-cell { display: flex; align-items: center; justify-content: center; min-height: 44px; cursor: pointer; }
.grid-cell input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.grid-clear { align-self: flex-start; background: none; border: 0; padding: 4px 0; color: var(--brand); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
