:root {
  color-scheme: light;
  --ink: #11182a;
  --muted: #667085;
  --line: #dce3f0;
  --paper: #ffffff;
  --surface: #f5f8ff;
  --primary: #3157e8;
  --primary-dark: #2243c7;
  --accent: #12b8cf;
  --danger: #c93445;
  --shadow: 0 18px 50px rgba(26, 46, 95, 0.1);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #eef3fb; color: var(--ink); font-size: 16px; line-height: 1.65; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }

.document-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; min-height: 76px; padding: 14px max(24px, env(safe-area-inset-left));
  background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-logo { display: block; width: 64px; height: 43px; object-fit: contain; flex: 0 0 auto; }
.brand-name { font-weight: 750; }
.document-actions, .success-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 18px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; text-decoration: none; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(49,87,232,.24); outline-offset: 2px; }
.button-primary { color: #fff; background: linear-gradient(135deg,var(--primary),#1daee5); box-shadow: 0 9px 22px rgba(49,87,232,.2); }
.button-primary:hover { background: linear-gradient(135deg,var(--primary-dark),#148dbf); }
.button-secondary { color: var(--primary); background: #fff; border-color: #9db0f4; }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; box-shadow: none; }

.page-shell { width: min(980px, calc(100% - 32px)); margin: 30px auto; }
.document-cover, .format-summary, .toc, .legal-document, .bottom-cta { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.document-cover { display: grid; grid-template-columns: 1.45fr .8fr; gap: 42px; padding: 54px; border-radius: 8px 8px 0 0; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 13px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 18px; font-family: Georgia,"Times New Roman",serif; font-size: clamp(34px,5vw,56px); line-height: 1.08; letter-spacing: 0; }
h2 { line-height: 1.25; letter-spacing: 0; }
.cover-copy { max-width: 620px; margin: 0; color: var(--muted); font-size: 18px; }
.document-meta { margin: 0; padding: 22px; background: var(--surface); border-left: 3px solid var(--primary); }
.document-meta div + div { margin-top: 14px; }
.document-meta dt { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.document-meta dd { margin: 2px 0 0; font-weight: 700; }

.format-summary { margin-top: 18px; padding: 32px; border-radius: 8px; }
.section-heading h2 { margin: 0 0 8px; }
.section-heading > p:last-child { margin: 0; color: var(--muted); }
.format-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-top: 22px; }
.format-card { padding: 22px; border: 1px solid var(--line); border-top: 4px solid var(--primary); border-radius: 7px; background: linear-gradient(180deg,#fff,#f8faff); }
.format-card h3 { margin: 0 0 14px; }
.condition-list { display: grid; gap: 10px; margin: 0; }
.condition-list div { padding-top: 10px; border-top: 1px solid #e8edf6; }
.condition-list dt { color: var(--muted); font-size: 12px; }
.condition-list dd { margin: 2px 0 0; font-weight: 650; }
.format-cta { margin-top: 20px; }

.toc { margin-top: 18px; padding: 24px 28px; border-radius: 8px; }
.toc-heading { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.toc-toggle { padding: 6px 10px; color: var(--primary); background: transparent; border: 0; cursor: pointer; }
.toc ol { columns: 2; column-gap: 34px; margin: 16px 0 0; padding-left: 22px; }
.toc li { break-inside: avoid; padding: 3px 0; }
.toc a { color: #33415c; text-decoration: none; }
.toc a:hover { color: var(--primary); text-decoration: underline; }
.toc.collapsed ol { display: none; }

.legal-document { margin-top: 18px; padding: 58px 68px; border-radius: 8px; font-family: Georgia,"Times New Roman",serif; }
.legal-document > :first-child { margin-top: 0; }
.legal-document h2 { scroll-margin-top: 96px; margin: 52px 0 18px; padding-bottom: 10px; border-bottom: 1px solid #cbd4e3; font-size: 25px; }
.legal-document h3 { margin: 32px 0 12px; font-size: 20px; }
.legal-document p { margin: 0 0 13px; text-align: justify; }
.legal-document .doc-title { text-align: center; font-size: 28px; font-weight: 800; }
.legal-table-wrap { margin: 22px 0; overflow-x: auto; }
.legal-table { width: 100%; border-collapse: collapse; font-family: Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif; font-size: 14px; }
.legal-table th, .legal-table td { min-width: 150px; padding: 12px; border: 1px solid #cfd7e5; text-align: left; vertical-align: top; white-space: pre-line; }
.legal-table tr:first-child > * { background: #edf3ff; font-weight: 800; }
.bottom-cta { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 18px; padding: 28px 32px; border-radius: 8px; }
.bottom-cta h2, .bottom-cta p { margin: 0; }
.bottom-cta p { color: var(--muted); }
.document-footer { display: flex; justify-content: center; gap: 28px; padding: 20px 24px calc(24px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 14px; }

.accept-dialog { width: min(900px,calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 8px; color: var(--ink); background: var(--paper); box-shadow: 0 30px 90px rgba(0,14,48,.35); }
.accept-dialog::backdrop { background: rgba(8,17,38,.7); backdrop-filter: blur(4px); }
.accept-form, .success-panel { padding: 30px; }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: -30px -30px 24px; padding: 24px 30px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; }
.icon-button { flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 26px; }
.accept-form fieldset { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin: 0 0 22px; padding: 22px; border: 1px solid var(--line); border-radius: 7px; }
.accept-form legend { padding: 0 8px; font-size: 19px; font-weight: 800; }
.fieldset-copy { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.field { display: block; align-self: start; font-weight: 700; }
.field span, fieldset legend span { color: var(--danger); }
.field-wide { grid-column: 1 / -1; }
.field input, .field select { display: block; width: 100%; min-height: 48px; margin-top: 7px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #aebbd0; border-radius: 6px; }
.field small { display: block; margin-top: 7px; color: var(--muted); font-weight: 400; }
.field input:user-invalid, .field select:user-invalid { border-color: var(--danger); }
.choice-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.choice-card { position: relative; display: block; padding: 20px; border: 2px solid var(--line); border-radius: 7px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--primary); background: #f1f5ff; box-shadow: 0 0 0 3px rgba(49,87,232,.08); }
.choice-card input { position: absolute; top: 20px; right: 20px; width: 20px; height: 20px; accent-color: var(--primary); }
.choice-card h3 { max-width: calc(100% - 28px); margin: 0 0 12px; }
.choice-card .legal-summary { margin: 0; color: #33415c; font-size: 14px; }
.confirmations { grid-column: 1 / -1; display: grid; gap: 11px; }
.confirmation { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-weight: 550; cursor: pointer; }
.confirmation input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); }
.accept-footer { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.accept-footer p { max-width: 520px; margin: 0; color: var(--muted); font-size: 13px; }
.form-error { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #ef9baa; border-radius: 6px; background: #fff2f4; color: #9f1f34; }
.success-panel { text-align: center; }
.success-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 10px auto 18px; border-radius: 50%; background: #e6f8ef; color: #098b50; font-size: 34px; font-weight: 900; }
.success-panel h2 { max-width: 650px; margin: 0 auto 24px; }
.success-panel dl { width: min(560px,100%); margin: 0 auto 26px; text-align: left; border: 1px solid var(--line); border-radius: 7px; }
.success-panel dl div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 12px 16px; }
.success-panel dl div + div { border-top: 1px solid var(--line); }
.success-panel dt { color: var(--muted); }
.success-panel dd { margin: 0; font-weight: 750; }
.success-actions { justify-content: center; }
.print-statement { display: none; }

@media (max-width: 720px) {
  body { font-size: 15px; }
  .document-header { align-items: stretch; padding: 10px 14px; }
  .brand-name { display: none; }
  .document-actions { flex: 1; display: grid; grid-template-columns: 1fr 1fr; }
  .document-actions .button { min-height: 42px; padding: 8px; font-size: 13px; }
  .page-shell { width: min(100% - 20px,620px); margin: 14px auto; }
  .document-cover { grid-template-columns: 1fr; gap: 24px; padding: 28px 20px; }
  .cover-copy { font-size: 16px; }
  .format-summary, .toc { padding: 22px 18px; }
  .format-grid, .choice-grid { grid-template-columns: 1fr; }
  .toc ol { columns: 1; }
  .legal-document { padding: 30px 20px; }
  .legal-document h2 { margin-top: 38px; font-size: 21px; }
  .legal-document h3 { font-size: 18px; }
  .legal-document p { text-align: left; }
  .legal-table-wrap { margin-left: -20px; margin-right: -20px; padding: 0 20px; }
  .bottom-cta { align-items: stretch; flex-direction: column; padding: 22px 20px; }
  .document-footer { flex-direction: column; align-items: center; gap: 4px; }
  .accept-dialog { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .accept-form, .success-panel { padding: 20px 14px calc(24px + env(safe-area-inset-bottom)); }
  .dialog-header { margin: -20px -14px 20px; padding: calc(14px + env(safe-area-inset-top)) 14px 14px; }
  .accept-form fieldset { grid-template-columns: 1fr; padding: 18px 14px; }
  .field-wide { grid-column: auto; }
  .accept-footer { align-items: stretch; flex-direction: column; }
  .success-panel dl div { grid-template-columns: 1fr; gap: 2px; }
  .success-actions { display: grid; }
}

@page { size: A4; margin: 18mm 16mm 18mm; }
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 10.5pt; line-height: 1.4; }
  .no-print, .accept-dialog, .document-footer { display: none !important; }
  .page-shell { width: 100%; margin: 0; }
  .document-cover, .legal-document { padding: 0; border: 0; box-shadow: none; }
  .document-cover { display: block; page-break-after: always; }
  .document-meta { margin-top: 20mm; background: transparent; border: 1px solid #777; }
  .legal-document { margin: 0; }
  .legal-document h2 { margin-top: 12mm; scroll-margin: 0; page-break-after: avoid; }
  .legal-document h3, .legal-document p { page-break-inside: avoid; }
  .legal-table-wrap { overflow: visible; page-break-inside: avoid; }
  .legal-table { font-size: 8.5pt; }
  .legal-table th, .legal-table td { min-width: 0; padding: 5px; }
  body.print-application .page-shell { display: none; }
  body.print-application .print-statement { display: block; }
  .print-statement h1 { font-size: 18pt; text-align: center; }
  .print-statement h2 { margin-top: 10mm; font-size: 13pt; }
  .print-statement table { width: 100%; border-collapse: collapse; }
  .print-statement th, .print-statement td { padding: 7px; border: 1px solid #444; text-align: left; vertical-align: top; }
  .statement-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 18mm; margin-top: 18mm; }
  .statement-signatures div { padding-top: 12mm; border-top: 1px solid #000; }
}
