:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #5c667a;
  --line: #dce3ee;
  --primary: #0f5c73;
  --primary-dark: #0a4658;
  --primary-soft: #e8f4f7;
  --danger: #a22525;
  --danger-soft: #fff0f0;
  --success: #16734a;
  --success-soft: #eaf8f1;
  --shadow: 0 14px 40px rgba(31, 48, 73, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazir", Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}
button, input, textarea { font: inherit; }
a { color: var(--primary); }

.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.site-header { background: linear-gradient(135deg, #0e5065, #153954); color: #fff; }
.header-inner { min-height: 92px; display: flex; align-items: center; }
.site-name { margin: 0; font-size: 1.1rem; font-weight: 800; }
.eyebrow { margin: 0 0 4px; font-size: .78rem; font-weight: 800; letter-spacing: .02em; opacity: .78; }
.page-shell { padding-block: 28px 64px; }
.site-footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); padding: 24px 0; text-align: center; }

.skip-link { position: fixed; top: -100px; right: 16px; z-index: 1000; background: #111; color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 3vw, 36px); margin-bottom: 22px; }
.hero h1 { margin: 14px 0 18px; font-size: clamp(1.5rem, 3vw, 2.3rem); line-height: 1.5; }
.hero h2, .card h2 { margin-top: 0; }
.badge { display: inline-flex; align-items: center; background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #c9e4ea; border-radius: 999px; padding: 5px 12px; font-size: .85rem; font-weight: 800; }
.muted { color: var(--muted); }
.centered { text-align: center; }
.narrow-card { max-width: 620px; margin-inline: auto; }

.alert { border-radius: 12px; padding: 14px 16px; margin: 18px 0; border: 1px solid; }
.alert p { margin: 4px 0 0; }
.alert-error { background: var(--danger-soft); border-color: #efb9b9; color: #7e1717; }
.alert-info { background: var(--primary-soft); border-color: #c4dfe6; color: var(--primary-dark); }

.progress-wrap { position: sticky; top: 10px; z-index: 20; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(31,48,73,.10); padding: 10px 14px; margin-bottom: 18px; }
.progress-text { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.progress-track { height: 8px; background: #e9eef5; border-radius: 999px; overflow: hidden; margin-top: 8px; direction: ltr; }
.progress-bar { width: 0; height: 100%; background: var(--primary); border-radius: inherit; transition: width .2s ease; }

.instructions { margin: 0; padding-right: 1.4rem; }
.instructions li { margin-block: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-group { display: flex; flex-direction: column; gap: 7px; margin-block: 14px; }
.field-group label, legend { font-weight: 800; }
.field-group input, .field-group textarea, .login-form input {
  width: 100%; border: 1px solid #bcc8d7; border-radius: 10px; background: #fff; color: var(--text); padding: 11px 12px;
}
.field-group input:focus, .field-group textarea:focus, .login-form input:focus { outline: 3px solid rgba(15,92,115,.17); border-color: var(--primary); }
.field-group.compact { margin-bottom: 0; }
textarea { resize: vertical; min-height: 70px; }

.choice-block { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 18px 0; }
.choice-block legend { padding-inline: 6px; }
.choice-block small { color: var(--muted); font-weight: 500; }
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-stack { display: grid; gap: 10px; }
.choice-pill { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.choice-pill input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pill span { display: inline-flex; min-height: 42px; align-items: center; border: 1px solid #c8d1dd; background: #fff; border-radius: 10px; padding: 8px 13px; transition: .15s ease; }
.choice-pill input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.choice-pill input:focus-visible + span { outline: 3px solid rgba(15,92,115,.24); }

.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.section-heading h1, .section-heading h2 { margin: 0; }
.question-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 18px 0; background: var(--surface-soft); }
.question-title { display: flex; gap: 12px; align-items: flex-start; }
.question-title h3 { margin: 0; font-size: 1rem; line-height: 1.8; }
.code-badge { flex: 0 0 auto; direction: ltr; background: #e7edf4; color: #33445c; border-radius: 8px; font: 700 .82rem/1.2 Arial, sans-serif; padding: 7px 8px; margin-top: 2px; }
.dual-scale { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.dual-scale fieldset, .question-card > fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.scale-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.scale-options label { position: relative; cursor: pointer; }
.scale-options input { position: absolute; opacity: 0; }
.scale-options span { display: flex; min-height: 48px; align-items: center; justify-content: center; text-align: center; border: 1px solid #c6d0dc; border-radius: 9px; background: #fff; padding: 7px; font-size: .88rem; }
.scale-options input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.scale-options input:focus-visible + span { outline: 3px solid rgba(15,92,115,.24); }
.quality-scale { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.has-error { border-color: #dc8c8c !important; background: #fffafa; }
.field-error { color: var(--danger); margin: 5px 0 0; font-size: .88rem; font-weight: 700; }

.step-navigation { display: flex; position: sticky; bottom: 10px; z-index: 19; align-items: center; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(31,48,73,.11); padding: 12px; }
.step-counter { color: var(--muted); font-weight: 800; text-align: center; }
.button { appearance: none; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: #fff; border-color: #b9c5d3; color: var(--text); }
.button.danger { color: var(--danger); border-color: #e0adad; }
.button.ghost { background: transparent; }
.button.large { padding: 13px 22px; font-size: 1rem; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.submit-panel { margin-top: 26px; border: 1px solid #c5dfd2; background: var(--success-soft); border-radius: 14px; padding: 18px; text-align: center; }

.success-card { max-width: 700px; margin-inline: auto; }
.success-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); font-size: 2.2rem; font-weight: 900; margin: 0 auto 16px; }
.reference-code { direction: rtl; color: var(--muted); }
.reference-code code { direction: ltr; display: inline-block; background: #eef2f6; border-radius: 6px; padding: 3px 6px; user-select: all; }

.login-form { display: grid; gap: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 24px 0; }
.stat-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.stat-card span { color: var(--muted); }
.stat-card strong { font-size: 2rem; }
.stat-card .small-stat { font-size: .92rem; direction: ltr; text-align: right; word-break: break-all; }
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.download-card { text-decoration: none; border: 1px solid #b9d5dc; background: var(--primary-soft); color: var(--text); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 7px; }
.download-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.download-card span { color: var(--muted); font-size: .9rem; }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

html.js .form-step { display: none; }
html.js .form-step.active { display: block; }
html:not(.js) .step-navigation, html:not(.js) .progress-wrap { display: none; }

@media (max-width: 860px) {
  .field-grid, .dual-scale, .stats-grid, .download-grid { grid-template-columns: 1fr; }
  .quality-scale { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .container { width: min(100% - 20px, 1180px); }
  .card { border-radius: 14px; padding: 16px; }
  .choice-row { display: grid; grid-template-columns: 1fr; }
  .choice-pill span { width: 100%; }
  .choice-pill { width: 100%; }
  .scale-options, .quality-scale { grid-template-columns: 1fr; }
  .section-heading { flex-direction: column; }
  .step-navigation { bottom: 4px; }
  .step-counter { font-size: .82rem; }
  .button { padding: 9px 11px; }
}

@media print {
  .site-header, .site-footer, .step-navigation, .progress-wrap { display: none !important; }
  body { background: #fff; }
  .card, .question-card { box-shadow: none; break-inside: avoid; }
  html.js .form-step { display: block !important; }
}

.draft-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px dashed #bdcad8;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 11px 13px;
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: .9rem;
}

@media (max-width: 560px) {
  .draft-actions { align-items: stretch; flex-direction: column; }
}

input[type="hidden"] { display: none !important; }

@media print {
  .skip-link, .draft-actions, #clear-draft { display: none !important; }
}

.progress-native {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e9eef5;
  direction: ltr;
  appearance: none;
}
.progress-native::-webkit-progress-bar { background: #e9eef5; border-radius: 999px; }
.progress-native::-webkit-progress-value { background: var(--primary); border-radius: 999px; transition: width .2s ease; }
.progress-native::-moz-progress-bar { background: var(--primary); border-radius: 999px; transition: width .2s ease; }

.required-mark {
  color: var(--danger);
  font-weight: 900;
  margin-inline-start: 3px;
}

.step-validation-alert {
  position: relative;
  border-width: 2px;
  box-shadow: 0 10px 28px rgba(162, 37, 37, 0.13);
}
.step-validation-alert[hidden] { display: none !important; }
.step-validation-alert:focus { outline: 3px solid rgba(162, 37, 37, 0.22); outline-offset: 2px; }

.client-invalid {
  border-color: #cf5353 !important;
  background: #fff7f7 !important;
  box-shadow: 0 0 0 2px rgba(162, 37, 37, 0.08);
}
.client-invalid .scale-options span,
.client-invalid .choice-pill span,
.field-group.client-invalid input,
.field-group.client-invalid textarea {
  border-color: #d88787;
}
