:root {
  color-scheme: light dark;
  --background: #f5f7fa;
  --surface: #fefefe;
  --text: #202c3b;
  --muted: #536174;
  --border: #7c899b;
  --accent: #2458a6;
  --accent-hover: #194783;
  --button-text: #fefefe;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--background);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
}

.page {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.brands {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 48px;
}

.brands img {
  display: block;
  max-width: 48%;
  height: auto;
}

.page-header {
  margin-bottom: 32px;
}

h1 {
  max-width: 26ch;
  margin: 0;
  font-size: clamp(28px, 4.5vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.subtitle {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.document-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.document-panel summary {
  display: block;
  padding: 16px 24px;
  list-style: none;
  font-weight: 600;
  cursor: pointer;
}

.document-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}

.document-preview {
  display: block;
  height: 8.25em;
  margin-top: 16px;
  overflow: hidden;
  font-weight: 400;
  line-height: 1.65;
  overflow-wrap: anywhere;
  -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent);
  mask-image: linear-gradient(to bottom, #000 50%, transparent);
}

.document-panel summary::-webkit-details-marker {
  display: none;
}

.document-action {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 14px;
}

.document-close,
.document-panel[open] .document-preview,
.document-panel[open] .document-open {
  display: none;
}

.document-panel[open] .document-close {
  display: inline;
}

.document {
  padding: 32px;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.document p {
  margin: 0 0 16px;
}

.document p:first-child {
  font-weight: 700;
}

.document p:last-child {
  margin-bottom: 0;
}

.document h2 {
  margin: 28px 0 8px;
  font-size: 18px;
  line-height: 1.4;
}

.consent-form {
  margin-top: 40px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-size: 23px;
  font-weight: 700;
}

.form-hint {
  margin: 8px 0 24px;
  color: var(--muted);
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 600;
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 1;
}

:where(input, button, a, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.confirmation {
  margin-top: 40px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  cursor: pointer;
}

.checkbox-label input {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-actions {
  display: grid;
  justify-items: start;
  gap: 20px;
  margin-top: 32px;
}

button {
  min-height: 52px;
  padding: 14px 24px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--button-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.withdrawal-note {
  margin: 80px 0 0;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.withdrawal-note a {
  color: var(--accent);
  text-underline-offset: 4px;
}

.withdrawal-note a:hover {
  text-decoration-thickness: 2px;
}

.form-status {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.unavailable {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.success-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgb(10 18 30 / 25%);
}

.success-dialog::backdrop {
  background: rgb(10 18 30 / 58%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.success-dialog h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.success-dialog p {
  margin: 16px 0 0;
  color: var(--muted);
}

.success-dialog button {
  width: 100%;
}

body:has(.success-dialog[open]) {
  overflow: hidden;
}

@media (max-width: 767px) {
  .page {
    padding: 24px 16px 40px;
  }

  .brands {
    margin-bottom: 32px;
  }

  .document {
    padding: 24px 20px;
  }

  .document-panel summary {
    padding: 16px;
  }

  .withdrawal-note {
    padding: 20px;
  }

  .fields {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  button {
    width: 100%;
  }

  .form-actions {
    justify-items: stretch;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #171d26;
    --surface: #202935;
    --text: #edf1f6;
    --muted: #bac5d3;
    --border: #64748b;
    --accent: #a3c6ff;
    --accent-hover: #c2d8ff;
    --button-text: #172941;
  }

  .brands img {
    filter: invert(1);
  }
}
