/* ==============================================
   Momentos Dorados — CSS Base Centralizado
   ============================================== */

/* --- Design Tokens --- */
:root {
    --md-primary: #2c3e50;
    --md-accent: #3498db;      /* Acento visual del sistema (antes --md-secondary) */
    --md-danger: #e74c3c;      /* Estados de error/peligro (antes --md-accent) */
    --md-success: #27ae60;
    --md-warning: #f39c12;
    --md-info: #17a2b8;
    --md-muted: #6c757d;       /* Texto secundario/atenuado */
    --md-light-bg: #ecf0f1;
    --md-dark-text: #2c3e50;

    /* Superficies semánticas (fondos tenues para estados) */
    --md-danger-bg: #fdedec;
    --md-success-bg: #eafaf1;
    --md-warning-bg: #fef9e7;
    --md-info-bg: #ebf5fb;
    --md-accent-bg: #eaf2f8;

    /* Bordes */
    --md-border: #dee2e6;
    --md-border-light: #e9ecef;

    /* Turnos (calendario/staff) — colores base */
    --md-shift-morning: #f39c12;
    --md-shift-afternoon: #e67e22;
    --md-shift-night: #2c3e50;

    /* Turnos — celdas y badges (bg claro + texto oscuro) */
    --md-shift-morning-bg: #fef3c7;
    --md-shift-morning-text: #92400e;
    --md-shift-afternoon-bg: #ffedd5;
    --md-shift-afternoon-text: #9a3412;
    --md-shift-night-bg: #dbeafe;
    --md-shift-night-text: #1e40af;
    --md-shift-off-bg: #dcfce7;
    --md-shift-off-text: #166534;

    /* Gradientes reutilizables */
    --md-gradient-primary: linear-gradient(135deg, var(--md-primary), var(--md-accent));
    --md-gradient-accent: linear-gradient(135deg, var(--md-accent), #2980b9);
    --md-gradient-success: linear-gradient(135deg, var(--md-success), #229954);
    --md-gradient-warning: linear-gradient(135deg, var(--md-warning), #e67e22);
    --md-gradient-danger: linear-gradient(135deg, var(--md-danger), #c0392b);

    /* Bordes y sombras */
    --md-radius-sm: 8px;
    --md-radius-md: 10px;
    --md-radius-lg: 15px;
    --md-radius-xl: 25px;
    --md-shadow-sm: 0 3px 10px rgba(0,0,0,0.1);
    --md-shadow-md: 0 5px 15px rgba(0,0,0,0.08);
    --md-shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --md-shadow-xl: 0 20px 60px rgba(0,0,0,0.3);

    /* Transiciones */
    --md-transition: all 0.3s ease;

    /* Legacy aliases (compatibilidad con templates existentes) */
    --md-secondary: var(--md-accent);   /* DEPRECATED: usar --md-accent */
    --primary-color: var(--md-primary);
    --secondary-color: var(--md-accent);
    --accent-color: var(--md-danger);
    --success-color: var(--md-success);
    --warning-color: var(--md-warning);
    --light-bg: var(--md-light-bg);
    --dark-text: var(--md-dark-text);
}

/* Override Bootstrap utilities para usar nuestros tokens */
.text-muted    { color: var(--md-muted) !important; }
.text-primary  { color: var(--md-primary) !important; }
.text-danger   { color: var(--md-danger) !important; }
.text-success  { color: var(--md-success) !important; }
.text-warning  { color: var(--md-warning) !important; }
.text-info     { color: var(--md-info) !important; }

/* Override Bootstrap RGB variables para que bg-opacity-* funcione con nuestros colores */
:root {
    --bs-primary-rgb: 44, 62, 80;      /* #2c3e50 */
    --bs-success-rgb: 39, 174, 96;     /* #27ae60 */
    --bs-danger-rgb: 231, 76, 60;      /* #e74c3c */
    --bs-warning-rgb: 243, 156, 18;    /* #f39c12 */
    --bs-info-rgb: 23, 162, 184;       /* #17a2b8 */
}

/* --- Base --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--md-light-bg);
    color: var(--md-dark-text);
}

/* --- App Layout (sidebar + content) --- */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 62px;
    --topbar-height: 56px;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--md-primary);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

/* --- Botón colapsar sidebar (desktop) --- */
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: color 0.2s, transform 0.3s;
    display: none;
    position: absolute;
    right: 0.75rem;
    top: calc(var(--topbar-height) + 0.75rem + 0.55rem);
    z-index: 2;
}

.sidebar-collapse-btn:hover {
    color: #fff;
}

@media (min-width: 993px) {
    .sidebar-collapse-btn {
        display: block;
    }
}

.app-sidebar.sidebar-collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
}

.app-sidebar.sidebar-collapsed:not(:hover) .sidebar-collapse-btn {
    top: 1rem;
    right: auto;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}

.sidebar-logo {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo:hover {
    color: white;
}

.sidebar-logo .logo-compact {
    display: none;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-text {
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.sidebar-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    padding: 1rem 1.25rem 0.4rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link span {
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar-link:hover {
    color: white;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--md-accent);
}

.sidebar-link:hover i {
    opacity: 1;
}

.sidebar-link.active {
    color: white;
    background: rgba(52, 152, 219, 0.25);
    border-left-color: var(--md-accent);
}

.sidebar-link.active i {
    opacity: 1;
    color: var(--md-accent);
}

/* Submenú colapsable */
.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    background: rgba(0,0,0,0.15);
}

.sidebar-submenu.open {
    max-height: 500px;
}

.sidebar-submenu .sidebar-link {
    padding-left: 3.25rem;
    font-size: 0.825rem;
    border-left: none;
}

.sidebar-submenu .sidebar-link:hover {
    border-left: none;
    background: rgba(255,255,255,0.05);
}

.sidebar-toggle-icon {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.25s;
    opacity: 0.5;
}

.sidebar-link.open .sidebar-toggle-icon {
    transform: rotate(90deg);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--md-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar-user-name {
    font-size: 0.85rem;
    color: white;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.825rem;
    transition: color 0.15s;
    white-space: nowrap;
}

.sidebar-logout i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    color: var(--md-danger);
}

/* --- Botón hamburguesa móvil --- */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1045;
    background: var(--md-primary);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.mobile-menu-toggle:hover {
    background: var(--md-accent);
}

/* --- Main content wrapper --- */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease, width 0.3s ease;
    overflow-x: hidden;
}

.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* --- Sidebar colapsado (tablet) --- */
@media (max-width: 992px) and (min-width: 769px) {
    .app-sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .app-sidebar .logo-text,
    .app-sidebar .sidebar-link span,
    .app-sidebar .sidebar-section-title,
    .app-sidebar .sidebar-user-info,
    .app-sidebar .sidebar-logout span,
    .app-sidebar .sidebar-toggle-icon {
        display: none;
    }

    .app-sidebar .logo-compact {
        display: inline;
    }

    .app-sidebar .sidebar-link {
        justify-content: center;
        padding: 0.7rem 0;
        border-left: none;
        gap: 0;
    }

    .app-sidebar .sidebar-link i {
        font-size: 1.1rem;
    }

    .app-sidebar .sidebar-header {
        justify-content: center;
        padding: 1rem 0;
    }

    .app-sidebar .sidebar-footer {
        padding: 0.75rem 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .app-sidebar .sidebar-user {
        justify-content: center;
    }

    .app-sidebar .sidebar-logout {
        justify-content: center;
    }

    .app-sidebar .sidebar-submenu {
        display: none;
    }

    /* Expand on hover */
    .app-sidebar:hover {
        width: var(--sidebar-width);
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }

    .app-sidebar:hover .logo-text,
    .app-sidebar:hover .sidebar-link span,
    .app-sidebar:hover .sidebar-user-info,
    .app-sidebar:hover .sidebar-logout span {
        display: inline;
    }

    .app-sidebar:hover .logo-compact {
        display: none;
    }

    .app-sidebar:hover .sidebar-section-title {
        display: block;
    }

    .app-sidebar:hover .sidebar-toggle-icon {
        display: inline;
    }

    .app-sidebar:hover .sidebar-link {
        justify-content: flex-start;
        padding: 0.55rem 1.25rem;
        border-left: 3px solid transparent;
        gap: 0.75rem;
    }

    .app-sidebar:hover .sidebar-header {
        justify-content: flex-start;
        padding: 1rem 1.25rem;
    }

    .app-sidebar:hover .sidebar-footer {
        padding: 0.75rem 1.25rem;
        align-items: stretch;
    }

    .app-sidebar:hover .sidebar-user {
        justify-content: flex-start;
    }

    .app-sidebar:hover .sidebar-logout {
        justify-content: flex-start;
    }

    .app-sidebar:hover .sidebar-submenu {
        display: block;
    }

    .app-main {
        margin-left: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }

}

/* --- Sidebar colapsado (desktop, por botón) --- */
.app-sidebar.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar.sidebar-collapsed .logo-text,
.app-sidebar.sidebar-collapsed .sidebar-link span,
.app-sidebar.sidebar-collapsed .sidebar-section-title,
.app-sidebar.sidebar-collapsed .sidebar-user-info,
.app-sidebar.sidebar-collapsed .sidebar-logout span,
.app-sidebar.sidebar-collapsed .sidebar-toggle-icon {
    display: none;
}

.app-sidebar.sidebar-collapsed .logo-compact {
    display: inline;
}

.app-sidebar.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.7rem 0;
    border-left: none;
    gap: 0;
}

.app-sidebar.sidebar-collapsed .sidebar-link i {
    font-size: 1.1rem;
}

.app-sidebar.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0;
}

.app-sidebar.sidebar-collapsed .sidebar-footer {
    padding: 0.75rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-sidebar.sidebar-collapsed .sidebar-user {
    justify-content: center;
}

.app-sidebar.sidebar-collapsed .sidebar-logout {
    justify-content: center;
}

.app-sidebar.sidebar-collapsed .sidebar-submenu {
    display: none;
}

/* Expand on hover (mismo comportamiento que tablet) */
.app-sidebar.sidebar-collapsed:hover {
    width: var(--sidebar-width);
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
}

.app-sidebar.sidebar-collapsed:hover .logo-text,
.app-sidebar.sidebar-collapsed:hover .sidebar-link span,
.app-sidebar.sidebar-collapsed:hover .sidebar-user-info,
.app-sidebar.sidebar-collapsed:hover .sidebar-logout span {
    display: inline;
}

.app-sidebar.sidebar-collapsed:hover .logo-compact {
    display: none;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-section-title {
    display: block;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-toggle-icon {
    display: inline;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-link {
    justify-content: flex-start;
    padding: 0.55rem 1.25rem;
    border-left: 3px solid transparent;
    gap: 0.75rem;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-header {
    justify-content: flex-start;
    padding: 1rem 1.25rem;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-footer {
    padding: 0.75rem 1.25rem;
    align-items: stretch;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-user {
    justify-content: flex-start;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-logout {
    justify-content: flex-start;
}

.app-sidebar.sidebar-collapsed:hover .sidebar-submenu {
    display: block;
}

/* Contenido se adapta cuando sidebar está colapsado */
.app-main.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* --- Sidebar móvil (overlay) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        width: var(--sidebar-width);
    }

    .app-sidebar.mobile-open + .sidebar-overlay {
        display: block;
    }

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .app-content {
        padding: 1rem;
    }
}

/* --- Tooltips para sidebar colapsado --- */
.app-sidebar .sidebar-link {
    position: relative;
}

@media (max-width: 992px) and (min-width: 769px) {
    .app-sidebar:not(:hover) .sidebar-link:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(var(--sidebar-collapsed-width) + 4px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--md-primary);
        color: white;
        padding: 0.35rem 0.75rem;
        border-radius: 6px;
        font-size: 0.8rem;
        white-space: nowrap;
        z-index: 1060;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        pointer-events: none;
    }
}

/* Tooltip también para colapsado desktop */
.app-sidebar.sidebar-collapsed:not(:hover) .sidebar-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--md-primary);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1060;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
}

/* --- Dropdowns --- */
.dropdown-menu {
    border: none;
    box-shadow: var(--md-shadow-md);
    border-radius: var(--md-radius-sm);
}

.dropdown-item {
    transition: var(--md-transition);
    padding: 10px 20px;
}

.dropdown-item:hover {
    background-color: var(--md-accent);
    color: white;
    transform: translateX(5px);
}

/* --- Cards --- */
.card {
    border: none;
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-shadow-md);
    transition: var(--md-transition);
}

/* Hover solo en tarjetas clickeables — no en todas las .card */
.card-clickable:hover,
a > .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--md-shadow-lg);
}

.card-header {
    background: var(--md-gradient-primary);
    color: white;
    border-radius: var(--md-radius-lg) var(--md-radius-lg) 0 0 !important;
    font-weight: 600;
}

/* Fix: texto dentro de card-header siempre blanco (evita text-primary azul sobre fondo azul) */
.card-header .text-primary,
.card-header h5,
.card-header h6 {
    color: white !important;
}

/* Card-header con nav-tabs: fondo claro para que las pestañas sean legibles */
.card-header:has(.nav-tabs) {
    background: #f8f9fa;
    color: #212529;
}
.card-header:has(.nav-tabs) h5,
.card-header:has(.nav-tabs) h6 {
    color: #212529 !important;
}
.card-header:has(.nav-tabs) .nav-link {
    color: #495057;
}
.card-header:has(.nav-tabs) .nav-link.active {
    color: #212529;
    background-color: #fff;
    border-bottom-color: #fff;
}
.card-header:has(.nav-tabs) .btn-outline-primary {
    color: var(--md-primary);
    border-color: var(--md-primary);
}

/* ==============================================
   KPI Card — Estilo sobrio con borde lateral
   Referencia: Libro Diario summary-card
   ============================================== */
.kpi-card {
    background: #fff;
    border-radius: var(--md-radius-md);
    border: 1px solid #e9ecef;
    border-left: 4px solid var(--md-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1.25rem 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.kpi-trend {
    font-size: 0.8rem;
    font-weight: 500;
}

.kpi-trend.up { color: var(--md-success); }
.kpi-trend.down { color: var(--md-danger); }
.kpi-trend.neutral { color: #6c757d; }

/* Variantes de accent por color */
.kpi-accent-success { border-left-color: var(--md-success); }
.kpi-accent-success .kpi-value { color: var(--md-success); }

.kpi-accent-danger { border-left-color: var(--md-danger); }
.kpi-accent-danger .kpi-value { color: var(--md-danger); }

.kpi-accent-warning { border-left-color: var(--md-warning); }
.kpi-accent-warning .kpi-value { color: var(--md-warning); }

.kpi-accent-info { border-left-color: var(--md-info); }
.kpi-accent-info .kpi-value { color: var(--md-info); }

.kpi-accent-primary { border-left-color: var(--md-accent); }
.kpi-accent-primary .kpi-value { color: var(--md-accent); }

.kpi-accent-secondary { border-left-color: #6c757d; }
.kpi-accent-secondary .kpi-value { color: #6c757d; }

.kpi-accent-purple { border-left-color: #6f42c1; }
.kpi-accent-purple .kpi-value { color: #6f42c1; }

/* Clickable KPI */
a.kpi-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

a.kpi-card-link:hover .kpi-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ==============================================
   Module Nav Card — Tarjeta de navegación sobria
   ============================================== */
.module-nav-card {
    background: #fff;
    border-radius: var(--md-radius-md);
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.module-nav-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-color: var(--md-accent);
    color: inherit;
    text-decoration: none;
}

.module-nav-card .nav-card-icon {
    font-size: 1.4rem;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.module-nav-card .nav-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--md-dark-text);
}

.module-nav-card .nav-card-desc {
    font-size: 0.825rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
    flex: 1;
}

.module-nav-card .nav-card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Icon background variants */
.nav-icon-success { background: rgba(39, 174, 96, 0.1); color: var(--md-success); }
.nav-icon-warning { background: rgba(243, 156, 18, 0.1); color: var(--md-warning); }
.nav-icon-primary { background: rgba(52, 152, 219, 0.1); color: var(--md-accent); }
.nav-icon-danger { background: rgba(231, 76, 60, 0.1); color: var(--md-danger); }
.nav-icon-info { background: rgba(23, 162, 184, 0.1); color: var(--md-info); }
.nav-icon-purple { background: rgba(111, 66, 193, 0.1); color: #6f42c1; }
.nav-icon-secondary { background: rgba(108, 117, 125, 0.1); color: #6c757d; }

/* ==============================================
   Page Header — Título estandarizado
   ============================================== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header .page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--md-dark-text);
    margin-bottom: 0.25rem;
}

.page-header .page-subtitle {
    font-size: 1rem;
    color: #495057;
    margin-bottom: 0;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.page-header .page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==============================================
   Data Table Card — Wrapper para tablas
   ============================================== */
.data-table-card {
    background: #fff;
    border-radius: var(--md-radius-md);
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.data-table-card .table-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.data-table-card .table-card-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.data-table-card .table-card-body {
    padding: 0;
}

.data-table-card .table {
    margin-bottom: 0;
    border-radius: 0;
}

.data-table-card .table thead {
    background: #f1f3f5;
    color: var(--md-dark-text);
}

.data-table-card .table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem 1rem;
}

.data-table-card .table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

/* ==============================================
   Card Header Actions — Botones en headers
   ============================================== */
.card-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.card-header-actions .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Botones outline sobre card-header con fondo oscuro */
.card-header .btn-outline-primary,
.card-header .btn-outline-secondary,
.card-header .btn-outline-info,
.card-header .btn-outline-danger {
    color: #fff;
    border-color: rgba(255,255,255,0.7);
    background-color: transparent;
}

.card-header .btn-outline-primary:hover,
.card-header .btn-outline-secondary:hover,
.card-header .btn-outline-info:hover {
    color: var(--md-primary);
    background-color: #fff;
    border-color: #fff;
}

.card-header .btn-outline-danger:hover {
    color: #fff;
    background-color: var(--md-danger);
    border-color: var(--md-danger);
}

/* Excepción: card-header con nav-tabs (fondo claro) — botones normales */
.card-header:has(.nav-tabs) .btn-outline-primary,
.card-header:has(.nav-tabs) .btn-outline-secondary,
.card-header:has(.nav-tabs) .btn-outline-info {
    color: var(--md-primary);
    border-color: var(--md-primary);
}
.card-header:has(.nav-tabs) .btn-outline-primary:hover,
.card-header:has(.nav-tabs) .btn-outline-secondary:hover {
    color: #fff;
    background-color: var(--md-primary);
}

/* --- Stat Card (componente unificado) --- */
.stat-card {
    background: var(--md-gradient-accent);
    color: white;
    border-radius: var(--md-radius-lg);
    padding: 25px;
    text-align: center;
    transition: var(--md-transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(52, 152, 219, 0.4);
}

.stat-card i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

/* Variantes de stat-card por color */
.stat-card-success {
    background: var(--md-gradient-success);
}

.stat-card-warning {
    background: var(--md-gradient-warning);
}

.stat-card-danger {
    background: var(--md-gradient-danger);
}

.stat-card-info {
    background: linear-gradient(135deg, var(--md-info), #138496);
}

/* --- Section Card (componente unificado para secciones colapsables) --- */
.section-card {
    border: 1px solid #dee2e6;
    border-radius: var(--md-radius-md);
    overflow: hidden;
    margin-bottom: 1rem;
}

.section-header {
    background: #f8f9fa;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.section-header:hover {
    background: #eef0f2;
}

.section-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
}

.section-header .section-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header .toggle-icon {
    transition: transform 0.2s;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-body {
    padding: 1rem 1.25rem;
}

/* --- Buttons --- */
.btn-primary {
    background: var(--md-primary);
    border: none;
    border-radius: var(--md-radius-xl);
    padding: 10px 25px;
    color: #fff;
    transition: var(--md-transition);
}

.btn-primary:hover, .btn-primary:focus {
    background: #3d5269;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.35);
}

.btn-outline-primary {
    color: var(--md-primary);
    border-color: var(--md-primary);
    border-radius: var(--md-radius-xl);
    transition: var(--md-transition);
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.25);
}

.btn-success {
    background: var(--md-gradient-success);
    border: none;
    border-radius: var(--md-radius-xl);
}

.btn-warning {
    background: var(--md-gradient-warning);
    border: none;
    border-radius: var(--md-radius-xl);
}

.btn-danger {
    background: var(--md-gradient-danger);
    border: none;
    border-radius: var(--md-radius-xl);
}

/* --- Badges --- */
.badge {
    border-radius: 20px;
    padding: 5px 12px;
}

/* --- Forms --- */
.form-control, .form-select {
    border-radius: var(--md-radius-md);
    border: 2px solid #e0e0e0;
    transition: var(--md-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.15);
}

/* --- Sidebar --- */
.sidebar {
    background: white;
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-shadow-md);
    padding: 20px;
}

.sidebar .nav-link {
    color: var(--md-dark-text);
    border-radius: var(--md-radius-md);
    margin-bottom: 5px;
    padding: 12px 15px;
    transition: var(--md-transition);
}

.sidebar .nav-link:hover {
    background-color: var(--md-light-bg);
    color: var(--md-accent);
}

.sidebar .nav-link.active {
    background: var(--md-gradient-accent);
    color: white;
}

/* --- Tables --- */
.table {
    border-radius: var(--md-radius-md);
    overflow: hidden;
}

.table thead {
    background: var(--md-gradient-primary);
    color: white;
}

.table-hover tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

/* --- Breadcrumbs responsive --- */
.breadcrumb-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;  /* Firefox */
}

.breadcrumb-wrapper::-webkit-scrollbar {
    display: none;
}

.breadcrumb-wrapper .breadcrumb {
    flex-wrap: nowrap;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.breadcrumb-wrapper .breadcrumb-item {
    display: inline-flex;
    align-items: center;
}

.breadcrumb-wrapper .breadcrumb-item a {
    color: var(--md-accent);
    text-decoration: none;
}

.breadcrumb-wrapper .breadcrumb-item a:hover {
    text-decoration: underline;
}

@media (max-width: 576px) {
    .breadcrumb-wrapper .breadcrumb {
        font-size: 0.8rem;
    }
}

/* --- Footer --- */
.footer {
    background: var(--md-gradient-primary);
    color: white;
    padding: 15px 0;
    margin-top: auto;
    font-size: 0.85rem;
}

/* --- Alerts --- */
.alert {
    border: none;
    border-radius: var(--md-radius-md);
    box-shadow: var(--md-shadow-sm);
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--md-light-bg);
    border-top-color: var(--md-accent);
    border-radius: 50%;
    animation: loadingSpin 0.7s linear infinite;
}

@keyframes loadingSpin {
    to { transform: rotate(360deg); }
}

/* Contenedor con position relative para que el overlay se posicione bien */
.loading-container {
    position: relative;
}

/* --- Animations --- */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--md-accent);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--md-primary);
}

/* --- Skip to main (accesibilidad) --- */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--md-primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.2s;
    text-decoration: none;
    font-weight: 600;
}

.skip-to-main:focus {
    top: 0;
    color: white;
}

/* --- Tablas responsive: columna sticky + indicador de scroll --- */
@media (max-width: 992px) {
    .table-responsive {
        position: relative;
    }

    /* Sombra indicadora de que hay más contenido a la derecha */
    .table-responsive.has-overflow::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
        pointer-events: none;
        z-index: 2;
        transition: opacity 0.3s;
    }

    /* Ocultar sombra cuando se scrolleó hasta el final */
    .table-responsive.scrolled-end::after {
        opacity: 0;
    }

    /* Primera columna fija */
    .table-responsive table thead th:first-child,
    .table-responsive table tbody td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: inherit;
    }

    .table-responsive table thead th:first-child {
        z-index: 3;
    }

    /* Sombra sutil en la columna fija para separarla del scroll */
    .table-responsive table th:first-child::after,
    .table-responsive table td:first-child::after {
        content: '';
        position: absolute;
        top: 0;
        right: -4px;
        bottom: 0;
        width: 4px;
        background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
        pointer-events: none;
    }

    /* Fondo explícito para filas (sticky necesita fondo opaco) */
    .table-responsive table tbody tr td:first-child {
        background: #fff;
    }

    .table-responsive table tbody tr:hover td:first-child {
        background: rgba(52, 152, 219, 0.1);
    }

    .table-responsive table thead tr th:first-child {
        background: var(--md-primary);
    }

    /* thead con clase table-light (Bootstrap) */
    .table-responsive table thead.table-light tr th:first-child {
        background: #f8f9fa;
    }

    /* thead con clase thead-dark */
    .table-responsive table thead.thead-dark tr th:first-child {
        background: #343a40;
    }
}

/* --- Columna de acciones fija a la derecha ---
   Aplicar clase .sticky-actions al div.table-responsive para que la
   ultima columna (acciones) quede siempre visible aunque la tabla tenga
   scroll horizontal. Funciona en todos los tamaños de pantalla. */
.table-responsive.sticky-actions {
    position: relative;
}

.table-responsive.sticky-actions table thead th:last-child,
.table-responsive.sticky-actions table tbody td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
}

.table-responsive.sticky-actions table thead th:last-child {
    z-index: 3;
    background: #f8f9fa;
}

/* Sombra sutil a la izquierda de la columna sticky para separarla del scroll */
.table-responsive.sticky-actions table th:last-child::before,
.table-responsive.sticky-actions table td:last-child::before {
    content: '';
    position: absolute;
    top: 0;
    left: -6px;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

/* Preservar hover en columna sticky */
.table-responsive.sticky-actions table.table-hover tbody tr:hover td:last-child {
    background: #f5faff;
}

/* --- Avatar Circle (componente reutilizable) --- */
.avatar-circle {
    width: 42px;
    height: 42px;
    background: var(--md-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ==============================================
   Empty State — Estado vacío reutilizable
   ============================================== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ==============================================
   Filter Card — Tarjeta de filtros
   ============================================== */
.filter-card {
    background: #f8f9fa;
    border: none;
    border-radius: var(--md-radius-md);
}

/* ==============================================
   Ledger / Contabilidad — Estilos de tabla
   ============================================== */
.row-income { background-color: rgba(40, 167, 69, 0.05); }
.row-expense { background-color: rgba(220, 53, 69, 0.05); }
.amount-debe { color: var(--md-danger); font-weight: 600; }
.amount-haber { color: #28a745; font-weight: 600; }
.balance-positive { color: #28a745; }
.balance-negative { color: var(--md-danger); }

.type-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.type-badge.income { background-color: #d4edda; color: #155724; }
.type-badge.expense { background-color: #f8d7da; color: #721c24; }

/* ==============================================
   Control Center — Centro de Control Financiero
   ============================================== */
.health-indicator {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.health-good { background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%); color: #155724; }
.health-warning { background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%); color: #856404; }
.health-danger { background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%); color: #721c24; }

.resident-card {
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.resident-card:hover { border-color: var(--md-primary); background-color: #f8f9fa; }
.resident-card.selected { border-color: var(--md-primary); background-color: #e8f4fd; }

.action-btn {
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.action-btn:hover { transform: translateY(-1px); }

.danger-zone {
    border: 2px solid var(--md-danger);
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fff5f5;
}

.resident-search-box { position: relative; }
.resident-search-box input { padding-left: 2.5rem; }
.resident-search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

.resident-list {
    max-height: 400px;
    overflow-y: auto;
}

.transaction-item {
    border-left: 3px solid #dee2e6;
    padding-left: 1rem;
    margin-bottom: 0.5rem;
}

.transaction-item.payment { border-left-color: #28a745; }
.transaction-item.charge { border-left-color: var(--md-danger); }

/* ==============================================
   Nav Tabs — Estilos limpios para pestañas
   ============================================== */
.nav-tabs-clean .nav-link {
    color: #495057;
    font-weight: 500;
    border: none;
    padding: 0.75rem 1.25rem;
}

.nav-tabs-clean .nav-link.active {
    color: var(--md-primary);
    border-bottom: 3px solid var(--md-primary);
    background: transparent;
}

.nav-tabs-clean .nav-link:hover:not(.active) {
    color: var(--md-primary);
    border-bottom: 3px solid #e2e8f0;
}

.confirmation-modal .modal-header {
    background: var(--md-danger);
    color: white;
}

/* ==============================================
   Quick Action Buttons — Acciones rápidas
   ============================================== */
.quick-action-btn {
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

/* ==============================================
   Care Module — Items de actividades e incidencias
   ============================================== */
.activity-item {
    border-left: 4px solid var(--md-accent);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 6px 6px 0;
}

.activity-item.completed { border-left-color: var(--md-success); background: #eafaf1; }
.activity-item.overdue   { border-left-color: var(--md-danger); background: #fdedec; }

.incident-item {
    border-left: 4px solid var(--md-warning);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #fef9e7;
    border-radius: 0 6px 6px 0;
}

.incident-item.critical { border-left-color: var(--md-danger); background: #fdedec; }

/* ==============================================
   Staff Module — Turnos, items, status dots
   ============================================== */
.shift-block {
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.shift-block .shift-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.shift-block.morning   { background: #fffbf0; border: 1px solid #f0e6c8; }
.shift-block.afternoon { background: #f0f7ff; border: 1px solid #c8ddf0; }
.shift-block.night     { background: #f3f0f8; border: 1px solid #d5cce6; }

.staff-item {
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid var(--md-accent);
}

.staff-item:hover { background: #eef0f2; }

.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active    { background: var(--md-success); }
.status-dot.inactive  { background: var(--md-warning); }
.status-dot.on_leave  { background: var(--md-accent); }
.status-dot.terminated{ background: var(--md-danger); }
.status-dot.suspended { background: #95a5a6; }

.chart-container { position: relative; height: 280px; margin: 0.5rem 0; }

/* ==============================================
   Sortable Header — Indicador de columna ordenable
   ============================================== */
.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header::after {
    content: ' \f0dc';
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.7em;
    opacity: 0.4;
    margin-left: 0.3rem;
}

.sortable-header.sort-asc::after {
    content: ' \f0de';
    opacity: 0.8;
}

.sortable-header.sort-desc::after {
    content: ' \f0dd';
    opacity: 0.8;
}
