/* --- Importación de Fuentes --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

/* --- Reset y Estilos Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    /* Esto es importante para asegurar la renderización correcta de los acentos */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Contenedores Principales --- */
.main-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

/* .content-wrapper-full se usa para layouts de una sola columna o como base */
.content-wrapper-full {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem; /* Añadido un gap para consistencia */
}

/* --- Encabezado Profesional (Header) --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #dee2e6;
    margin-bottom: 2rem;
}

    /* --- Estilos específicos para Espacio de Trabajo --- */
    .espacio-work-wrapper .card {
        padding: 1.25rem;
    }
    .espacio-search-form {
        display:flex;
        gap:0.75rem;
        align-items:center;
        margin-bottom:1rem;
    }
    .espacio-search-form input[type="text"]{
        padding:0.65rem 0.75rem;
        border:1px solid #ced4da;
        border-radius:6px;
        background:#fff;
    }
    .espacio-search-form .header-btn{ padding:0.6rem 0.9rem }
    .comment {
        background: linear-gradient(180deg, #ffffff, #fbfdff);
        border:1px solid #e6eef8;
        border-radius:8px;
        padding:12px;
        margin-bottom:10px;
    }
    .comment .small { color:#6c757d }
    .comment strong { color:#343a40 }
    .comment .meta {
        display:flex;flex-direction:column;align-items:flex-end;gap:6px;font-size:0.85rem;color:#6c757d;
    }
    .comment .meta .time { font-weight:600;color:#495057 }

    @media (max-width:900px){
        .espacio-search-form { flex-direction:column; align-items:stretch }
        .comment { padding:10px }
        .comment .meta { align-items:flex-start }
    }

    /* Desktop: keep header elements on one line and ensure greeting and actions align */
    @media (min-width: 900px) {
        .main-header {
            flex-wrap: nowrap;
            align-items: center;
        }
        .header-greeting { order: 1; flex: 0 1 auto; display: flex; flex-direction: column; justify-content: center; }
        .header-actions { order: 2; margin-left: auto; flex: 0 0 auto; }
        .header-info { order: 3; flex: 0 0 auto; }
    }

    /* Ajustes visuales para formulario y botones dentro del card */
    .card label { font-weight:600; color:#495057 }
    .card textarea { min-height:90px }
    .card select { max-width:100% }


.header-greeting {
    flex-grow: 1;
}

.header-greeting h2 {
    font-size: 1.4rem;
    font-weight: 400;
    margin: 0;
    color: #343a40;
    letter-spacing: -0.5px;
}

.header-company-name {
    color: #0056b3;
    font-weight: 700;
    font-style: italic;
}

.header-greeting strong {
    font-weight: 700;
}

.user-role {
    font-size: 0.85rem;
    color: #6c757d;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: #6c757d;
    padding: 0 1.5rem;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
}


.stat-item {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.stat-item span {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.2rem;
}

.stat-item strong {
    font-size: 1.1rem;
    font-weight: 700;
    color: #343a40;
}


#real-time-clock-container,
#exchange-rate-container {
    background: none;
    padding: 0;
    border: none;
    font-weight: 500;
    white-space: nowrap;
}

#exchange-rate-container {
    color: #28a745;
}

#real-time-clock-container span,
#exchange-rate-container span {
    margin-right: 0.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* Permite que los botones se envuelvan en pantallas pequeñas */
    justify-content: flex-end; /* Alinea los botones a la derecha */
}

/* Force header-actions to stay at the right of the header and not wrap below the greeting */
.header-actions {
    margin-left: auto;
}

/* Ensure header-info does not grow and push actions to a new line */
.header-info {
    flex: 0 0 auto;
}

.header-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    border: 1px solid #ced4da;
    background-color: #f8f9fa;
    color: #495057;
    transition: all 0.2s ease-in-out;
    white-space: nowrap; /* Evita que el texto del botón se rompa */
}

.header-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.header-btn.logout {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.header-btn.logout:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

/* Asegurar altura y alineación consistente entre <a> y <button> con clase .header-btn */
.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    line-height: 1.4;
}

/* Botones de acción rápida (usar en crm.php y otras páginas) */
.action-button-header {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    color: #fff;
    transition: transform 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: none;
}


.action-button-header:hover {
    transform: translateY(-2px);
}

.action-button-header.red { background-color: #dc3545; }
.action-button-header.teal { background-color: #17a2b8; }
.action-button-header.orange { background-color: #fd7e14; }
.action-button-header.purple { background-color: #6f42c1; }
.action-button-header.green { background-color: #28a745; }
.action-button-header.yellow { background-color: #ffc107; color: #212529; }
.action-button-header.ventas-dia {
    background-color: #007bff;
    color: #fff;
}
.action-button-header.seguimientos {
    background-color: #e83e8c;
    color: #fff;
}
.action-button-header.espacio-trabajo {
    background-color: #795548;
    color: #fff;
}

/* --- Visor de Tasas de Cambio (Currency Viewer) --- */
.currency-viewer {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background-color: #f0f7ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    font-size: 0.85rem;
}

.currency-rates {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.currency-label {
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.rate-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.rate-item .currency-code {
    font-weight: 700;
    color: #007bff;
}

.rate-item .currency-symbol {
    color: #28a745;
    font-weight: bold;
}

.rate-item .rate-value {
    color: #212529;
    font-weight: 600;
}

/* Efecto Hover para mostrar nombre completo */
.currency-hover {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.currency-hover .currency-fullname {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #212529;
    color: #ffffff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.currency-hover:hover .currency-fullname {
    opacity: 1;
    visibility: visible;
    bottom: -35px;
}

@media (max-width: 768px) {
    .currency-viewer {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .currency-rates {
        gap: 0.5rem;
    }
    
    .rate-item {
        gap: 0.15rem;
    }
    
    .currency-hover .currency-fullname {
        font-size: 0.7rem;
        padding: 0.4rem 0.6rem;
        bottom: -28px;
    }
    
    .currency-hover:hover .currency-fullname {
        bottom: -32px;
    }
}

/* --- Paneles de Resumen (Dashboard Principal) --- */
.panels-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-panel {
    background-color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #343a40;
    margin-bottom: 1rem;
    text-align: center;
}

.summary-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 1px solid #e9ecef;
}

.summary-card:first-of-type {
    border-top: none;
}

.summary-card h5 {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
}

.summary-card p {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
}

.summary-card.highlight p {
    color: #28a745;
}

/* Resumen Financiero en Detalle de Cliente (también usado en CRM general) */
.financial-summary-new {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    text-align: center;
    padding: 1rem;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.07);
    border: 1px solid #e9ecef;
    margin-bottom: 2rem;
}

.summary-item-new {
    padding: 1rem;
    position: relative;
}

.summary-item-new:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 60%;
    background-color: #dee2e6;
}

.summary-item-new h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.summary-item-new p {
    font-size: 2rem;
    font-weight: 700;
    color: #343a40;
    margin: 0;
    line-height: 1;
}

/* --- Layout Detalle de Cliente --- */
.client-dashboard {
    display: grid;
    grid-template-columns: 1fr; /* Default a columna única para móviles */
    gap: 2rem;
}

.client-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.client-main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default a columna única para móviles */
    gap: 1rem;
    margin-top: 1rem;
}

.info-grid.single-col {
    grid-template-columns: 1fr;
}

.info-grid div {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f1f1;
}

.info-grid div:last-child {
    border-bottom: none;
}

.link-cliente {
    text-decoration: none;
    color: #0056b3;
    font-weight: 600;
}

.link-cliente:hover {
    text-decoration: underline;
}

/* --- Tarjetas y Paneles Desplegables --- */
.list-card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.list-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0;
    font-weight: 700;
    color: #343a40;
}

.registro-panel {
    display: none !important;
    padding: 1.5rem;
    margin-top: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    animation: fade-in 0.4s ease;
    visibility: visible;
    opacity: 1;
}

.registro-panel.visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.registro-panel h4 {
    font-size: 1.2rem;
    font-weight: 600;
}

/* --- Formularios --- */
.cliente-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.cliente-form-grid .full-width {
    grid-column: 1 / -1;
}

.comision-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.inline-form {
    display: inline-block;
    margin: 0;
    padding: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="date"], /* Añadido para estilos consistentes con fechas */
input[type="month"], /* Añadido para estilos consistentes con meses */
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

input[type="checkbox"] {
    width: 1.2em;
    height: 1.2em;
    cursor: pointer;
    vertical-align: middle;
}

.submit-button {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.5rem;
    background: linear-gradient(90deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: background 0.3s ease, transform 0.2s ease; /* Transiciones suaves */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Sombra sutil para profundidad */
    text-shadow: 0 1px 1px rgba(0,0,0,0.2); /* Sombra en el texto para legibilidad */
}

.submit-button:hover {
    background: linear-gradient(90deg, #0056b3, #003b7a); /* Cambio de color al pasar el ratón */
    transform: translateY(-2px); /* Efecto "elevado" */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); /* Sombra más pronunciada */
}

/* Colores específicos para submit-button (si se anulan en HTML) */
.submit-button[style*="background: #17a2b8"] {
    background: linear-gradient(90deg, #17a2b8, #138496) !important;
}
.submit-button[style*="background: #dc3545"] {
    background: linear-gradient(90deg, #dc3545, #c82333) !important;
}
.submit-button[style*="background: #28a745"] {
    background: linear-gradient(90deg, #28a745, #1e7e34) !important;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
}

.checkbox-group input {
    width: auto;
}

/* --- Tabla de Clientes --- */
.table-container {
    margin-top: 1.5rem;
    overflow-x: auto; /* Permite desplazamiento horizontal en pantallas pequeñas */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Asegura un ancho mínimo para la tabla */
}

th,
td {
    padding: 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
}

thead th {
    background-color: #f8f9fa;
    font-weight: 700;
    color: #495057;
}

tbody tr:hover {
    background-color: #e9ecef;
}

td strong {
    color: #343a40;
}

.monto {
    font-weight: 700;
    color: #28a745;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.timestamp-info {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 4px;
    font-style: italic;
}

/* --- Insignias (Badges) y Estados --- */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.admin-badge,
.user-role {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
}

.team-name {
    font-size: 0.85em;
    color: #6c757d;
    font-weight: 500;
    margin-left: 0.25rem;
}

.badge.pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.badge.aprobada, /* Para revision_tarjetas.php y comisiones */
.badge.aprobado { /* Para panel_administrativo.php abonos */
    background-color: #d4edda;
    color: #155724;
}

.badge.pagada,
.badge.revisado {
    background-color: #e9ecef;
    color: #6c757d;
}

.badge.no-revisado {
    background-color: #f8d7da;
    color: #721c24;
}

.badge.vencido {
    background-color: #dc3545;
    color: white;
}

.firmado-status {
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.firmado-status.si {
    color: #155724;
    background-color: #d4edda;
}

.firmado-status.no {
    color: #721c24;
    background-color: #f8d7da;
}

/* --- Acciones y Filtros --- */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center; /* Centra los botones de acción en móviles */
}

.action-button {
    border: none;
    padding: 0.5rem 1rem; /* Aumenta el padding para que sean más grandes */
    border-radius: 0.25rem;
    color: white;
    font-weight: 500;
    font-size: 0.85rem; /* Ligeramente más grande */
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease; /* Más transiciones */
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15); /* Sombra sutil */
    white-space: nowrap; /* Evita que el texto se rompa */
}

.action-button:hover {
    opacity: 0.9; /* Opacidad ligera */
    transform: translateY(-1px); /* Efecto de elevación */
    box-shadow: 0 2px 5px rgba(0,0,0,0.25); /* Sombra más pronunciada */
}

.action-button.approve { background-color: #28a745; }
.action-button.pay { background-color: #007bff; }
.action-button.delete { background-color: #dc3545; }

/* Styles for user state buttons added for user_management.php */
.new-user-state-button, .active-user-state-button, .inactive-user-state-button {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    color: white;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    white-space: nowrap;
}


/* More specific selectors to ensure these styles win over other rules */
.new-user-state-button, .new-user-state-button { background-color: #17a2b8; }
.new-user-state-button:hover, .new-user-state-button:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.25); }

.active-user-state-button, .active-user-state-button { background-color: #28a745; }
.active-user-state-button:hover, .active-user-state-button:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.25); }

.inactive-user-state-button { background-color: #6c757d; }
.inactive-user-state-button:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.25); }

/* Asegurar que los botones dentro de formularios inline no tengan márgenes extra */
.inline-form .action-button {
    margin: 0; /* Elimina márgenes automáticos si los tuvieran */
}


.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.filter-button {
    background-color: #e9ecef;
    color: #495057;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.filter-button:hover {
    background-color: #ced4da;
}

.filter-button.active {
    background-color: #007bff;
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.report-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.report-form .form-group {
    flex-grow: 1;
}

.report-form .submit-button {
    width: auto;
    padding: 0.75rem 1.5rem;
    margin-top: 0;
}

/* --- Lista de Tarjetas (General) --- */
.card-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.card-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.card-info {
    display: flex;
    flex-direction: column;
}

.card-details {
    display: flex;
    flex-direction: column;
    text-align: right;
    font-size: 0.85rem;
    color: #6c757d;
}

.card-type {
    font-weight: 600;
    font-size: 0.9rem;
}

.card-number {
    font-family: monospace;
    font-size: 1rem;
    color: #495057;
}

/* --- Mensajes de Alerta y Notificación --- */
.mensaje {
    padding: 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    text-align: center;
    font-weight: 500;
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.mensaje.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* --- ESTILOS PARA VENTANA EMERGENTE (MODAL) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 2rem 2.5rem;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 0.75rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slide-down 0.4s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.link-detalle {
    text-decoration: underline;
    color: #0056b3;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

.link-detalle:hover {
    color: #003d7a;
}

#detalle-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

#detalle-content .info-grid {
    margin-top: 0;
}

#detalle-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    border: 1px solid #dee2e6;
}

/* --- Estilos para Botones de Acción Principales (CTA) --- */
.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-button .icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
    line-height: 1;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Colores específicos */
.cta-button.venta {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    /* Verde */
}

.cta-button.abono {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    /* Azul */
}

/* Color específico para el botón Notas */
.cta-button.notas {
    background: linear-gradient(135deg, #d4911d 0%, #d9b068 100%); /* morado */
}

.cta-button.notas .icon {
    background-color: rgba(255,255,255,0.18);
}

/* ===== ESTILOS PARA EL MENÚ PRINCIPAL (Vistoso y Elegante) ===== */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem; /* Aumenta el padding para más espacio */
    text-align: center;
    background-color: #ffffff; /* Fondo blanco para destacar */
    border-radius: 1rem; /* Bordes más suaves */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); /* Sombra más suave y profunda */
    margin: 2rem auto; /* Centrar y dar espacio */
    max-width: 900px; /* Limitar el ancho para estética */
    animation: fadeIn 1s ease-out; /* Animación de entrada suave */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-title {
    font-size: 3rem; /* Más grande y prominente */
    font-weight: 700;
    color: #2c3e50; /* Un azul oscuro más profundo */
    margin-bottom: 0.75rem; /* Más espacio */
    letter-spacing: -0.05rem; /* Ligeramente más ajustado */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.05); /* Sutil sombra en el texto */
}

.menu-subtitle {
    font-size: 1.25rem; /* Un poco más grande */
    color: #7f8c8d; /* Gris más suave y amigable */
    margin-bottom: 3rem; /* Más espacio para separar de los botones */
    max-width: 500px; /* Limitar el ancho para legibilidad */
    line-height: 1.5;
}

.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem; /* Espacio entre los botones */
    width: 100%; /* Asegurar que ocupe el ancho disponible */
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center; /* Centrar contenido dentro del botón */
    gap: 0.85rem; /* Espacio entre ícono y texto */
    padding: 1.1rem 2.8rem; /* Mayor padding para un botón más grande */
    font-size: 1.15rem; /* Tamaño de fuente ligeramente mayor */
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%); /* Gradiente azul vibrante */
    border: none;
    border-radius: 50px; /* Botones más redondeados (píldora) */
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease; /* Transiciones suaves */
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3); /* Sombra inicial más profunda */
    min-width: 220px; /* Ancho mínimo para consistencia */
    text-align: center;
}

.menu-button:hover {
    transform: translateY(-7px) scale(1.03); /* Elevación y ligero aumento de tamaño */
    box-shadow: 0 12px 35px rgba(0, 123, 255, 0.45); /* Sombra más dramática al hover */
    background: linear-gradient(135deg, #0056b3 0%, #003b7a 100%); /* Cambio de gradiente al hover */
}

.menu-button.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%); /* Gradiente gris */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.menu-button.secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

/* Colores específicos para botones especiales con gradiente y sombra */
.menu-button[style*="background: #ffc107"] { /* Panel Administrativo */
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
    color: #212529 !important;
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.3) !important;
}
.menu-button[style*="background: #ffc107"]:hover {
    background: linear-gradient(135deg, #e0a800 0%, #c69500 100%) !important;
    box-shadow: 0 12px 35px rgba(255, 193, 7, 0.45) !important;
}

.menu-button[style*="background: #17a2b8"] { /* Estadísticas */
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.3) !important;
}
.menu-button[style*="background: #17a2b8"]:hover {
    background: linear-gradient(135deg, #138496 0%, #0f6674 100%) !important;
    box-shadow: 0 12px 35px rgba(23, 162, 184, 0.45) !important;
}

.menu-button[style*="background: #6f42c1"] { /* Admin Leads */
    background: linear-gradient(135deg, #6f42c1 0%, #5b36a1 100%) !important;
    box-shadow: 0 6px 20px rgba(111, 66, 193, 0.3) !important;
}
.menu-button[style*="background: #6f42c1"]:hover {
    background: linear-gradient(135deg, #5b36a1 0%, #482a82 100%) !important;
    box-shadow: 0 12px 35px rgba(111, 66, 193, 0.45) !important;
}


/* Estilo del logo en Menú y Login */
.header-logo-container {
    text-align: center;
    margin-bottom: 2.5rem; /* Más espacio debajo del logo */
    margin-top: -1.5rem;
}
.header-logo-container img {
    max-width: 280px; /* Un poco más grande */
    height: auto;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.1)); /* Sombra para el logo */
}

/* --- Estilos para Tareas Completadas en la Agenda --- */
.note-card.completed {
    border-left-color: #6c757d;
    background-color: #f8f9fa;
    opacity: 0.7;
}

.note-card.completed:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.note-card.completed .note-header h4 {
    text-decoration: line-through;
    color: #6c757d;
}

/* --- Estilos para el Modal de Alarma --- */
#alarm-content h3 {
    font-size: 1.8rem;
    color: #007bff;
    margin-bottom: 1rem;
}

#alarm-content h4 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

#alarm-content p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* --- Estilos para Interfaz de Pestañas --- */
.tab-nav {
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap; /* Permite que las pestañas se envuelvan */
    justify-content: center; /* Centra las pestañas en móvil */
}

.tab-button {
    background-color: transparent;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    /* Alinea con el borde inferior del nav */
    white-space: nowrap; /* Evita que el texto de la pestaña se rompa */
}

.tab-button:hover {
    background-color: #e9ecef;
    color: #0056b3;
}

.tab-button.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.tab-content {
    display: none;
    /* Oculto por defecto */
    animation: fade-in 0.5s;
}

/* --- Estilos para Pie de Página --- */
.page-footer {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    font-size: 0.8rem;
    color: #adb5bd;
    /* Un gris claro y sutil */
    text-align: right;
    z-index: 999; /* Asegura que esté sobre otros elementos */
}

/* --- Estilos para Sub-Pestañas --- */
.tab-button-inner {
    background-color: #e9ecef;
    border: none;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
    border-radius: 6px;
    white-space: nowrap;
}

.tab-button-inner:hover {
    background-color: #dee2e6;
}

.tab-button-inner.active {
    background-color: #007bff;
    color: white;
}

.tab-content-inner {
    display: none;
    /* Oculto por defecto */
    margin-top: 1.5rem;
    animation: fade-in 0.5s;
}

/* --- Estilos para Etiquetas de Tiempo Restante --- */
.time-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
    white-space: nowrap;
}

.time-badge.safe {
    background-color: #28a745;
    /* Verde */
}

.time-badge.warning {
    background-color: #ffc107;
    /* Amarillo */
    color: #212529;
}

.time-badge.soon {
    background-color: #dc3545;
    /* Rojo */
}

/* --- Estilos para Formulario de Reasignación en Tabla --- */
.reassign-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* Permite que los elementos se envuelvan */
}

.reassign-form select {
    flex-grow: 1;
    /* El selector ocupa el espacio disponible */
    min-width: 120px; /* Ancho mínimo para el select */
}

/* --- Estilos para Formulario de Búsqueda --- */
.search-form {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    flex-wrap: wrap; /* Permite que los elementos se envuelvan */
}

.search-form input {
    flex-grow: 1;
    /* Hace que el campo de texto ocupe el espacio disponible */
    min-width: 200px; /* Ancho mínimo para el input de búsqueda */
}

.search-form button {
    width: auto;
    padding: 0.75rem 1.5rem;
}

/* --- Estilos para Banner de Permiso de Audio --- */
#audio-permission-banner {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* --- Estilos para Panel de Supervisión --- */
.team-header {
    padding: 0.75rem 1.5rem;
    margin: -2rem -2rem 1.5rem -2rem;
    /* Saca el header para que ocupe todo el ancho */
    background-color: #007bff;
    color: white;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    font-size: 1.4rem;
}

.team-total-row {
    background-color: #f8f9fa;
    font-weight: 700;
    border-top: 2px solid #dee2e6;
}

.team-total-row td {
    color: #343a40;
}

/* --- Estilos para Página de Historial de Eventos --- */
/* Esta sección fue eliminada ya que la función fue removida del menú */
.history-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.user-list {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.user-list a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #495057;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.user-list a:hover {
    background-color: #e9ecef;
}

.user-list a.active {
    background-color: #007bff;
    color: white;
}

/* --- ESTILOS PARA NOTAS Y AGENDA (CUADRÍCULA) --- */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Ajustado min-width */
    gap: 1.5rem;
    margin-top: 2rem;
}

.note-card {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-left: 5px solid #007bff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.note-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.note-header h4 {
    margin: 0;
    font-size: 1.2rem;
    color: #343a40;
}

/* Permitir que títulos largos se envuelvan en varias líneas y romper palabras largas si es necesario */
.note-header h4,
.note-card .note-header h4 {
    white-space: normal; /* Permite saltos de línea automáticos */
    overflow-wrap: anywhere; /* Rompe palabras muy largas cuando es necesario */
    word-wrap: break-word; /* Compatibilidad legacy */
    word-break: break-word;
}

/* Asegurar que los campos dentro del contenido (cliente, empresa, etc.) también se ajusten */
.note-content p,
.note-content p strong,
.note-content span,
.note-content div {
    white-space: normal;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    font-size: 1.2rem;
    font-weight: 600;
    color: #343a40;
    cursor: pointer;
    text-align: left;
    white-space: normal; /* Permite que el título se envuelva si es muy largo */
}

.note-title-button:hover {
    color: #007bff;
}

.note-delete-btn {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease;
}

.note-delete-btn:hover {
    color: #dc3545;
}

.note-content {
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.7;
    color: #495057;
    flex-grow: 1;
    white-space: pre-wrap;
}

.note-footer {
    padding: 0.75rem 1.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 0.8rem;
    color: #6c757d;
    text-align: right;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* --- Estilos para Vista Previa de Notas con Formato --- */
.note-content-preview {
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.7;
    color: #495057;
    flex-grow: 1;

    /* Limita la altura y oculta el exceso */
    max-height: 150px;
    overflow: hidden;
    position: relative;
}

/* Añade un degradado en la parte inferior para indicar que hay más texto */
.note-content-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, white, rgba(255, 255, 255, 0));
}

/* Ajuste para que el contenido del modal no tenga el degradado */
#note-modal-content.note-content {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 1rem;
    /* Espacio para la barra de scroll */
}

/* --- NUEVOS ESTILOS PARA VISTA AGRUPADA DE CLIENTES (CRM.PHP) --- */
.content-grouped-view {
    display: grid;
    grid-template-columns: 250px 1fr; /* Sidebar de 250px y contenido principal */
    gap: 2rem;
    align-items: start; /* Alinea los elementos al inicio de la cuadrícula */
}

.sidebar-users {
    /* Reutiliza .list-card para la sidebar */
    padding: 1.5rem; /* Ajusta el padding si es necesario */
    position: sticky; /* Hace que la sidebar se quede fija al desplazarse */
    top: 2rem; /* Distancia desde la parte superior (ajusta si tu header es muy alto) */
    max-height: calc(100vh - 4rem); /* Ajusta la altura máxima para que quepa en la pantalla */
    overflow-y: auto; /* Agrega scroll si los usuarios son muchos */
    min-width: 280px; /* Ancho mínimo para evitar que se comprima */
    flex-shrink: 0; /* Evita que el sidebar se comprima en layouts flexbox */
}

.sidebar-users h3 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
    color: #343a40;
}

.user-list-navigation {
    list-style: none;
    padding: 0;
    margin: 0;
}

.user-list-navigation li {
    margin-bottom: 0.5rem;
}

.user-list-navigation a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #495057;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap; /* Evita que los nombres de usuario se rompan */
    overflow: hidden; /* Oculta el texto que exceda */
    text-overflow: ellipsis; /* Añade puntos suspensivos si el texto es muy largo */
}

.user-list-navigation a:hover {
    background-color: #e9ecef;
    color: #007bff;
}

.user-list-navigation a.active {
    background-color: #007bff;
    color: white;
    font-weight: 600;
}




/* --- Media Queries para Responsividad --- */

/* Teléfonos (hasta 576px) */
@media (max-width: 576px) {
    .main-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    .header-greeting h2 {
        font-size: 1.1rem;
        text-align: center;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .header-info {
        flex-direction: column;
        align-items: flex-start;
        border: none;
        padding: 0;
        width: 100%;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }

    .header-btn {
        flex-grow: 1;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .financial-summary-new {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .summary-item-new:not(:last-child)::after {
        content: none; /* Elimina el separador vertical en móvil */
    }

    .summary-item-new {
        border-bottom: 1px solid #eee;
        padding-bottom: 0.5rem;
    }

    .summary-item-new:last-child {
        border-bottom: none;
    }

    .summary-item-new p {
        font-size: 1.5rem;
    }

    .list-card {
        padding: 1.5rem;
    }

    .list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .list-card h3 {
        font-size: 1.2rem;
        width: 100%;
        text-align: center;
    }

    .list-header .header-actions {
        justify-content: flex-start; /* Alinear los botones al inicio dentro del list-header */
        margin-left: 0; /* Anular margen automático que los empujaba demasiado a la derecha */
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    /* Permitir que los botones dentro del list-header se ajusten en varias líneas */
    .list-header .action-button-header {
        white-space: normal;
    }

    /* Refuerzo: evitar que los botones del list-header se salgan del contenedor
       aplicando reglas más específicas que anulen white-space:nowrap global */
    .list-card .list-header .header-actions {
        flex-wrap: wrap;
        max-width: 100%;
        box-sizing: border-box;
    }

    .list-card .list-header .header-actions .action-button-header {
        white-space: normal !important;
        flex: 0 1 auto; /* permitir que los botones se reduzcan si hace falta */
        min-width: 0; /* evitar que el contenido fuerce ancho mayor */
    }

    /* Reglas adicionales para asegurar comportamiento de wrap dentro de list-header
       Mantener h3 y header-actions en la misma línea si hay espacio, y mover acciones
       a la siguiente línea cuando excedan el ancho disponible. */
    .list-card .list-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem;
    }

    .list-card .list-header > h3 {
        flex: 0 1 auto; /* no forzar crecimiento excesivo */
        margin: 0;
        white-space: normal;
        min-width: 180px; /* permite al título ocupar espacio suficiente antes del wrap */
    }

    .list-card .list-header > .header-actions {
        flex: 1 1 auto; /* ocupar el resto del espacio y envolver cuando sea necesario */
        display: flex;
        justify-content: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap;
        margin-left: 0 !important;
        max-width: 100%;
        box-sizing: border-box;
    }

/* Opción A: forzar que las acciones pasen a la línea siguiente cuando el ancho
   del viewport sea menor o igual a 1100px. Esto mantiene el título arriba y las
   acciones ocupando 100% del ancho del card, ajustándose hacia abajo. */
@media (max-width: 1100px) {
    .list-card .list-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .list-card .list-header > h3 {
        flex: 0 0 100%;
        width: 100%;
        text-align: left;
        margin-bottom: 0.5rem;
    }

    .list-card .list-header > .header-actions {
        flex: 0 0 100%;
        width: 100%;
        justify-content: flex-start;
        margin-top: 0;
    }

    .list-card .list-header .action-button-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.88rem;
    }
}

    .registro-panel {
        padding: 1rem;
    }

    .cliente-form-grid {
        grid-template-columns: 1fr;
    }

    .submit-button {
        font-size: 1rem;
        padding: 0.75rem;
    }

    table {
        min-width: unset; /* Permite que la tabla se encoja más */
        width: 100%;
    }

    /* Ocultar columnas específicas en pantallas pequeñas */
    /* Estas reglas son ejemplo. Ajusta según las columnas que tengas y quieras ocultar. */
    /* .table-container th:nth-child(2), /* Columna de ejemplo */
    /* .table-container td:nth-child(2) {
        display: none;
    } */

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .action-button {
        width: 100%;
    }

    .filter-buttons {
        justify-content: center;
    }

    .filter-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8em;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form input,
    .search-form button {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }

    .menu-title {
        font-size: 2rem;
    }

    .menu-subtitle {
        font-size: 1rem;
    }

    .menu-button {
        width: 100%;
        text-align: center;
        justify-content: center;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }

    .notes-grid {
        grid-template-columns: 1fr; /* Apila las notas en una sola columna */
    }

    .note-content-preview::after {
        height: 20px; /* Reduce el tamaño del degradado */
    }

    .history-layout {
        grid-template-columns: 1fr;
    }

    /* Ajustes para la nueva vista agrupada en móviles */
    .content-grouped-view {
        grid-template-columns: 1fr; /* Apila la sidebar y el contenido principal */
        gap: 1.5rem;
    }

    .sidebar-users {
        position: static; /* No sticky en pantallas pequeñas */
        max-height: none; /* No limita la altura */
        order: -1; /* Mueve la sidebar arriba en móviles */
        margin-bottom: 1.5rem; /* Espacio debajo de la sidebar */
    }

    .sidebar-users h3 {
        text-align: center;
    }

    .user-list-navigation {
        display: flex; /* Permite que los usuarios se muestren en fila */
        flex-wrap: wrap; /* Se envuelven si no hay espacio */
        justify-content: center; /* Centra los elementos */
        gap: 0.5rem; /* Espacio entre los elementos de la lista */
    }

    .user-list-navigation li {
        margin-bottom: 0; /* Elimina el margen inferior cuando están en fila */
    }

    .user-list-navigation a {
        padding: 0.5rem 0.8rem; /* Reduce el padding para botones más pequeños */
        font-size: 0.9rem;
    }
}

/* Tablets (577px a 991px) */
@media (min-width: 577px) and (max-width: 991px) {
    .main-container {
        padding: 0 1.5rem;
    }

    .main-header {
        flex-direction: row; /* Vuelve a la fila normal */
        flex-wrap: wrap; /* Asegura que se envuelva si es necesario */
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }

    .header-greeting {
        flex-basis: 100%; /* Ocupa todo el ancho */
        text-align: center;
        margin-bottom: 1rem;
    }
    .header-greeting h2 {
        font-size: 1.3rem;
    }

    .header-info {
        border-left: none;
        border-right: none;
        padding: 0;
        flex-grow: 1; /* Permite que ocupen el espacio */
        justify-content: center;
        gap: 1rem;
        flex-direction: row;
        margin-bottom: 1rem; /* Espacio debajo de la info de usuario/estadísticas */
    }
    .header-info { order: 2; } /* Reordenar para que la info vaya debajo del saludo */

    .header-actions {
        width: 100%; /* Los botones ocupan todo el ancho */
        justify-content: center;
        order: 4; /* Vienen después de la info/stats */
    }

    .financial-summary-new {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 1rem;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cliente-form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-container table {
        min-width: 700px; /* Mantén un ancho mínimo para la tabla */
    }

    .client-dashboard {
        grid-template-columns: 1fr; /* Apila sidebar y main-content */
    }

    .notes-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .history-layout {
        grid-template-columns: 1fr;
    }

    /* Ajustes para la nueva vista agrupada en tablets */
    .content-grouped-view {
        grid-template-columns: 1fr; /* Apila la sidebar y el contenido principal */
        gap: 1.5rem;
    }

    .sidebar-users {
        position: static; /* No sticky en pantallas pequeñas */
        max-height: none; /* No limita la altura */
        order: -1; /* Mueve la sidebar arriba en móviles */
        margin-bottom: 1.5rem; /* Espacio debajo de la sidebar */
    }

    .sidebar-users h3 {
        text-align: center;
    }

    .user-list-navigation {
        display: flex; /* Permite que los usuarios se muestren en fila */
        flex-wrap: wrap; /* Se envuelven si no hay espacio */
        justify-content: center; /* Centra los elementos */
        gap: 0.75rem; /* Espacio entre los elementos de la lista */
    }

    .user-list-navigation li {
        margin-bottom: 0; /* Elimina el margen inferior cuando están en fila */
    }

    .user-list-navigation a {
        padding: 0.6rem 1rem; /* Ajusta el padding para botones más grandes que móvil */
        font-size: 0.95rem;
    }
}

/* Escritorio (992px y más) */
@media (min-width: 992px) {
    .panels-container {
        grid-template-columns: 1fr 1fr;
    }

    .client-dashboard {
        grid-template-columns: 400px 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr; /* Vuelve a dos columnas por defecto */
    }

    .history-layout {
        grid-template-columns: 280px 1fr; /* Barra lateral más angosta */
    }

    /* Para la vista agrupada en escritorio, se mantienen las 2 columnas */
    .content-grouped-view {
        grid-template-columns: 250px 1fr;
    }
}

/* Final override: asegurar que las acciones dentro de list-header nunca desborden */
.list-card .list-header .header-actions {
    margin-left: 0 !important;
    flex-wrap: wrap !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.list-card .list-header .header-actions .action-button-header {
    white-space: normal !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
}

/* Si algún ancho interno fuerza overflow, permitir que el contenedor envuelva y empuje hacia abajo */
.list-card .list-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
}