/* app.css — estilos del panel y de la página de reservas */

@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900; font-style: normal; font-display: swap;
}

:root {
  --bg: #f2f2ee;
  --surface: #ffffff;
  --ink: #1d1b22;
  --muted: #67646f;
  --line: #e0dde6;
  --primary: #4b2e63;
  --on-primary: #ffffff;
  --tint: #ece5f2;
  --ok: #2b7455;
  --ok-bg: #e0f0e8;
  --warn: #8a5a00;
  --warn-bg: #fbecc8;
  --danger: #b0303a;
  --danger-bg: #f9e1e3;
  --shadow: 0 1px 2px rgba(29, 27, 34, .06), 0 6px 18px rgba(29, 27, 34, .06);
  --display: "Bricolage", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tabs-h: 64px;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141218;
    --surface: #1f1c27;
    --ink: #f1eef5;
    --muted: #a7a2b3;
    --line: #302c3b;
    --primary: #c9a8ea;
    --on-primary: #24153a;
    --tint: #2b2238;
    --ok: #7fd3a8;
    --ok-bg: #163527;
    --warn: #f0c46a;
    --warn-bg: #3a2c0c;
    --danger: #ff9aa2;
    --danger-bg: #3d1b20;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
}
body.panel { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.015em; margin: 0; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 560px; margin: 0 auto; padding: 20px 18px 28px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 14px; border: 1.5px solid transparent;
  background: var(--primary); color: var(--on-primary); font-weight: 650; text-decoration: none; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn.tint { background: var(--tint); color: var(--primary); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger-bg); }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 12px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--surface); display: grid; place-items: center; color: var(--ink);
}
.icon-btn svg, .btn svg { width: 20px; height: 20px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="number"], input[type="email"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; font-size: 16px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--tint); }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: .92rem; margin-bottom: 14px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--tint); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; min-height: 40px; border-radius: 11px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 30px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Tarjetas y etiquetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.card + .card { margin-top: 10px; }
.section-title { font-size: 1.05rem; margin: 22px 0 10px; }
.badge { display: inline-block; font-size: .78rem; font-weight: 650; padding: 2px 10px; border-radius: 20px; background: var(--tint); color: var(--primary); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.pend { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; margin-bottom: 12px; }
.notice.err { background: var(--danger-bg); color: var(--danger); }
.notice.info { background: var(--tint); color: var(--primary); }

/* ---------- Cabecera y semana ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.head h1 { font-size: 1.75rem; }
.head .sub { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.head .nav { display: flex; gap: 8px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.week button {
  display: grid; justify-items: center; gap: 1px; padding: 8px 0 7px; border-radius: 14px;
  border: 1.5px solid transparent; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 600; position: relative;
}
.week button b { font: 650 1.15rem/1.2 var(--display); color: var(--ink); }
.week button[aria-current="date"] b { text-decoration: underline; text-underline-offset: 3px; }
.week button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.week button[aria-pressed="true"] b { color: var(--on-primary); }
.week button i { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.week button[aria-pressed="true"] i { background: var(--on-primary); }

/* ---------- Línea del día ---------- */
.tl { display: grid; gap: 8px; }
.tl .row { display: grid; grid-template-columns: 3.6rem 1fr; gap: 10px; align-items: start; }
.tl .time { font: 650 1.2rem/1.2 var(--display); font-variant-numeric: tabular-nums; padding-top: 14px; }
.tl .time small { display: block; font: 500 .75rem/1.3 var(--body); color: var(--muted); }
.appt { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; }
.appt.pend { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface)); }
.appt .who { font-weight: 650; }
.appt .meta { color: var(--muted); font-size: .88rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gap {
  width: 100%; text-align: left; border: 1.5px dashed var(--line); background: transparent; border-radius: 14px;
  padding: 9px 14px; color: var(--muted); font-size: .88rem; display: flex; justify-content: space-between; align-items: center;
}
.gap b { color: var(--primary); font-weight: 650; }
.empty { text-align: center; padding: 34px 12px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 1.15rem; margin-bottom: 6px; }

/* ---------- Recordatorios ---------- */
.rem { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.rem .who { font-weight: 650; }
.rem .meta { color: var(--muted); font-size: .88rem; }
.rem.done { opacity: .75; }

/* ---------- Navegación inferior ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabs-h); }
#tabs button { border: 0; background: transparent; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 600; position: relative; }
#tabs button svg { width: 24px; height: 24px; }
#tabs button[aria-current="page"] { color: var(--primary); }
#tabs button[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primary); }
#tabs .count { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }

/* ---------- Hoja inferior y avisos ---------- */
dialog.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(10, 8, 14, .5); }
dialog.sheet h2 { font-size: 1.35rem; }
dialog.sheet .acts { display: grid; gap: 10px; margin-top: 16px; }
dialog.sheet .kv { display: grid; grid-template-columns: 6.5rem 1fr; gap: 4px 10px; margin-top: 12px; font-size: .95rem; }
dialog.sheet .kv dt { color: var(--muted); }
dialog.sheet .kv dd { margin: 0; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 40; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body:not(.panel) #toast { bottom: 24px; }

/* ---------- Ajustes ---------- */
.day-set { padding: 12px 16px; }
.day-set .top { display: flex; justify-content: space-between; align-items: center; font-weight: 650; }
.day-set .ranges { display: grid; gap: 8px; margin-top: 10px; }
.range { display: grid; grid-template-columns: 4rem 1fr auto 1fr; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); }
.range input { min-height: 42px; padding: 6px 10px; }
.svc { display: grid; grid-template-columns: 1fr 5.5rem auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.qr-box { display: grid; justify-items: center; gap: 10px; padding: 8px 0 2px; }
.qr-box canvas { width: 168px; height: 168px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); }
.linkbox { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.linkbox input { font-size: .88rem; }
.chips-help { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips-help code { background: var(--tint); color: var(--primary); padding: 2px 8px; border-radius: 8px; font-size: .8rem; }

/* ---------- Acceso ---------- */
.login { min-height: 100dvh; display: grid; align-content: center; }
.mark { width: 56px; height: 56px; border-radius: 16px; background: var(--primary); display: grid; place-items: center; margin-bottom: 22px; }
.mark svg { width: 30px; height: 30px; color: var(--on-primary); }
.login h1 { font-size: 2.1rem; margin-bottom: 8px; }
.login p.lead { color: var(--muted); margin-bottom: 24px; }

/* ---------- Página de reservas (clientes) ---------- */
.pub-head { padding: 26px 0 8px; }
.pub-head .who { color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.pub-head h1 { font-size: 2.2rem; }
.step { margin-top: 26px; }
.step h2 { font-size: 1.15rem; display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.step h2 .n { font: 650 .95rem/1 var(--display); color: var(--on-primary); background: var(--primary); width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; }
.opts { display: grid; gap: 8px; }
.opt { width: 100%; text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.opt b { font-weight: 650; }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--tint); }
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; margin: 0 -18px; padding-inline: 18px; }
.days button { flex: none; scroll-snap-align: start; min-width: 64px; display: grid; justify-items: center; padding: 9px 6px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-size: .78rem; font-weight: 600; color: var(--muted); }
.days button b { font: 650 1.3rem/1.2 var(--display); color: var(--ink); }
.days button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.days button[aria-pressed="true"] b { color: var(--on-primary); }
.days button[disabled] { opacity: .4; cursor: not-allowed; }
.hours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hours button { min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 650; font-variant-numeric: tabular-nums; }
.hours button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.done-card { text-align: center; padding: 26px 18px; }
.done-card .tick { width: 60px; height: 60px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 0 auto 14px; }
.done-card .tick svg { width: 30px; height: 30px; }
.done-card h2 { font-size: 1.6rem; margin-bottom: 8px; }
.done-card .when { font: 650 1.2rem/1.3 var(--display); margin: 12px 0 4px; }
.stack { display: grid; gap: 10px; margin-top: 18px; }
.foot { margin-top: 30px; font-size: .8rem; color: var(--muted); }
.skeleton { height: 54px; border-radius: 14px; background: linear-gradient(90deg, var(--line), var(--tint), var(--line)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

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

/* ---------- Clientes (recuento + donut) ---------- */
.stat-hero { text-align: center; margin: 6px 0 18px; }
.stat-hero b { display: block; font: 650 2.4rem/1.1 var(--display); }
.stat-hero span { color: var(--muted); font-size: .9rem; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.donut { width: 140px; height: 140px; flex: none; }
.donut circle { transition: stroke-dasharray .3s ease; }
.legend { display: grid; gap: 8px; min-width: 160px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend .li b { font-weight: 650; }
.legend .li .pct { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.client-list { display: grid; gap: 8px; margin-top: 4px; }
.client-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.client-row .rank { width: 22px; text-align: center; font-weight: 650; color: var(--muted); font-size: .85rem; flex: none; }
.client-row .who { flex: 1; min-width: 0; }
.client-row .who b { display: block; }
.client-row .who small { color: var(--muted); }
.client-row .n { font: 650 1.1rem/1 var(--display); font-variant-numeric: tabular-nums; flex: none; text-align: right; }
.client-row .n small { display: block; font: 500 .72rem/1.3 var(--body); color: var(--muted); font-weight: 500; }
