/* ===== Paleta: azul petróleo oscuro + naranja, texto blanco · estilo Apple ===== */
:root {
  color-scheme: dark;
  --bg: #070708;
  --bg-2: #0e0e10;
  --petrol: #18181b;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.09);
  --text: #ffffff;
  --text-2: rgba(255, 255, 255, 0.68);
  --text-3: rgba(255, 255, 255, 0.42);
  --orange: #e50914;
  --orange-2: #ff2635;
  --orange-soft: rgba(229, 9, 20, 0.16);
  --danger: #ff5a5f;
  --radius: 20px;
  --radius-sm: 13px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Inter", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --s-entrenamiento: #e50914;
  --s-masaje: #ff6fa1;
  --s-nutricion: #3ddc97;
  --s-entrevista_personal: #64b5ff;
  --s-entrevista_online: #b08cff;
  --s-rutina: #ffd166;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(229, 9, 20, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(120, 10, 16, 0.35), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Barra superior ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 12px;
  background: linear-gradient(180deg, rgba(8, 8, 9, 0.92), rgba(8, 8, 9, 0.6));
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.eyebrow { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--orange); text-transform: uppercase; letter-spacing: 0.04em; }
h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(130px + var(--safe-b)); }
.view { display: none; animation: fade .28s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Elementos base ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.card h3 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
.section-title { font-size: 20px; font-weight: 700; margin: 22px 4px 10px; letter-spacing: -0.02em; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--card-strong); transition: transform .15s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.accent { background: var(--orange); color: #fff; box-shadow: 0 6px 18px rgba(229, 9, 20, .35); }
.icon-btn.ghost { background: transparent; color: var(--orange); }
.icon-btn svg { width: 20px; height: 20px; stroke-width: 2.2; }

.primary-btn {
  border: 0; cursor: pointer; border-radius: 14px; padding: 14px 18px;
  background: var(--orange); color: #fff; font-size: 16px; font-weight: 600;
  box-shadow: 0 8px 22px rgba(229, 9, 20, .28); transition: transform .15s, filter .2s;
}
.primary-btn:active { transform: scale(.98); filter: brightness(.95); }
.primary-btn.wide { width: 100%; margin: 4px 0 16px; }
.secondary-btn {
  border: 1px solid var(--line); cursor: pointer; border-radius: 14px; padding: 12px 16px;
  background: var(--card-strong); color: #fff; font-size: 15px; font-weight: 600;
}
.danger-btn {
  width: 100%; border: 0; cursor: pointer; border-radius: 14px; padding: 14px;
  background: rgba(255, 90, 95, .12); color: var(--danger); font-size: 16px; font-weight: 600; margin-top: 8px;
}
.link-btn { border: 0; background: none; color: var(--orange); font-size: 16px; cursor: pointer; padding: 6px 4px; }
.link-btn.strong { font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--orange-soft); color: var(--orange-2);
}
.pill.muted { background: var(--card-strong); color: var(--text-2); }
.empty { text-align: center; color: var(--text-3); padding: 34px 12px; font-size: 15px; }

/* ===== Calendario ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-week span { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 0; }
.cal-grid { gap: 2px; }
.day {
  aspect-ratio: 1 / 1; max-height: 64px; border: 0; background: none; cursor: pointer;
  border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 17px; font-weight: 500; transition: background .2s;
}
.day:hover { background: var(--card); }
.day.other { color: var(--text-3); }
.day.today .num { color: var(--orange); font-weight: 700; }
.day.selected { background: var(--orange); }
.day.selected .num { color: #fff; font-weight: 700; }
.day.selected .dot { background: #fff !important; }
.dots { display: flex; gap: 3px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.calendar .link-btn { display: block; margin: 6px auto 0; font-weight: 600; }

.service-buttons { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.service-buttons::-webkit-scrollbar { display: none; }
.svc-btn {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 128px;
  border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 14px; cursor: pointer;
  text-align: left; font-size: 14px; font-weight: 600; transition: transform .15s, border-color .2s;
}
.svc-btn:hover { border-color: rgba(229, 9, 20, .5); }
.svc-btn:active { transform: scale(.96); }
.svc-btn .plus { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: #0e0e10; font-size: 19px; font-weight: 700; }

.day-head { display: flex; align-items: center; justify-content: space-between; }
.day-head .section-title { text-transform: capitalize; }

/* ===== Tarjeta de cita ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.appt {
  display: flex; gap: 14px; align-items: stretch; padding: 14px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; transition: background .2s, transform .15s;
}
.appt:hover { background: var(--card-strong); }
.appt:active { transform: scale(.99); }
.appt .bar { width: 4px; border-radius: 4px; flex: 0 0 4px; }
.appt .time { min-width: 52px; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.appt .time b { font-size: 16px; font-weight: 600; }
.appt .time small { color: var(--text-3); font-size: 13px; }
.appt .info { flex: 1; min-width: 0; }
.appt .info .client { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .info .svc { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.appt .meta { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 6px; }
.appt .price { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.gcal { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.gcal svg { width: 13px; height: 13px; }
.gcal.on { color: var(--s-nutricion); }

/* ===== Clientes ===== */
.month-switch { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 14px; font-size: 17px; font-weight: 600; }
.month-switch span { min-width: 160px; text-align: center; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.stat small { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; }
.stat b { display: block; font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat b.accent { color: var(--orange); }

.client-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.client-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 46px; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  background: linear-gradient(135deg, var(--orange), #b00610);
}
.client-top .who { flex: 1; min-width: 0; }
.client-top .who b { display: block; font-size: 17px; font-weight: 600; }
.client-top .who small { color: var(--text-2); font-size: 13px; }
.client-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.kv { background: rgba(0, 0, 0, .14); border-radius: 13px; padding: 10px 12px; }
.kv small { display: block; color: var(--text-3); font-size: 12px; }
.kv span { display: block; font-size: 15px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.client-total {
  display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 12px 14px;
  border-radius: 14px; background: var(--orange-soft);
}
.client-total small { color: var(--text-2); font-size: 13px; display: block; }
.client-total b { font-size: 24px; color: var(--orange); font-variant-numeric: tabular-nums; }
.client-actions { display: flex; gap: 8px; margin-top: 12px; }
.client-actions button { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ===== Tarifas ===== */
.tarifa-group h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text-2); margin: 20px 4px 10px; text-transform: uppercase; letter-spacing: .03em; }
.tarifa-group h3 i { width: 10px; height: 10px; border-radius: 50%; }
.tarifa {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start;
}
.tarifa .name { font-size: 17px; font-weight: 600; }
.tarifa .desc { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }
.tarifa .amount { text-align: right; }
.tarifa .amount b { font-size: 28px; font-weight: 700; color: var(--orange); letter-spacing: -0.03em; }
.tarifa .amount small { display: block; color: var(--text-3); font-size: 12px; }
.tarifa .chips { grid-column: 1 / -1; margin-top: 4px; }
.tarifa .edit { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }

/* ===== Cronología ===== */
.segmented { display: flex; background: var(--card-strong); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.segmented button {
  flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-2); transition: background .2s, color .2s;
}
.segmented button.on { background: var(--orange); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.select, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: rgba(0, 0, 0, .2); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
.select { margin-bottom: 8px; }
select option { background: var(--petrol); color: #fff; }
.tl-month { font-size: 15px; font-weight: 700; color: var(--orange); margin: 22px 4px 10px; }
.tl-item { display: flex; gap: 12px; position: relative; }
.tl-date {
  width: 54px; flex: 0 0 54px; text-align: center; padding-top: 12px;
}
.tl-date b { display: block; font-size: 22px; font-weight: 700; line-height: 1; }
.tl-date small { display: block; font-size: 12px; color: var(--text-3); text-transform: uppercase; margin-top: 3px; }
.tl-item .appt { flex: 1; min-width: 0; margin-bottom: 10px; }
.tl-item.past .appt { opacity: .55; }
.tl-rail { position: absolute; left: 26px; top: 50px; bottom: 0; width: 1px; background: var(--line); }

/* ===== Ajustes ===== */
.google-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.google-row .g {
  width: 44px; height: 44px; border-radius: 12px; background: #fff; display: grid; place-items: center;
  color: #0e0e10; font-weight: 800; font-size: 20px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--text-3); }
.status-dot.on { background: var(--s-nutricion); }
.card p { color: var(--text-2); font-size: 14px; line-height: 1.45; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.footnote { text-align: center; color: var(--text-3); font-size: 12px; }

/* ===== Menú inferior flotante ===== */
.tabbar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b));
  width: min(520px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px; border-radius: 28px;
  background: rgba(14, 14, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.tabbar button {
  border: 0; background: none; cursor: pointer; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 6px; border-radius: 20px; font-size: 10.5px; font-weight: 600;
  transition: color .2s, background .25s;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--orange); background: rgba(229, 9, 20, .12); }

/* ===== Hoja modal (estilo iOS) ===== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 60; left: 50%; bottom: 0;
  width: min(620px, 100%); max-height: 92vh; overflow: hidden;
  transform: translate(-50%, 105%); transition: transform .38s cubic-bezier(.32, .72, 0, 1);
  background: #141416; border-radius: 26px 26px 0 0; border: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0, 0, 0, .4);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); margin: 8px auto 0; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 14px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-head .link-btn:first-child { justify-self: start; }
.sheet-head .link-btn:last-child { justify-self: end; }
.sheet-body { overflow-y: auto; padding: 16px 16px calc(28px + var(--safe-b)); }

.group { background: var(--card); border-radius: 16px; padding: 4px 14px; margin-bottom: 14px; border: 1px solid var(--line); }
.field { padding: 10px 0; border-bottom: 1px solid var(--line); }
.group .field:last-child { border-bottom: 0; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field textarea { min-height: 76px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; font-size: 15px; }
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 51px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 31px; background: rgba(255, 255, 255, .18); transition: background .25s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .25s; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--orange); }
.switch input:checked + span::after { transform: translateX(20px); }

.day-chips { display: flex; gap: 6px; }
.day-chips label {
  flex: 1; text-align: center; padding: 10px 0; border-radius: 10px; cursor: pointer; margin: 0;
  background: rgba(0, 0, 0, .2); border: 1px solid var(--line); color: var(--text-2); font-weight: 600; font-size: 14px;
}
.day-chips input { display: none; }
.day-chips input:checked + span { color: #fff; }
.day-chips label:has(input:checked) { background: var(--orange); border-color: var(--orange); color: #fff; }

.svc-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.svc-picker label {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; cursor: pointer; margin: 0;
  background: rgba(0, 0, 0, .2); border: 1px solid var(--line); color: #fff; font-size: 14px; font-weight: 500;
}
.svc-picker input { display: none; }
.svc-picker label:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.svc-picker i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ===== Aviso ===== */
.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(16px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -140%); transition: transform .35s cubic-bezier(.32, .72, 0, 1);
  background: rgba(24, 24, 27, .95); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 18px; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px);
  backdrop-filter: blur(20px); box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 90, 95, .5); }

@media (min-width: 900px) {
  main { padding-top: 16px; }
  .client-grid { grid-template-columns: repeat(4, 1fr); }
  .sheet { bottom: auto; top: 50%; border-radius: 26px; transform: translate(-50%, -40%) scale(.96); opacity: 0; pointer-events: none; transition: transform .3s, opacity .25s; }
  .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
  .sheet-grabber { display: none; }
}
