:root {
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --secondary: #34B7F1;
  --surface: #FFFFFF;
  --background: #F5F5F5;
  --error: #B00020;
  --success: #4CAF50;
  --warning: #FF9800;
  --text: #1c1c1c;
  --text-muted: #6b7280;
  --border: #e5e7eb;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "San Francisco", system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 20px;
}

.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  padding: 36px 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  color: var(--primary-dark);
  text-align: center;
}

.login-card .subtitle {
  margin: 0 0 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  min-height: 44px;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; }

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 20px 0;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.login-divider span { padding: 0 12px; }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  background: #fff;
  color: #3c4043;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}
.btn-google:active { background: #f7f7f7; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.flash-error { background: #fdecea; color: var(--error); }
.flash-success { background: #e9f9ef; color: var(--primary-dark); }

/* ---------- App layout (mobile-first) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.topbar .brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.topbar .logout {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 10px;
}

.main-content {
  padding: 16px 16px 88px;
  max-width: 720px;
  margin: 0 auto;
}

.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 10;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 6px;
}

.bottom-nav a .icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary-dark); font-weight: 700; }

@media (min-width: 768px) {
  .main-content { padding: 24px 16px 40px; max-width: 900px; }
}

.card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

/* ---------- Dashboard ---------- */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.9rem;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok { background: var(--primary); }
.status-dot.pending { background: var(--warning); }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.summary-tile .value { font-size: 1.6rem; font-weight: 700; }
.summary-tile .label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.summary-tile.enviados .value { color: var(--secondary); }
.summary-tile.confirmadas .value { color: var(--primary); }
.summary-tile.canceladas .value { color: var(--error); }
.summary-tile.fallidos .value { color: var(--warning); }

.placeholder-card {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-send-reminders {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 52px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-send-reminders:active { background: var(--primary-dark); }
.btn-send-reminders:disabled { opacity: 0.7; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.spinner.visible { display: inline-block; }

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

.send-result {
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 8px;
  margin: -8px 0 16px;
}
.send-result.error { background: #fdecea; color: var(--error); }
.send-result.success { background: #e9f9ef; color: var(--primary-dark); }

.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-info .name { font-size: 0.9rem; font-weight: 600; }
.activity-info .meta { font-size: 0.78rem; color: var(--text-muted); }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.enviado { background: #e6f4ff; color: var(--secondary); }
.badge.confirmed { background: #e9f9ef; color: var(--primary-dark); }
.badge.cancelled { background: #fdecea; color: var(--error); }
.badge.rescheduled { background: #fff3e0; color: var(--warning); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 24px 0;
}

/* ---------- Directorio ---------- */
.search-bar-sticky {
  position: sticky;
  top: 57px;
  z-index: 4;
  background: var(--background);
  padding: 8px 0 12px;
}

.search-bar-sticky input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 1rem;
  min-height: 44px;
  background: var(--surface);
}

.search-bar-sticky input:focus { outline: none; border-color: var(--primary); }

.secondary-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-secondary {
  flex: 1;
  min-width: 150px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
}

.btn-secondary:active { background: var(--background); }
.btn-secondary:disabled { opacity: 0.5; }

.contact-list { list-style: none; margin: 0; padding: 0; }

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.contact-item:last-child { border-bottom: none; }

.contact-info .name { font-size: 0.92rem; font-weight: 600; }
.contact-info .meta { font-size: 0.8rem; color: var(--text-muted); }

.child-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-schedule {
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ---------- Modal de importación ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 20;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.visible { display: flex; }

.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: 16px; }
}

.modal-card h2 { margin-top: 0; font-size: 1.05rem; }

.modal-card input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.btn-close {
  width: 100%;
  margin-top: 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.9rem;
  min-height: 44px;
}

.modal-card .field { margin-bottom: 14px; }
.modal-card select, .modal-card textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  min-height: 44px;
  font-family: inherit;
}

/* ---------- Citas ---------- */
.date-picker-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.date-picker-bar input[type="date"] {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  min-height: 44px;
  background: var(--surface);
}

.btn-delete {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  border-radius: 8px;
}
.btn-delete:active { background: #fdecea; }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  z-index: 8;
}
.fab:active { background: var(--primary-dark); }

.suggestions-wrap { position: relative; }

.suggestions-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 6;
}

.suggestion-item {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:active { background: var(--background); }

/* ---------- Reviews ---------- */
.review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.check-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  min-height: 44px;
}

.check-all-label input[type="checkbox"] { width: 20px; height: 20px; }

.review-item-label {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-height: 44px;
}

.review-item-label input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; }

.progress-wrap { margin: 4px 0 16px; }

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* ---------- Configuración ---------- */
.accordion-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.accordion-section summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  cursor: pointer;
}

.accordion-section summary::-webkit-details-marker { display: none; }

.accordion-section summary::after {
  content: "▾";
  color: var(--text-muted);
  margin-left: 10px;
}

.accordion-section[open] summary::after { content: "▴"; }

.accordion-body {
  padding: 4px 20px 20px;
  border-top: 1px solid var(--border);
}

.config-status {
  font-size: 0.85rem;
  margin: 14px 0 4px;
}

.input-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-action input { flex: 1; }

.btn-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 1.1rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  min-height: 44px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

.logo-preview {
  display: block;
  max-width: 160px;
  max-height: 160px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 14px 0;
  object-fit: contain;
  background: var(--background);
}
