:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #1f2d33;
  --muted: #4f5f66;
  --primary: #2b6777;
  --primary-dark: #1f4f5c;
  --primary-soft: #e3eff1;
  --border: #c9d6d9;
  --success: #2e7d5b;
  --danger: #b3261e;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 20px 20px 18px;
  text-align: center;
}
.topbar h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
.topbar .subtitle { margin: 2px 0 0; opacity: 0.9; font-size: 1rem; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

h2 { font-size: 1.35rem; margin: 8px 0 16px; }
h2[tabindex="-1"]:focus { outline: none; }

/* Progress */
.steps ol {
  list-style: none; margin: 0 0 16px; padding: 0;
  display: flex; justify-content: space-between; gap: 4px;
}
.step-dot {
  flex: 1; text-align: center; font-weight: 600; color: var(--muted);
  font-size: 0.95rem; padding: 8px 0; border-bottom: 4px solid var(--border);
}
.step-dot span { display: block; font-size: 0.75rem; font-weight: 500; }
.step-dot.active { color: var(--primary-dark); border-color: var(--primary); }
.step-dot.done { color: var(--success); border-color: var(--success); }

/* Steps */
.step { display: none; }
.step.active-step { display: block; }

.helper-text { color: var(--muted); margin: -8px 0 16px; }

/* Shared button reset */
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 3px solid #f0a500; outline-offset: 2px;
}

.back-btn {
  min-height: 48px; padding: 8px 14px; margin-bottom: 4px;
  background: transparent; border: none; color: var(--primary-dark);
  font-weight: 600; font-size: 1rem; border-radius: 10px;
}
.back-btn:hover { background: var(--primary-soft); }

/* Practitioner cards */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.practitioner-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: 84px; padding: 16px; text-align: left;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); color: var(--ink);
}
.practitioner-card:hover { border-color: var(--primary); }
.avatar {
  flex: 0 0 52px; height: 52px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}
.p-name { display: block; font-weight: 600; font-size: 1.1rem; }
.p-role { display: block; color: var(--muted); font-size: 0.95rem; }

/* Days */
.day-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.day-btn, .slot-btn {
  min-height: var(--tap); padding: 10px; width: 100%;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); color: var(--ink);
}
.day-btn:hover:not(:disabled), .slot-btn:hover:not(:disabled) {
  border-color: var(--primary); background: var(--primary-soft);
}
.day-btn .d-week { display: block; font-weight: 600; }
.day-btn .d-date { display: block; color: var(--muted); font-size: 0.95rem; }
.day-btn .d-free { display: block; font-size: 0.8rem; color: var(--success); }
.day-btn:disabled, .slot-btn:disabled {
  cursor: not-allowed; background: #eceff0; color: #6b777c;
  border-style: dashed;
}
.day-btn:disabled .d-free, .day-btn:disabled .d-date { color: #6b777c; }

/* Slots */
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.slot-btn { font-weight: 600; font-size: 1.05rem; }
.slot-btn:disabled { text-decoration: line-through; font-weight: 500; }

.no-slots-msg {
  padding: 16px; background: var(--primary-soft); border-radius: var(--radius);
}

/* Summary / confirm */
.summary-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}
.summary-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.summary-card dt { color: var(--muted); }
.summary-card dd { margin: 0; font-weight: 600; }

.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.text-input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.text-input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); margin: 6px 0 0; font-weight: 600; }

.primary-btn {
  display: block; width: 100%; min-height: 60px; margin-top: 20px;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1.1rem; font-weight: 600;
}
.primary-btn:hover { background: var(--primary-dark); }

.form-error {
  color: var(--danger); font-weight: 600; margin-top: 12px;
}

/* Success */
.success-card { text-align: center; }
.success-card .summary-card { text-align: left; }
.success-icon {
  width: 72px; height: 72px; margin: 12px auto 8px; border-radius: 50%;
  background: var(--success); color: #fff; font-size: 2.4rem;
  display: flex; align-items: center; justify-content: center;
}

.foot-note { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 8px 16px 24px; }

@media (min-width: 480px) {
  .day-grid { grid-template-columns: repeat(3, 1fr); }
  .slot-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
