/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a56db;
  --blue-dark: #1340b0;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fef2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 12px 40px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  min-height: 100vh;
  color: var(--gray-900);
  line-height: 1.6;
}

/* ── Layout ───────────────────────────────────────────────── */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-logo {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 1.25rem; font-weight: 700; color: var(--blue);
}
.header-subtitle { font-size: 0.85rem; color: var(--gray-400); }

/* ── Main ─────────────────────────────────────────────────── */
.main-content { max-width: 720px; margin: 0 auto; padding: 2rem 1rem 4rem; width: 100%; flex: 1; }

/* ── Steps bar ────────────────────────────────────────────── */
.steps-bar {
  display: flex; align-items: center;
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.step { display: flex; align-items: center; gap: 0.5rem; flex-direction: column; }
.step-circle {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  background: var(--gray-100); color: var(--gray-400);
  border: 2px solid var(--gray-200);
  transition: all .25s;
}
.step-label { font-size: 0.72rem; color: var(--gray-400); font-weight: 500; white-space: nowrap; }
.step.active .step-circle { background: var(--blue); color: white; border-color: var(--blue); }
.step.active .step-label { color: var(--blue); }
.step.completed .step-circle { background: var(--green); color: white; border-color: var(--green); }
.step.completed .step-label { color: var(--green); }
.step-line { flex: 1; height: 2px; background: var(--gray-200); margin: 0 .25rem; margin-bottom: 1.2rem; transition: background .25s; }
.step-line.completed { background: var(--green); }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.card-title {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.1rem; font-weight: 700; color: var(--gray-900);
  margin-bottom: 1.5rem;
}
.card-title svg { color: var(--blue); }
.card-desc { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ── Form elements ────────────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

label {
  font-size: 0.85rem; font-weight: 600; color: var(--gray-700);
  display: flex; align-items: center; gap: 0.35rem;
}
.req { color: var(--blue); }
.label-hint { font-size: 0.75rem; font-weight: 400; color: var(--gray-400); margin-left: 0.25rem; }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--gray-900);
  background: var(--gray-50);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
  background: white;
}
input.invalid, textarea.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
textarea { resize: vertical; min-height: 80px; }

.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 3rem; }
.unit {
  position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%);
  font-size: 0.85rem; font-weight: 600; color: var(--gray-400);
}

.field-error { font-size: 0.8rem; color: var(--red); min-height: 1rem; }

/* ── Trip type ────────────────────────────────────────────── */
.trip-type-group { margin: 1.25rem 0; }
.trip-type-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.6rem; }
.trip-type-options { display: flex; gap: 1rem; }
.trip-option { cursor: pointer; flex: 1; }
.trip-option input[type="radio"] { display: none; }
.trip-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  padding: 1rem; border-radius: 10px;
  border: 2px solid var(--gray-200);
  background: var(--gray-50);
  text-align: center;
  transition: all .2s;
  color: var(--gray-600);
}
.trip-card strong { font-size: 0.9rem; color: var(--gray-900); }
.trip-card span { font-size: 0.78rem; color: var(--gray-400); }
.trip-option input:checked + .trip-card {
  border-color: var(--blue); background: var(--blue-light); color: var(--blue);
}
.trip-option input:checked + .trip-card strong { color: var(--blue); }

/* ── Distance section ─────────────────────────────────────── */
.distance-section { margin: 1.25rem 0; }
.distance-result { margin-top: 0.75rem; }
.distance-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--blue-light); color: var(--blue);
  padding: 0.5rem 1rem; border-radius: 999px;
  font-size: 0.875rem; font-weight: 600;
  border: 1px solid #bfdbfe;
}
.manual-distance { margin-top: 1rem; }

/* ── Total preview ────────────────────────────────────────── */
.total-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}
.total-row {
  display: flex; justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.total-row:last-child { border-bottom: none; }
.total-row.highlight { color: var(--gray-900); font-weight: 600; }
.total-row.grand-total {
  font-size: 1.05rem; font-weight: 700;
  color: var(--blue); margin-top: 0.25rem;
  border-top: 2px solid var(--blue); border-bottom: none;
  padding-top: 0.6rem;
}

/* ── Signature ────────────────────────────────────────────── */
.signature-container { margin-bottom: 1rem; }
.signature-wrapper {
  position: relative;
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  background: var(--gray-50);
  cursor: crosshair;
  height: 160px;
}
.signature-wrapper:hover { border-color: var(--blue); }
#signatureCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; touch-action: none; }
.sig-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--gray-400);
  pointer-events: none; user-select: none;
  transition: opacity .2s;
}
.sig-placeholder.hidden { opacity: 0; }
.signature-actions { margin-top: 0.5rem; display: flex; justify-content: flex-end; }

/* ── Summary box ──────────────────────────────────────────── */
.summary-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.summary-box h3 { font-size: 0.95rem; font-weight: 700; color: var(--gray-700); margin-bottom: 0.75rem; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.summary-item { font-size: 0.85rem; }
.summary-item .s-label { color: var(--gray-400); font-size: 0.75rem; }
.summary-item .s-value { color: var(--gray-900); font-weight: 500; }
.summary-total {
  grid-column: 1 / -1;
  background: var(--blue);
  color: white;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem;
}
.summary-total .s-label { color: rgba(255,255,255,.8); font-size: 0.85rem; }
.summary-total .s-value { font-size: 1.2rem; font-weight: 800; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .2s;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,.35); }
.btn-outline { background: white; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-outline:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-secondary { background: var(--blue-light); color: var(--blue); border: 1.5px solid #bfdbfe; }
.btn-secondary:hover:not(:disabled) { background: #dbeafe; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,.35); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ── Step actions ─────────────────────────────────────────── */
.step-actions { display: flex; justify-content: space-between; align-items: center; }
.action-group { display: flex; gap: 0.75rem; }

/* ── Confirmation ─────────────────────────────────────────── */
.confirmation-card { text-align: center; padding: 3rem 2rem; }
.confirmation-icon { margin-bottom: 1.25rem; }
.confirmation-card h2 { font-size: 1.6rem; color: var(--green); margin-bottom: 0.5rem; }
.confirmation-card p { color: var(--gray-600); margin-bottom: 1.5rem; }
.confirm-details {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 1rem 1.5rem; margin-bottom: 2rem;
  display: inline-block; min-width: 300px;
}
.confirm-row { display: flex; justify-content: space-between; padding: 0.35rem 0; font-size: 0.9rem; }
.confirm-row:not(:last-child) { border-bottom: 1px solid var(--gray-200); }
.confirm-row strong { color: var(--gray-900); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 2rem; right: 2rem;
  background: var(--gray-900); color: white;
  padding: 0.85rem 1.25rem; border-radius: 10px;
  font-size: 0.9rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(120%); opacity: 0;
  transition: all .35s cubic-bezier(.34, 1.56, .64, 1);
  z-index: 1000; max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ── Form step transitions ────────────────────────────────── */
.form-step { display: none; }
.form-step.active { display: block; animation: fadeSlide .3s ease; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading state ────────────────────────────────────────── */
.loading { position: relative; pointer-events: none; }
.loading::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.hidden { display: none !important; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: white; border-top: 1px solid var(--gray-200);
  text-align: center; padding: 1rem;
  font-size: 0.8rem; color: var(--gray-400);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .steps-bar { padding: 1rem; }
  .step-label { font-size: 0.65rem; }
  .card { padding: 1.25rem; }
  .header-subtitle { display: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .action-group { flex-direction: column; }
  .trip-type-options { flex-direction: column; }
}
