@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink: #2B2622;
  --rose: #561B2D;
  --rose-soft: #F3E4E8;
  --sage: #4F6D5B;
  --sage-soft: #E4EDE6;
  --amber: #9A6B23;
  --amber-soft: #F5EBD8;
  --muted: #8B8079;
  --line: #E7DFD9;
  --paper: #FBF8F5;
  --danger: #A32D2D;
  --danger-soft: #F1E4E4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: #EFE9E3;
  color: var(--ink);
}

#app {
  max-width: 900px;
  margin: 24px auto;
  background: var(--paper);
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
  min-height: 80vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand .tagline {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
@media (max-width: 640px) { .brand .tagline { display: none; } }

.view-toggle { display: flex; gap: 4px; background: #F3F0EC; padding: 4px; border-radius: 10px; }
.view-toggle button {
  font-family: inherit; font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: 7px;
  border: none; cursor: pointer; background: transparent; color: var(--muted);
}
.view-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.content { padding: 20px; }

.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; flex: 1 1 140px;
}
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value { font-size: 22px; font-weight: 600; font-family: 'Fraunces', serif; }

.tabs { display: flex; gap: 20px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button {
  font-family: inherit; font-size: 14px; font-weight: 500; padding: 9px 2px; margin-right: 0;
  border: none; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.tabs button.active { border-bottom-color: var(--rose); color: var(--rose); }

button.btn {
  font-family: inherit; font-size: 14px; font-weight: 500; padding: 9px 16px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--rose); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-subtle { background: var(--rose-soft); color: var(--rose); }

input, select, textarea {
  width: 100%; font-family: inherit; font-size: 14px; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
textarea { resize: vertical; }

.field { display: block; margin-bottom: 14px; }
.field .flabel { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }

.pill { font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 20px; white-space: nowrap; border: none; cursor: pointer; font-family: inherit; }

.avatar {
  border-radius: 50%; background: var(--rose-soft); color: var(--rose);
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}

.day-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; justify-content: space-between;
}
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav button.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.appt-card {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.appt-time { font-size: 13px; font-weight: 500; color: var(--muted); min-width: 52px; }
.appt-info { flex: 1; min-width: 120px; }
.appt-info .name { font-size: 14px; font-weight: 500; }
.appt-info .meta { font-size: 12px; color: var(--muted); }

.empty-box {
  text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: 14px;
  background: #fff; border-radius: 12px; border: 1px solid var(--line);
}

.clients-grid { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 16px; }
@media (max-width: 720px) { .clients-grid { grid-template-columns: 1fr; } }

.client-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; }
.client-row {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; width: 100%;
}
.client-row.active { border-color: var(--rose); background: var(--rose-soft); }
.client-row .cname { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-row .cphone { font-size: 11.5px; color: var(--muted); }

.profile-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.profile-head .cname { font-size: 16px; font-weight: 600; font-family: 'Fraunces', serif; }
.profile-head .ccontact { font-size: 12px; color: var(--muted); display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }

.stat-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 100px; border-radius: 10px; padding: 8px 12px; }
.stat-box .slabel { font-size: 11px; }
.stat-box .svalue { font-size: 15px; font-weight: 600; }

.history-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.history-row .date { color: var(--muted); min-width: 60px; }
.history-row .svc { flex: 1; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(43,38,34,.35); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
}
.modal-box { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; max-height: 85vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head .title { font-size: 16px; font-weight: 600; font-family: 'Fraunces', serif; }
.modal-head button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 18px; }

.error-text { color: var(--danger); font-size: 13px; margin: 6px 0; }
.slot-btn {
  font-family: inherit; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.slot-btn.selected { border-color: var(--rose); background: var(--rose); color: #fff; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 20px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 100;
}

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 160px; display: flex; flex-direction: column; }
.week-col.is-today { border-color: var(--rose); background: var(--rose-soft); }
.week-col-head { font-size: 12px; font-weight: 600; text-align: center; margin-bottom: 6px; text-transform: capitalize; cursor: pointer; }
.week-col-head .num { display: block; font-size: 15px; font-family: 'Fraunces', serif; }
.week-appt { font-size: 11px; padding: 4px 6px; border-radius: 6px; margin-bottom: 4px; cursor: pointer; line-height: 1.3; }
.week-more { font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 2px; }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 500; padding-bottom: 4px; }
.month-cell { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 64px; padding: 5px; cursor: pointer; }
.month-cell.other-month { opacity: .35; }
.month-cell.is-today { border-color: var(--rose); }
.month-cell .num { font-size: 12px; font-weight: 500; font-family: 'Fraunces', serif; }
.month-dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.month-dot { width: 6px; height: 6px; border-radius: 50%; }
.month-count { font-size: 10px; color: var(--muted); margin-top: 2px; }

.agenda-view-toggle { display: flex; gap: 4px; background: #F3F0EC; padding: 4px; border-radius: 10px; }
.agenda-view-toggle button { font-family: inherit; font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 7px; border: none; cursor: pointer; background: transparent; color: var(--muted); }
.agenda-view-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
@media (max-width: 720px) {
  .week-grid { grid-template-columns: repeat(7, minmax(90px,1fr)); overflow-x: auto; }
}

.wizard-steps { display: flex; gap: 6px; margin-bottom: 22px; }

.wizard-step { flex: 1; text-align: center; }
.wizard-step .bar { height: 3px; border-radius: 2px; background: var(--line); margin-bottom: 6px; }
.wizard-step.done .bar, .wizard-step.active .bar { background: var(--rose); }
.wizard-step .label { font-size: 11px; color: var(--muted); }
.wizard-step.active .label { color: var(--rose); font-weight: 600; }

.option-row {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; text-align: left; width: 100%; margin-bottom: 8px;
}
.option-row.selected { border-color: var(--rose); background: var(--rose-soft); }
.option-row .oname { font-size: 14px; font-weight: 500; }
.option-row .ometa { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.option-row .oprice { font-size: 14px; font-weight: 600; color: var(--rose); }

.confirm-box { text-align: center; padding: 3rem 1rem; }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--sage-soft); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 26px; color: var(--sage); }

/* ---------- Reserva: titulos, calendario y horas ---------- */
.step-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 22px; letter-spacing: -0.01em; margin: 4px 0 4px; }
.step-sub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.step-title + .option-row, .step-title + .summary-box { margin-top: 12px; }
.option-row .ochevron { font-size: 20px; color: var(--rose); padding-left: 10px; }
.option-row .ometa { line-height: 1.5; }
.link-back { background: none; border: none; padding: 0; margin: 0 0 8px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--rose); cursor: pointer; }

.cal-card {
  background: linear-gradient(180deg, #fff 0%, #FDF7F8 100%);
  border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px 14px;
  box-shadow: 0 10px 30px -18px rgba(86, 27, 45, .35);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-month { font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; }
.cal-nav {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--rose);
  font-size: 18px; line-height: 1; cursor: pointer; font-family: inherit;
}
.cal-nav:disabled { opacity: .3; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; justify-items: center; }
.cal-dows { margin-bottom: 6px; }
.cal-dows span { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.cal-day {
  position: relative; width: 100%; max-width: 44px; aspect-ratio: 1; border-radius: 50%; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; font-family: inherit; font-size: 14px; background: transparent; color: var(--ink);
}
button.cal-day { cursor: pointer; font-weight: 500; background: var(--rose-soft); color: var(--rose); transition: transform .12s ease, background .12s ease; }
button.cal-day:hover { transform: scale(1.06); background: #EBD3DA; }
button.cal-day:focus-visible, .cal-nav:focus-visible, .slot-btn:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.cal-day.is-off { color: #C9BFB8; }
.cal-day.is-today { border-color: var(--rose); }
.cal-day.is-selected, button.cal-day.is-selected:hover { background: var(--rose); color: #fff; box-shadow: 0 6px 14px -6px rgba(86, 27, 45, .7); }
.cal-legend { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 11.5px; color: var(--muted); margin-top: 12px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rose-soft); border: 1px solid #E3C3CC; display: inline-block; }

.slots-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; margin-top: 22px; }
.slots-date { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.slots-hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 18px; }
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.slots-grid .slot-btn { padding: 10px 6px; border-radius: 999px; font-size: 13px; font-weight: 500; }

.summary-box { background: var(--sage-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--sage); line-height: 1.5; }
.ref-drop {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 1.5px dashed #D9C3C9;
  background: #fff; cursor: pointer; font-size: 13px; line-height: 1.4;
}
.ref-drop:hover { border-color: var(--rose); background: #FDF7F8; }
.ref-plus { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--rose-soft); color: var(--rose); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.ref-preview { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ref-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
button.btn:disabled { opacity: .6; cursor: default; }

/* ---------- Panel: mensajes para copiar ---------- */
.appt-extra { margin: -2px 0 14px 4px; }
.appt-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { font-family: inherit; font-size: 12px; font-weight: 500; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.chip-btn:hover { border-color: var(--rose); color: var(--rose); }
.chip-tag { font-size: 11px; color: var(--sage); background: var(--sage-soft); padding: 4px 9px; border-radius: 999px; }
.copy-block { margin-top: 8px; background: #F7F3EF; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.copy-block pre { margin: 0 0 10px; font-family: inherit; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.copy-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-actions .btn { font-size: 12.5px; padding: 7px 12px; }

a.btn { font-family: inherit; font-size: 12.5px; font-weight: 500; padding: 7px 12px; border-radius: 8px; text-decoration: none; display: inline-block; border: 1px solid transparent; }
.btn-wa { background: #1F8F55; color: #fff; }
.btn-wa:hover { background: #197a48; }
.btn-wa-ghost { background: #fff; color: #1F8F55; border-color: #BFDCCB !important; }
.wa-missing { font-size: 12px; color: var(--muted); }

.price-note { background: var(--amber-soft); color: var(--amber); font-size: 13px; line-height: 1.45; padding: 10px 14px; border-radius: 12px; margin: 10px 0 12px; }
.chip-new { color: var(--rose); background: var(--rose-soft); }
.appt-note { font-size: 13px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--rose); border-radius: 8px; padding: 8px 12px; margin-top: 8px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Panel: galeria y pestañas ---------- */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { white-space: nowrap; flex-shrink: 0; }
.gallery-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery-admin figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gallery-admin img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.gallery-admin figcaption { padding: 8px 10px 10px; font-size: 12px; line-height: 1.4; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- Reserva terminada ---------- */
.done-card { max-width: 340px; margin: 0 auto; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px 16px; }
.done-card > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--line); }
.done-card > div:last-child { border-bottom: 0; }
.done-card span { color: var(--muted); font-weight: 400; }
a.btn.done-wa { margin-top: 16px; font-size: 15px; padding: 13px 26px; border-radius: 999px; }
