/* =========================================================
   VARIABLES
========================================================= */
:root {
    --primary: #034347;
    --primary-hover: #0f766e;
    --accent: #a3b305;
    --accent-hover: #8d9c04;

    --bg: #f7f9f9;
    --card-bg: #ffffff;

    --text: #1F1F1F;
    --text-light: #6b7280;

    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --error: #dc2626;
    --error-hover: #b91c1c;
    --success: #16a34a;
    --success-hover: #15803d;
    --warning: #d97706;
    --warning-hover: #b45309;
    --info: #2563eb;
    --info-hover: #1d4ed8;

    --btn-secondary-bg: #f8fafc;
    --btn-secondary-hover: #eef2f7;
    --sidebar-icon: #64748b;
    --sidebar-icon-active: var(--primary);
    --sidebar-active-bg: rgba(3, 67, 71, 0.1);
    --sidebar-hover-bg: #f3f6f6;
    --modal-backdrop: rgba(15, 23, 42, 0.56);
    --table-head-bg: #eef7f4;
    --table-head-text: #064e3b;
    --field-bg: #ffffff;
    --field-focus: rgba(15, 118, 110, 0.18);
    --muted: #94a3b8;
    --surface-muted: #f8fafc;
    --surface-warning: #fffbeb;
    --border-warning: #fde68a;
    --text-warning: #92400e;
    --type-individual-bg: #dbeafe;
    --type-individual-text: #1d4ed8;
    --type-grupal-bg: #f3e8ff;
    --type-grupal-text: #7c3aed;
    --badge-cimentacion-bg: #ccfbf1;
    --badge-cimentacion-text: #115e59;
    --avatar-1: #4f46e5;
    --avatar-2: #0891b2;
    --avatar-3: #059669;
    --avatar-4: #d97706;
    --avatar-5: #dc2626;
    --avatar-6: #7c3aed;
    --avatar-7: #0284c7;
    --avatar-8: #0f766e;

    /* Proyecto Generaciones: paleta tomada de docs/Generaciones/_DISEÑO.md */
    --gen-as: #084044;
    --gen-verde: #1d6b3e;
    --gen-verde-bg: #e8f5ee;
    --gen-verde-med: #2d8653;
    --gen-morado: #4a3aaa;
    --gen-morado-bg: #eeedfe;
    --gen-teal: #0f6e56;
    --gen-teal-bg: #e1f5ee;
    --gen-teal-med: #2e7d6b;
    --gen-teal-med-bg: #e8f5f2;
    --gen-azul: #185fa5;
    --gen-azul-bg: #e6f1fb;
    --gen-ambar: #854f0b;
    --gen-ambar-bg: #faeeda;
    --gen-oro: #b8860b;
    --gen-oro-bg: #fdf8e8;
    --gen-inicial: #27ae60;
    --gen-inicial-bg: #eafaf1;
    --gen-inter: #1a8a5a;
    --gen-inter-bg: #d5f5e3;
    --gen-adn: #4a3aaa;
    --gen-adn-bg: #eeedfe;
    --gen-semillitas: #ffd700;
    --gen-retonitos: #c8920a;
    --gen-pampanitos: #5dbf6a;
    --gen-renuevos: #60aedd;
    --gen-guerreros: #1a3a6b;
    --gen-escuderos: #7c3aed;
    --gen-conquistadores: #c0392b;
    --gen-artilleros: #1a4d3a;
    --gen-neutral-bg: #f4f4f2;
    --gen-neutral-border: #e0ded8;
    --gen-neutral-text: #5a5a5a;

    --radius: 10px;
}

/* FIX GLOBAL BOX MODEL */
*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

/* =========================================================
   BASE
========================================================= */
html, body {
    font-family: system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    margin: 0;
    overflow-x: hidden;
}
.app-body {
    min-height: 100dvh;
    display: flex;
}

/* =========================================================
   LOGIN LAYOUT (SPLIT SCREEN)
========================================================= */

.login-layout {
    display: flex;
    min-height: 100vh;
}

/* HERO IZQUIERDO */
.login-hero {
    flex: 1;
    background: linear-gradient(135deg, var(--primary), #0ea5e9);
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 40px;
}

.hero-content {
    max-width: 400px;
}

.hero-content h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.hero-content p {
    font-size: 16px;
    opacity: 0.9;
}

/* FORM DERECHO */
.login-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* FORM CARD */
.login-form form {
    width: 100%;
    max-width: 380px;
}

/* TITULO */
.login-form h2 {
    margin-bottom: 20px;
}

/* PASSWORD TOGGLE */
.password-group {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 14px;
}

/* SWITCH CUSTOM (usa tu sistema pero lo adaptamos) */
.switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 15px;
}

.switch-container input {
    display: none;
}

.switch-slider {
    width: 38px;
    height: 20px;
    background: #ccc;
    border-radius: 50px;
    position: relative;
    cursor: pointer;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 2px;
    left: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.switch-container input:checked + .switch-slider {
    background: var(--primary);
}

.switch-container input:checked + .switch-slider::before {
    transform: translateX(18px);
}

/* BOTON LOGIN */
#loginBtn {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
}

#loginBtn:hover {
    background: var(--primary-hover);
}

/* SPINNER */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    margin-left: 8px;
    animation: spin 1s linear infinite;
}

.btn.is-loading {
    cursor: wait;
    opacity: 0.82;
    pointer-events: none;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    display: inline-block;
    flex: 0 0 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

/* FORGOT */
.forgot {
    margin-top: 10px;
    text-align: center;
}

.forgot a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}

/* ERROR */
.error {
    margin-top: 15px;
    padding: 10px;
    border-radius: var(--radius);
    background: #fef2f2;
    color: var(--error);
    font-size: 14px;
    text-align: center;
}


/* =========================================================
   LAYOUT
========================================================= */
.app {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* zona derecha */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* contenido crece */
.main-content {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.content-header {
    margin-bottom: 20px;
}

.content-header h1 {
    margin: 0;
    font-size: 22px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

/* =========================================================
   OVERLAY
========================================================= */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: .2s;
    z-index: 2000;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}


/* =========================================================
   TOPBAR (HEADER) - MEJORADO
========================================================= */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    z-index: 2500;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    text-decoration: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

/* hover tipo SaaS */
.topbar-user:hover {
    background: #f8fafc;
    text-decoration: none;
}

.topbar-user:focus-visible {
    outline: 2px solid rgba(3, 67, 71, 0.35);
    outline-offset: 2px;
}

/* nombre usuario */
.topbar-user span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.topbar-user:active {
    transform: scale(0.97);
}

.topbar-user.is-active {
    background: var(--sidebar-active-bg);
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.topbar-icon-btn {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    height: 40px;
    justify-content: center;
    padding: 0;
    width: 40px;
}

.topbar-icon-btn svg {
    height: 20px;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 20px;
}

.topbar-icon-btn:hover {
    background: var(--sidebar-active-bg);
    border-color: var(--primary);
}

.topbar-icon-btn.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.topbar-icon-btn.is-disabled {
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.65;
}

.notification-bell {
    position: relative;
    text-decoration: none;
}

.notification-bell-count {
    align-items: center;
    background: var(--error);
    border: 2px solid #fff;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 10px;
    font-weight: 800;
    height: 18px;
    justify-content: center;
    line-height: 1;
    min-width: 18px;
    padding: 0 4px;
    position: absolute;
    right: -5px;
    top: -5px;
}

.push-subscribe-btn {
    gap: 8px;
    padding-inline: 12px;
    width: auto;
}

.push-subscribe-btn span {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.push-subscribe-btn[hidden] {
    display: none;
}

/* MENU BUTTON (Hamburger) */
.menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.menu-btn:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.menu-btn:active {
    transform: scale(0.95);
}

.menu-btn-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===============================
   AVATAR
=============================== */

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #0ea5e9);
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 13px;
    font-weight: 600;

    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.account-form {
    border: 0;
    margin: 0;
    max-width: 560px;
    padding: 0;
}

.account-profile-avatar {
    background: linear-gradient(135deg, var(--primary), #0ea5e9);
}

.account-danger {
    border-color: #fecaca;
}

.account-danger p {
    color: var(--text-light);
    margin-top: 0;
    max-width: 680px;
}

/* =========================================================
   CARDS (MEJORADO)
========================================================= */
.card {
    background: var(--card-bg);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: 0.2s;
}

.card:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

/* =========================================================
   FORMULARIOS (PRO)
========================================================= */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    background: #fff;
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 16px;
}

.form-group input,
.form-group select,
.form-group textarea {
    display: block;
    max-width: 100%;
}

label {
    font-size: 13px;
    margin-bottom: 5px;
    display: block;
}

input, select, textarea {
    width: 100%;
    padding: 11px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

input:focus {
    border-color: var(--primary);
}

/* ===============================
   SWITCH
=============================== */

.switch-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch {
    position: relative;
    width: 42px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 50px;
    transition: 0.3s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(18px);
}

.switch-label {
    font-size: 14px;
    color: var(--text);
}

/* =========================================================
   BOTONES
========================================================= */
.btn {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    background: #fff;
    color: var(--text);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
}

.btn-secondary {
    background: #f8fafc;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border: none;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   ALERTS
========================================================= */
.alert {
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.alert-success { background:#ecfdf5; color: var(--success); }
.alert-error { background:#fef2f2; color: var(--error); }
.alert-danger { background:#fef2f2; color: var(--error); }
.alert-info { background:#eff6ff; color:#2563eb; }
.alert-warning { background:#fffbeb; color: var(--warning); }

/* =========================================================
   EMPTY STATE
========================================================= */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* =========================================================
   LOADER
========================================================= */
.loader {
    border: 4px solid #eee;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   MODALES (PRO)
========================================================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);

    display: flex;
    justify-content: center;
    align-items: center;

    opacity: 0;
    visibility: hidden;
    transition: .2s;
    z-index: 3000;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    background: #fff;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.modal-content.modal-large {
    max-width: 860px;
}

/* HEADER */
.modal-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.modal-close {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--btn-secondary-bg);
    color: var(--text-light);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: background var(--shell-transition), color var(--shell-transition), border-color var(--shell-transition);
}

.modal-close:hover {
    border-color: var(--border-strong);
    background: var(--btn-secondary-hover);
    color: var(--text);
}

.modal-overlay {
    display: none;
}

/* BODY SCROLL */
.modal-body {
    padding: 15px;
    overflow-y: auto;
}

/* FOOTER */
.modal-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-content > form.form-container,
.modal-content > form .form-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.modal-content > form.form-container .form-actions,
.modal-content > form .form-actions {
    margin: 16px -16px -16px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* =========================================================
   TOAST
========================================================= */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 4000;
}

.toast {
    background: #fff;
    padding: 10px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 768px) {

    /* Sidebar como drawer overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100%;
        transform: translateX(-110%);
        overflow-y: auto;
        box-shadow: 2px 0 20px rgba(0,0,0,0.15);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 3000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* No hay collapsed en mobile */
    .sidebar.collapsed {
        width: 280px;
        padding: 12px 8px;
    }

    .sidebar.collapsed .sidebar-brand-text {
        display: block;
    }

    .sidebar.collapsed .sidebar-label {
        display: block;
    }

    .sidebar.collapsed .sidebar-chevron {
        display: block;
    }

    .overlay {
        z-index: 2000;
    }

    .main-content {
        padding: 15px;
    }

    /* Mostrar menu-btn en móvil */
    .menu-btn {
        display: flex;
    }

    /* Ocultar nombre de usuario en móvil */
    .topbar-user-name {
        display: none;
    }

    .topbar-user {
        padding: 4px;
    }

    /* Responsive grids */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Login responsive */
    .login-layout {
        flex-direction: column;
    }

    .login-hero {
        display: none;
    }

    .login-form {
        flex: none;
        min-height: 100vh;
    }
}


/* =========================================================
   SIDEBAR (ENTERPRISE)
========================================================= */

/* CONTAINER BASE */
.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3000;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ═══════════════════════════════════════════════════════
   COLLAPSED STATE (DESKTOP)
═══════════════════════════════════════════════════════ */

.sidebar.collapsed {
    width: 70px;
    padding: 12px 4px;
}

.sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .sidebar-chevron {
    display: none;
}

/* Mostrar tooltip en collapsed (usa title o data-tooltip) */
.sidebar.collapsed .sidebar-link {
    position: relative;
}

/* ═══════════════════════════════════════════════════════
   HEADER / BRAND
═══════════════════════════════════════════════════════ */

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    transition: opacity 0.2s ease;
}

.sidebar-brand:hover {
    opacity: 0.8;
}

.sidebar-brand-mark {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand-mark img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.sidebar-brand-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   NAV CONTAINER
═══════════════════════════════════════════════════════ */

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR ITEMS (LINKS)
═══════════════════════════════════════════════════════ */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.sidebar-link:hover {
    background: #f0f4f8;
    color: var(--primary);
}

.sidebar-link:active {
    transform: scale(0.97);
}

/* ACTIVE STATE (Mejor contraste) */
.sidebar-link.active {
    background: rgba(3, 67, 71, 0.08);
    color: var(--primary);
    font-weight: 600;
}

/* Indicator left bar (subtle) */
.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

/* ═══════════════════════════════════════════════════════
   ICONS (SVG)
═══════════════════════════════════════════════════════ */

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════
   LABELS (TEXT)
═══════════════════════════════════════════════════════ */

.sidebar-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════
   CHEVRON (TOGGLE INDICATOR)
═══════════════════════════════════════════════════════ */

.sidebar-chevron {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-chevron svg {
    width: 14px;
    height: 14px;
}

/* Rotate cuando el grupo está abierto */
.sidebar-group-toggle.open .sidebar-chevron {
    transform: rotate(180deg);
}

/* ═══════════════════════════════════════════════════════
   SECTIONS (GRUPOS/CATEGORÍAS)
═══════════════════════════════════════════════════════ */

.sidebar-section {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

/* Separador visual entre secciones */
.sidebar-section + .sidebar-section {
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════
   SECTION TOGGLE (EXPANDIBLE)
═══════════════════════════════════════════════════════ */

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
    position: relative;
}

.sidebar-group-toggle:hover {
    background: #f0f4f8;
    color: var(--primary);
}

.sidebar-group-toggle:active {
    transform: scale(0.97);
}

/* Estado abierto */
.sidebar-group-toggle.open {
    background: rgba(3, 67, 71, 0.06);
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════════
   SUBMENU (ITEMS ANIDADOS)
═══════════════════════════════════════════════════════ */

.sidebar-submenu {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 4px 14px;
    margin: 4px 0;
    border-left: 2px solid #e5e7eb;
    animation: slideDown 0.15s ease-out;
}

.sidebar-submenu.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Items dentro del submenu */
.sidebar-submenu .sidebar-link {
    gap: 10px;
    padding: 8px 8px;
    font-size: 12px;
    font-weight: 400;
    color: #6b7280;
}

.sidebar-submenu .sidebar-link:hover {
    background: #f5f7fb;
    color: var(--primary);
}

.sidebar-submenu .sidebar-link.active {
    background: rgba(3, 67, 71, 0.1);
    color: var(--primary);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   BADGES (CONTADORES / INDICADORES)
═══════════════════════════════════════════════════════ */

.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Badge primario (rojo - urgente) */
.sidebar-badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

/* Badge warning (amarillo) */
.sidebar-badge-warning {
    background: #fef3c7;
    color: #d97706;
}

/* Badge success (verde) */
.sidebar-badge-success {
    background: #dcfce7;
    color: #16a34a;
}

/* Badge neutral */
.sidebar-badge-gray {
    background: #f3f4f6;
    color: #6b7280;
}

/* ═══════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════ */

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.sidebar-footer .sidebar-link {
    color: #6b7280;
    font-size: 13px;
}

.sidebar-footer .sidebar-link:hover {
    background: #fef2f2;
    color: var(--error);
}

/* =========================================================
   TABLE PRO (SaaS STYLE)
========================================================= */

.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
}

/* TABLA BASE */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
}

/* HEADER */
.table thead {
    background: #f9fafb;
}

.table th {
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    padding: 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* FILAS */
.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

/* HOVER */
.table tbody tr {
    transition: all 0.15s ease;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* CLICKABLE ROW */
.table tbody tr.clickable {
    cursor: pointer;
}

.table tbody tr.clickable:active {
    transform: scale(0.998);
}

.table tbody tr.fila-intento:hover {
    background: #eef6f7;
}

/* EMPTY */
.table-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

/* =========================================================
   BADGES (ESTADO / SEMAFORO)
========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

/* COLORES */
.badge-gray {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-green {
    background: #ecfdf5;
    color: var(--success);
}

.badge-yellow {
    background: #fffbeb;
    color: var(--warning);
}

.badge-red {
    background: #fef2f2;
    color: var(--error);
}

.badge-blue {
    background: #eff6ff;
    color: var(--info);
}

.badge-purple {
    background: #f3e8ff;
    color: #7c3aed;
}

/* DOT */
.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* =========================================================
   USUARIOS
========================================================= */

.users-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.users-new-button {
    flex: 0 0 auto;
}

.users-create-card,
.users-filter-card {
    margin-bottom: 18px;
}

.users-create-card[hidden] {
    display: none;
}

.users-section-heading,
.users-list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.users-section-heading h2,
.users-list-header h2 {
    margin: 0;
    font-size: 22px;
}

.users-section-heading p,
.users-list-header p {
    margin: 4px 0 0;
    color: var(--text-light);
    font-size: 14px;
}

.users-create-form,
.users-filter-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 250px) auto auto;
    gap: 12px;
    align-items: end;
}

.users-create-form .form-group,
.users-filter-form .form-group {
    margin-bottom: 0;
}

.users-person-field,
.users-search-field {
    min-width: 0;
}

.users-active-field {
    margin-bottom: 6px;
    white-space: nowrap;
}

.users-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.users-mobile-list {
    display: none;
}

.user-mobile-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    background: #fff;
}

.user-mobile-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.user-mobile-main h3 {
    margin: 0;
    font-size: 16px;
}

.user-mobile-main p {
    margin: 4px 0 0;
    color: var(--text-light);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.user-mobile-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    color: var(--text-light);
    font-size: 13px;
}

.user-mobile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.user-mobile-actions .btn {
    text-align: center;
}

/* =========================================================
   PERSON CELL (AVATAR + TEXTO)
========================================================= */

.cell-person {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-person .avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

/* =========================================================
   DETALLE PAGE PRO
========================================================= */

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.detail-header h1 {
    margin: 0;
    font-size: 20px;
}

/* GRID INFO */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.detail-grid .full {
    grid-column: 1 / -1;
}

/* ACTION BAR */
.actions-bar {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

/* CARD HEADER */
.card-header {
    padding-bottom: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

/* FILA INTENTO CLICK */
.fila-intento {
    cursor: pointer;
}

/* =========================================================
   DASHBOARD SHELL - META BUSINESS STYLE
========================================================= */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;
    --shell-transition: 200ms ease;
}

html,
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-body {
    display: block;
    min-height: 100dvh;
    background: #f6f7f9;
}

.app-shell {
    min-height: 100dvh;
    width: 100%;
}

.app-main {
    min-height: 100dvh;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--shell-transition);
}

.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
}

.main-content {
    max-width: 1280px;
    padding: calc(var(--topbar-height) + 24px) 24px 32px;
}

.overlay {
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(1px);
    z-index: 1050;
}

/* ===============================
   TOPBAR
=============================== */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 1000;
    min-height: var(--topbar-height);
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e6e8ec;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    backdrop-filter: saturate(160%) blur(10px);
    transition: left var(--shell-transition);
}

.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed-width);
}

.topbar-left {
    min-width: 0;
    gap: 14px;
}

.topbar-title {
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    letter-spacing: 0;
}

.topbar-title span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-btn {
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    cursor: pointer;
    transition: background var(--shell-transition), border-color var(--shell-transition), color var(--shell-transition);
}

.menu-btn:hover {
    background: #f8fafc;
    border-color: #d1d5db;
    color: var(--primary);
}

.menu-btn:focus-visible,
.sidebar-link:focus-visible {
    outline: 2px solid rgba(3, 67, 71, 0.35);
    outline-offset: 2px;
}

.topbar-user {
    min-width: 0;
    height: 40px;
    gap: 10px;
    padding: 4px 6px 4px 12px;
    border: 1px solid transparent;
    border-radius: 999px;
}

.topbar-user:hover {
    background: #f8fafc;
    border-color: #e5e7eb;
}

.topbar-user-name {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===============================
   SIDEBAR
=============================== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1100;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #ffffff;
    border-right: 1px solid #e6e8ec;
    box-shadow: none;
    overflow: hidden;
    transition: width var(--shell-transition), transform var(--shell-transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    overflow: visible;
}

.sidebar-header {
    flex: 0 0 auto;
    height: 48px;
    padding: 0 4px 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eef0f3;
}

.sidebar-brand {
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #111827;
    text-decoration: none;
    border-radius: 8px;
}

.sidebar-brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f3f6f6;
}

.sidebar-brand-mark img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.sidebar-brand-text {
    min-width: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}

.sidebar-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    min-height: 0;
    padding-right: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #b9bec5 transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #b9bec5;
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #8f969e;
}

.sidebar-section {
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.sidebar-link {
    position: relative;
    min-height: 42px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--shell-transition), color var(--shell-transition);
}

.sidebar-link:hover {
    background: #f3f6f6;
    color: #0f172a;
}

.sidebar-link.active {
    background: rgba(3, 67, 71, 0.1);
    color: var(--primary);
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 999px;
    background: var(--primary);
}

.sidebar-icon {
    width: 21px;
    height: 21px;
    flex: 0 0 21px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-chevron {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: #94a3b8;
    transition: transform var(--shell-transition);
}

.sidebar-chevron .sidebar-icon {
    width: 16px;
    height: 16px;
}

.sidebar-group-toggle.open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    display: none;
    gap: 3px;
    padding: 2px 0 2px 16px;
    margin-left: 10px;
    border-left: 1px solid #e7eaee;
}

.sidebar-submenu.show {
    display: grid;
}

.sidebar-submenu .sidebar-link {
    min-height: 38px;
    padding-left: 10px;
    font-size: 13px;
    font-weight: 600;
}

.sidebar-footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 12px;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-chevron {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
}

.sidebar.collapsed .sidebar-submenu {
    display: none;
}

.sidebar.collapsed .sidebar-link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    z-index: 1300;
    max-width: 220px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(-4px);
    transition: opacity var(--shell-transition), transform var(--shell-transition);
}

.sidebar.collapsed .sidebar-link[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.sidebar.collapsed .sidebar-link[data-tooltip]:hover {
    overflow: visible;
}

@media (max-width: 768px) {
    .app-main,
    .sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .topbar,
    .sidebar-collapsed .topbar {
        left: 0;
        min-height: 58px;
        padding-right: max(14px, env(safe-area-inset-right));
        padding-left: max(14px, env(safe-area-inset-left));
    }

    .menu-btn {
        display: inline-flex;
    }

    .main-content {
        padding: calc(58px + 16px) max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left));
    }

    .sidebar,
    .sidebar.collapsed {
        width: min(86vw, var(--sidebar-width));
        padding-top: max(12px, env(safe-area-inset-top));
        padding-right: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        overflow: hidden;
        touch-action: pan-y;
        transform: translateX(-105%);
        box-shadow: 18px 0 40px rgba(15, 23, 42, 0.18);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed .sidebar-brand {
        justify-content: flex-start;
    }

    .sidebar.collapsed .sidebar-brand-text,
    .sidebar.collapsed .sidebar-label,
    .sidebar.collapsed .sidebar-chevron {
        width: auto;
        opacity: 1;
        visibility: visible;
    }

    .sidebar.collapsed .sidebar-link {
        justify-content: flex-start;
        gap: 12px;
        padding: 9px 10px;
    }

    .topbar-user-name {
        display: none;
    }

    .users-header {
        display: block;
    }

    .users-header h1 {
        font-size: 24px;
        line-height: 1.2;
    }

    .users-header p {
        font-size: 15px;
    }

    .users-new-button {
        width: 100%;
        margin-top: 14px;
        text-align: center;
    }

    .users-section-heading {
        display: grid;
        gap: 12px;
    }

    .users-close-button {
        width: 100%;
        text-align: center;
    }

    .users-create-form,
    .users-filter-form {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .users-create-form .btn,
    .users-filter-form .btn {
        width: 100%;
        text-align: center;
    }

    .users-active-field {
        justify-content: space-between;
        padding: 10px 0;
        margin-bottom: 0;
    }

    .users-list-header {
        margin-bottom: 12px;
    }

    .users-table-view {
        display: none;
    }

    .users-mobile-list {
        display: grid;
        gap: 12px;
    }
}

/* =========================================================
   UI CONSOLIDATION OVERRIDES
========================================================= */
.btn,
button.btn,
a.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    vertical-align: middle;
    transition: background var(--shell-transition), border-color var(--shell-transition), color var(--shell-transition), box-shadow var(--shell-transition), transform var(--shell-transition);
}

.btn:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: #fff;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid rgba(3, 67, 71, 0.3);
    outline-offset: 2px;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: #fff;
}

.btn.btn-secondary,
button.btn.btn-secondary,
a.btn.btn-secondary {
    border-color: var(--border);
    background: var(--btn-secondary-bg);
    color: #334155;
}

.btn.btn-secondary:hover,
button.btn.btn-secondary:hover,
a.btn.btn-secondary:hover {
    border-color: var(--border-strong);
    background: var(--btn-secondary-hover);
    color: #0f172a;
}

.btn.btn-danger,
button.btn.btn-danger,
a.btn.btn-danger {
    border-color: var(--error);
    background: var(--error);
    color: #fff;
}

.btn.btn-danger:hover,
button.btn.btn-danger:hover,
a.btn.btn-danger:hover {
    border-color: var(--error-hover);
    background: var(--error-hover);
    color: #fff;
}

.btn.btn-warning,
button.btn.btn-warning,
a.btn.btn-warning {
    border-color: var(--warning);
    background: var(--warning);
    color: #fff;
}

.btn.btn-warning:hover,
button.btn.btn-warning:hover,
a.btn.btn-warning:hover {
    border-color: var(--warning-hover);
    background: var(--warning-hover);
    color: #fff;
}

.btn.btn-success,
button.btn.btn-success,
a.btn.btn-success {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.btn.btn-success:hover,
button.btn.btn-success:hover,
a.btn.btn-success:hover {
    border-color: var(--success-hover);
    background: var(--success-hover);
    color: #fff;
}

.btn.btn-info,
button.btn.btn-info,
a.btn.btn-info {
    border-color: var(--info);
    background: var(--info);
    color: #fff;
}

.btn.btn-info:hover,
button.btn.btn-info:hover,
a.btn.btn-info:hover {
    border-color: var(--info-hover);
    background: var(--info-hover);
    color: #fff;
}

.btn.btn-accent,
button.btn.btn-accent,
a.btn.btn-accent {
    border-color: var(--accent);
    background: var(--accent);
    color: #1f2937;
}

.btn.btn-accent:hover,
button.btn.btn-accent:hover,
a.btn.btn-accent:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: #111827;
}

.btn-sm {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 13px;
}

.table-container,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.table th,
.table td {
    vertical-align: middle;
}

.table thead,
.table th {
    background: var(--table-head-bg);
}

.table th {
    color: var(--table-head-text);
    letter-spacing: 0;
}

.table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.action-buttons,
.table-actions,
.users-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.action-buttons .btn,
.table-actions .btn,
.users-actions .btn {
    flex: 0 0 auto;
}

.action-buttons form,
.table-actions form,
.users-actions form {
    display: inline-flex;
    margin: 0;
}

.form-actions,
.actions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.actions-bar {
    justify-content: flex-start;
}

.modal {
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    background: var(--modal-backdrop);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: min(100%, 600px);
    max-width: 100%;
    max-height: calc(100dvh - 32px);
    margin: auto 0;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.modal-content.modal-large {
    width: min(100%, 860px);
}

.modal-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-footer {
    align-items: center;
    flex-wrap: wrap;
}

.modal-footer .btn {
    min-width: 110px;
}

.ui-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke-width: 1.8;
}

.btn-icon {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 8px;
}

.btn-icon.btn-sm {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
}

.btn-icon.btn-secondary {
    border-color: var(--border);
    background: var(--btn-secondary-bg);
    color: var(--primary);
}

.btn-icon.btn-secondary:hover {
    color: #fff;
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn-icon.btn-danger {
    color: var(--error);
    border-color: #fecaca;
    background: #fff;
}

.btn-icon.btn-danger:hover {
    color: #fff;
    border-color: var(--error-hover);
    background: var(--error-hover);
}

.btn-primary {
    box-shadow: 0 1px 2px rgba(3, 67, 71, 0.12);
}

.btn-primary:hover {
    box-shadow: 0 6px 14px rgba(15, 118, 110, 0.18);
}

input,
select,
textarea {
    background: var(--field-bg);
    transition: border-color var(--shell-transition), box-shadow var(--shell-transition), background var(--shell-transition);
}

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

.form-grid,
.modal-body.detail-grid,
.modal-body .detail-grid,
.modal-body:has(> .form-group) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.modal-content.modal-large .modal-body.detail-grid,
.modal-content.modal-large .modal-body .detail-grid,
.modal-content.modal-large .modal-body:has(> .form-group) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .full,
.modal-body.detail-grid .full,
.modal-body .detail-grid .full,
.modal-body:has(> .form-group) > .full,
.modal-body:has(> .form-group) > :not(.form-group),
.modal-body:has(> .form-group) > .form-group:has(textarea) {
    grid-column: 1 / -1;
}

.form-grid .form-group,
.modal-body.detail-grid .form-group,
.modal-body .detail-grid .form-group,
.modal-body:has(> .form-group) > .form-group {
    min-width: 0;
    margin-bottom: 0;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-compact {
    overflow: hidden;
    padding: 0;
}

.card-muted {
    padding: 48px;
    text-align: center;
    color: var(--muted);
}

.is-inactive {
    opacity: 0.56;
}

.inline-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-form {
    margin: 0;
}

.muted {
    color: var(--muted);
}

.context-note {
    margin: 0 0 12px;
    color: var(--text-light);
    font-size: 13px;
}

.alert-spaced {
    margin-bottom: 16px;
}

.section-spaced {
    margin-top: 20px;
}

.block-spaced {
    margin-bottom: 18px;
}

.mb-16 {
    margin-bottom: 16px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.btn-full {
    width: 100%;
}

.text-light {
    color: var(--text-light);
}

.text-muted {
    color: var(--muted);
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.link-button:hover {
    color: var(--primary);
}

.info-box {
    margin-bottom: 15px;
}

.warning-card {
    margin-top: 20px;
    background: #fff3cd;
    border-color: #ffc107;
}

.card-inner {
    padding: 15px;
}

.flush-top {
    margin-top: 0;
}

.cell-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-card {
    overflow: hidden;
    padding: 0;
}

.tree-header,
.tree-row,
.tree-child-row,
.tree-warning-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.tree-header {
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface-muted);
    border-bottom: 2px solid var(--border);
}

.tree-title {
    font-size: 16px;
    font-weight: 700;
}

.tree-order {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.tree-next {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
    font-size: 13px;
}

.tree-next svg {
    width: 12px;
    height: 12px;
}

.tree-section {
    border-bottom: 1px solid var(--border);
}

.tree-row {
    gap: 10px;
    padding: 11px 20px 11px 44px;
    background: #fff;
}

.tree-child-list {
    display: none;
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
}

.tree-child-list.open,
.tree-child-list.is-open {
    display: block;
}

.tree-child-row {
    gap: 12px;
    padding: 8px 20px 8px 80px;
    border-bottom: 1px solid var(--border);
}

.tree-child-order {
    min-width: 24px;
    flex: 0 0 24px;
    color: #cbd5e1;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
}

.tree-name {
    flex: 1;
    min-width: 140px;
    font-size: 14px;
    font-weight: 600;
}

.tree-meta {
    color: var(--muted);
    font-size: 13px;
}

.tree-empty {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    font-style: italic;
}

.tree-type {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

.tree-type-individual {
    background: var(--type-individual-bg);
    color: var(--type-individual-text);
}

.tree-type-grupal {
    background: var(--type-grupal-bg);
    color: var(--type-grupal-text);
}

.tree-toggle {
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.tree-warning-card {
    overflow: hidden;
    padding: 0;
    border-left: 3px solid var(--warning);
}

.tree-warning-header {
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface-warning);
    border-bottom: 1px solid var(--border-warning);
    color: var(--text-warning);
}

.tree-warning-title {
    color: var(--text-warning);
    font-size: 15px;
    font-weight: 700;
}

.tree-warning-row {
    border-bottom-color: var(--border-warning);
}

.badge-compact {
    font-size: 12px;
}

.avatar-color-1 { background: var(--avatar-1); }
.avatar-color-2 { background: var(--avatar-2); }
.avatar-color-3 { background: var(--avatar-3); }
.avatar-color-4 { background: var(--avatar-4); }
.avatar-color-5 { background: var(--avatar-5); }
.avatar-color-6 { background: var(--avatar-6); }
.avatar-color-7 { background: var(--avatar-7); }
.avatar-color-8 { background: var(--avatar-8); }

.badge-status-nueva {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-status-seguimiento {
    background: #fef3c7;
    color: #92400e;
}

.badge-status-contactada {
    background: #dbeafe;
    color: #1e40af;
}

.badge-status-integrada {
    background: #d1fae5;
    color: #065f46;
}

.badge-status-cimentacion {
    background: var(--badge-cimentacion-bg);
    color: var(--badge-cimentacion-text);
}

.badge-status-desarrollo {
    background: #ccfbf1;
    color: #115e59;
}

.badge-status-consolidado {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-status-multiplicando {
    background: #fce7f3;
    color: #9d174d;
}

.badge-status-discipulado {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-status-inactiva {
    background: #fee2e2;
    color: #991b1b;
}

.profile-wrap {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.profile-sidebar {
    width: 240px;
    flex: 0 0 240px;
}

.profile-main {
    flex: 1;
    min-width: 0;
}

.profile-card {
    margin-bottom: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    text-align: center;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 27px;
    font-weight: 700;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    margin-bottom: 6px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
}

.profile-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.profile-nav-btn {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: background var(--shell-transition), color var(--shell-transition);
}

.profile-nav-btn:hover {
    background: var(--sidebar-hover-bg);
}

.profile-nav-btn.active {
    background: var(--sidebar-active-bg);
    color: var(--primary);
    font-weight: 700;
}

.profile-section {
    display: none;
}

.profile-section.active {
    display: block;
}

.section-card {
    margin-bottom: 14px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.modal-info-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.modal-info-panel .card-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
}

.modal-context {
    margin: 0;
    color: var(--text-light);
    font-size: 14px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 700;
}

.field-row {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.field-row:last-child {
    border-bottom: 0;
}

.field-lbl {
    width: 140px;
    flex: 0 0 140px;
    color: var(--text-light);
}

.field-val {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.spin-wrap,
.sec-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--muted);
    font-size: 14px;
}

.proc-item {
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.proc-hd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    background: var(--surface-muted);
    cursor: pointer;
}

.proc-title {
    font-size: 14px;
    font-weight: 700;
}

.proc-meta,
.intento-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.proc-prog {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    color: var(--text-light);
    font-size: 13px;
}

.pbar-wrap {
    width: 72px;
    height: 5px;
    border-radius: 999px;
    background: var(--border);
}

.pbar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.pbar {
    width: 72px;
    height: 6px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: var(--border);
}

.pbar::-webkit-progress-bar {
    background: var(--border);
}

.pbar::-webkit-progress-value,
.pbar::-moz-progress-bar {
    border-radius: 999px;
    background: var(--primary);
}

.status-text-active {
    margin-left: 8px;
    color: var(--success);
    font-size: 12px;
}

.status-text-inactive,
.ses-muted {
    color: var(--muted);
}

.status-text-inactive {
    margin-left: 8px;
    font-size: 12px;
}

.proc-body {
    display: none;
    padding: 12px 16px;
}

.proc-body.open {
    display: block;
}

.proc-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.ses-info {
    flex: 1;
    min-width: 0;
}

.ses-schedule-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}

.ses-schedule-summary span {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
}

.ses-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.ses-action-field {
    display: grid;
    gap: 4px;
}

.ses-action-field > span {
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.ses-action-field input {
    min-height: 38px;
    margin: 0;
}

.ses-action-buttons {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 19px;
}

.ses-action-buttons .btn {
    flex: 1 1 auto;
}

.ses-actions input[type="date"] {
    width: auto;
    min-width: 150px;
}

.select-scroll {
    height: auto;
    overflow-y: auto;
}

.page-header-row,
.content-header .users-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.page-header-row > div,
.content-header .users-header > div {
    min-width: 0;
}

.individual-section {
    margin-bottom: 28px;
}

.individual-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.individual-section-head h2 {
    margin: 0;
    font-size: 19px;
}

.individual-section-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.individual-count {
    display: inline-grid;
    min-width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-light);
    font-weight: 700;
}

.individual-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.individual-summary-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
}

.individual-summary-card.waiting {
    border-top: 3px solid #d97706;
}

.individual-summary-card.completed {
    border-top: 3px solid var(--success);
}

.individual-card-top,
.individual-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.individual-summary-card h3 {
    margin: 14px 0 4px;
    font-size: 16px;
}

.individual-process-name,
.individual-responsible {
    margin: 0 0 8px;
    color: var(--text-light);
    font-size: 13px;
}

.individual-responsible {
    min-height: 38px;
}

.individual-card-date,
.form-help {
    color: var(--muted);
    font-size: 12px;
}

.individual-summary-card .badge-warning {
    background: #fff7ed;
    color: #9a3412;
}

.individual-summary-card .badge-success {
    background: #ecfdf5;
    color: #047857;
}

.empty-state.compact {
    min-height: 96px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.dashboard-card p {
    margin: 0;
    color: var(--text-light);
}

/* =========================================================
   DASHBOARD CONTEXTUAL
========================================================= */
.dashboard-page {
    display: grid;
    gap: 18px;
}

.dashboard-hero {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.dashboard-hero h1 {
    font-size: 26px;
    line-height: 1.15;
    margin: 0;
}

.dashboard-hero p {
    color: var(--text-light);
    margin: 6px 0 0;
}

.dashboard-actions {
    display: flex;
    flex: 0 1 520px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.dashboard-action-btn {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    gap: 8px;
    min-height: 42px;
    padding: 10px 12px;
    text-decoration: none;
}

.dashboard-action-btn:hover {
    background: var(--sidebar-active-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.dashboard-action-btn svg {
    height: 18px;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 18px;
}

.dashboard-kpi-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.dashboard-kpi {
    --dashboard-tone: var(--primary);
    --dashboard-tone-bg: rgba(3, 67, 71, 0.08);
    border-left: 4px solid var(--dashboard-tone);
    color: inherit;
    display: grid;
    gap: 6px;
    min-height: 124px;
    overflow: hidden;
    position: relative;
    text-decoration: none;
}

.dashboard-kpi::after {
    background: var(--dashboard-tone-bg);
    border-radius: 999px;
    content: "";
    height: 68px;
    position: absolute;
    right: -18px;
    top: -22px;
    width: 68px;
}

.dashboard-kpi span,
.dashboard-kpi small,
.dashboard-list-item small,
.dashboard-card-head p {
    color: var(--text-light);
}

.dashboard-kpi span {
    font-size: 13px;
    font-weight: 700;
}

.dashboard-kpi strong {
    color: var(--dashboard-tone);
    font-size: 30px;
    line-height: 1;
}

.dashboard-kpi small {
    font-size: 12px;
}

.dashboard-widget-grid {
    align-items: start;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-card {
    --dashboard-tone: var(--primary);
    border-top: 4px solid var(--dashboard-tone);
    display: grid;
    gap: 14px;
}

.dashboard-tone-people {
    --dashboard-tone: #0f766e;
    --dashboard-tone-bg: rgba(15, 118, 110, 0.1);
}

.dashboard-tone-growth {
    --dashboard-tone: #16a34a;
    --dashboard-tone-bg: rgba(22, 163, 74, 0.1);
}

.dashboard-tone-followup {
    --dashboard-tone: #2563eb;
    --dashboard-tone-bg: rgba(37, 99, 235, 0.1);
}

.dashboard-tone-warning {
    --dashboard-tone: #d97706;
    --dashboard-tone-bg: rgba(217, 119, 6, 0.12);
}

.dashboard-tone-calendar {
    --dashboard-tone: #7c3aed;
    --dashboard-tone-bg: rgba(124, 58, 237, 0.1);
}

.dashboard-tone-process {
    --dashboard-tone: #0891b2;
    --dashboard-tone-bg: rgba(8, 145, 178, 0.1);
}

.dashboard-tone-groups {
    --dashboard-tone: #65a30d;
    --dashboard-tone-bg: rgba(101, 163, 13, 0.12);
}

.dashboard-tone-visitors {
    --dashboard-tone: #db2777;
    --dashboard-tone-bg: rgba(219, 39, 119, 0.1);
}

.dashboard-tone-notifications {
    --dashboard-tone: #dc2626;
    --dashboard-tone-bg: rgba(220, 38, 38, 0.1);
}

.dashboard-tone-today {
    --dashboard-tone: #034347;
    --dashboard-tone-bg: rgba(3, 67, 71, 0.08);
}

.dashboard-card-head {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.dashboard-card-head h2 {
    font-size: 18px;
    line-height: 1.2;
    margin: 0;
}

.dashboard-card-head p {
    font-size: 13px;
    margin: 4px 0 0;
}

.dashboard-list {
    display: grid;
    gap: 8px;
}

.dashboard-list-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    color: inherit;
    display: grid;
    gap: 5px;
    padding: 12px;
    text-decoration: none;
}

.dashboard-list-item:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
}

.dashboard-list-item strong {
    font-size: 14px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.dashboard-list-item small {
    font-size: 12px;
    line-height: 1.35;
}

.dashboard-badge {
    align-self: start;
    background: var(--dashboard-tone-bg, var(--surface-muted));
    border-radius: 999px;
    color: var(--dashboard-tone, var(--primary));
    font-size: 11px;
    font-weight: 800;
    justify-self: start;
    padding: 4px 8px;
}

.dashboard-empty {
    align-items: center;
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    color: var(--text-light);
    display: flex;
    justify-content: center;
    min-height: 86px;
    padding: 18px;
    text-align: center;
}

.ses-row,
.intento-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.ses-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 0;
}

.ses-row:last-child,
.intento-row:last-child {
    border-bottom: 0;
}

.ses-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    margin-top: 4px;
    border-radius: 50%;
}

.dot-c { background: var(--success); }
.dot-p { background: var(--border-strong); }
.dot-s { background: var(--warning); }

.hist-proceso {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.hist-proceso:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.hist-sesiones {
    margin-top: 6px;
    padding-left: 12px;
}

.modal-narrow {
    width: min(100%, 540px);
}

#modal-nueva-asignacion .modal-content {
    width: min(100%, 680px);
}

#modal-nueva-asignacion .modal-content > form.form-container {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#modal-iniciar-proceso .modal-content > form.form-container {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#modal-nueva-asignacion #na-buscar,
#modal-nueva-asignacion #na-persona-id,
#modal-nueva-asignacion .na-persona-select-wrap {
    display: none;
}

#modal-nueva-asignacion .search-results {
    max-height: 220px;
    overflow-y: auto;
}

#modal-nueva-asignacion .select-scroll {
    max-height: 160px;
}

#modal-nueva-asignacion .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#modal-nueva-asignacion .form-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
}

#modal-iniciar-proceso .form-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
}

.small-note {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.members-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.members-search {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.members-search input,
.members-search select {
    min-width: 200px;
    width: auto;
}

.members-grid {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    transition: border-color var(--shell-transition), box-shadow var(--shell-transition);
}

.member-row:hover {
    border-color: var(--border-strong);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.avatar-sm {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 700;
}

.member-sub {
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-light);
    font-size: 13px;
}

.badge-sm {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: inherit;
    font-size: 13px;
    text-decoration: none;
}

.pagination a:hover {
    background: var(--btn-secondary-hover);
}

.pagination .pg-current {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.total-chip {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.public-page {
    min-height: 100dvh;
    margin: 0;
    background: var(--bg);
    font-family: system-ui, -apple-system, Roboto, sans-serif;
}

.public-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
    text-align: center;
}

.public-container {
    max-width: 600px;
    margin: auto;
    padding: 20px 15px;
}

.public-card {
    width: 100%;
    padding: 25px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    text-align: center;
}

.public-card input,
.public-card select {
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 16px;
}

.public-card button {
    width: 100%;
    margin-top: 10px;
}

.seguimiento-public-page .public-container {
    width: min(100%, 640px);
}

.seguimiento-public-page .public-card {
    text-align: left;
}

.seguimiento-public-page .public-card h1,
.seguimiento-public-page .public-card h3,
.seguimiento-public-page .public-card p {
    text-align: center;
}

.seguimiento-public-page .public-card label {
    display: block;
    font-weight: 700;
    margin-top: 16px;
}

.seguimiento-public-page .public-card input,
.seguimiento-public-page .public-card select {
    min-height: 48px;
    width: 100%;
}

.sidebar-link,
.sidebar-group-toggle {
    color: #334155;
}

.sidebar-icon {
    color: var(--sidebar-icon);
    stroke: currentColor;
}

.sidebar-link:hover,
.sidebar-group-toggle:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar-link:hover .sidebar-icon,
.sidebar-group-toggle:hover .sidebar-icon {
    color: var(--primary);
}

.sidebar-link.active,
.sidebar-group-toggle.open {
    background: var(--sidebar-active-bg);
    color: var(--primary);
}

.sidebar-link.active .sidebar-icon,
.sidebar-group-toggle.open > .sidebar-icon {
    color: var(--sidebar-icon-active);
}

.sidebar-chevron .sidebar-icon {
    color: currentColor;
}

@media (max-width: 768px) {
    .btn,
    button.btn,
    a.btn {
        max-width: 100%;
        white-space: normal;
    }

    .actions-bar,
    .form-actions,
    .modal-footer {
        justify-content: stretch;
    }

    .actions-bar .btn,
    .form-actions .btn,
    .modal-footer .btn {
        flex: 1 1 140px;
    }

    .modal {
        padding: 10px;
    }

    .modal-content,
    .modal-content.modal-large {
        width: 100%;
        max-height: calc(100dvh - 20px);
    }

    #modal-nueva-asignacion .modal-content {
        width: 100%;
    }

    #modal-nueva-asignacion .detail-grid {
        grid-template-columns: 1fr;
    }

    .modal-body.detail-grid,
    .modal-body .detail-grid,
    .modal-body:has(> .form-group),
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .stack {
        gap: 14px;
    }

    .card-muted {
        padding: 28px 18px;
    }

    .inline-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .tree-header,
    .tree-row,
    .tree-child-row,
    .tree-warning-header {
        align-items: flex-start;
    }

    .tree-row {
        padding: 12px 14px;
    }

    .tree-child-row {
        padding: 10px 14px 10px 28px;
    }

    .tree-name {
        flex-basis: 100%;
    }

    .profile-wrap {
        flex-direction: column;
        gap: 0;
    }

    .profile-sidebar {
        width: 100%;
        flex-basis: auto;
    }

    .profile-main {
        width: 100%;
    }

    .profile-card {
        display: flex;
        align-items: center;
        gap: 14px;
        margin-bottom: 0;
        padding: 14px;
        border-radius: var(--radius) var(--radius) 0 0;
        border-bottom: 0;
        text-align: left;
    }

    .profile-avatar {
        width: 52px;
        height: 52px;
        margin: 0;
        font-size: 21px;
    }

    .profile-name {
        font-size: 16px;
    }

    .profile-nav {
        flex-direction: row;
        gap: 4px;
        flex-wrap: wrap;
        overflow-x: visible;
        margin: 0 0 14px;
        padding: 8px;
        border: 1px solid var(--border);
        border-radius: 0 0 var(--radius) var(--radius);
        background: #fff;
    }

    .profile-nav::-webkit-scrollbar {
        display: none;
    }

    .profile-nav-btn {
        width: auto;
        flex: 1 1 calc(50% - 4px);
        min-height: 44px;
        padding: 11px 14px;
        white-space: normal;
        text-align: center;
    }

    .section-card {
        width: 100%;
        box-sizing: border-box;
    }

    .field-row {
        display: grid;
        gap: 4px;
        font-size: 16px;
        line-height: 1.45;
        padding: 12px 0;
    }

    .field-lbl {
        width: auto;
        flex-basis: auto;
        font-size: 13px;
    }

    .field-val {
        font-size: 16px;
    }

    .proc-hd {
        align-items: flex-start;
    }

    .proc-footer,
    .ses-actions {
        width: 100%;
    }

    .ses-actions input[type="date"],
    .ses-actions input[type="time"],
    .ses-actions .btn {
        width: 100%;
    }

    .ses-row {
        flex-wrap: wrap;
    }

    .ses-action-field,
    .ses-action-buttons {
        width: 100%;
    }

    .ses-action-buttons {
        padding-top: 0;
    }

    .page-header-row,
    .content-header .users-header {
        display: grid;
        gap: 12px;
    }

    .page-header-row .btn,
    .content-header .users-header .btn {
        width: 100%;
    }

    .individual-card-grid {
        grid-template-columns: 1fr;
    }

    .individual-section-head {
        align-items: center;
    }

    .individual-card-actions .btn,
    .individual-summary-card > .btn {
        flex: 1;
        width: 100%;
    }

    #modal-iniciar-proceso .detail-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-hero,
    .dashboard-card-head {
        display: grid;
        gap: 12px;
    }

    .dashboard-hero h1 {
        font-size: 24px;
    }

    .dashboard-actions {
        display: grid;
        flex-basis: auto;
        grid-template-columns: 1fr;
        justify-content: stretch;
        width: 100%;
    }

    .dashboard-action-btn {
        justify-content: center;
        width: 100%;
    }

    .dashboard-widget-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-card-head .btn {
        width: 100%;
    }

    .members-toolbar {
        align-items: stretch;
    }

    .members-toolbar h1,
    .members-toolbar .btn {
        width: 100%;
    }

    .members-search,
    .members-search input,
    .members-search select,
    .members-search .btn {
        width: 100%;
    }

    .member-row {
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr);
        align-items: flex-start;
        gap: 10px 12px;
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
    }

    .member-row .badge-sm {
        grid-column: 2;
        justify-self: start;
        max-width: 100%;
        white-space: normal;
        text-align: left;
    }

    .member-name,
    .member-sub {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }

    .public-centered {
        padding: 24px 12px;
    }

    .public-container {
        padding: 10px;
    }

    .public-card {
        border-radius: 8px;
        box-shadow: none;
    }

    .public-card h1 {
        font-size: 22px;
    }

    .public-card h3 {
        font-size: 16px;
    }

    .seguimiento-public-page {
        background: #fff;
    }

    .seguimiento-public-page.public-centered {
        align-items: stretch;
        padding: 16px;
    }

    .seguimiento-public-page .public-container {
        align-items: stretch;
        display: flex;
        min-height: 100dvh;
        padding: 0;
        width: 100%;
    }

    .seguimiento-public-page .public-card {
        border: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 100dvh;
        padding: 28px 22px;
    }

    .seguimiento-public-page .public-card h1 {
        font-size: 30px;
        line-height: 1.12;
        margin-bottom: 10px;
    }

    .seguimiento-public-page .public-card h3 {
        font-size: 20px;
        line-height: 1.25;
        margin-bottom: 10px;
    }

    .seguimiento-public-page .public-card p {
        font-size: 18px;
        line-height: 1.5;
        margin-bottom: 20px;
    }

    .seguimiento-public-page.public-centered .public-card h2 {
        font-size: 30px;
        line-height: 1.15;
    }

    .seguimiento-public-page.public-centered .public-card p {
        font-size: 20px;
        line-height: 1.45;
    }

    .seguimiento-public-page .public-card label {
        font-size: 15px;
        margin-top: 18px;
    }

    .seguimiento-public-page .public-card input,
    .seguimiento-public-page .public-card select {
        border-radius: 10px;
        font-size: 18px;
        min-height: 54px;
        padding: 12px 14px;
    }

    .seguimiento-public-page .public-card button {
        border-radius: 10px;
        font-size: 17px;
        min-height: 54px;
        margin-top: 18px;
    }
}

@media (min-width: 769px) {
    .profile-sidebar {
        position: sticky;
        top: calc(var(--topbar-height) + 16px);
    }
}

/* =========================================================
   CALENDARIO
========================================================= */
.calendar-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.calendar-toolbar input[type="month"] {
    min-width: 170px;
}

.calendar-nav-btn {
    min-width: 42px;
    padding-inline: 12px;
}

.calendar-tabs {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-flex;
    overflow: hidden;
}

.calendar-tabs a {
    color: var(--text);
    padding: 9px 14px;
    text-decoration: none;
}

.calendar-tabs a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.calendar-list {
    display: none;
    gap: 10px;
}

.calendar-month {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}

.calendar-weekdays span {
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
    padding: 10px 8px;
    text-align: center;
    text-transform: uppercase;
}

.calendar-day {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 128px;
    min-width: 0;
    padding: 8px;
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-day.is-muted {
    background: #fafafa;
    color: var(--muted);
}

.calendar-day.is-today .calendar-day-number {
    background: var(--primary);
    color: #fff;
}

.calendar-day-number {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    height: 26px;
    justify-content: center;
    margin-bottom: 6px;
    width: 26px;
}

.calendar-day-events {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.calendar-pill,
.calendar-more {
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    padding: 5px 6px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-pill span {
    font-weight: 800;
    margin-right: 4px;
}

.calendar-pill-event {
    background: #ecfdf5;
    color: #047857;
}

.calendar-pill-personal {
    background: #eff6ff;
    color: #1d4ed8;
}

.calendar-pill-class {
    background: #eff6ff;
    color: #1d4ed8;
}

.calendar-pill-activity {
    background: #f3e8ff;
    color: #7c3aed;
}

.calendar-more {
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    padding-left: 2px;
}

.calendar-item {
    align-items: start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: 58px 1fr auto;
    padding: 14px;
}

.calendar-item time {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 58px;
    text-align: center;
}

.calendar-item time strong {
    font-size: 20px;
    line-height: 1;
}

.calendar-item time span {
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
}

.calendar-item h2 {
    font-size: 16px;
    line-height: 1.25;
    margin: 6px 0 4px;
}

.calendar-item p {
    color: var(--text-light);
    margin: 0;
}

.calendar-item-head,
.calendar-meta {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calendar-date,
.calendar-meta span {
    color: var(--text-light);
    font-size: 13px;
}

.calendar-meta {
    margin-top: 9px;
}

.calendar-meta span {
    background: var(--surface-muted);
    border-radius: 999px;
    padding: 4px 9px;
}

.calendar-detail-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.calendar-detail-head > span:last-child {
    color: var(--text-light);
    font-size: 14px;
}

.calendar-detail-description {
    color: var(--text);
    margin: 0 0 16px;
    white-space: pre-wrap;
}

.calendar-detail-fields {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.calendar-detail-fields div {
    display: grid;
    gap: 8px;
    grid-template-columns: 110px 1fr;
    padding: 10px 12px;
}

.calendar-detail-fields div + div {
    border-top: 1px solid var(--border);
}

.calendar-detail-fields span {
    color: var(--text-light);
    font-size: 13px;
}

.calendar-detail-fields strong {
    font-size: 14px;
}

.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-span {
    grid-column: 1 / -1;
}

.notification-filter {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 1fr) 180px 180px auto auto;
}

.actividad-filter {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
    margin-bottom: 16px;
}

.actividad-filter .form-group {
    margin-bottom: 0;
}

.actividad-list.is-visible {
    display: grid;
}

.actividad-detail {
    margin-bottom: 16px;
}

.actividad-assignment-list {
    display: grid;
    gap: 10px;
}

.actividad-function-heading {
    color: var(--text-light);
    font-size: 13px;
    letter-spacing: 0;
    margin: 8px 0 0;
    text-transform: uppercase;
}

.actividad-assignment {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px;
}

.actividad-assignment strong,
.actividad-assignment span,
.actividad-assignment small {
    display: block;
}

.actividad-assignment small {
    color: var(--text-light);
}

.participation-people-list {
    display: grid;
    gap: 8px;
    margin: -2px 0 8px 14px;
}

.participation-person-row {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(140px, 1fr) minmax(120px, 1fr) auto;
    padding: 9px 10px;
}

.participation-person-row span,
.participation-person-row small {
    color: var(--text-light);
    font-size: 13px;
}

.modal-section-divider {
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.modal-participacion-operativa {
    display: grid;
    gap: 14px;
    max-height: min(70dvh, 620px);
}

.modal-participacion-operativa .form-grid {
    margin: 0;
}

.template-preview {
    display: grid;
    gap: 12px;
}

.template-preview[hidden] {
    display: none;
}

.template-participation {
    align-items: stretch;
}

.template-participation-main {
    display: grid;
    gap: 10px;
}

.template-participation-fields {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.template-participation-fields label,
.template-notes {
    color: var(--text-light);
    display: grid;
    font-size: 13px;
    gap: 4px;
}

.template-equipos {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-switch-row,
.template-equipo-switch {
    margin: 0;
}

.template-equipo-switch {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
}

.template-equipos .is-muted {
    opacity: .45;
}

.actividad-cover-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.actividad-cover-search {
    min-width: 220px;
    position: relative;
}

.actividad-cover-search input {
    width: 100%;
}

.notification-filter .form-group {
    margin-bottom: 0;
}

.notification-wizard {
    display: grid;
    gap: 18px;
}

.wizard-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wizard-step {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
}

.wizard-step.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
}

.wizard-actions {
    align-items: center;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
}

.channel-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.channel-option {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 14px;
}

.channel-option .switch-label {
    font-weight: 700;
}

.channel-message {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 14px;
}

.notification-window-note {
    align-self: end;
    margin: 0;
}

.notification-summary {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.notification-message-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.notification-message {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.notification-message h2 {
    font-size: 16px;
    margin: 0 0 8px;
}

.channel-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.notification-inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.notification-inline-form label {
    margin: 0;
}

.notification-inline-form input {
    min-width: 220px;
}

.personal-notification-tabs {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.personal-notification-tabs a {
    color: var(--text);
    padding: 10px 14px;
    text-decoration: none;
}

.personal-notification-tabs a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.personal-notifications {
    display: grid;
    gap: 12px;
}

.personal-notification-card {
    align-items: start;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.personal-notification-card.is-read {
    background: var(--surface-muted);
}

.personal-notification-head {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.personal-notification-head h2 {
    font-size: 16px;
    line-height: 1.3;
    margin: 0;
}

.personal-notification-main p {
    color: var(--text-light);
    margin: 8px 0 0;
}

.personal-notification-meta {
    color: var(--text-light);
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    gap: 8px;
    margin-top: 10px;
}

.personal-notification-meta span {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 9px;
}

.personal-notification-actions {
    align-self: center;
}

/* =========================================================
   ROLES Y PERMISOS
========================================================= */
.roles-tabs {
    display: inline-flex;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.roles-tabs a {
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
}

.roles-tabs a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.roles-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.roles-list {
    display: grid;
    gap: 8px;
}

.roles-list a {
    display: grid;
    gap: 3px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
}

.roles-list a.active {
    border-color: var(--primary);
    background: var(--sidebar-active-bg);
    color: var(--primary);
}

.roles-list span,
.roles-editor-head p,
.roles-permission-option small {
    color: var(--text-light);
    font-size: 12px;
}

.roles-editor-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.roles-editor-head h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.roles-editor-head p {
    margin: 0;
}

.roles-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.roles-permission-groups {
    display: grid;
    gap: 14px;
}

.roles-permission-group {
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.roles-permission-group legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 800;
}

.roles-permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.roles-permission-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
}

.roles-permission-option input {
    width: auto;
    margin-top: 2px;
}

.roles-permission-option span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.roles-permission-option strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

@media (max-width: 768px) {
    .calendar-month {
        display: none;
    }

    .calendar-list {
        display: grid;
    }

    .calendar-item {
        grid-template-columns: 52px 1fr;
    }

    .calendar-item > form,
    .calendar-item-action {
        grid-column: 1 / -1;
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .notification-filter,
    .actividad-filter,
    .channel-grid,
    .notification-message-grid,
    .personal-notification-card,
    .roles-layout,
    .roles-permission-grid {
        grid-template-columns: 1fr;
    }

    .personal-notification-tabs,
    .personal-notification-actions,
    .personal-notification-actions .btn {
        width: 100%;
    }

    .personal-notification-tabs {
        display: grid;
    }

    .personal-notification-tabs a {
        text-align: center;
    }

    .actividad-assignment {
        grid-template-columns: 1fr;
    }

    .participation-people-list {
        margin-left: 0;
    }

    .participation-person-row {
        grid-template-columns: 1fr;
    }

    .template-participation-fields {
        grid-template-columns: 1fr;
    }

    .template-equipos {
        display: grid;
        grid-template-columns: 1fr;
    }

    .template-equipo-switch,
    .channel-option {
        width: 100%;
    }

    .actividad-cover-form,
    .actividad-cover-form input,
    .actividad-cover-form .btn {
        width: 100%;
    }

    .roles-tabs,
    .roles-editor-head {
        width: 100%;
    }

    .roles-tabs,
    .roles-editor-head,
    .roles-tools {
        display: grid;
    }

    .roles-tabs a,
    .roles-editor-head .btn,
    .roles-tools .btn {
        width: 100%;
        text-align: center;
    }
}

/* =========================================================
   CONSISTENCIA DE PAGINAS Y CONTENCION RESPONSIVE
========================================================= */
.main-content,
.main-content > *,
.card,
.section-card,
form,
fieldset {
    min-width: 0;
    max-width: 100%;
}

.content-header h1,
.content-header p,
.detail-header h1,
.section-head,
.field-val,
.card p {
    overflow-wrap: anywhere;
}

.content-header p {
    margin: 6px 0 0;
    color: var(--text-light);
}

.header-actions,
.header-actions form,
.form-inline {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.header-actions input,
.header-actions select,
.form-inline input,
.form-inline select {
    width: auto;
    min-width: 0;
}

.main-content > .card + .card {
    margin-top: 16px;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

.table-container,
.table-responsive {
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.search-results {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    overflow: hidden;
}

.search-result-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
}

.search-result-item:last-child {
    border-bottom: 0;
}

.search-result-item:hover,
.search-result-item:focus {
    background: var(--surface-muted);
}

.search-result-item strong,
.search-result-item small,
.search-result-empty {
    display: block;
}

.search-result-item small,
.search-result-empty {
    color: var(--text-light);
}

.search-result-empty {
    padding: 10px 12px;
}

.group-member-search {
    position: relative;
    flex: 1 1 280px;
    min-width: min(100%, 280px);
}

.group-member-search + select[name="persona_id"] {
    display: none;
}

.group-member-search .search-results {
    max-height: 220px;
    overflow-y: auto;
}

.family-picker,
.family-picker-form {
    display: grid;
    gap: 14px;
}

.family-search-results {
    display: grid;
    gap: 10px;
}

.family-result-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 5px;
    padding: 14px;
    text-align: left;
    width: 100%;
}

.family-result-item:hover,
.family-result-item:focus-visible {
    background: var(--sidebar-active-bg);
    border-color: var(--primary);
    outline: none;
}

.family-result-item strong,
.family-selected strong {
    font-size: 15px;
}

.family-result-item span,
.family-selected span {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.family-result-item small,
.family-selected small {
    color: var(--text-light);
    font-size: 12px;
}

.family-selected {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    display: grid;
    gap: 5px;
    padding: 14px;
}

/* =========================================================
   GENERACIONES - TEMA VISUAL
   Fuente: docs/Generaciones/_DISEÑO.md
========================================================= */
body.module-generaciones {
    --primary: var(--gen-as);
    --primary-hover: var(--gen-teal);
    --accent: var(--gen-oro);
    --accent-hover: #9f7209;
    --sidebar-active-bg: rgba(29, 107, 62, 0.12);
    --field-focus: rgba(45, 134, 83, 0.2);
    --table-head-bg: var(--gen-verde);
    --table-head-text: #ffffff;
}

body.module-generaciones .content-header {
    background:
        linear-gradient(90deg, rgba(29, 107, 62, 0.1), rgba(24, 95, 165, 0.08)),
        #ffffff;
    border: 1px solid var(--gen-neutral-border);
    border-left: 6px solid var(--gen-verde);
    border-radius: 8px;
    padding: 18px;
}

body.module-generaciones .content-header h1 {
    color: var(--gen-verde);
}

body.module-generaciones .content-header p {
    color: var(--gen-neutral-text);
}

body.module-generaciones .dashboard-kpi:nth-child(1),
body.module-generaciones .dashboard-tone-people {
    --dashboard-tone: var(--gen-inicial);
    --dashboard-tone-bg: var(--gen-inicial-bg);
}

body.module-generaciones .dashboard-kpi:nth-child(2),
body.module-generaciones .dashboard-tone-calendar {
    --dashboard-tone: var(--gen-morado);
    --dashboard-tone-bg: var(--gen-morado-bg);
}

body.module-generaciones .dashboard-kpi:nth-child(3),
body.module-generaciones .dashboard-tone-warning {
    --dashboard-tone: var(--gen-ambar);
    --dashboard-tone-bg: var(--gen-ambar-bg);
}

body.module-generaciones .dashboard-kpi:nth-child(4),
body.module-generaciones .dashboard-tone-followup {
    --dashboard-tone: var(--gen-azul);
    --dashboard-tone-bg: var(--gen-azul-bg);
}

body.module-generaciones .dashboard-tone-process {
    --dashboard-tone: var(--gen-teal-med);
    --dashboard-tone-bg: var(--gen-teal-med-bg);
}

body.module-generaciones .dashboard-card,
body.module-generaciones .dashboard-kpi,
body.module-generaciones .section-card,
body.module-generaciones .card {
    border-radius: 8px;
}

body.module-generaciones .dashboard-card,
body.module-generaciones .section-card {
    border-color: var(--gen-neutral-border);
}

body.module-generaciones .section-head {
    color: var(--gen-as);
}

body.module-generaciones .dashboard-list-item:hover,
body.module-generaciones .calendar-item:hover {
    background: var(--gen-verde-bg);
    border-color: rgba(29, 107, 62, 0.28);
}

body.module-generaciones .table th {
    background: var(--gen-verde);
    color: #fff;
}

body.module-generaciones .table tbody tr:nth-child(even) {
    background: rgba(244, 244, 242, 0.48);
}

body.module-generaciones .badge-blue {
    background: var(--gen-azul-bg);
    color: var(--gen-azul);
}

body.module-generaciones .badge-green {
    background: var(--gen-verde-bg);
    color: var(--gen-verde);
}

body.module-generaciones .badge-purple {
    background: var(--gen-morado-bg);
    color: var(--gen-morado);
}

body.module-generaciones .badge-yellow {
    background: var(--gen-ambar-bg);
    color: var(--gen-ambar);
}

body.module-generaciones .badge-red {
    background: #fee2e2;
    color: #991b1b;
}

body.module-generaciones .badge-gray {
    background: var(--gen-neutral-bg);
    color: var(--gen-neutral-text);
}

body.module-generaciones .field-lbl {
    color: var(--gen-neutral-text);
}

body.module-generaciones .empty-state,
body.module-generaciones .dashboard-empty,
body.module-generaciones .sec-empty {
    background: var(--gen-neutral-bg);
    border-color: var(--gen-neutral-border);
}

body.module-generaciones .profile-nav-btn.active {
    background: var(--gen-verde-bg);
    color: var(--gen-verde);
}

body.module-generaciones .calendar-item time {
    background: var(--gen-as);
    color: #fff;
}

body.module-generaciones .calendar-item time span {
    color: rgba(255, 255, 255, 0.78);
}

.gen-grade-chip {
    align-items: center;
    border: 1px solid currentColor;
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    gap: 7px;
    line-height: 1;
    padding: 6px 9px;
}

.gen-grade-chip::before {
    background: currentColor;
    border-radius: 999px;
    content: "";
    height: 8px;
    width: 8px;
}

.gen-grade-semillitas { color: #8a7400; background: rgba(255, 215, 0, 0.18); }
.gen-grade-retonitos { color: var(--gen-retonitos); background: rgba(200, 146, 10, 0.13); }
.gen-grade-pampanitos { color: #287c34; background: rgba(93, 191, 106, 0.16); }
.gen-grade-renuevos { color: #126895; background: rgba(96, 174, 221, 0.16); }
.gen-grade-guerreros { color: var(--gen-guerreros); background: rgba(26, 58, 107, 0.1); }
.gen-grade-escuderos { color: var(--gen-escuderos); background: rgba(124, 58, 237, 0.1); }
.gen-grade-conquistadores { color: var(--gen-conquistadores); background: rgba(192, 57, 43, 0.1); }
.gen-grade-artilleros { color: var(--gen-artilleros); background: rgba(26, 77, 58, 0.12); }

@media (max-width: 768px) {
    .detail-header {
        display: grid;
        align-items: stretch;
        gap: 12px;
    }

    .detail-header .btn,
    .header-actions,
    .header-actions form,
    .header-actions .btn,
    .header-actions input,
    .header-actions select,
    .form-inline,
    .form-inline input,
    .form-inline select,
    .form-inline .btn {
        width: 100%;
    }

    .section-card,
    .card {
        padding: 16px;
    }

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .section-head .btn {
        width: 100%;
    }

    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-width: 0;
    }
}
