:root {
  --bg: #FBFAFC;
  --surface: #FFFFFF;
  --ink: #22202A;
  --muted: #6E6878;
  --line: #E4E0EA;
  --accent: #5A3462;
  --accent-soft: #F1EAF3;
  --ok: #2F6B4F;
  --ok-soft: #E6F1EB;
  --danger: #A23B3B;
  --danger-soft: #F8E9E9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-sm: 6px;
  --r-md: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151B; --surface: #1F1C24; --ink: #EEEAF2; --muted: #A69FB0; --line: #353040;
    --accent: #C79AD0; --accent-soft: #2E2433; --ok: #7CC4A0; --ok-soft: #1D2D25;
    --danger: #E28C8C; --danger-soft: #3A2223;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--sans);
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; }
p { margin: 0; }
.wrap { max-width: 640px; margin: 0 auto; padding: 32px 16px 64px; }
.wrap-wide { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Encabezado del profesional */
.pro { padding-bottom: 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.pro h1 { font-family: var(--serif); font-size: clamp(30px, 6vw, 40px); font-weight: 500; letter-spacing: -0.01em; }
.pro .title { color: var(--muted); margin-top: 4px; }
.pro .bio { margin-top: 14px; max-width: 60ch; }

/* Pasos */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 28px; }
.steps > li, .step > * { min-width: 0; }
.step > h2 { font-size: 19px; display: flex; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.step > h2 .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  font: 600 14px var(--sans); background: var(--accent-soft); color: var(--accent);
}
.step.done > h2 .n { background: var(--accent); color: var(--surface); }
.step.locked { opacity: .45; }
.step.locked > :not(h2) { display: none; }
.summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Opciones de servicio */
.choices { display: grid; gap: 10px; }
.choice {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; text-align: left; width: 100%;
  padding: 14px 16px; background: var(--surface); color: inherit; font: inherit;
  border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice .name { font-weight: 600; }
.choice .price { font-weight: 600; text-align: right; }
.choice .meta { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

/* Franja de días: el elemento protagonista */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.day {
  flex: none; width: 74px; padding: 10px 4px 8px; scroll-snap-align: start;
  display: grid; justify-items: center; gap: 0;
  background: var(--surface); color: inherit; font: inherit; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.day .wd { font-size: 13px; color: var(--muted); text-transform: capitalize; }
.day .dn { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.day .mo { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.day .count { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }
.day[disabled] { cursor: default; opacity: .4; }
.day[disabled] .count { color: var(--muted); font-weight: 400; }
.day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.day[aria-pressed="true"] .wd, .day[aria-pressed="true"] .mo, .day[aria-pressed="true"] .count { color: inherit; }
.days-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 14px; }
.time {
  padding: 10px 0; text-align: center; font: 600 16px var(--sans); color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.time:hover { border-color: var(--accent); }
.time[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin-top: 16px; }
.seg button { padding: 8px 14px; font: inherit; border: 0; background: var(--surface); color: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Formularios */
form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 600; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 80px; resize: vertical; }
.field label.check, label.check { font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { form.grid { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; font: 600 16px var(--sans); border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--surface); text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: progress; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.notice { padding: 12px 14px; border-radius: var(--r-sm); background: var(--accent-soft); font-size: 15px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.confirm { text-align: left; }
.confirm h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; margin-bottom: 10px; }
.confirm dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 20px 0; }
.confirm dt { color: var(--muted); }
.confirm dd { margin: 0; font-weight: 600; }

.footer { margin-top: 48px; font-size: 13px; color: var(--muted); }

/* Panel */
.topbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.topbar h1 { font-family: var(--serif); font-weight: 500; font-size: 26px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { padding: 10px 14px; font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 8px; overflow-x: auto; }
.col h3 { font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.col h3::first-letter { text-transform: uppercase; }
.col.today h3 { color: var(--accent); }
.appt { padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-bottom: 6px; font-size: 14px; cursor: pointer; width: 100%; text-align: left; font-family: inherit; color: inherit; border-top: 0; border-right: 0; border-bottom: 0; }
.appt .t { font-weight: 600; }
.appt.pending_payment { border-left-color: #B7862C; }
.appt.cancelled, .appt.no_show { border-left-color: var(--muted); opacity: .6; text-decoration: line-through; }
.appt.completed { border-left-color: var(--ok); }
.block { padding: 6px 10px; font-size: 13px; color: var(--muted); background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line) 6px 7px); border-radius: var(--r-sm); margin-bottom: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.rule-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.3fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
@media (max-width: 640px) { .rule-row { grid-template-columns: 1fr 1fr; } }
dialog { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); padding: 24px; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(20, 16, 24, .45); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: grid; gap: 14px; }

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: reveal .28s ease-out both; }
  @keyframes reveal { from { opacity: 0; transform: translateY(6px); } }
}

/* Boletas */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.badge.issued { background: var(--ok-soft); color: var(--ok); }
.badge.failed, .badge.needs_review { background: var(--danger-soft); color: var(--danger); }
.badge.voided { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.copy-list { display: grid; gap: 6px; }
.copy-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.copy-row code { font: 600 15px var(--sans); overflow-wrap: anywhere; }
@media (max-width: 520px) { .copy-row { grid-template-columns: 1fr auto; } .copy-row > span { grid-column: 1 / -1; } }
