/* ============ Tokens ============ */
:root {
  --brand-950: #1c0742;
  --brand-900: #2a0b5c;
  --accent: #4e18a0;
  --accent-hover: #5f22bf;
  --accent-subtle: rgba(78, 24, 160, .14);
  --accent-soft: #f3edfc;
  --amber: #f4a917;

  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --border: #e4e1ec;
  --border-strong: #cfcadb;
  --text: #17131f;
  --text-2: #5b5668;
  --text-3: #8a8597;
  --danger: #c4314b;
  --danger-soft: #fdeef1;
  --success: #1f8a5b;
  --success-soft: #e8f6ef;

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", var(--font);

  --text-xs: 12px; --text-sm: 14px; --text-md: 16px; --text-lg: 18px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(23, 19, 31, .06);
  --shadow-md: 0 8px 24px -8px rgba(42, 11, 92, .18);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 150ms; --dur: 260ms;
  --actions-h: 84px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ============ Base / comportamento de app ============ */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;          /* sem zoom por duplo toque */
  overscroll-behavior: none;
}
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font); font-size: var(--text-md); line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
/* 16px em todo campo impede o zoom automático do iOS ao focar */
input, select, textarea { font-size: 16px !important; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
[hidden] { display: none !important; }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before { content: ""; width: 14px; height: 2px; border-radius: 2px; background: currentColor; }
.eyebrow--light { color: var(--amber); }

/* ============ Layout ============ */
.app { display: grid; grid-template-columns: 1fr; }

.brand { display: none; }

.shell {
  width: 100%; max-width: 680px; margin-inline: auto;
  min-height: 100dvh; display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--space-5) 12px;
  background: var(--brand-900); color: #fff;
}
.topbar__logo { height: 34px; width: auto; }
.topbar__meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.topbar__step { font-size: var(--text-xs); color: rgba(255,255,255,.65); font-weight: 500; }
.topbar__name { font-size: var(--text-sm); font-weight: 700; }

.progress {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 12px var(--space-5) 0; background: var(--brand-900);
  position: sticky; top: 58px; z-index: 19; padding-bottom: 14px;
}
.progress__bar { display: block; height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); position: relative; overflow: hidden; }
.progress__bar::after {
  content: ""; position: absolute; inset: 0; background: var(--amber);
  transform: scaleX(0); transform-origin: left; transition: transform var(--dur) var(--ease-out);
}
.progress__item.is-active .progress__bar::after,
.progress__item.is-done .progress__bar::after { transform: scaleX(1); }
.progress__label { display: none; }

.form { flex: 1; display: flex; flex-direction: column; }

.step {
  flex: 1;
  padding: var(--space-6) var(--space-5) calc(var(--actions-h) + var(--safe-b) + var(--space-6));
  animation: stepIn var(--dur) var(--ease-out);
}
.step.is-back { animation-name: stepInBack; }
@keyframes stepIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes stepInBack { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

.step__title {
  font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em;
  font-size: 28px; line-height: 1.1; margin: var(--space-2) 0 var(--space-2);
}
.step__title strong { color: var(--accent); font-weight: 700; }
.step__lead { margin: 0 0 var(--space-6); color: var(--text-2); font-size: var(--text-sm); }

/* ============ Campos ============ */
.grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.field { margin-bottom: var(--space-6); }
.field > label, .field legend { font-size: var(--text-sm); font-weight: 600; color: var(--text); padding: 0; }
.field legend { margin-bottom: 10px; }
.field label em, .field legend em { font-style: normal; font-weight: 500; color: var(--text-3); margin-left: 4px; font-size: var(--text-xs); }

.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea {
  width: 100%; height: 52px; padding: 0 var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; appearance: none; -webkit-appearance: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.field textarea { height: auto; min-height: 96px; padding: 14px var(--space-4); resize: vertical; line-height: 1.45; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-subtle); }
.field.is-invalid input:not([type=radio]):not([type=checkbox]), .field.is-invalid select { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.field.is-valid input:not([type=radio]):not([type=checkbox]) { border-color: #bfe3d1; }
.field__error { display: none; color: var(--danger); font-size: var(--text-xs); font-weight: 500; }
.field.is-invalid .field__error, .field__error.is-shown { display: block; }

.select { position: relative; }
.select::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 1.6px solid var(--accent); border-bottom: 1.6px solid var(--accent); transform: rotate(45deg); pointer-events: none;
}
.input-wrap { position: relative; }
.input-wrap .spinner { position: absolute; right: 16px; top: 50%; margin-top: -9px; }

.is-pj .pf-only { display: none; }

/* Cartões de plano */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.plan input, .chip input, .consent input { position: absolute; opacity: 0; pointer-events: none; }
.plan__body {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: var(--space-4); min-height: 104px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.plan:active .plan__body { transform: scale(.98); }
.plan__name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; line-height: 1.1; padding-right: 26px; }
.plan__price { font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--text); margin-top: auto; }
.plan__price small { font-size: 12px; font-weight: 600; color: var(--text-2); }
.plan__price small:first-child { margin-right: 2px; }
.plan__check {
  position: absolute; top: 14px; right: 14px; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: #fff;
  transition: all var(--dur-fast);
}
.plan__check svg { width: 14px; opacity: 0; }
.plan input:checked + .plan__body { border-color: var(--accent); background: var(--accent-soft); }
.plan input:checked + .plan__body .plan__check { background: var(--accent); border-color: var(--accent); }
.plan input:checked + .plan__body .plan__check svg { opacity: 1; }
.plan input:focus-visible + .plan__body { box-shadow: 0 0 0 4px var(--accent-subtle); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chips--days { display: grid; grid-template-columns: repeat(6, 1fr); }
.chip span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--space-4);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 999px;
  font-size: var(--text-sm); font-weight: 600; color: var(--text-2); cursor: pointer;
  transition: all var(--dur-fast);
}
.chips--days .chip span { padding: 0; border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; font-size: var(--text-md); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-subtle); }

/* Localização */
.locate { margin-bottom: var(--space-6); gap: var(--space-3); }
.btn--locate {
  width: 100%; height: 56px; border-radius: var(--radius-md);
  background: var(--accent-soft); color: var(--accent); border: 1.5px dashed rgba(78,24,160,.45);
  font-weight: 700; font-size: var(--text-md);
}
.btn--locate svg { width: 22px; height: 22px; }
.btn--locate.is-loading { opacity: .8; pointer-events: none; }
.btn--locate.is-loading svg { animation: pulse 1s ease-in-out infinite; }
.btn--locate.is-done { background: var(--success-soft); color: var(--success); border-style: solid; border-color: #bfe3d1; }
@keyframes pulse { 50% { transform: scale(.8); opacity: .5; } }

.map-card { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.map { height: 240px; background: #e9e6f0; z-index: 0; }
.map-card__status { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0; padding: 12px 14px; font-size: var(--text-xs); color: var(--text-2); border-top: 1px solid var(--border); }
.map-card__status svg { width: 16px; flex: none; color: var(--accent); margin-top: 1px; }
.map-card__status.is-ok { color: var(--success); }
.map-card__status.is-ok svg { color: var(--success); }
.locate.is-invalid .map-card { border-color: var(--danger); }

.pin {
  width: 36px; height: 36px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 6px 14px rgba(42,11,92,.35);
}
.pin::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--amber); }
.accuracy { stroke: var(--accent); fill: var(--accent); }

/* Consentimento */
.consent { flex-direction: row; align-items: flex-start; gap: var(--space-3); margin-top: var(--space-6); font-size: var(--text-sm); color: var(--text-2); cursor: pointer; position: relative; }
.consent__box {
  flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; background: var(--surface); color: #fff; margin-top: 1px; transition: all var(--dur-fast);
}
.consent__box svg { width: 14px; opacity: 0; }
.consent input:checked + .consent__box { background: var(--accent); border-color: var(--accent); }
.consent input:checked + .consent__box svg { opacity: 1; }
.consent.is-invalid .consent__box { border-color: var(--danger); }

.alert { margin-top: var(--space-4); padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); font-weight: 500; }

/* ============ Botões / barra de ações ============ */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: var(--space-3);
  padding: 14px var(--space-5) calc(14px + var(--safe-b));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--border);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 54px; padding: 0 var(--space-5); border-radius: var(--radius-md); border: 0;
  font-weight: 700; font-size: var(--text-md); text-decoration: none;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn--primary { flex: 1; background: var(--accent); color: #fff; box-shadow: var(--shadow-md); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary .btn__icon { transition: transform var(--dur-fast) var(--ease-out); }
.btn--primary:hover .btn__icon { transform: translateX(3px); }
.btn--primary[disabled] { opacity: .7; pointer-events: none; }
.btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn--ghost span { display: none; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent-subtle); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
.spinner--light { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }

/* ============ Telas maiores ============ */
@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .col-2 { grid-column: span 2; }
  .plans { grid-template-columns: repeat(3, 1fr); }
  .plan__name { font-size: 20px; }
  .btn--ghost span { display: inline; }
  .map { height: 300px; }
}

@media (min-width: 1024px) {
  .app { grid-template-columns: minmax(380px, 38%) 1fr; min-height: 100dvh; }
  .brand {
    display: block; position: sticky; top: 0; height: 100dvh; overflow: hidden;
    background: var(--brand-950); color: #fff;
  }
  .brand::before {
    content: ""; position: absolute; width: 520px; height: 520px; left: -160px; top: -180px; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(95,34,191,.55), transparent); pointer-events: none;
  }
  .brand__inner { position: relative; height: 100%; display: flex; flex-direction: column; padding: 48px clamp(32px, 4vw, 64px); }
  .brand__logo { width: 140px; height: auto; margin-bottom: 56px; }
  .brand__title { font-family: var(--font-display); font-weight: 600; font-size: clamp(32px, 3vw, 44px); line-height: 1.05; letter-spacing: -.025em; margin: 16px 0 16px; }
  .brand__title strong { color: var(--amber); font-weight: 700; }
  .brand__text { color: rgba(255,255,255,.7); margin: 0 0 32px; max-width: 42ch; font-size: var(--text-md); }
  .brand__list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
  .brand__list li { display: flex; align-items: center; gap: 12px; font-size: var(--text-sm); font-weight: 500; color: rgba(255,255,255,.88); }
  .brand__list svg { width: 20px; height: 20px; color: var(--amber); flex: none; }
  .brand__banner { margin-top: auto; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,.1); }

  .shell { max-width: 720px; padding: 0 40px; }
  .topbar { position: static; background: transparent; color: var(--text); padding: 40px 0 0; }
  .topbar__logo { display: none; }
  .topbar__meta { align-items: flex-start; }
  .topbar__step { color: var(--text-3); }
  .progress { position: static; background: transparent; padding: 16px 0 0; gap: 12px; }
  .progress__bar { background: var(--border); }
  .progress__bar::after { background: var(--accent); }
  .progress__label { display: block; margin-top: 8px; font-size: var(--text-xs); font-weight: 600; color: var(--text-3); }
  .progress__item.is-active .progress__label { color: var(--accent); }
  .progress__item.is-done .progress__label { color: var(--text-2); }
  .topbar { display: none; }
  .progress { padding-top: 48px; }
  .step { padding: 40px 0 calc(var(--actions-h) + 48px); }
  .step__title { font-size: 36px; }
  .actions { left: auto; right: auto; width: 100%; max-width: 640px; position: sticky; bottom: 0; padding: 16px 0 24px; background: linear-gradient(to top, var(--bg) 70%, transparent); border: 0; }
  .btn--primary { flex: 0 0 auto; min-width: 220px; margin-left: auto; }
}

@media (min-width: 1024px) and (max-height: 820px) {
  .brand__banner { display: none; }
  .brand__logo { margin-bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
