:root {
  --ink: #111111;
  --muted: #62676e;
  --soft: #f3f4f5;
  --line: #d9dcdf;
  --paper: #ffffff;
  --page: #eceeef;
  --green: #22b14c;
  --green-dark: #16863a;
  --green-soft: #eaf8ee;
  --red: #b42318;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #f8f8f8 0, var(--page) 420px),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea,
canvas {
  outline-offset: 3px;
}

:focus-visible {
  outline: 3px solid rgba(34, 177, 76, 0.42);
}

a {
  color: #0a6b2d;
  text-underline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100% - 32px, 1120px);
  margin: 0 auto;
  padding: 34px 0 72px;
}

.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto 26px;
  text-align: center;
}

.brand-logo {
  width: 190px;
  height: auto;
  object-fit: contain;
}

.brand-tagline {
  margin: 5px 0 0;
  color: #555b61;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.entry-card,
.authorization-card {
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.entry-card {
  position: relative;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: clamp(30px, 6vw, 58px);
  border-top: 7px solid var(--green);
}

.entry-card h1,
.authorization-header h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.step-badge,
.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.step-badge {
  position: absolute;
  top: 28px;
  right: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

.test-id-form {
  margin-top: 34px;
}

.test-id-form > label {
  display: block;
  margin-bottom: 10px;
  font-size: 17px;
  font-weight: 800;
}

#testId {
  width: 100%;
  padding: 17px 20px;
  border: 2px solid #9da2a7;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(30px, 9vw, 48px);
  font-weight: 800;
  letter-spacing: 0.23em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

#testId:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 177, 76, 0.12);
}

#testId[aria-invalid="true"] {
  border-color: var(--red);
}

.field-hint,
.privacy-note,
.signature-box p {
  color: var(--muted);
  font-size: 13px;
}

.field-hint {
  margin: 9px 0 0;
}

.privacy-note {
  margin: 26px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-message {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--red);
  border-radius: 5px;
  background: #fff1f0;
  color: #781d16;
  font-weight: 700;
}

.primary-action,
.decision-button {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-action {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 24px;
  padding: 17px 20px;
  background: var(--green);
  color: #fff;
  font-size: 17px;
  box-shadow: 0 10px 24px rgba(34, 177, 76, 0.24);
}

.primary-action:hover,
.decision-authorize:hover {
  transform: translateY(-2px);
  background: var(--green-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status-card {
  text-align: center;
}

.status-error {
  border-top-color: var(--red);
}

.authorization-card {
  border-top: 7px solid var(--ink);
}

.authorization-header {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding: clamp(28px, 5vw, 54px);
  background: #fff;
}

.authorization-header h1 {
  max-width: 780px;
}

.mode-badge {
  align-self: flex-start;
  min-width: 112px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.exam-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0 clamp(28px, 5vw, 54px) 30px;
}

.exam-summary div {
  padding: 18px 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.exam-summary div:first-child {
  border-left: 1px solid var(--line);
  border-radius: 8px 0 0 8px;
}

.exam-summary div:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
}

.exam-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.exam-summary dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.form-section,
.ratification-section {
  display: flex;
  gap: clamp(18px, 4vw, 36px);
  padding: clamp(32px, 6vw, 64px) clamp(28px, 6vw, 70px);
  border-top: 1px solid var(--line);
}

.form-section:nth-of-type(even) {
  background: #fafafa;
}

.section-copy {
  min-width: 0;
  flex: 1;
}

.section-copy h2 {
  margin: 0 0 24px;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.document-copy > p {
  max-width: 82ch;
}

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

.readonly-grid {
  margin-bottom: 24px;
}

.readonly-grid div {
  padding: 17px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--green-soft);
}

.readonly-grid span,
.readonly-grid strong {
  display: block;
}

.readonly-grid span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 750;
}

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

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #9ea3a8;
  border-radius: 7px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 500;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 177, 76, 0.1);
}

.field textarea {
  resize: vertical;
}

.recipient-field {
  display: grid;
  gap: 14px;
}

.recipient-options {
  margin: 0;
  padding: 0;
  border: 0;
}

.recipient-options legend {
  margin-bottom: 10px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.recipient-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
}

.recipient-grid label.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
}

.recipient-grid input {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.sensor-card {
  appearance: none;
  display: flex;
  min-height: 210px;
  flex-direction: column;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: #7a7e82;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.sensor-card:hover {
  transform: translateY(-2px);
}

.sensor-card.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--ink);
}

.sensor-card.is-neutral {
  border-color: var(--line);
  background: var(--soft);
  color: #7a7e82;
}

.sensor-card.is-disabled {
  border-color: #a11212;
  background: #c62828;
  color: #fff;
}

.sensor-card.is-disabled .sensor-code {
  background: #fff;
  color: #111;
}

.sensor-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.sensor-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #777d82;
}

.sensor-icon svg {
  width: 38px;
  height: 38px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.sensor-card.is-selected .sensor-icon {
  color: var(--green-dark);
}

.sensor-card.is-disabled .sensor-icon {
  color: #fff;
}

.sensor-card h3 {
  margin: 12px 0 8px;
  font-size: 16px;
  line-height: 1.15;
}

.sensor-card p {
  margin: 0;
  font-size: 13px;
}

.sensor-code {
  align-self: flex-start;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.sensor-status {
  margin-top: auto;
  padding-top: 14px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sensor-requirement {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.sensor-requirement strong {
  color: var(--ink);
}

.sensor-requirement.is-valid {
  border-color: var(--green);
  background: var(--green-soft);
}

.sensor-requirement.is-under-minimum {
  border-color: #d65a51;
  background: #fff1f0;
  color: #781d16;
}

.declaration-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  margin: 0;
  padding-left: 24px;
}

.declaration-list li {
  padding: 0 0 14px 6px;
  border-bottom: 1px solid var(--line);
}

.declaration-list li::marker {
  color: var(--green-dark);
  font-weight: 900;
}

.consent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0;
  padding: 20px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.consent-row legend {
  min-width: 0;
  padding: 0;
}

.consent-row legend strong,
.consent-row legend span {
  display: block;
}

.consent-row legend span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 450;
}

.consent-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.consent-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.consent-choice.consent-yes.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
}

.consent-choice.consent-no.is-selected {
  border-color: #8f0f0f;
  background: #d52b2b;
  color: #fff;
}

.consent-choice.consent-no input {
  accent-color: #111;
}

.consent-row input,
.accept-all input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.privacy-panel {
  margin: 18px 0;
  padding: 20px 22px;
  border-left: 5px solid var(--green);
  border-radius: 7px;
  background: var(--green-soft);
}

.privacy-panel p {
  margin: 6px 0;
}

.signature-section {
  background: #fafafa;
}

.accept-all {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.signature-box {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.signature-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  font-weight: 800;
}

.signature-heading button {
  border: 1px solid #a9adb1;
  border-radius: 5px;
  padding: 7px 10px;
  background: #f5f5f5;
  cursor: pointer;
  color: #4e5357;
  font-size: 13px;
  font-weight: 700;
}

#signatureCanvas {
  display: block;
  width: 100%;
  height: 220px;
  border: 2px dashed #9fa4a8;
  border-radius: 5px;
  background: #fff;
  touch-action: none;
}

.ratification-section {
  padding-top: 52px;
  padding-bottom: 60px;
}

.ratification-section blockquote {
  margin: 0 0 30px;
  padding: clamp(22px, 4vw, 34px);
  border: 0;
  border-left: 6px solid var(--green);
  border-radius: 8px;
  background: var(--green-soft);
  font-size: clamp(17px, 2.5vw, 20px);
  line-height: 1.7;
}

.signature-name {
  max-width: 680px;
}

.decision-panel {
  padding: clamp(34px, 6vw, 64px) clamp(28px, 6vw, 70px);
  border-top: 1px solid #2f3336;
  background: #151719;
  color: #fff;
}

.decision-heading {
  margin: 0 0 18px;
  color: #dfe2e4;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.decision-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  width: 100%;
  padding: 18px 22px;
  text-align: center;
}

.decision-authorize {
  min-height: 72px;
  background: var(--green);
  color: #fff;
  font-size: clamp(16px, 2.6vw, 20px);
  box-shadow: 0 12px 34px rgba(34, 177, 76, 0.25);
}

.decision-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.decision-decline {
  width: auto;
  margin: 18px auto 0;
  padding: 11px 18px;
  border: 1px solid #555b60;
  background: #34383b;
  color: #c8cccf;
  font-size: 14px;
  font-weight: 650;
}

.decision-decline:hover {
  background: #41464a;
  color: #fff;
}

.decision-panel .form-message {
  max-width: 760px;
  margin: 0 auto 18px;
  background: #3a1714;
  color: #ffd7d3;
}

.has-open-dialog {
  overflow: hidden;
}

.warning-dialog-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}

.warning-dialog-backdrop[hidden] {
  display: none;
}

.warning-dialog {
  width: min(100%, 560px);
  padding: clamp(28px, 6vw, 46px);
  border-top: 7px solid #d39b00;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32);
  text-align: center;
}

.warning-dialog-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 25px;
  font-weight: 900;
}

.warning-dialog h2 {
  margin: 0 0 14px;
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.1;
}

.warning-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.warning-dialog-action {
  justify-content: center;
  margin-top: 28px;
}

.noscript-note {
  margin: 0;
  padding: 16px;
  background: #fff1f0;
  color: #781d16;
  text-align: center;
}

@media (max-width: 880px) {
  .exam-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .exam-summary div,
  .exam-summary div:first-child,
  .exam-summary div:last-child {
    border: 1px solid var(--line);
    border-radius: 0;
  }

  .sensor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 18px, 1120px);
    padding-top: 22px;
  }

  .authorization-header {
    flex-direction: column;
  }

  .mode-badge {
    align-self: flex-start;
  }

  .form-section,
  .ratification-section {
    flex-direction: column;
  }

  .section-number {
    width: 38px;
    height: 38px;
  }

  .field-grid,
  .readonly-grid,
  .declaration-list {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .consent-row {
    grid-template-columns: 1fr;
  }

  .consent-row legend {
    width: 100%;
  }

.consent-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .consent-options label {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .entry-card {
    padding: 30px 22px;
  }

  .step-badge {
    position: static;
    margin-bottom: 24px;
  }

  #testId {
    padding-right: 12px;
    padding-left: 12px;
    letter-spacing: 0.16em;
  }

  .exam-summary {
    grid-template-columns: 1fr;
  }

  .sensor-grid {
    grid-template-columns: 1fr;
  }

  .recipient-grid {
    grid-template-columns: 1fr;
  }

  .sensor-requirement {
    flex-direction: column;
    gap: 3px;
  }

  #signatureCanvas {
    height: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
