:root, [data-theme="profesional"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-border: rgba(255,255,255,0.1);
  --sidebar-muted: #94a3b8;
  --login-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="naturaleza"] {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: #d1fae5;
  --bg: #f0fdf4;
  --card: #ffffff;
  --text: #1a2e1a;
  --text-light: #4b6b4b;
  --border: #d1e7d1;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-bg: #14532d;
  --sidebar-text: #bbf7d0;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-border: rgba(255,255,255,0.12);
  --sidebar-muted: #86efac;
  --login-gradient: linear-gradient(135deg, #059669 0%, #14532d 100%);
}

[data-theme="oceano"] {
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-light: #e0f2fe;
  --bg: #f0f9ff;
  --card: #ffffff;
  --text: #0c2d48;
  --text-light: #4b7a9b;
  --border: #bae6fd;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-bg: #0c4a6e;
  --sidebar-text: #bae6fd;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-border: rgba(255,255,255,0.12);
  --sidebar-muted: #7dd3fc;
  --login-gradient: linear-gradient(135deg, #0ea5e9 0%, #0c4a6e 100%);
}

[data-theme="vibrante"] {
  --primary: #e11d48;
  --primary-hover: #be123c;
  --primary-light: #ffe4e6;
  --bg: #fff1f2;
  --card: #ffffff;
  --text: #1c1917;
  --text-light: #78716c;
  --border: #fecdd3;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-bg: #4c0519;
  --sidebar-text: #fecdd3;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-border: rgba(255,255,255,0.12);
  --sidebar-muted: #fda4af;
  --login-gradient: linear-gradient(135deg, #f43f5e 0%, #881337 100%);
}

[data-theme="elegante"] {
  --primary: #a855f7;
  --primary-hover: #9333ea;
  --primary-light: #f3e8ff;
  --bg: #faf5ff;
  --card: #ffffff;
  --text: #1e1b2e;
  --text-light: #6b6480;
  --border: #e9d5ff;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-bg: #2e1065;
  --sidebar-text: #e9d5ff;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-border: rgba(255,255,255,0.12);
  --sidebar-muted: #c084fc;
  --login-gradient: linear-gradient(135deg, #a855f7 0%, #3b0764 100%);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-gradient);
}

.login-card {
  background: var(--card);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-card p { color: var(--text-light); margin-bottom: 1.5rem; }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 1.5rem 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 1rem;
}

.sidebar-brand h2 { font-size: 1.2rem; font-weight: 700; }
.sidebar-brand small { color: var(--sidebar-muted); font-size: 0.8rem; }

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.95rem;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; border-radius: 0; }
.nav-item .icon { font-size: 1.2rem; width: 24px; text-align: center; }

.nav-label {
  padding: 0.5rem 1.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  margin-top: 0.5rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
}

.sidebar-footer button:hover { color: #fff; }

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.stat-card .label { color: var(--text-light); font-size: 0.85rem; margin-bottom: 0.25rem; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

tr:hover td { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-sa { background: #e0e7ff; color: #4f46e5; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.modal h3 { font-weight: 600; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Calendar overrides */
.fc { font-size: 0.9rem; }
.fc .fc-toolbar-title { font-size: 1.2rem; }
.fc .fc-button-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.fc .fc-button-primary:hover {
  background: var(--primary-hover) !important;
}
.fc .fc-button-active {
  background: var(--primary-hover) !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15) !important;
}
.fc .fc-daygrid-event {
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.8rem;
}
.fc .fc-timegrid-event {
  border-radius: 6px;
  border-left-width: 4px;
  font-size: 0.82rem;
}
.fc .fc-timegrid-event .fc-event-title {
  font-weight: 600;
}
.fc .fc-timegrid-event .fc-event-time {
  font-size: 0.75rem;
  opacity: 0.9;
}
.fc .fc-event { cursor: pointer; }
.fc .fc-now-indicator-line {
  border-color: var(--danger);
  border-width: 2px;
}
.fc .fc-now-indicator-arrow { border-color: var(--danger); }
.fc td.fc-day-today { background: #f0f0ff !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  z-index: 2000;
  animation: slideUp 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

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

/* Responsive */
@media (max-width: 1024px) {
  #page-dashboard > div[style*="grid-template-columns"],
  .card div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand h2, .sidebar-brand small, .nav-item span, .sidebar-footer span { display: none; }
  .nav-item { justify-content: center; padding: 0.75rem; }
  .main-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Onboarding steps */
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ob-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

.ob-step p { color: var(--text-light); font-size: 0.9rem; margin-top: 0.25rem; line-height: 1.5; }
.ob-step code { background: #e0e7ff; padding: 1px 5px; border-radius: 3px; font-size: 0.85rem; }
.ob-step ol { color: var(--text-light); }
.ob-step a { color: var(--primary); }

.ob-num {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Theme picker */
.theme-picker {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-swatch {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 3px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }

.theme-swatch .swatch-sidebar { height: 100%; width: 35%; }
.theme-swatch .swatch-main { height: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.theme-swatch .swatch-dot { width: 10px; height: 10px; border-radius: 50%; }

.theme-swatch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.theme-swatch-wrap small {
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
}

.hidden { display: none !important; }
