:root {
  --bg: #0b1f2a;
  --card: #122a36;
  --text: #f4f7f8;
  --muted: #9bb0ba;
  --accent: #3db8a6;
  --accent-press: #2f9a8a;
  --danger: #e56b6b;
  --border: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --sales-max: 420px;
  --sales-pad-x: 1.15rem;
  --sales-pad-y: 1.5rem;
  --sig-height: 180px;
  --tap: 52px;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 20% -10%, #1a4a5a 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

.sales {
  width: 100%;
  max-width: var(--sales-max);
  margin: 0 auto;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  padding:
    max(var(--sales-pad-y), env(safe-area-inset-top, 0px))
    max(var(--sales-pad-x), env(safe-area-inset-right, 0px))
    0
    max(var(--sales-pad-x), env(safe-area-inset-left, 0px));
}

.sales__header { margin-bottom: 1.25rem; }
.sales__brand {
  display: block;
  width: 5.46rem;
  max-width: 32%;
  height: auto;
  margin: 0 0 1.35rem;
}
h1 {
  font-size: clamp(1.65rem, 2.4vw + 1rem, 2.15rem);
  line-height: 1.2;
  margin: 0 0 0.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.sales__lede {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 1rem;
  max-width: 38rem;
}

.sales__footer {
  margin-top: auto;
  padding-top: 2.5rem;
  padding-bottom: max(1.75rem, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  flex-shrink: 0;
}

.sales__footer-links {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sales__footer-links a {
  color: inherit;
  text-decoration: none;
}

.sales__footer-links a:hover {
  text-decoration: underline;
}

.sales__footer-links a:focus-visible {
  outline: 2px solid var(--fg, #fff);
  outline-offset: 2px;
}

.sales__azolla {
  display: block;
  width: 7.5rem;
  max-width: 45%;
  height: auto;
  opacity: 0.92;
}

.card {
  background: color-mix(in srgb, var(--card) 92%, black);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
  max-width: 100%;
}

.label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.stepper {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  gap: 0.5rem;
  align-items: center;
}

.stepper__btn,
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
}

.stepper__btn {
  height: var(--tap);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}
.stepper__btn:active { background: rgba(255, 255, 255, 0.14); }

.stepper__value {
  height: var(--tap);
  text-align: center;
  font-size: 1.5rem;
  font-weight: 650;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  width: 100%;
}

.text-input {
  height: 48px;
  width: 100%;
  padding: 0 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.text-input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }

/* Hide number spinners */
.stepper__value::-webkit-outer-spin-button,
.stepper__value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__value { -moz-appearance: textfield; }

.plan {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.plan__option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.15);
  min-height: var(--tap);
}
.plan__option:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 70%, white);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.plan__option input { margin-top: 0.25rem; accent-color: var(--accent); }
.plan__option strong { display: block; }
.plan__option small { color: var(--muted); }

.summary {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  line-height: 1.45;
}
.summary strong { color: var(--text); }
.summary .muted { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.85rem 1.1rem;
  text-decoration: none;
  font-weight: 650;
  text-align: center;
}
.btn--primary {
  width: 100%;
  max-width: 100%;
  background: var(--accent);
  color: #042029;
}
.btn--primary:active { background: var(--accent-press); }
.btn--primary:disabled {
  opacity: 0.55;
  cursor: wait;
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.sales__note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.sales__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

/* .card sets display:grid which otherwise beats the UA [hidden] rule */
[hidden],
.state-panel[hidden],
.state-panel.is-hidden {
  display: none !important;
}

.sales--wide {
  --sales-max: 640px;
  overflow-x: clip;
}

.state-panel--plain {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.agreement-flow {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.agreement-end {
  height: 1px;
  width: 100%;
  pointer-events: none;
}

.sign-form {
  display: grid;
  gap: 1rem;
  margin-top: 0.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.sign-form__row {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.agreement h3 {
  margin: 1.25rem 0 0.45rem;
  font-size: 1rem;
}
.agreement__meta {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.agreement__intro {
  margin: 0 0 0.85rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.venue-card {
  display: grid;
  gap: 0;
  margin: 0 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.venue-row {
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr);
  gap: 0.35rem 0.85rem;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.venue-row:first-child {
  border-top: 0;
}
.venue-label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.venue-value {
  font-size: 0.92rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.venue-note {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.82rem;
}

.agreement__terms p {
  margin: 0.55rem 0;
  font-size: 0.94rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

.confirm__body {
  display: grid;
  gap: 1.15rem;
}
.confirm__next h2 {
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
}
.confirm__next p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.confirm__note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}
.confirm__actions {
  display: grid;
  gap: 0.75rem;
}

.sig-pad-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  touch-action: none;
}

.sig-pad-wrap canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: var(--sig-height);
  cursor: crosshair;
  vertical-align: top;
  touch-action: none;
}

.sig-clear {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 2;
  background: rgba(11, 31, 42, 0.88) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.agree {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  min-width: 0;
}
.agree span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.agree input {
  margin-top: 0.2rem;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.btn--tiny {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn--accent {
  width: 100%;
  max-width: 100%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #e8fffb;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, white);
}

.btn--accent:active {
  background: color-mix(in srgb, var(--accent) 32%, transparent);
}

a.btn {
  text-decoration: none;
}

.muted { color: var(--muted); }

/* —— Phone (narrow) —— */
@media (max-width: 699px) {
  :root {
    --sales-pad-x: 0.9rem;
    --sales-pad-y: 1.15rem;
  }
}

/* —— iPad portrait / small tablet —— */
@media (min-width: 700px) {
  :root {
    --sales-max: 560px;
    --sales-pad-x: 2rem;
    --sales-pad-y: 2.25rem;
    --sig-height: 240px;
    --tap: 56px;
    --radius: 18px;
  }

  .sales--wide {
    --sales-max: 760px;
  }

  .sales__header {
    margin-bottom: 1.6rem;
  }

  .sales__lede {
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .card {
    padding: 1.5rem;
    gap: 1.15rem;
  }

  .text-input {
    height: 52px;
    font-size: 1.05rem;
  }

  .plan {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .plan__option {
    padding: 1rem 1.05rem;
  }

  .sign-form__row {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .venue-card {
    grid-template-columns: 1fr 1fr;
  }
  .venue-row {
    border-top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.85rem 1rem;
  }
  .venue-row:nth-child(2n) {
    border-right: 0;
  }
  /* Last odd item spans full width cleanly */
  .venue-row:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .agreement h3 { font-size: 1.08rem; margin-top: 1.45rem; }
  .agreement__intro,
  .agreement__terms p {
    font-size: 1.02rem;
    line-height: 1.55;
  }

  .confirm__body {
    gap: 1.35rem;
    max-width: 40rem;
  }
  .confirm__next h2 {
    font-size: 1.3rem;
  }
  .confirm__note {
    font-size: 1.02rem;
  }
  .confirm__actions {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    align-items: stretch;
  }

  .agree {
    font-size: 0.98rem;
    gap: 0.8rem;
  }

  .sig-clear {
    min-height: 40px;
    padding: 0.4rem 0.85rem;
  }
}

/* —— iPad landscape / large tablet —— */
@media (min-width: 1024px) {
  :root {
    --sales-max: 600px;
    --sales-pad-x: 2.5rem;
    --sales-pad-y: 2.75rem;
    --sig-height: 260px;
  }

  .sales--wide {
    --sales-max: 880px;
  }

  .sales--wide.sales--confirm {
    --sales-max: 760px;
  }

  .confirm__body {
    max-width: none;
    grid-template-columns: 1.2fr 0.8fr;
    grid-template-areas:
      "next actions"
      "note actions";
    column-gap: 1.75rem;
    row-gap: 1rem;
    align-items: start;
  }
  .confirm__next { grid-area: next; }
  .confirm__note { grid-area: note; }
  .confirm__actions {
    grid-area: actions;
    grid-template-columns: 1fr;
    position: sticky;
    top: 1.5rem;
  }

  .sign-form {
    gap: 1.15rem;
    padding-top: 1.5rem;
  }
}
