:root {
  --bg: #0b1120;
  --bg-card: #151f32;
  --bg-card-hover: #1d2a44;
  --bg-input: #0f172a;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --accent-xmas: #f43f5e;
  --whatsapp: #22c55e;
  --whatsapp-dark: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  background-color: #0b1120 !important;
  color-scheme: dark;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background-color: #0b1120 !important;
  background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding-bottom: 100px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  overflow-x: hidden;
  max-width: 100vw;
}

body.modal-open {
  overflow: hidden !important;
  touch-action: pan-y;
}

.app-shell {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Header */
.top-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(21, 31, 50, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 40;
  box-shadow: var(--shadow);
}

@media (max-width: 520px) {
  .top-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1.3fr 1.1fr 1fr auto;
    gap: 6px;
  }
  .header-actions .btn-icon {
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.78rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-icon,
.brand-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.brand-icon {
  background: linear-gradient(135deg, #be123c, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}
.sync-dot.connected {
  background: var(--whatsapp);
  box-shadow: 0 0 8px var(--whatsapp);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-icon.btn-galleries-active {
  background: linear-gradient(135deg, #0284c7, #38bdf8) !important;
  color: #ffffff !important;
  border-color: rgba(56, 189, 248, 0.7) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  border: none;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 18px -4px rgba(56, 189, 248, 0.45);
}

/* KPI Stats */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.25rem;
  font-weight: 800;
  margin-top: 3px;
  letter-spacing: -0.02em;
}

.kpi-value.green { color: #4ade80; }
.kpi-value.amber { color: #fbbf24; }
.kpi-value.blue  { color: #38bdf8; }

.kpi-sub {
  font-size: 0.71rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Controls & Filters */
.controls-bar {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 42px;
  outline: none;
  box-sizing: border-box;
}
.search-input:focus {
  border-color: var(--primary);
}

.date-filter-wrap {
  position: relative;
  flex: 0 0 115px;
  width: 115px;
  display: inline-flex;
  align-items: center;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  box-sizing: border-box;
}

.date-filter-input {
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.date-filter-input:focus,
.date-filter-input:active {
  border-color: var(--primary);
}

.date-filter-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.3);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.date-filter-wrap.has-value .date-filter-input {
  padding-right: 28px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  border-color: rgba(56, 189, 248, 0.4);
}

/* Selector emergente de Fecha estilo iOS con puntitos en días agendados */
.date-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.date-picker-backdrop.open {
  display: flex;
}

.date-picker-card {
  background: #1c1f2b;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 26px;
  padding: 20px 16px 18px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78);
  animation: dpPopIn 0.16s ease-out;
}
@keyframes dpPopIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 6px;
}
.dp-month-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: #f8fafc;
  text-transform: capitalize;
}
.dp-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dp-nav-btn {
  background: transparent;
  border: none;
  color: #38bdf8;
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 8px;
}
.dp-nav-btn:active {
  background: rgba(56, 189, 248, 0.15);
}

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
  column-gap: 2px;
  margin-bottom: 14px;
}

.dp-day {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  position: relative;
  transition: background 0.12s ease, transform 0.1s ease;
}
.dp-day:active {
  transform: scale(0.92);
}
.dp-day.empty {
  pointer-events: none;
  cursor: default;
}
.dp-day-num {
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.05;
}
.dp-day.has-sessions:not(.selected) .dp-day-num {
  font-weight: 700;
  color: #ffffff;
}
.dp-day.today:not(.selected) .dp-day-num {
  color: #38bdf8;
  font-weight: 800;
}
.dp-day.selected {
  background: #3b82f6;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.5);
}
.dp-day.selected .dp-day-num {
  color: #ffffff;
  font-weight: 700;
}

.dp-dot-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  height: 6px;
  margin-top: 2px;
}
.dp-dot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.9);
}
.dp-day.selected .dp-dot {
  background: #ffffff;
  box-shadow: none;
}

.dp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
}
.dp-btn-reset {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
}
.dp-btn-reset:active {
  background: rgba(255, 255, 255, 0.16);
}
.dp-btn-confirm {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #3b82f6;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.5);
}
.dp-btn-confirm:active {
  transform: scale(0.93);
}

.chips-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.chip.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--primary);
  border-color: var(--primary);
}

/* Sessions List */
.sessions-container {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.day-group-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 4px 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.session-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
  position: relative;
  overflow: hidden;
}

.session-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary);
}
.session-card[data-type="Sesión Navideña"]::before { background: #22c55e; }
.session-card[data-type="Boda"]::before { background: #eab308; }
.session-card[data-type="XV Años"]::before { background: #a855f7; }
.session-card[data-type="Sesión Exterior"]::before { background: #f97316; }

.session-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.type-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.session-card[data-type="Sesión Navideña"] .type-badge {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.session-card[data-type="Sesión Exterior"] .type-badge {
  background: rgba(249, 115, 22, 0.18);
  color: #fdba74;
}

.time-pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.07);
  padding: 3px 9px;
  border-radius: 7px;
}

.sync-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}
.sync-badge.synced {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.client-name {
  font-size: 1.12rem;
  font-weight: 700;
  margin-top: 8px;
}

.package-info {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #cbd5e1;
}

/* Financial Box inside Card */
.finance-strip {
  margin-top: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.fin-item-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.fin-item-val {
  font-size: 0.95rem;
  font-weight: 800;
  margin-top: 1px;
}

.fin-item-val.due { color: #fbbf24; }
.fin-item-val.paid { color: #4ade80; }

.session-notes {
  margin-top: 9px;
  font-size: 0.8rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.03);
  padding: 7px 10px;
  border-radius: 8px;
  border-left: 3px solid rgba(148, 163, 184, 0.35);
}

/* Card Action Buttons */
.card-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn-wa {
  flex: 1.4;
  min-width: 125px;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-wa:hover {
  background: rgba(34, 197, 94, 0.26);
}

.btn-act {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.btn-act:hover {
  border-color: var(--primary);
}
.btn-act.danger:hover {
  border-color: var(--danger);
  color: #fca5a5;
}

/* Floating New Session Button on Mobile */
.fab-new {
  position: fixed;
  bottom: 22px;
  right: 20px;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 12px 28px -4px rgba(244, 63, 94, 0.65);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 45;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 0;
  overscroll-behavior: contain;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}
.modal-backdrop.open {
  display: flex;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

/* ===== Asistente IA para Autocompletar Sesiones ===== */
.ai-box {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.22) 0%, rgba(30, 58, 138, 0.22) 100%);
  border: 1px solid rgba(168, 85, 247, 0.38);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 4px;
}
.ai-box-header {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  background: rgba(147, 51, 234, 0.08);
}
.ai-box-header:active {
  background: rgba(147, 51, 234, 0.16);
}
.ai-box-body {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(168, 85, 247, 0.2);
}
.ai-sparkle {
  font-size: 1.1rem;
  display: inline-block;
  animation: aiSparklePulse 2.2s infinite ease-in-out;
}
@keyframes aiSparklePulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.18); filter: brightness(1.35); }
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px 28px;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 20px;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

/* Form Elements */
#sessionForm {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 11px;
  align-items: end;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.form-grid > * {
  min-width: 0;
}
.form-grid > div:not(.form-full) {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.form-full {
  grid-column: 1 / -1;
}

.modal-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  align-items: stretch;
}
.modal-actions-row .btn-act {
  flex: 0 0 90px;
  min-width: 75px;
  justify-content: center;
  padding: 10px 12px;
}
.modal-actions-row .btn-submit-session {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
  padding: 10px 10px;
  font-size: 0.84rem;
}
@media (max-width: 360px) {
  .modal-actions-row {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-actions-row .btn-act,
  .modal-actions-row .btn-submit-session {
    width: 100%;
    flex: none;
  }
}

.field-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  line-height: 1.25;
}

.field-input,
.field-select,
.field-textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}
.field-input,
.field-select {
  height: 44px;
  line-height: 1.2;
}
.field-select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
/* iOS Safari: los campos de fecha/hora tienen un ancho interno propio que se desborda de su columna */
.field-input[type="date"],
.field-input[type="time"] {
  text-align: left;
  min-height: 44px;
}
.field-input[type="date"]::-webkit-date-and-time-value,
.field-input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
  min-width: 0;
}
.field-input[type="date"]::-webkit-datetime-edit,
.field-input[type="time"]::-webkit-datetime-edit {
  padding: 0;
}
.field-textarea {
  resize: vertical;
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--primary);
}

.resta-preview {
  background: rgba(56, 189, 248, 0.1);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.conflict-banner {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: none;
}
.conflict-banner.show {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 42px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 90;
  display: none;
}
.toast.show {
  display: block;
}

/* Lock Screen / Auth Gate */
body:not(.authenticated) .app-shell,
body:not(.authenticated) .fab-new,
body:not(.authenticated) .modal-backdrop {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg) 55%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

body.authenticated .auth-overlay {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(21, 31, 50, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 14px;
  display: none;
}
.auth-error.show {
  display: block;
}

/* View Switcher (Lista vs Calendario) */
.view-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px;
  margin-top: 14px;
}

.view-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.view-tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(99, 102, 241, 0.25));
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.45);
}

/* Monthly Calendar View */
.calendar-box {
  margin-top: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  box-shadow: var(--shadow);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.cal-month-title {
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: capitalize;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  min-height: 64px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.14s ease;
  overflow: hidden;
}

.cal-cell.other-month {
  opacity: 0.32;
}

.cal-cell.today {
  border-color: var(--primary);
}

.cal-cell.selected {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.cal-day-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cal-cell.today .cal-day-num span {
  background: var(--primary);
  color: #0b1120;
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 800;
}

.cal-mini-ev {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.2);
  color: #bae6fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-mini-ev[data-type="Sesión Navideña"] {
  background: rgba(34, 197, 94, 0.25);
  color: #bbf7d0;
}
.cal-mini-ev[data-type="Boda"] {
  background: rgba(234, 179, 8, 0.25);
  color: #fef08a;
}
.cal-mini-ev[data-type="XV Años"] {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
}
.cal-mini-ev[data-type="Sesión Exterior"] {
  background: rgba(249, 115, 22, 0.25);
  color: #fed7aa;
}

/* Variable Pills for WhatsApp Template Editor */
.var-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.var-pill {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}
.var-pill:hover {
  background: rgba(56, 189, 248, 0.26);
}

.wa-img-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.wa-img-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}



/* ===== Calendario mensual estilo iPhone (número + puntos de color) ===== */
.cal-grid {
  gap: 2px;
}
.cal-cell {
  min-height: 54px;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 6px 2px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
}
.cal-cell .cal-day-num {
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
}
.cal-cell .cal-day-num span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
}
.cal-cell.today {
  border-color: transparent;
}
.cal-cell.today .cal-day-num span {
  background: transparent;
  color: var(--accent-xmas);
  padding: 0;
  font-weight: 800;
}
.cal-cell.selected {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
  border-color: transparent;
}
.cal-cell.selected .cal-day-num span {
  background: #ffffff !important;
  color: #0b1120 !important;
  font-weight: 800 !important;
  border-radius: 8px !important;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.cal-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 7px;
  flex-wrap: wrap;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.cal-more {
  font-size: 0.55rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ===== Horarios para agendar debajo del calendario (10:00 AM a 9:30 PM) ===== */
.cal-slots-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.cal-slots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.cal-slots-date {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.cal-slots-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-day-view-link {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}
.btn-day-view-link:active {
  transform: scale(0.96);
  background: rgba(56, 189, 248, 0.22);
}

.cal-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.cal-slot-btn {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 9px;
  height: 48px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 2px 8px;
  box-sizing: border-box;
}

.cal-slot-btn:active {
  transform: scale(0.97);
}

.cal-slot-time {
  font-size: 0.94rem;
  font-weight: 600;
  color: #f3f4f6;
  letter-spacing: 0.02em;
}

/* Horario disponible */
.cal-slot-btn.available {
  background: #131d31;
  border-color: #27354f;
}
.cal-slot-btn.available:hover,
.cal-slot-btn.available:active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--primary);
}

/* Horario ocupado */
.cal-slot-btn.occupied {
  background: rgba(30, 41, 59, 0.55);
  border-color: rgba(245, 158, 11, 0.45);
}
.cal-slot-btn.occupied .cal-slot-time {
  color: #fbbf24;
}
.cal-slot-occupied-info {
  font-size: 0.68rem;
  color: #cbd5e1;
  font-weight: 500;
  margin-top: 1px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Vista completa del día (pantalla completa) ===== */
.day-view {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: none;
  flex-direction: column;
  background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg) 45%);
  padding-top: env(safe-area-inset-top, 0px);
}
.day-view.open {
  display: flex;
}
body:not(.authenticated) .day-view {
  display: none !important;
}

.day-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
}
.day-view-back {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 4px;
}
.day-view-back .chev {
  font-size: 1.9rem;
  line-height: 0.8;
  font-weight: 400;
}
.day-view-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-view-add {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px -4px rgba(244, 63, 94, 0.6);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--border);
}
.week-day {
  background: transparent;
  border: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  cursor: pointer;
}
.week-letter {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}
.week-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.02rem;
  font-weight: 600;
}
.week-day.today .week-num {
  color: var(--accent-xmas);
  font-weight: 800;
}
.week-day.selected .week-num {
  background: var(--primary);
  color: #0b1120;
  font-weight: 800;
}
.week-day.selected.today .week-num {
  background: var(--accent-xmas);
  color: #fff;
}
.week-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.day-view-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 4px;
}
.day-view-title {
  flex: 1;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: capitalize;
}
.day-view-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  padding: 2px 14px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.day-view-summary strong {
  color: var(--text);
}

.day-view-timeline {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  padding: 14px 0 calc(90px + env(safe-area-inset-bottom, 0px));
}
.tl-body {
  position: relative;
  margin-right: 8px;
}
.tl-hour {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  display: flex;
  align-items: center;
}
.tl-hour-label {
  width: 60px;
  padding-right: 8px;
  text-align: right;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.tl-hour-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.tl-events {
  position: absolute;
  left: 66px;
  right: 0;
  top: 0;
  bottom: 0;
}
.tl-event {
  position: absolute;
  overflow: hidden;
  border-radius: 8px;
  border-left: 4px solid var(--ev-color);
  background: var(--bg-card);
  padding: 4px 7px;
  cursor: pointer;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.5);
}
.tl-event::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ev-color);
  opacity: 0.22;
  pointer-events: none;
}
.tl-event > * {
  position: relative;
}
.tl-event-title {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-event-sub {
  font-size: 0.68rem;
  color: #cbd5e1;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-now {
  position: absolute;
  left: 60px;
  right: 0;
  height: 2px;
  background: var(--accent-xmas);
  pointer-events: none;
}
.tl-now::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-xmas);
}

/* Vista previa de WhatsApp: solo lectura (el texto se cambia desde "Personalizar Plantilla e Imagen") */
.field-textarea[readonly],
.wa-preview {
  background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1;
  cursor: default;
  caret-color: transparent;
}
.field-textarea[readonly]:focus {
  border-color: var(--border);
}

/* Ventana emergente bloqueante para análisis de IA */
.ai-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
}

.ai-loading-card {
  background: linear-gradient(145deg, rgba(26, 29, 48, 0.96), rgba(15, 18, 32, 0.98));
  border: 1px solid rgba(192, 132, 252, 0.4);
  border-radius: 24px;
  padding: 32px 24px 26px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(168, 85, 247, 0.25);
  width: 90%;
  max-width: 320px;
  animation: aiPopIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-loading-spinner-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
}

.ai-loading-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #c084fc;
  border-right-color: #38bdf8;
  animation: aiSpin 0.9s linear infinite;
}

.ai-loading-pulse-ring::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed rgba(192, 132, 252, 0.45);
  animation: aiSpinReverse 2.4s linear infinite;
}

.ai-loading-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  animation: aiPulse 1.1s ease-in-out infinite alternate;
}

.ai-loading-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 6px;
  background: linear-gradient(135deg, #fdf4ff, #c084fc, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.3px;
}

.ai-loading-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  margin: 0;
  line-height: 1.45;
}

@keyframes aiSpin {
  to { transform: rotate(360deg); }
}

@keyframes aiSpinReverse {
  to { transform: rotate(-360deg); }
}

@keyframes aiPulse {
  0% { transform: scale(0.9); opacity: 0.85; }
  100% { transform: scale(1.12); opacity: 1; filter: drop-shadow(0 0 10px rgba(192, 132, 252, 0.8)); }
}

@keyframes aiPopIn {
  from { opacity: 0; transform: scale(0.88) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== Ventanas Emergentes Personalizadas (Confirmaciones y Avisos) ===== */
.custom-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.76);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 130;
  padding: 20px;
}
.custom-dialog-backdrop.open {
  display: flex;
}

.custom-dialog-card {
  background: linear-gradient(180deg, #1b2438 0%, #131b2e 100%);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78);
  animation: cdPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-dialog-card.step-2 {
  animation: cdPopStep2 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cdPopIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes cdPopStep2 {
  0% {
    opacity: 0.4;
    transform: scale(0.92);
  }
  60% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.cd-icon-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.22);
}
.cd-icon-badge.danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.32);
}
.cd-icon-badge.warning {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.28);
}

.cd-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 8px;
  line-height: 1.25;
}

.cd-message {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.48;
  margin-bottom: 20px;
  white-space: pre-line;
}

.cd-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.cd-btn {
  flex: 1;
  height: 44px;
  border-radius: 13px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  transition: transform 0.1s ease, background 0.15s ease;
}
.cd-btn:active {
  transform: scale(0.96);
}

.cd-btn-cancel {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

.cd-btn-confirm {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: #ffffff;
  box-shadow: 0 6px 16px -3px rgba(59, 130, 246, 0.45);
}
.cd-btn-confirm.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 6px 18px -3px rgba(239, 68, 68, 0.5);
}
.cd-btn-confirm.warning {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  box-shadow: 0 6px 18px -3px rgba(245, 158, 11, 0.45);
}
