:root {
  --pink: #e8508f;
  --pink-dark: #c23574;
  --pink-soft: #fbd3e4;
  --pink-light: #fff0f6;
  --bg: #fff7fa;
  --card: #ffffff;
  --text: #3a1f2e;
  --muted: #8f6b7d;
  --line: #f3dbe6;
  --green: #2e9e6b;
  --green-soft: #ddf5e9;
  --red: #d64545;
  --red-soft: #fde3e3;
  --amber: #c98a12;
  --amber-soft: #fdf1d8;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(200, 60, 120, .10);
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 90px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, var(--pink) 0%, #f27aae 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(200, 60, 120, .25);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.7); }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.brand small { opacity: .9; font-size: 13px; }
.btn-install {
  background: #fff; color: var(--pink-dark); border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: 14px;
}

main { max-width: 640px; margin: 0 auto; padding: 14px 14px 0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  height: calc(var(--tabbar-h) + var(--safe-b));
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12.5px; font-weight: 600;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--pink); }
.tabbar button.active svg { background: var(--pink-light); border-radius: 12px; padding: 2px 10px; width: 46px; box-sizing: content-box; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; z-index: 21;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 62px; height: 62px; border-radius: 20px; border: 0;
  background: var(--pink); color: #fff;
  box-shadow: 0 8px 22px rgba(232, 80, 143, .45);
  display: grid; place-items: center;
}
.fab svg { width: 30px; height: 30px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.fab:active { transform: scale(.94); }

/* ---------- Generic ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
}
.pill {
  border: 1.5px solid var(--pink); color: var(--pink); background: #fff;
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--pink-light); color: var(--pink-dark); font-size: 22px; font-weight: 700;
}
.section-title { font-size: 15px; font-weight: 800; color: var(--pink-dark); margin: 22px 4px 10px; text-transform: uppercase; letter-spacing: .6px; }
.empty {
  text-align: center; color: var(--muted); padding: 34px 20px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
}
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }
.list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Agenda ---------- */
.agenda-head { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; }
.month-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-label {
  position: relative; font-weight: 800; font-size: 17px;
  padding: 8px 12px; border-radius: 12px; color: var(--pink-dark);
}
.month-label input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day {
  border: 0; background: none; border-radius: 14px; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.day span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.day b { font-size: 18px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.day i { font-style: normal; color: var(--pink); font-size: 14px; line-height: 10px; height: 10px; letter-spacing: -1px; }
.day.today b { color: var(--pink); border: 2px solid var(--pink-soft); }
.day.sel b { background: var(--pink); color: #fff; border-color: var(--pink); }

.day-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 10px; gap: 10px; }
.day-title h2 { font-size: 19px; }
.day-title p { color: var(--muted); font-size: 14px; margin-top: 2px; }

.appt { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; border-left: 5px solid var(--pink); }
.appt.completada { border-left-color: var(--green); }
.appt.cancelada { border-left-color: #ccc; opacity: .65; }
.appt-time { font-weight: 800; color: var(--pink-dark); font-size: 15px; min-width: 64px; padding-top: 1px; }
.appt-main h3 { font-size: 16.5px; }
.appt-main p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.appt-main .note { font-style: italic; }
.appt-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.appt-side strong { font-size: 16px; }
.appt-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.appt-actions:empty { display: none; }
.mini {
  border: 0; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 700;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.mini.ok { background: var(--green-soft); color: var(--green); }
.mini.wa { background: #e3f7ea; color: #1c8b4a; }

.chip { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.chip.pendiente { background: var(--amber-soft); color: var(--amber); }
.chip.completada { background: var(--green-soft); color: var(--green); }
.chip.cancelada { background: #eee; color: #777; }

/* ---------- Servicios ---------- */
.svc { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.svc h3 { font-size: 16.5px; }
.svc p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.svc strong { color: var(--pink-dark); font-size: 17px; white-space: nowrap; }
.hint { color: var(--muted); font-size: 14px; margin: 0 4px 12px; line-height: 1.4; }

/* ---------- Cuentas ---------- */
.seg { display: flex; background: #fff; border-radius: 14px; padding: 4px; box-shadow: var(--shadow); gap: 4px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 10px; padding: 9px 4px;
  font-weight: 700; color: var(--muted); font-size: 14px;
}
.seg button.on { background: var(--pink); color: #fff; }
.period-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.period-row b { font-size: 17px; text-align: center; flex: 1; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat small { color: var(--muted); font-weight: 600; font-size: 13px; display: block; }
.stat b { font-size: 21px; display: block; margin-top: 4px; }
.stat.main { grid-column: 1 / -1; background: linear-gradient(135deg, var(--pink) 0%, #f27aae 100%); color: #fff; }
.stat.main small { color: rgba(255,255,255,.9); }
.stat.main b { font-size: 30px; }
.stat .sub { font-size: 13px; opacity: .9; margin-top: 4px; display: block; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-top { display: flex; justify-content: space-between; font-size: 14.5px; margin-bottom: 5px; gap: 10px; }
.bar-top span { color: var(--muted); }
.bar { height: 9px; background: var(--pink-light); border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; background: var(--pink); border-radius: 999px; }

.mov { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mov:last-child { border-bottom: 0; }
.mov h4 { margin: 0; font-size: 15px; }
.mov p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mov strong { white-space: nowrap; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 700; font-size: 15.5px;
  background: var(--pink-light); color: var(--pink-dark); flex: 1; min-width: 140px;
}
.btn.primary { background: var(--pink); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.full { width: 100%; }

/* ---------- Sheet (formularios) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(58, 31, 46, 0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background .2s;
}
.sheet-backdrop.open { background: rgba(58, 31, 46, .45); }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 44px; height: 5px; background: var(--pink-soft); border-radius: 9px; margin: 4px auto 12px; }
.sheet h2 { font-size: 21px; margin-bottom: 14px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--pink-dark); }
.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 14px;
  padding: 13px 14px; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-light); }
textarea.input { resize: vertical; min-height: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.svc-chip {
  border: 1.5px solid var(--pink-soft); background: #fff; color: var(--text);
  border-radius: 999px; padding: 8px 13px; font-size: 14px; font-weight: 600;
}
.svc-chip:active, .svc-chip.add { background: var(--pink-light); }
.svc-chip.add { border-style: dashed; color: var(--pink-dark); }

.items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.item {
  display: grid; grid-template-columns: 1fr 130px 36px; gap: 8px; align-items: center;
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 12px;
}
.item span { font-weight: 600; font-size: 15px; }
.item .input { padding: 9px 10px; text-align: right; font-weight: 700; }
.item button { border: 0; background: var(--red-soft); color: var(--red); border-radius: 10px; height: 36px; font-size: 18px; }
.money-input { position: relative; }
.money-input::before { content: "$"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.money-input .input { padding-left: 22px; }
.total-line {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--pink-light); border-radius: 14px; padding: 12px 14px; font-weight: 800; font-size: 17px;
}
.total-line b { color: var(--pink-dark); font-size: 21px; }
.small-note { font-size: 13px; color: var(--muted); margin-top: 6px; }

.status-seg button.on[data-v="pendiente"] { background: var(--amber); }
.status-seg button.on[data-v="completada"] { background: var(--green); }
.status-seg button.on[data-v="cancelada"] { background: #888; }

.quick-add { display: grid; grid-template-columns: 1fr 120px auto; gap: 8px; margin-top: 10px; }
.quick-add .btn { min-width: 0; padding: 10px 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 92px);
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; white-space: nowrap; max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Forma de pago ---------- */
.cobrar-label { align-self: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.mini.transf { background: #e3eefc; color: #2a62b8; }
.pay-seg button.on { background: var(--pink); }

/* ---------- Editar / borrar ---------- */
.appt-edit { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.appt-edit .mini { flex: 1; justify-content: center; padding: 10px 12px; }
.mini.edit { background: var(--pink-light); color: var(--pink-dark); }
.mini.del { background: var(--red-soft); color: var(--red); }

/* ---------- Clientas ---------- */
.search { margin-bottom: 2px; }
.client-card { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--pink-light); color: var(--pink-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 19px;
}
.client-info { flex: 1; min-width: 0; }
.client-info h3 { font-size: 16.5px; }
.client-info p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.client-visits { text-align: center; color: var(--pink-dark); }
.client-visits b { display: block; font-size: 20px; line-height: 1; }
.client-visits small { font-size: 11.5px; color: var(--muted); }
.client-pick { margin-top: 8px; align-items: center; }
.client-pick:empty { display: none; }
.client-hint { font-size: 13px; color: var(--muted); font-weight: 600; }
.client-ok { font-size: 13.5px; color: var(--green); font-weight: 700; }
.btn.wa-btn { background: #e3f7ea; color: #1c8b4a; text-decoration: none; text-align: center; }
.tabbar button { font-size: 12px; }
