:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --church-navy: #1e3a8a;
  
  --nuevo-color: #15803d;
  --nuevo-bg: #dcfce7;
  --nuevo-border: #86efac;
  
  --consolidado-color: #1d4ed8;
  --consolidado-bg: #dbeafe;
  --consolidado-border: #93c5fd;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* App Layout */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .app-container {
    padding: 1rem 0.75rem;
  }
}

/* Header Banner */
.church-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.church-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.church-identity {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.church-logo-badge {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  width: 68px;
  height: 68px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.church-title-group h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.church-title-group p {
  color: #bfdbfe;
  font-size: 0.95rem;
  font-weight: 500;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.live-pulse {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-clock {
  font-size: 0.85rem;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
}

/* Church Details Grid in Banner */
.church-info-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.church-info-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.info-content {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.75rem;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.info-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffffff;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 992px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-content p {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.stat-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.icon-blue { background-color: #eff6ff; color: #2563eb; }
.icon-green { background-color: #f0fdf4; color: #16a34a; }
.icon-indigo { background-color: #eef2ff; color: #4f46e5; }
.icon-amber { background-color: #fffbeb; color: #d97706; }

/* Main Split Layout: Form & Table */
.main-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Card Styling */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}

.card-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title-group p {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.card-body {
  padding: 1.5rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-label .required {
  color: #ef4444;
  margin-left: 0.2rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.875rem;
  color: var(--text-light);
  font-size: 1rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  font-size: 0.925rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  background-color: #fff;
  transition: all 0.2s ease;
  font-family: inherit;
}

.form-control.no-icon {
  padding-left: 0.85rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
  padding: 0.65rem 0.85rem;
}

/* Custom Selector for "Nuevo" vs "Consolidado" */
.type-selector-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.type-option {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  background-color: var(--bg-card);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.type-option:hover {
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.type-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  background: white;
}

.custom-checkbox::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: 800;
  display: none;
}

.type-label-box {
  display: flex;
  flex-direction: column;
}

.type-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.type-desc {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Active State for Nuevo */
.type-option.option-nuevo.selected {
  border-color: var(--nuevo-color);
  background-color: var(--nuevo-bg);
}

.type-option.option-nuevo.selected .custom-checkbox {
  background-color: var(--nuevo-color);
  border-color: var(--nuevo-color);
}

.type-option.option-nuevo.selected .custom-checkbox::after {
  display: block;
}

.type-option.option-nuevo.selected .type-title {
  color: var(--nuevo-color);
}

/* Active State for Consolidado */
.type-option.option-consolidado.selected {
  border-color: var(--consolidado-color);
  background-color: var(--consolidado-bg);
}

.type-option.option-consolidado.selected .custom-checkbox {
  background-color: var(--consolidado-color);
  border-color: var(--consolidado-color);
}

.type-option.option-consolidado.selected .custom-checkbox::after {
  display: block;
}

.type-option.option-consolidado.selected .type-title {
  color: var(--consolidado-color);
}

/* Date Time Field with Quick Action */
.datetime-row {
  display: flex;
  gap: 0.5rem;
}

.btn-now {
  padding: 0 0.85rem;
  background-color: #f1f5f9;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-now:hover {
  background-color: #e2e8f0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.925rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(30, 64, 175, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(30, 64, 175, 0.35);
  transform: translateY(-1px);
}

.btn-success {
  background-color: #16a34a;
  color: white;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.25);
}

.btn-success:hover {
  background-color: #15803d;
  box-shadow: 0 4px 8px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-block {
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Toolbar & Filters */
.table-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-container {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.filter-pills {
  display: flex;
  background-color: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill.active {
  background: white;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Export Dropdown / Action Buttons */
.export-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: white;
  min-width: 260px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  padding: 0.5rem;
  display: none;
}

.dropdown.open .dropdown-menu {
  display: block;
  animation: fadeInDown 0.15s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background-color: #f1f5f9;
}

.dropdown-item-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.dropdown-item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border);
  margin: 0.4rem 0;
}

.clear-search-btn {
  position: absolute;
  right: 0.75rem;
  background: #e2e8f0;
  border: none;
  font-size: 0.75rem;
  color: #475569;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.clear-search-btn:hover {
  background-color: #cbd5e1;
  color: #0f172a;
}

/* Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table thead {
  background-color: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.data-table th {
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table td {
  padding: 0.85rem 1rem;
  color: var(--text-main);
  vertical-align: middle;
}

/* Table Badges & Cell Styles */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-nuevo {
  background-color: var(--nuevo-bg);
  color: var(--nuevo-color);
  border: 1px solid var(--nuevo-border);
}

.badge-consolidado {
  background-color: var(--consolidado-bg);
  color: var(--consolidado-color);
  border: 1px solid var(--consolidado-border);
}

.phone-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
}

.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: #25d366;
  color: white;
  border-radius: 50%;
  text-decoration: none;
  font-size: 0.85rem;
  margin-left: 0.35rem;
  transition: transform 0.15s;
}

.whatsapp-btn:hover {
  transform: scale(1.15);
}

.cell-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.action-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.action-btn:hover {
  color: var(--text-main);
  border-color: #cbd5e1;
  background-color: #f1f5f9;
}

.action-btn.btn-delete:hover {
  color: #ef4444;
  border-color: #fca5a5;
  background-color: #fef2f2;
}

/* Empty State */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background-color: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideInRight 0.25s ease-out;
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  background-color: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background-color: #eff6ff;
}

.dropzone-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

