/* ============================================
   RESIDENCE ERP — Design System
   Estilo: Moderno minimalista · Acento azul
   Fuente: Inter (Google Fonts)
   ============================================ */
 
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
 
/* ── TOKENS ─────────────────────────────────── */
:root {
  /* Colores */
  --color-bg:          #F8FAFC;
  --color-surface:     #FFFFFF;
  --color-border:      #E2E8F0;
  --color-border-soft: #F1F5F9;
 
  --color-text:        #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted:  #94A3B8;
 
  --color-sidebar-bg:  #0F172A;
  --color-sidebar-hover: #1E293B;
  --color-sidebar-active: #1E3A5F;
 
  --color-accent:      #2563EB;
  --color-accent-hover:#1D4ED8;
  --color-accent-light:#EFF6FF;
 
  --color-success:     #16A34A;
  --color-success-bg:  #F0FDF4;
  --color-warning:     #D97706;
  --color-warning-bg:  #FFFBEB;
  --color-danger:      #DC2626;
  --color-danger-bg:   #FEF2F2;
  --color-info:        #0891B2;
  --color-info-bg:     #ECFEFF;
 
  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:  0 4px 6px rgba(15,23,42,.05), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:  0 10px 15px rgba(15,23,42,.06), 0 4px 6px rgba(15,23,42,.04);
  --shadow-xl:  0 20px 25px rgba(15,23,42,.08), 0 8px 10px rgba(15,23,42,.04);
 
  /* Radios */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-full: 9999px;
 
  /* Espaciado */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
 
  /* Sidebar */
  --sidebar-width: 248px;
  --topbar-height: 72px;
 
  /* Transición */
  --transition: .18s ease;
}
 
/* ── RESET BASE ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
 
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
 
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
 
/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  border-right: 1px solid rgba(255,255,255,.04);
}
 
.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
 
.sidebar-logo img {
  max-width: 240px;
  max-height: 80px;
  object-fit: contain;
}
 
.sidebar-menu {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
 
/* Scrollbar del sidebar */
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
 
.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: #94A3B8;
  text-decoration: none;
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .01em;
  transition: color var(--transition), background var(--transition);
  position: relative;
}
 
.sidebar-menu a i {
  width: 18px;
  text-align: center;
  font-size: .9rem;
  flex-shrink: 0;
  opacity: .7;
  transition: opacity var(--transition);
}
 
.sidebar-menu a:hover {
  color: #E2E8F0;
  background: var(--color-sidebar-hover);
}
 
.sidebar-menu a:hover i { opacity: 1; }
 
/* Enlace activo — firma: barra izquierda 3px */
.sidebar-menu a.active,
.sidebar-menu a[aria-current="page"] {
  color: #FFFFFF;
  background: var(--color-sidebar-active);
}
 
.sidebar-menu a.active::before,
.sidebar-menu a[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--color-accent);
  border-radius: 0 3px 3px 0;
}
 
.sidebar-menu a.active i { opacity: 1; }
 
/* Separador de sección en sidebar */
.sidebar-section-label {
  color: #475569;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-3) var(--space-2);
}
 
/* ── TOPBAR ──────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
 
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-xs);
}
 
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
 
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: relative;
}
 
/* UF badge */
#ufValor {
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-border-soft);
  padding: 5px var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  letter-spacing: .01em;
}
 
/* ── BOTONES DE RESIDENCIA ───────────────────── */
.residencias-container {
  display: flex;
  gap: var(--space-2);
}
 
.residencia-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
  letter-spacing: .02em;
}
 
.residencia-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}
 
.residencia-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

/* ── SELECTOR DE RESIDENCIA EN MÓVIL ─────────── */
.residencia-selector-movil {
  display: none;
  align-items: center;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-residencias-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-residencias-header h2 { margin-bottom: 0; }

.residencias-container-modal {
  flex-direction: column;
}

.residencias-container-modal .residencia-btn {
  width: 100%;
  text-align: left;
}

/* ── AVATAR ──────────────────────────────────── */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--color-border);
  transition: border-color var(--transition);
  cursor: pointer;
}
 
.avatar:hover { border-color: var(--color-accent); }
 
/* ── MENÚ HAMBURGUESA ────────────────────────── */
.menu-btn {
  background: transparent !important;
  border: none !important;
  color: var(--color-text-secondary) !important;
  font-size: 1.3rem;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
 
.menu-btn:hover {
  color: var(--color-text) !important;
  background: var(--color-border-soft) !important;
}
 
/* ── DROPDOWN ────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 220px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  display: none;
  overflow: hidden;
  z-index: 9999;
}
 
.dropdown-menu.active { display: block; }
 
.dropdown-user {
  padding: var(--space-4) var(--space-4) var(--space-3);
  font-weight: 600;
  font-size: .875rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
 
.dropdown-menu a {
  display: block;
  padding: 11px var(--space-4);
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
 
.dropdown-menu a:hover {
  background: var(--color-border-soft);
  color: var(--color-text);
}
 
.logout-link {
  color: var(--color-danger) !important;
  border-top: 1px solid var(--color-border);
  font-weight: 600 !important;
}
 
.logout-link:hover {
  background: var(--color-danger-bg) !important;
  color: var(--color-danger) !important;
}
 
/* ── NOTIFICACIONES ──────────────────────────── */
.notification-wrapper { position: relative; }
 
.notification-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: color var(--transition), background var(--transition);
  position: relative;
}
 
.notification-btn svg { display: block; }
.notification-btn svg path { fill: currentColor; }
 
.notification-btn:hover {
  background: var(--color-border-soft);
  color: var(--color-text);
}
 
.notification-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--color-danger);
  color: white;
  min-width: 17px;
  height: 17px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  border: 2px solid var(--color-surface);
  letter-spacing: 0;
}
 
.notification-menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  z-index: 9999;
}
 
.notification-menu.active { display: block; }
 
.notification-menu::-webkit-scrollbar { width: 4px; }
.notification-menu::-webkit-scrollbar-track { background: transparent; }
.notification-menu::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
 
.notification-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-soft);
  font-size: .8rem;
  color: var(--color-text);
  transition: background var(--transition);
  line-height: 1.5;
}
 
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--color-border-soft); }
 
.notification-item strong {
  display: block;
  font-weight: 600;
  font-size: .8rem;
  color: var(--color-text);
  margin-bottom: 2px;
}
 
.notification-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: .875rem;
}
 
/* ── CONTENIDO PRINCIPAL ─────────────────────── */
.page-content {
  flex: 1;
  padding: var(--space-5) var(--space-8);
  max-width: 1400px;
  width: 100%;
}
 
.page-content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.02em;
  margin-bottom: var(--space-6);
  line-height: 1.2;
}
 
/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
 
.card + .card { margin-top: var(--space-4); }
 
/* ── DASHBOARD GRID ──────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-6);
}
 
.widget-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
 
.widget-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
 
.widget-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
 
.widget-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
 
/* ── TABLAS ──────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  font-size: .875rem;
}
 
.table th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  padding: 11px var(--space-4);
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--color-border);
}
 
.table td {
  padding: 13px var(--space-4);
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text);
  vertical-align: middle;
}
 
.table tr:last-child td { border-bottom: none; }
 
.table tbody tr {
  transition: background var(--transition);
}
 
.table tbody tr:hover { background: var(--color-border-soft); }
 
.table td:first-child,
.table th:first-child {
  width: auto;
  text-align: left;
}
 
/* ── BOTONES ─────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--color-accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 9px var(--space-5);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  letter-spacing: .01em;
  white-space: nowrap;
}
 
.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 12px rgba(37,99,235,.25);
  transform: translateY(-1px);
}
 
.btn-primary:active { transform: translateY(0); box-shadow: none; }
 
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px var(--space-5);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
 
.btn-secondary:hover {
  background: var(--color-border-soft);
  border-color: #CBD5E1;
  color: var(--color-text);
}
 
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent-light);
  color: var(--color-accent);
  border: 1px solid #BFDBFE;
  padding: 5px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
 
.btn-small:hover {
  background: var(--color-accent);
  color: #FFFFFF;
  border-color: var(--color-accent);
}
 
.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid #FECACA;
}
 
.btn-danger:hover {
  background: var(--color-danger);
  color: #FFFFFF;
  border-color: var(--color-danger);
}

.btn-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #BBF7D0;
}

.btn-success:hover {
  background: var(--color-success);
  color: #FFFFFF;
  border-color: var(--color-success);
}
 
/* ── TABS ────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  margin: var(--space-5) 0 var(--space-6);
  background: var(--color-border-soft);
  padding: 4px;
  border-radius: var(--radius-md);
  width: fit-content;
}
 
.tab-btn {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: .8rem;
  font-family: inherit;
  transition: all var(--transition);
  letter-spacing: .01em;
}
 
.tab-btn:hover { color: var(--color-text); }
 
.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
 
.tab-content { display: none; }
.tab-content.active { display: block; }
 
/* ── MODALES ─────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
}
 
.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.modal-content {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  min-width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
}
 
.modal-content h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-5);
  letter-spacing: -.01em;
}
 
/* ── FORMULARIOS ─────────────────────────────── */
.form-card {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
 
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
 
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
 
.form-group label,
.form-grid label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
 
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 9px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.5;
}
 
input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
 
input::placeholder { color: var(--color-text-muted); }
 
select { cursor: pointer; }
 
textarea {
  resize: vertical;
  min-height: 90px;
}
 
/* Quitar flechas en number */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
 
.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
 
/* ── SECCIÓN FINANZAS ────────────────────────── */
.finance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}
 
.finance-controls {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
 
.finance-chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-3); /* antes: var(--space-6) */
  box-shadow: var(--shadow-sm);
}
 
.finance-chart-wrapper {
  position: relative;
  width: 100%;
  height: auto;
}
 
#financeChart {
  width: 100% !important;
  height: 100% !important;
}
 
.finance-summary {
  text-align: center;
  margin-bottom: var(--space-5);
}
 
.finance-summary h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
 
.finance-summary p {
  font-size: .8rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
}
 
.finance-sections {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}
 
.finance-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
 
.finance-card h2 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
 
.finance-total {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-4);
}
 
/* ── SWITCH ──────────────────────────────────── */
.switch-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
 
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}
 
.switch input { opacity: 0; width: 0; height: 0; }
 
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition);
}
 
.slider:before {
  position: absolute;
  content: '';
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-xs);
}
 
input:checked + .slider { background: var(--color-accent); }
input:checked + .slider:before { transform: translateX(20px); }
 
/* ── RRHH LAYOUT ─────────────────────────────── */
.rrhh-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  align-items: start;
}
 
.rrhh-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
 
.rrhh-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
 
.rrhh-card h3 {
  font-size: .875rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  letter-spacing: -.01em;
}
 
.rrhh-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}
 
.rrhh-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
 
.card-title {
  text-align: center;
  font-size: .875rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
 
.card-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
 
.card-actions button { flex: 1; }
 
.chart-placeholder {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  margin: var(--space-4) 0;
  color: var(--color-text-muted);
  font-size: .8rem;
  font-weight: 500;
  background: var(--color-border-soft);
}
 
/* ── CONFIGURACIÓN ───────────────────────────── */
.config-card {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  max-width: 520px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
 
.profile-image {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--color-border);
  display: block;
  margin-bottom: var(--space-4);
}
 
/* ── TELÉFONO / DIRECCIÓN ────────────────────── */
.telefono-group {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}
 
.telefono-group select { width: 120px; flex-shrink: 0; }
.telefono-group input[type="text"] { flex: 1; }
 
/* ── TOASTS ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  min-width: 300px;
  max-width: 420px;
  padding: 14px var(--space-5);
  border-radius: var(--radius-lg);
  color: white;
  font-weight: 600;
  font-size: .875rem;
  z-index: 99999;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: toast-in .25s ease, toast-out .4s ease 4.6s forwards;
  border: 1px solid rgba(255,255,255,.1);
}
 
.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); }
.toast-info    { background: var(--color-info); }
 
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
 
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; visibility: hidden; }
}
 
/* ── BADGES / ESTADOS ────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}
 
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-neutral { background: var(--color-border-soft); color: var(--color-text-secondary); }
 
/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 1200px) {
  .finance-sections { grid-template-columns: 1fr; }
}
 
@media (max-width: 1024px) {
  .rrhh-layout { grid-template-columns: 1fr; }
}
 
/* ── BOTÓN HAMBURGUESA (menú móvil) ──────────── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 1.15rem;
  width: 34px;
  height: 34px;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.hamburger-btn:hover {
  background: var(--color-border-soft);
  color: var(--color-text);
}

/* ── OVERLAY DETRÁS DEL SIDEBAR EN MÓVIL ─────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 999;
}

.sidebar-overlay.active { display: block; }

/* ── CONTENEDOR DE SCROLL HORIZONTAL PARA TABLAS ─ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 60px;
  }
 
  .hamburger-btn { display: flex; }

  .sidebar {
    width: 248px;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: none;
  }
 
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
 
  .main-content { margin-left: 0; width: 100%; }
 
  .page-content { padding: var(--space-4); }

  .topbar { padding: 0 var(--space-3); gap: var(--space-2); }

  .topbar-left {
    gap: var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
  }

  .topbar-left::-webkit-scrollbar { display: none; }

  .residencias-container-topbar { display: none; }

  .residencia-selector-movil { display: flex; }

  .topbar-right { gap: var(--space-2); }

  #ufValor { font-size: .72rem; padding: 5px 8px; white-space: nowrap; }

  .selector-mes-topbar span { min-width: unset !important; font-size: .72rem !important; }

  .notification-menu { width: min(340px, calc(100vw - 32px)); right: -8px; }

  .dropdown-menu { width: min(220px, calc(100vw - 32px)); }

  .form-grid { grid-template-columns: 1fr; }
 
  .finance-sections { grid-template-columns: 1fr; }

  .finance-header,
  .finance-controls,
  .rrhh-header,
  .rrhh-actions {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .rrhh-actions { margin-bottom: var(--space-4); }

  .modal-content { min-width: unset; width: 95vw; padding: var(--space-5); }

  .modal-gasto-content { width: 95vw; padding: var(--space-4); }

  .form-gasto-row { flex-wrap: wrap; }

  .table { font-size: .8rem; }

  .table th, .table td { padding: 9px var(--space-3); }
}

@media (max-width: 480px) {
  .page-content h1 { font-size: 1.3rem; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .porcentajes-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}
 
/* ── SCROLLBAR GLOBAL ────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #CBD5E1; }
 
/* ── UTILIDADES ──────────────────────────────── */
.text-muted  { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-accent { color: var(--color-accent); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4   { margin-top: var(--space-4); }
.mt-6   { margin-top: var(--space-6); }
.mb-4   { margin-bottom: var(--space-4); }
.gap-3  { gap: var(--space-3); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
 
/* ── MODAL GASTO VARIABLE ── */
.modal-gasto-container {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}
.modal-gasto-container.active { display: flex !important; }

.modal-gasto-content {
    background: var(--color-surface);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    width: 560px;
    max-width: 95vw;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    font-family: 'Inter', sans-serif;
    color: var(--color-text);
}

.modal-gasto-content::-webkit-scrollbar { width: 4px; }
.modal-gasto-content::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

.modal-gasto-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-5);
}

.modal-gasto-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -.01em;
}

.modal-gasto-close {
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
    transition: color var(--transition);
}
.modal-gasto-close:hover { color: var(--color-text); }

.form-gasto-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    align-items: flex-end;
}

.form-gasto-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: var(--space-3);
}

.form-gasto-group label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
}

.form-gasto-group input[type="text"],
.form-gasto-group input[type="date"],
.form-gasto-group input[type="number"],
.form-gasto-group select {
    padding: 9px var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    color: var(--color-text);
    background: var(--color-surface);
    width: 100%;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-gasto-group input:focus,
.form-gasto-group select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* Botones de residencia dentro del modal */
.residencia-buttons { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); }

.btn-residencia {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .8rem;
    font-family: 'Inter', sans-serif;
    transition: all var(--transition);
}

.btn-residencia:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.btn-residencia.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
    box-shadow: 0 2px 8px rgba(37,99,235,.2);
}

/* Porcentajes */
.porcentajes-container {
    background: var(--color-border-soft);
    border: 1px solid var(--color-border);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
}

.porcentajes-header-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--color-accent);
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.porcentajes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--space-2);
}

.pct-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.pct-input-group span {
    font-size: .72rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 3px;
}

/* File input */
.file-input-container { display: flex; align-items: center; gap: var(--space-2); width: 100%; }
.file-input-container input[type="file"] { flex: 1; min-width: 0; font-size: .8rem; }

.btn-eye {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    height: 38px;
    width: 42px;
    min-width: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background var(--transition);
}
.btn-eye:hover { background: var(--color-border); }
.btn-eye:disabled { opacity: .4; cursor: not-allowed; }

/* Categoría item */
.categoria-item {
    background: var(--color-border-soft);
    border: 1px solid var(--color-border);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
}

/* Footer del modal */
.modal-gasto-footer {
    margin-top: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-4);
}

.footer-actions-row { display: flex; gap: var(--space-2); width: 100%; }

.btn-block-action {
    width: 100%;
    padding: 10px;
    background: var(--color-info);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: opacity var(--transition);
}
.btn-block-action:hover { opacity: .9; }

.btn-secondary-modal {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary-modal:hover { background: var(--color-bg); color: var(--color-text); }

.btn-primary-modal {
    flex: 1;
    padding: 10px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background var(--transition);
}
.btn-primary-modal:hover { background: var(--color-accent-hover); }

/* Dona wrapper */
.dona-gasto-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    margin: var(--space-3) 0;
}

/* Finance card títulos unificados */
.finance-card h2 {
    font-size: .72rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: .06em !important;
    color: var(--color-text-muted) !important;
    margin-bottom: var(--space-3) !important;
    text-align: left !important;
}

/* ── SPINNER DE BOTÓN (estado "procesando") ─── */
.spinner-btn {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: girar-spinner .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes girar-spinner {
  to { transform: rotate(360deg); }
}

button:disabled {
  opacity: .7;
  cursor: not-allowed;
  pointer-events: none;
}

/* Modificación de acople para layouts analíticos en Escritorio */
@media (min-width: 769px) {
  .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
  }
}

/* Modificación menor para corregir saltos de línea en títulos de widgets */
.widget-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logo: ajuste proporcional completo */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 10px; /* O el padding que prefieras */
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-logo img {
    max-width: 85%;
    height: auto;
    object-fit: contain; /* Muestra el logo completo sin recortarlo */
}