:root {
  --bg-page: #F8F7FC;
  --bg-card: #FFFFFF;
  --bg-brand: #FFFFFF;
  --primary: #7743C9;
  --primary-hover: #6132B0;
  --primary-dark: #5B2D9E;
  --primary-tint: #F4EEFC;
  --primary-soft: #B794F4;
  --accent-green: #15803D;
  --text-main: #1f2937;
  --text-muted: #4B5563;
  --border-subtle: #E5E7EB;
  --border-brand: #EAE4F7;
  --border-focus: #7743C9;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --radius-card: 12px;
  --radius-input: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header thương hiệu VPSTTT (nền trắng, logo thật màu tím) */
.brand-header {
  background-color: var(--bg-brand);
  color: var(--text-main);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-brand);
  box-shadow: 0 1px 3px rgba(119, 67, 201, 0.04);
}

.brand-header__inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary);
}

.brand-logo img {
  height: 30px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
  line-height: 1.35;
}

/* Khung chính */
.main-wrap {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 36px;
}

/* Hộp tiêu đề biểu mẫu */
.form-intro {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 20px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border-brand);
  box-shadow: 0 1px 4px rgba(119, 67, 201, 0.04);
}

.form-intro__badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  background-color: var(--primary-tint);
  border: 1px solid #E2D4F8;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.form-intro__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.32;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.form-intro__subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Thanh tiến độ & trạng thái nháp */
.progress-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border-brand);
  box-shadow: 0 1px 4px rgba(119, 67, 201, 0.04);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.progress-step-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.draft-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.draft-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  display: inline-block;
}

.draft-clear-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12.5px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}

.draft-clear-btn:hover {
  color: var(--danger);
}

.progress-bars {
  display: grid;
  grid-template-columns: repeat(var(--step-count, 4), 1fr);
  gap: 6px;
}

.progress-seg {
  height: 5px;
  border-radius: 999px;
  background-color: #E5E7EB;
  transition: background-color 0.2s ease;
}

.progress-seg.is-active {
  background-color: var(--primary);
}

.progress-seg.is-done {
  background-color: var(--primary-soft);
}

/* Thẻ bước câu hỏi */
.step-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 20px 16px;
  border: 1px solid var(--border-brand);
  box-shadow: 0 2px 10px rgba(119, 67, 201, 0.05);
}

.step-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.step-header__title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.step-header__desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* Danh sách câu hỏi */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.q-item {
  display: flex;
  flex-direction: column;
}

.q-item[hidden] {
  display: none !important;
}

.q-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.45;
  margin-bottom: 4px;
  display: block;
}

.q-req {
  color: var(--danger);
  margin-left: 3px;
  font-weight: 700;
}

.q-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
  line-height: 1.45;
}

.q-control {
  margin-top: 4px;
}

/* Input & Textarea (>=16px chống auto-zoom iOS, cao >=48px) */
.input-text,
.input-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  padding: 12px 14px;
  min-height: 48px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.input-textarea {
  min-height: 96px;
  resize: vertical;
}

.input-text::placeholder,
.input-textarea::placeholder {
  color: #6B7280;
}

.input-text:focus,
.input-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(119, 67, 201, 0.16);
}

.q-item.has-error .input-text,
.q-item.has-error .input-textarea {
  border-color: var(--danger);
  background-color: #FFFBFB;
}

/* Lựa chọn Radio / Checkbox dạng thẻ chạm (>=48px) */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  background-color: #FFFFFF;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.opt-card:hover {
  border-color: #C4B5FD;
}

.opt-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.opt-indicator {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1.5px solid #9CA3AF;
  background-color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.opt-card[data-type="radio"] .opt-indicator {
  border-radius: 50%;
}

.opt-card[data-type="checkbox"] .opt-indicator {
  border-radius: 5px;
}

.opt-indicator svg {
  width: 12px;
  height: 12px;
  stroke: #FFFFFF;
  stroke-width: 2.5;
  fill: none;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.15s ease;
}

.opt-card.is-selected {
  background-color: var(--primary-tint);
  border-color: var(--primary);
}

.opt-card.is-selected .opt-indicator {
  background-color: var(--primary);
  border-color: var(--primary);
}

.opt-card.is-selected .opt-indicator svg {
  opacity: 1;
  transform: scale(1);
}

.opt-card:focus-within {
  box-shadow: 0 0 0 3px rgba(119, 67, 201, 0.16);
}

.opt-text {
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--text-main);
  font-weight: 400;
}

.opt-card.is-selected .opt-text {
  font-weight: 600;
  color: var(--text-main);
}

/* Thông báo lỗi từng câu */
.q-error {
  margin-top: 6px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
  display: none;
}

.q-item.has-error .q-error {
  display: block;
}

/* Hộp đồng ý Nghị định 13/2023/NĐ-CP ở bước cuối */
.consent-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  background-color: #FAFAFE;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.consent-label.is-checked {
  background-color: var(--primary-tint);
  border-color: var(--primary);
}

.consent-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.consent-text {
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.5;
}

.consent-text a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.consent-text a:hover {
  color: var(--primary-hover);
}

/* Hộp thông báo lỗi chung */
.alert-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.alert-banner[hidden] {
  display: none !important;
}

/* Honeypot chống bot (ẩn khỏi người dùng thật) */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Thanh điều hướng bước (1 nút chính duy nhất) */
.step-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-back {
  min-height: 48px;
  padding: 0 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-input);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-back:hover {
  color: var(--text-main);
  background-color: var(--primary-tint);
}

.btn-back[hidden] {
  visibility: hidden;
  pointer-events: none;
}

.btn-primary {
  min-height: 48px;
  padding: 0 24px;
  background-color: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-input);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-left: auto;
  transition: background-color 0.15s ease, transform 0.08s ease;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Màn hình Cảm ơn sau khi gửi */
.thankyou-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 28px 20px;
  text-align: center;
  border: 1px solid var(--border-brand);
  box-shadow: 0 2px 12px rgba(119, 67, 201, 0.06);
}

.thankyou-check {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: var(--primary-tint);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.thankyou-check svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

.thankyou-title {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 700;
  color: var(--text-main);
}

.thankyou-desc {
  margin: 0 auto 20px;
  max-width: 480px;
  font-size: 15px;
  color: var(--text-muted);
}

.ref-box {
  background-color: var(--primary-tint);
  border: 1px solid #E2D4F8;
  border-radius: var(--radius-input);
  padding: 14px 16px;
  margin: 0 auto 20px;
  max-width: 360px;
}

.ref-box__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.ref-box__code {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.thankyou-meta {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Chân trang pháp nhân VPSTTT */
.site-footer {
  border-top: 1px solid var(--border-brand);
  background-color: #FFFFFF;
  padding: 20px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.site-footer__inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-footer__company {
  font-weight: 700;
  color: var(--text-main);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 4px;
}

.site-footer__links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.site-footer__links a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Mở rộng cho màn hình lớn (Desktop 1440px) */
@media (min-width: 640px) {
  .brand-header {
    padding: 16px 24px;
  }

  .brand-logo img {
    height: 34px;
  }

  .brand-tagline {
    font-size: 13px;
  }

  .main-wrap {
    padding: 28px 24px 56px;
  }

  .form-intro {
    padding: 28px 32px;
    margin-bottom: 16px;
  }

  .form-intro__title {
    font-size: 24px;
  }

  .form-intro__subtitle {
    font-size: 15px;
  }

  .progress-box {
    padding: 16px 32px;
    margin-bottom: 16px;
  }

  .step-card {
    padding: 32px 36px;
  }

  .step-header__title {
    font-size: 19px;
  }

  .options-grid.cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .thankyou-card {
    padding: 40px 36px;
  }
}
