:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #13233a;
  --muted: #5b6b80;
  --line: #dfe6ef;
  --primary: #0b6bcb;
  --primary-soft: #e6f0fb;
  --ok: #128c4a;
  --wa: #25d366;
  --error: #c62828;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #0b6bcb, #0a4d93);
  color: #fff;
  padding: 40px 0 72px;
}
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; opacity: .85; }
.hero h1 { margin: 0 0 10px; font-size: clamp(1.5rem, 4.5vw, 2.1rem); line-height: 1.2; }
.lead { margin: 0; opacity: .92; max-width: 560px; }

main.wrap { margin-top: -44px; }

/* Steps */
.steps {
  list-style: none; margin: 0 0 16px; padding: 10px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(15, 40, 80, .08);
}
.steps li { display: flex; }
.steps button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; font-size: .72rem; color: var(--muted); text-align: center;
  background: none; border: 0; padding: 2px; border-radius: 10px;
}
.steps button:disabled { cursor: default; }
.steps button:not(:disabled) { cursor: pointer; }
.steps button:not(:disabled):hover { background: var(--primary-soft); }
.steps button:not(:disabled):hover span { box-shadow: 0 0 0 3px #b9d4f1; }
.steps span {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600;
  background: var(--line); color: var(--muted);
}
.steps li.active { color: var(--primary); font-weight: 600; }
.steps li.active span { background: var(--primary); color: #fff; }
.steps li.done span { background: var(--ok); color: #fff; }

/* Card */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
  box-shadow: 0 4px 18px rgba(15, 40, 80, .08);
}
h2 { font-size: 1.15rem; margin: 0 0 14px; }
h2 small { font-weight: 500; color: var(--muted); font-size: .85rem; }
h3 { font-size: 1rem; margin: 22px 0 4px; }
.muted { color: var(--muted); font-size: .92rem; margin: 0 0 12px; }
.opt { color: var(--muted); font-weight: 400; }

/* Presentación del médico */
.doctor {
  display: flex; gap: 16px; align-items: center;
  padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.doctor img {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 3px solid var(--primary-soft); background: #0a3a8c;
}
.doctor h2 { margin: 0; }
.doctor-role { margin: 2px 0 8px; color: var(--primary); font-weight: 600; font-size: .92rem; }
.doctor ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: .88rem; }
.doctor li + li { margin-top: 2px; }
@media (max-width: 420px) {
  .doctor { flex-direction: column; text-align: center; }
  .doctor ul { text-align: left; }
}

/* Qué incluye la consulta */
.includes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.includes li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); }
.includes .ico { font-size: 1.25rem; line-height: 1.3; }
.includes strong { display: block; font-size: .92rem; }
.includes small { display: block; color: var(--muted); font-size: .82rem; line-height: 1.4; }
@media (max-width: 520px) { .includes { grid-template-columns: 1fr; } }
.reeval { border: 1px solid #f3d27a; background: #fffaeb; border-radius: 12px; padding: 12px 14px; margin-bottom: 24px; }
.reeval p { margin: 0 0 6px; font-size: .9rem; }
.reeval p:last-child { margin: 0; }
.reeval-title { font-size: .95rem !important; }
.reeval .muted { font-size: .82rem; }
.hint { display: block; margin-top: 4px; font-weight: 400; font-size: .78rem; color: var(--muted); }

/* Tipos de consulta */
.type-hint { margin: -4px 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: .9rem; }
.type-hint strong { color: var(--primary); }
.types { display: grid; gap: 8px; margin-bottom: 24px; }
.type {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; font: inherit; color: var(--text); cursor: pointer;
}
.type:hover { border-color: #9cc3ec; }
.type.selected { border-color: var(--primary); background: var(--primary-soft); }
.type small { display: block; color: var(--muted); font-size: .82rem; }
.type em { font-style: normal; font-weight: 700; color: var(--primary); white-space: nowrap; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 1.3rem; cursor: pointer; color: var(--text);
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays span { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.day {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 10px;
  background: transparent; font: inherit; color: #b3bfcd; cursor: default;
}
.day.available { background: var(--primary-soft); color: var(--primary); font-weight: 600; cursor: pointer; }
.day.available:hover { border-color: var(--primary); }
.day.selected { background: var(--primary); color: #fff; }
.day.today { outline: 2px solid #9cc3ec; outline-offset: -2px; }
.legend { font-size: .78rem; color: var(--muted); margin: 10px 0 0; display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.dot:first-child { margin-left: 0; }
.dot.available { background: var(--primary-soft); border: 1px solid var(--primary); }
.dot.off { background: #eef2f6; }

#slots-wrap { margin-top: 24px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slot {
  padding: 10px 0; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-weight: 500; cursor: pointer; color: var(--text);
}
.slot:hover { border-color: var(--primary); }
.slot.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot:disabled { text-decoration: line-through; color: #b3bfcd; background: #f6f8fb; cursor: default; }

/* Form */
form label, .panel > label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 14px; }
input[type=text], input[type=tel], input[type=email], textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--text); background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
form label.consent, .panel > label.consent { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--muted); }
.consent input { margin-top: 3px; flex: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

.summary {
  background: var(--primary-soft); color: #0a4d93; border-radius: 10px;
  padding: 10px 12px; font-size: .92rem; margin: 0 0 16px;
}
.error { color: var(--error); font-size: .88rem; margin: 0 0 10px; }

/* Payment */
.amount { font-size: 1.05rem; margin: 0 0 14px; }
.amount strong { font-size: 1.3rem; }
.wallet {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px;
}
.wallet .qr { width: 260px; max-width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: #fff; }
.wallet .qr-missing {
  width: 220px; max-width: 100%; aspect-ratio: 1; border-radius: 10px;
  display: grid; place-items: center; padding: 16px;
  background: #f6f8fb; color: var(--muted); font-size: .85rem;
}
.wallet p { margin: 8px 0 0; }

.upload {
  display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed #b9cbe0; border-radius: var(--radius); padding: 20px;
  background: #f8fbff; cursor: pointer; text-align: center; color: var(--primary); font-weight: 500;
}
.upload.has-file { border-color: var(--ok); color: var(--ok); background: #f1faf4; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload img { max-width: 220px; max-height: 260px; border-radius: 8px; }

/* Buttons */
.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions.center { justify-content: center; }
.btn {
  padding: 12px 22px; border-radius: 10px; border: 0; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--primary); color: #fff; margin-left: auto; }
.btn.primary:disabled { background: #a9c3de; cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.paypal { background: #ffc439; color: #003087; margin-top: 12px; }
.paypal-logo { font-weight: 700; font-size: 1.6rem; font-style: italic; color: #003087; }
.btn.whatsapp { background: var(--wa); color: #073b1d; }
.link { display: block; margin: 18px auto 0; background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }

/* Done */
.done { text-align: center; }
.check {
  width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 14px;
  display: grid; place-items: center; font-size: 2rem; color: #fff; background: var(--ok);
}
.notice {
  font-size: 1.05rem; background: #fff8e1; border: 1px solid #ffe08a; color: #6b4e00;
  border-radius: 10px; padding: 12px 14px;
}
.done h3 { margin-top: 24px; }
.details {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left;
  background: var(--primary-soft); border-radius: 10px; padding: 14px 16px; margin: 0 0 16px; font-size: .92rem;
}
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* Footer & floating WA */
.foot { text-align: center; color: var(--muted); font-size: .88rem; padding-bottom: 90px; }
.foot a { color: var(--primary); }
.wa-float {
  position: fixed; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--wa); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.month-empty { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: .85rem; text-align: center; }
#no-slots p { margin: 0 0 6px; }
#no-slots p:last-child { margin: 0; }
#next-free { display: block; margin-top: 2px; }
#no-slots { font-size: .95rem; margin-bottom: 16px; }
.tips { text-align: left; background: #f3f8f4; border: 1px solid #cfe8d6; border-radius: 12px; padding: 4px 16px 12px; margin: 0 0 16px; }
.tips h3 { margin-top: 12px; }
.tips ul { margin: 6px 0 0; padding-left: 0; list-style: none; font-size: .9rem; }
.tips li + li { margin-top: 6px; }
.tip-note { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.tips .latidos { display: inline-block; margin: 8px 0 0; padding: 8px 14px; font-size: .88rem; background: #fff; color: #c62844; border: 1px solid #c62844; }
.wallet .btn.qr-download { margin: 4px 0 6px; padding: 10px 18px; border: 0; color: #fff; background: #742284; }
.small-hint { font-size: .82rem; max-width: 360px; margin: 0 auto 4px; }
.wa-inline { color: #128c4a; font-weight: 600; white-space: nowrap; }
/* Lectura de resultados */
.reeval-entry { margin: -16px 0 24px; }
.type.reeval-open { width: 100%; border-style: dashed; border-color: #e7b93a; background: #fffaeb; }
.type.reeval-open em { color: #8a6100; }
.reeval-form { margin-top: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.reeval-msg { font-size: .9rem; margin: 0 0 12px; }
.reeval-msg.ok { background: #dff3e6; border-color: #a9dcb9; color: #0c6b37; }
.reeval-msg .link { display: inline; margin: 0; padding: 0; font-size: inherit; }
.reeval-mode { background: #fffaeb; border: 1px solid #f3d27a; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: .9rem; }
.reeval-mode p { margin: 0 0 4px; }
.reeval-mode .link { display: inline-block; margin: 4px 0 0; padding: 0; font-size: .88rem; }
input[readonly] { background: #f2f5f9; color: var(--muted); }

/* Directorio de médicos */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.search input { display: block; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; margin-bottom: 16px; }
.search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.medicos { display: grid; gap: 12px; }
.medico { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.medico img, .medico .avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; border: 3px solid var(--primary-soft); }
.medico .avatar { display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 1.3rem; }
.medico-info { flex: 1; min-width: 0; }
.medico-info h2 { margin: 0; font-size: 1.05rem; }
.medico-info .doctor-role { margin: 2px 0 6px; }
.medico-info .muted { margin: 4px 0 0; font-size: .85rem; }
.medico .btn.primary { margin: 0; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chips span { font-size: .78rem; padding: 3px 8px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); }
.medico.pronto { opacity: .75; }
.badge-pronto { flex: none; font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 20px; background: #eef2f6; color: var(--muted); }
.center-text { text-align: center; }
@media (max-width: 520px) {
  .medico { flex-wrap: wrap; }
  .medico .btn.primary { width: 100%; }
}
.back-dir { color: inherit; text-decoration: none; opacity: .9; }
.back-dir:hover { text-decoration: underline; }
.pay-aviso { background: #eef5ff; border: 1px solid #c9dcf5; color: #1d3f6e; border-radius: 10px; padding: 10px 12px; font-size: .86rem; text-align: left; max-width: 420px; margin: 0 auto 12px; }
.tel-row { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 8px; margin-top: 6px; }
.tel-row input { margin-top: 0 !important; }
.tel-row select { width: 100%; padding: 11px 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; color: var(--text); background: #fff; }
.tel-row select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

/* Libro de Reclamaciones (pie de todas las páginas) */
.libro { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.libro .libro-ico { flex: none; width: 15px; height: 15px; opacity: .8; }

/* Barra «← Volver» + camino (todas las páginas internas, public/volver.js) */
.volver-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 0 0 14px; }
.volver { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px 8px 10px; min-height: 40px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .92rem; text-decoration: none; border: 1px solid #c8dcf3; white-space: nowrap; }
.volver svg { flex: none; }
.volver:hover { background: #d7e7f8; }
.volver:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.migas { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 0; padding: 0; list-style: none; font-size: .86rem; color: var(--muted); min-width: 0; }
.migas li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.migas li + li::before { content: "›"; opacity: .6; }
.migas a { color: inherit; text-decoration: none; }
.migas a:hover { text-decoration: underline; }
.migas [aria-current] { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
/* Sobre fondo azul (portadas) */
.volver-bar.oscuro .volver { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .45); color: #fff; }
.volver-bar.oscuro .volver:hover { background: rgba(255, 255, 255, .26); }
.volver-bar.oscuro .volver:focus-visible { outline-color: #fff; }
.volver-bar.oscuro .migas { color: rgba(255, 255, 255, .85); }
.volver-bar.oscuro .migas [aria-current] { color: #fff; }
/* Bajo el menú de las páginas con navegación superior */
.volver-franja { border-bottom: 1px solid var(--line); background: #fff; }
.volver-franja .volver-bar { max-width: 1080px; margin: 0 auto; padding: 10px 16px; }
@media (max-width: 560px) {
  .migas { font-size: .8rem; }
  .migas [aria-current] { max-width: 22ch; }
  .migas li.medio { display: none; } /* en celular se ocultan los niveles intermedios */
}

/* Botón flotante de WhatsApp en las páginas públicas (public/whatsapp.js) */
.wa-float { z-index: 40; text-decoration: none; transition: transform .15s; }
.wa-float:hover { transform: scale(1.06); }
.wa-globo { position: absolute; right: 66px; top: 50%; transform: translateY(-50%); white-space: nowrap; background: #fff; color: #13233a;
  font-size: .85rem; font-weight: 600; padding: 8px 12px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); animation: wa-aparece .3s ease-out; }
.wa-globo::after { content: ""; position: absolute; right: -6px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-right: 0; border-left-color: #fff; }
@keyframes wa-aparece { from { opacity: 0; transform: translate(8px, -50%); } to { opacity: 1; transform: translate(0, -50%); } }
/* En celular, sobre la barra fija de inscripción del curso */
@media (max-width: 860px) { body.cv .wa-float { bottom: calc(84px + env(safe-area-inset-bottom)); } }
