*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --border: #cbd5e1;
  --border-focus: #6366f1;
  --input-bg: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --error: #dc2626;
  --radius: 14px;
  --input-radius: 10px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --touch-min: 48px;
  color-scheme: light;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.header {
  text-align: center;
  padding: 0.75rem 0 1.25rem;
}

.logo {
  display: inline-block;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}

a.logo:hover,
a.logo:focus-visible {
  text-decoration: underline;
}

.tagline {
  margin: 0.35rem 0 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

main {
  flex: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.hidden {
  display: none !important;
}

.state-panel {
  text-align: center;
  padding: 2.5rem 1.25rem;
}

.state-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.state-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 52px;
  margin: 0 auto 1rem;
}

.progress {
  margin-bottom: 1.5rem;
}

.progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.progress-bar {
  height: 5px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.section {
  margin-bottom: 1.75rem;
}

.section:last-of-type {
  margin-bottom: 1.25rem;
}

.section h2 {
  margin: 0 0 1rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  position: relative;
}

.field span {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* All inputs — light bg, dark text, 16px prevents iOS zoom */
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="password"] {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.75rem 1rem;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--input-radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

/* Date inputs — keep native picker, force light color scheme */
.field input[type="date"] {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.75rem 1rem;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--input-radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: light;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  position: relative;
}

.field input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  color: var(--text);
}

.field input::placeholder {
  color: #94a3b8;
}

.field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Field-level validation errors */
.field.has-error > span:first-child,
.consent-section.has-error .consent span {
  color: var(--error);
}

.field.has-error input,
.consent-section.has-error {
  border-color: var(--error);
}

.field.has-error input[type="text"],
.field.has-error input[type="email"],
.field.has-error input[type="tel"],
.field.has-error input[type="password"],
.field.has-error input[type="date"] {
  border-color: var(--error);
  background: #fff8f8;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field.has-error input:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.consent-section.has-error {
  background: #fef2f2;
  border-color: #fca5a5;
}

.field-error-msg {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--error);
  line-height: 1.35;
  margin-top: -0.125rem;
}

.field-error-msg.hidden {
  display: none;
}

.hint {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.consent-section {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--accent-light);
  border-radius: var(--input-radius);
  border: 1px solid #c7d2fe;
}

.consent {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.consent input {
  margin-top: 0.15rem;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.form-error {
  color: var(--error);
  font-size: 0.9375rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border-radius: var(--input-radius);
  border: 1px solid #fecaca;
}

.additional-owners {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.owner-card {
  border: 1px solid var(--border);
  border-radius: var(--input-radius);
  padding: 0.875rem 0.875rem 0.25rem;
  background: #f8fafc;
}

.owner-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.owner-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.owner-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  -webkit-tap-highlight-color: transparent;
}

.owner-remove:hover {
  color: var(--error);
}

.add-owner-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 0.35rem;
  padding: 0.65rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px dashed #a5b4fc;
  border-radius: var(--input-radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.add-owner-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.add-owner-btn:disabled,
.add-owner-btn.hidden {
  display: none;
}

.add-owner-hint {
  display: block;
  margin: 0.4rem 0 0;
}

.submit-btn {
  width: 100%;
  min-height: 52px;
  padding: 0.875rem 1rem;
  font-size: 1.0625rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--input-radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
}

.secure-note svg {
  flex-shrink: 0;
  color: var(--muted);
}

.footer {
  text-align: center;
  padding: 1.25rem 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

/* Places API (New) — custom suggestion list */
.address-suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 0.25rem);
  z-index: 10000;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--input-radius);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
  max-height: 240px;
  overflow-y: auto;
}

.address-suggestion {
  padding: 0.875rem 1rem;
  min-height: var(--touch-min);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.125rem;
  color: var(--text);
  border-top: 1px solid #e2e8f0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.35;
}

.address-suggestion:first-child {
  border-top: none;
}

.address-suggestion:hover,
.address-suggestion.is-active {
  background: var(--accent-light);
}

.address-suggestion strong {
  font-weight: 600;
  color: var(--text);
}

.address-suggestion span {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

/* iPhone / small screens */
@media (max-width: 390px) {
  .card {
    padding: 1.125rem;
  }

  .logo {
    font-size: 1.5rem;
  }
}

@media (min-width: 480px) {
  .card {
    padding: 1.5rem;
  }

  .page {
    padding-top: 2rem;
  }
}


/* ── Dealer link (/d/<code>) ─────────────────────────────────────────────── */
.field select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.75rem 1rem;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--input-radius);
  outline: none;
}

.field select:focus {
  border-color: var(--accent);
}

.field.has-error select {
  border-color: var(--error);
}

#dealer-step1 .consent-section {
  margin-bottom: 0.75rem;
}

.consent-optional {
  background: transparent;
  border-color: var(--border);
}

.upload-offer {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.upload-link {
  display: block;
  text-align: center;
  text-decoration: none;
  line-height: 1.6;
}

.upload-offer p {
  margin-bottom: 0.875rem;
}


/* ── Typed dates (no calendar) ───────────────────────────────────────────── */
.date-parts {
  display: flex;
  gap: 0.5rem;
}

.date-parts input {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.date-parts input[maxlength="4"] {
  flex: 1.5 1 0;
}
