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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2B9D9C 0%, #1E7A79 50%, #2B9D9C 100%);
    background-size: 400% 400%;
    animation: gradientFlow 8s ease-in-out infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    box-sizing: border-box;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container, .calculator-container, .dashboard-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    margin: 20px auto;
    animation: slideIn 0.5s ease-out;
    box-sizing: border-box;
}

.dashboard-container {
    max-width: 800px;
    padding: 30px;
}

.login-container {
    max-width: 400px;
    text-align: center;
}

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

.header, .login-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header h1, .login-header h1 {
    color: #333;
    font-size: 2.2em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #2B9D9C, #1E7A79);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header h1 {
    font-size: 2em;
}

.header p, .login-header p {
    color: #666;
    font-size: 1em;
}

.login-header p {
    font-size: 0.9em;
    font-style: italic;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 1.1em;
}

.input-field {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1.1em;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.input-field:focus {
    outline: none;
    border-color: #2B9D9C;
    background: white;
    box-shadow: 0 0 0 3px rgba(43, 157, 156, 0.1);
    transform: translateY(-2px);
}

/* Estilos específicos para select */
select.input-field {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

select.input-field:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%232B9D9C' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

.unit {
    color: #888;
    font-size: 0.9em;
    margin-top: 5px;
}

.calculate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #2B9D9C, #1E7A79);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.calculate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(43, 157, 156, 0.3);
}

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

.result-container {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    margin-top: 20px;
    display: none;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-container.show {
    display: block;
}

.result-title {
    color: white;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 15px;
}

.result-value {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
}

.insulin-units {
    font-size: 3em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.units-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1em;
    margin-top: 5px;
}

.calculation-details {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    text-align: left;
}

.calculation-step {
    color: white;
    margin: 8px 0;
    font-size: 0.95em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-btn {
    background: none;
    color: #2B9D9C;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    margin: 0 auto 20px auto;
    transition: all 0.3s ease;
    display: block;
}

.info-btn:hover {
    transform: scale(1.2);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: linear-gradient(135deg, #2B9D9C 0%, #1E7A79 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideInModal 0.3s ease-out;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

@keyframes slideInModal {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    color: white;
    font-weight: 600;
    font-size: 1.3em;
    margin-bottom: 20px;
    text-align: center;
}

.modal-body {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.6;
}

.formula-section {
    margin-bottom: 15px;
}

.formula-title {
    color: white;
    font-weight: bold;
    margin-bottom: 8px;
}

.formula-item {
    color: rgba(255, 255, 255, 0.9);
    margin-left: 15px;
    margin-bottom: 5px;
}

.formula-calc {
    color: rgba(255, 255, 255, 0.95);
    margin-left: 15px;
    margin-bottom: 8px;
}

.formula-result {
    color: white;
    margin-left: 15px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin-top: 10px;
}

.formula-example {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9em;
    text-align: center;
    margin-top: 15px;
    font-style: italic;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.close-btn-calculator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.close-btn-calculator:hover {
    background: rgba(0, 0, 0, 1);
    transform: scale(1.1);
}

.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    display: none;
}

.error.show {
    display: block;
}

.install-banner {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 15px;
    text-align: center;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 1001;
    max-width: 300px;
    width: 90%;
}

.install-banner.show {
    display: block;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.install-btn {
    background: white;
    color: #28a745;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
}

.parameters-section {
    background: rgba(43, 157, 156, 0.05);
    border-radius: 15px;
    padding: 0;
    margin: 25px 0;
    border: 1px solid rgba(43, 157, 156, 0.1);
    overflow: hidden;
}

.parameters-header {
    background: rgba(43, 157, 156, 0.1);
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.parameters-header:hover {
    background: rgba(43, 157, 156, 0.15);
}

.parameters-header h3 {
    color: #333;
    font-size: 1.1em;
    margin: 0;
}

.accordion-arrow {
    font-size: 1.2em;
    color: #2B9D9C;
    transition: transform 0.3s ease;
}

.accordion-arrow.expanded {
    transform: rotate(180deg);
}

.parameters-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.parameters-content.expanded {
    max-height: 400px;
    padding: 20px;
}

.parameters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.parameter-group {
    text-align: center;
}

.parameter-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 0.95em;
}

.parameter-field {
    padding: 10px;
    font-size: 1em;
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
}

.parameter-field:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(43, 157, 156, 0.2);
}

.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.dashboard-header img {
    height: 60px;
    margin-bottom: 15px;
}

.dashboard-header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #2B9D9C, #1E7A79);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-header p {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 20px;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.module-circle {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.module-circle:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.module-active {
    background: linear-gradient(135deg, #2B9D9C, #1E7A79);
    color: white;
}

.module-active:hover {
    background: linear-gradient(135deg, #1E7A79, #2B9D9C);
}

.module-dummy {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #6c757d;
    cursor: not-allowed;
}

.module-dummy:hover {
    transform: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.module-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.module-title {
    font-size: 0.9em;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.coming-soon {
    position: initial;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #666;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

@media (max-width: 600px) {
    .calculator-container, .login-container, .dashboard-container {
        padding: 25px;
        margin: 10px;
    }
    
    .header h1, .login-header h1, .dashboard-header h1 {
        font-size: 1.8em;
    }
    
    .insulin-units {
        font-size: 2.5em;
    }

    .parameters-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .module-icon {
        font-size: 2em;
    }

    .module-title {
        font-size: 0.8em;
    }
    
    .parameters-content.expanded {
        max-height: 500px;
    }
}

/* Estilos adicionales para comentarios e historial */
/* Agregar estos estilos al archivo assets/css/styles.css existente */

/* === CAMPO DE COMENTARIOS === */
.input-group textarea.input-field {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    line-height: 1.4;
}

#commentCounter {
    font-size: 0.8em;
    transition: color 0.3s ease;
}

/* === BOTÓN DE LOGOUT === */
.logout-section {
    margin-top: 30px;
    text-align: center;
    padding: 20px;
}

.logout-btn {
    background: rgba(255, 107, 107, 0.2);
    border: 2px solid #ff6b6b;
    color: #ff6b6b;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.logout-btn:hover {
    background: #ff6b6b;
    color: white;
    transform: translateY(-2px);
}

/* === SECCIÓN DE HISTORIAL === */
.history-section {
    margin-top: 30px;
    background: rgba(30, 30, 30, 0.95) !important; /* Fondo oscuro sólido */
    border-radius: 15px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-header {
    padding: 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(40, 40, 40, 0.8); /* Fondo más oscuro */
    transition: background-color 0.3s ease;
}

.history-header:hover {
    background: rgba(50, 50, 50, 0.8);
}

.history-header h3 {
    margin: 0;
    color: #ffffff; /* Blanco sólido */
    font-size: 1.1em;
    font-weight: 600;
}

.history-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.history-content.expanded {
    max-height: 800px;
    padding-bottom: 20px;
}

.history-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: rgba(35, 35, 35, 0.9); /* Fondo oscuro */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8em;
    color: #b0b0b0; /* Gris claro */
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.1em;
    font-weight: bold;
    color: #4ECDC4; /* Turquesa - mantiene el color original */
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(25, 25, 25, 0.95); /* Fondo muy oscuro */
}

.history-item {
    background: rgba(45, 45, 45, 0.9); /* Fondo gris oscuro */
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-item:hover {
    background: rgba(55, 55, 55, 0.9);
    transform: translateY(-1px);
    border-color: rgba(78, 205, 196, 0.3);
}

.history-summary {
    padding: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: between;
    gap: 15px;
}

.history-date {
    font-size: 0.9em;
    color: #a0a0a0; /* Gris más claro */
    min-width: 120px;
}

.history-result {
    font-size: 1.2em;
    font-weight: bold;
    color: #4ECDC4; /* Turquesa */
    min-width: 60px;
}

.history-main-data {
    flex: 1;
    color: #f0f0f0; /* Blanco suave */
    font-size: 0.95em;
}

.history-comment-indicator {
    font-size: 1.2em;
    margin-left: 10px;
    color: #FFD93D; /* Amarillo */
}

.history-arrow {
    font-size: 0.8em;
    color: #888888; /* Gris medio */
    transition: transform 0.3s ease;
    min-width: 20px;
    text-align: center;
}

.history-details {
    padding: 0 15px 15px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(20, 20, 20, 0.9); /* Fondo muy oscuro */
}

.history-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.detail-label {
    color: #a0a0a0; /* Gris claro */
    font-size: 0.9em;
}

.detail-value {
    color: #f0f0f0; /* Blanco suave */
    font-weight: 500;
}

.detail-calculation {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 5px;
    padding-top: 12px;
}

.detail-final {
    grid-column: 1 / -1;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    margin-top: 10px;
    padding-top: 12px;
    font-weight: bold;
}

.detail-final .detail-value {
    color: #4ECDC4; /* Turquesa */
    font-size: 1.1em;
}

.detail-comment {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 10px;
    padding-top: 12px;
}

.comment-text {
    font-style: italic;
    color: #FFD93D; /* Amarillo */
    margin-left: 10px;
}

.loading-message,
.no-history-message,
.error-message {
    text-align: center;
    color: #b0b0b0; /* Gris claro */
    padding: 20px;
    font-style: italic;
}

.load-more-btn {
    display: block;
    margin: 20px auto;
    padding: 10px 20px;
    background: rgba(60, 60, 60, 0.8); /* Fondo gris oscuro */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff; /* Texto blanco */
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    background: rgba(78, 205, 196, 0.3); /* Turquesa al hover */
    border-color: #4ECDC4;
    transform: translateY(-1px);
}

/* === INFO DE USUARIO === */
.user-info {
    margin-top: 10px;
    font-size: 0.9em;
    color: #d0d0d0; /* Gris muy claro */
    text-align: center;
    background: rgba(30, 30, 30, 0.8);
    padding: 10px;
    border-radius: 8px;
}

.user-name {
    font-weight: bold;
    color: #4ECDC4; /* Turquesa */
}

.user-role {
    color: #FFD93D; /* Amarillo */
    font-size: 0.8em;
}

/* === SCROLLBAR PERSONALIZADA === */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(78, 205, 196, 0.5);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(78, 205, 196, 0.7);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .history-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .stat-label,
    .stat-value {
        display: inline;
        margin: 0;
    }
    
    .history-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .history-date {
        min-width: auto;
    }
    
    .history-details-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-final {
        grid-column: 1;
    }
}

/* === FORZAR FULL WIDTH EN MOBILE === */
@media (max-width: 768px) {
    /* Contenedor principal más ancho */
    .dashboard-container {
        max-width: 100%; /* Quitar límite de ancho */
        width: 100%;
        margin: 10px 0; /* Quitar márgenes laterales */
        padding: 20px 10px; /* Padding más pequeño */
        box-sizing: border-box;
    }

    /* Grid de módulos full width */
    .modules-grid {
        grid-template-columns: 1fr; /* Una sola columna */
        gap: 10px;
        margin-top: 20px;
        width: 100%;
    }

    /* Módulos individuales full width */
    .module-circle {
        width: 100%; /* Forzar ancho completo */
        aspect-ratio: auto; /* Quitar ratio cuadrado */
        border-radius: 15px; /* Rectángulo redondeado */
        min-height: 80px;
        flex-direction: row; /* Horizontal */
        padding: 20px 15px;
        justify-content: flex-start;
        text-align: left;
        box-sizing: border-box;
    }

    .module-icon {
        font-size: 2.5em;
        margin-bottom: 0;
        margin-right: 20px;
        min-width: 60px;
        flex-shrink: 0; /* No se encoge */
    }

    .module-title {
        font-size: 1.1em;
        text-align: left;
        flex: 1;
        line-height: 1.3;
    }

    .coming-soon {
        position: absolute;
        top: 10px;
        right: 15px;
        font-size: 0.8em;
        padding: 4px 8px;
        border-radius: 12px;
    }
}

/* === PANTALLAS MUY PEQUEÑAS === */
@media (max-width: 480px) {
    .dashboard-container {
        margin: 5px 0;
        padding: 15px 5px;
    }

    .module-circle {
        min-height: 70px;
        padding: 15px 10px;
    }

    .module-icon {
        font-size: 2.2em;
        margin-right: 15px;
        min-width: 50px;
    }

    .module-title {
        font-size: 1em;
    }
}

/* === OVERRIDE PARA ASEGURAR FULL WIDTH === */
@media (max-width: 768px) {
    body {
        padding: 10px 0; /* Quitar padding lateral del body */
    }
    
    .login-container, 
    .calculator-container, 
    .dashboard-container {
        margin: 10px 5px; /* Márgenes mínimos */
        max-width: none; /* Quitar restricción de ancho */
        width: calc(100% - 10px); /* Ancho completo menos márgenes */
    }
}

/* === LAYOUT DESKTOP CON HISTORIAL A LA DERECHA === */
@media (min-width: 769px) {
    .calculator-container {
        max-width: 1200px; /* Más ancho en desktop */
        display: flex;
        gap: 30px;
        align-items: flex-start;
    }
    
    .calculator-main {
        flex: 1;
        min-width: 400px;
        max-width: 500px;
    }
    
    .calculator-sidebar {
        flex: 1;
        min-width: 350px;
        max-width: 450px;
    }
    
    /* Historial siempre expandido en desktop */
    .history-section .history-content {
        max-height: none !important;
        padding: 0 !important;
    }
    
    .history-section .history-content.expanded {
        max-height: none;
        padding: 0;
    }
    
    /* Header del historial en desktop */
    .history-header {
        padding: 15px 20px;
        cursor: default; /* No clickeable en desktop */
    }
    
    .history-header .accordion-arrow {
        display: none; /* Ocultar flecha en desktop */
    }
}

/* === LAYOUT MOBILE MEJORADO === */
@media (max-width: 768px) {
    .calculator-container {
        padding: 20px 10px;
        margin: 10px 5px;
    }
    
    /* Layout vertical en mobile */
    .calculator-main,
    .calculator-sidebar {
        width: 100%;
    }
    
    /* Historial en mobile */
    .history-section {
        margin-top: 25px;
        background: rgba(30, 30, 30, 0.95) !important;
        border-radius: 15px;
    }
    
    .history-header {
        padding: 15px;
        cursor: pointer;
    }
    
    .history-stats {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .stat-item:last-child {
        border-bottom: none;
    }
    
    .stat-label,
    .stat-value {
        display: inline;
        margin: 0;
    }
    
    .stat-label {
        font-size: 0.9em;
        color: #b0b0b0;
    }
    
    .stat-value {
        font-size: 1em;
        font-weight: bold;
        color: #4ECDC4;
    }
    
    /* Lista de historial en mobile */
    .history-list {
        max-height: 300px; /* Altura fija en mobile */
        padding: 5px;
    }
    
    .history-item {
        margin-bottom: 8px;
        background: rgba(45, 45, 45, 0.9);
    }
    
    .history-summary {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .history-date {
        font-size: 0.85em;
        color: #a0a0a0;
        min-width: auto;
    }
    
    .history-result {
        font-size: 1.1em;
        font-weight: bold;
        color: #4ECDC4;
        align-self: flex-end;
        margin-top: -20px;
    }
    
    .history-main-data {
        color: #f0f0f0;
        font-size: 0.9em;
        width: 100%;
    }
    
    .history-arrow {
        position: absolute;
        top: 12px;
        right: 12px;
        font-size: 0.8em;
    }
    
    /* Detalles en mobile */
    .history-details {
        padding: 0 12px 12px 12px;
    }
    
    .history-details-grid {
        grid-template-columns: 1fr; /* Una columna en mobile */
        gap: 8px;
        margin-top: 10px;
    }
    
    .detail-item {
        padding: 6px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .detail-item:last-child {
        border-bottom: none;
    }
    
    .detail-label {
        font-size: 0.85em;
        margin-bottom: 2px;
        color: #a0a0a0;
    }
    
    .detail-value {
        color: #f0f0f0;
        font-weight: 500;
        font-size: 0.9em;
    }
    
    .detail-final {
        border-top: 2px solid rgba(255, 255, 255, 0.2);
        margin-top: 8px;
        padding-top: 8px;
        font-weight: bold;
    }
    
    .detail-final .detail-value {
        color: #4ECDC4;
        font-size: 1em;
    }
    
    .comment-text {
        font-style: italic;
        color: #FFD93D;
        font-size: 0.85em;
        margin-top: 5px;
        display: block;
    }
}

/* === LAYOUT DESKTOP: HISTORIAL Y PARÁMETROS A LA DERECHA === */
@media (min-width: 1024px) {
    .calculator-container {
        display: flex;
        gap: 30px;
        max-width: 1200px;
        align-items: flex-start;
    }
    
    .calculator-main {
        flex: 1;
        max-width: 500px;
    }
    
    .calculator-sidebar {
        flex: 1;
        max-width: 400px;
    }
}

/* === CORREGIR LAYOUT DESKTOP - MOSTRAR AMBAS COLUMNAS === */
@media (min-width: 1024px) {
    .calculator-container {
        display: flex !important;
        flex-direction: row !important;
        gap: 30px;
        max-width: 1000px;
        width: 80% !important;
        align-items: flex-start;
        padding: 50px !important;
    }
    
    .calculator-main {
        flex: 1;
        max-width: 500px;
        min-width: 400px;
    }
    
    .calculator-sidebar {
        flex: 1;
        max-width: 400px;
        min-width: 350px;
    }
    
    /* Asegurar que ambas partes sean visibles */
    .calculator-main,
    .calculator-sidebar {
        display: block;
        opacity: 1;
    }
}

/* === CORREGIR: SOLO APLICAR LAYOUT CUANDO CALCULADORA ESTÉ VISIBLE === */
@media (min-width: 1024px) {
    /* Solo aplicar flexbox cuando la calculadora esté visible */
    .calculator-container:not([style*="display: none"]) {
        display: flex !important;
        flex-direction: row !important;
        gap: 30px;
        max-width: 1200px;
        width: 100%;
        align-items: flex-start;
        padding: 30px;
    }
    
    .calculator-container:not([style*="display: none"]) .calculator-main {
        flex: 1;
        max-width: 500px;
        min-width: 400px;
    }
    
    .calculator-container:not([style*="display: none"]) .calculator-sidebar {
        flex: 1;
        max-width: 400px;
        min-width: 350px;
    }
    
    /* Cuando la calculadora NO esté visible, asegurar que esté oculta */
    .calculator-container[style*="display: none"] {
        display: none !important;
    }
    
    /* En el dashboard, la calculadora debe estar oculta */
    .dashboard-container:not([style*="display: none"]) ~ .calculator-container {
        display: none !important;
    }
}

/* === MODAL PARA RESULTADO DE INSULINA === */
.result-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.result-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-modal-content {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideInModal 0.3s ease-out;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.result-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.result-modal-title {
    color: white;
    font-size: 1.4em;
    font-weight: 600;
    margin: 0;
}

.result-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.result-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.result-modal-body {
    text-align: center;
}

.result-modal .result-value {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin: 15px 0;
}

.result-modal .insulin-units {
    font-size: 3.5em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.result-modal .units-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    margin-top: 8px;
}

.result-modal .calculation-details {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    text-align: left;
}

.result-modal .calculation-step {
    color: white;
    margin: 10px 0;
    font-size: 1em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.result-modal .calculation-step:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive para el modal */
@media (max-width: 768px) {
    .result-modal-content {
        padding: 20px;
        margin: 20px;
        max-width: none;
        width: calc(100% - 40px);
    }
    
    .result-modal .insulin-units {
        font-size: 2.8em;
    }
    
    .result-modal .calculation-step {
        font-size: 0.9em;
    }
}

/* === CENTRAR CONTENIDO DE LA CALCULADORA === */
@media (min-width: 1024px) {
    .calculator-main {
        text-align: center;
    }
    
    .calculator-main .header {
        text-align: center;
    }
    
    .calculator-main .input-group {
        text-align: left; /* Mantener los campos alineados a la izquierda para mejor UX */
        max-width: 400px;
        margin: 0 auto 25px auto; /* Centrar los grupos de input */
    }
    
    .calculator-main .calculate-btn {
        margin: 20px auto;
        display: block;
    }
    
    .calculator-main #errorContainer {
        max-width: 400px;
        margin: 0 auto;
    }
}

/* === CORREGIR ÍCONO DEL MODAL === */
.result-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: Arial, sans-serif; /* Asegurar que use una fuente que tenga el símbolo × */
}

.result-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.result-modal-close:before {
    content: "×";
    font-size: 24px;
    line-height: 1;
}

/* === CORREGIR ÍCONO DEL MODAL - OVERRIDE === */
.result-modal-close {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    width: 35px !important;
    height: 35px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    font-family: Arial, sans-serif !important;
    font-size: 20px !important;
}

.result-modal-close::before {
    content: "✕" !important;
    font-size: 18px !important;
    line-height: 1 !important;
}

.result-modal-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.1) !important;
}

/* === CENTRAR CALCULADORA - OVERRIDE MÁS ESPECÍFICO === */
@media (min-width: 1024px) {
    .calculator-container .calculator-main {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .calculator-container .calculator-main .header {
        text-align: center !important;
        margin-bottom: 30px !important;
    }
    
    .calculator-container .calculator-main #insulinForm {
        width: 100% !important;
        max-width: 400px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .calculator-container .calculator-main .input-group {
        width: 100% !important;
        max-width: 400px !important;
        text-align: left !important;
        margin-bottom: 25px !important;
    }
    
    .calculator-container .calculator-main .calculate-btn {
        width: 100% !important;
        max-width: 400px !important;
        margin: 20px 0 !important;
    }
    
    .calculator-container .calculator-main #errorContainer {
        width: 100% !important;
        max-width: 400px !important;
    }
}

/* === FORZAR CENTRADO COMPLETO DE LA CALCULADORA === */
@media (min-width: 1024px) {
    .calculator-container {
        justify-content: center !important;
        align-items: flex-start !important;
    }
    
    .calculator-main {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 500px !important;
        margin: 0 auto !important;
    }
    
    .calculator-main .header {
        width: 100% !important;
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .calculator-main .header h1,
    .calculator-main .header p,
    .calculator-main .header img,
    .calculator-main .header .info-btn {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .calculator-main form {
        width: 100% !important;
        max-width: 400px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .calculator-main .input-group {
        width: 100% !important;
        margin: 0 0 25px 0 !important;
        text-align: left !important;
    }
    
    .calculator-main .input-group label {
        display: block !important;
        text-align: left !important;
    }
    
    .calculator-main .calculate-btn {
        width: 100% !important;
        margin: 20px 0 !important;
        align-self: stretch !important;
    }
    
    .calculator-main #errorContainer {
        width: 100% !important;
        max-width: 400px !important;
        margin: 0 auto !important;
    }
}

/* === AJUSTAR CENTRADO PERFECTO DE LA CALCULADORA === */
@media (min-width: 1024px) {
    .calculator-container {
        display: flex !important;
        gap: 30px !important;
        max-width: 1200px !important;
        margin: 0 auto !important;
        padding: 30px !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
    }
    
    .calculator-main {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        max-width: 500px !important;
        margin: 0 !important;
        padding: 0 20px !important; /* Agregar padding interno */
    }
    
    .calculator-sidebar {
        flex: 1 !important;
        max-width: 400px !important;
        min-width: 350px !important;
    }
    
    /* Asegurar que ambas columnas tengan el mismo peso visual */
    .calculator-main,
    .calculator-sidebar {
        flex-basis: 50% !important;
    }
}

/* === CENTRADO VISUAL PERFECTO === */
@media (min-width: 1024px) {
    .calculator-main .header {
        width: 100% !important;
        text-align: center !important;
        margin-bottom: 30px !important;
    }
    
    .calculator-main .header * {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .calculator-main form {
        width: 100% !important;
        max-width: 380px !important; /* Reducir un poco el ancho máximo */
        margin: 0 auto !important;
    }
    
    .calculator-main .input-group {
        width: 100% !important;
        margin-bottom: 25px !important;
    }
    
    .calculator-main .calculate-btn {
        width: 100% !important;
        max-width: 380px !important;
        margin: 20px auto !important;
        display: block !important;
    }
}

/* === CENTRADO PERFECTO - AJUSTE FINAL === */
@media (min-width: 1024px) {
    .calculator-main {
        margin-left: -15px !important; /* Mover ligeramente hacia la izquierda */
        padding-left: 0 !important;
        padding-right: 40px !important; /* Más padding a la derecha para compensar */
    }
    
    /* Alternativamente, ajustar el gap del container */
    .calculator-container {
        gap: 20px !important; /* Reducir gap para que la calculadora se centre mejor */
    }
    
    /* Centrar específicamente el contenido dentro de calculator-main */
    .calculator-main .header,
    .calculator-main form,
    .calculator-main .calculate-btn,
    .calculator-main #errorContainer {
        transform: translateX(-10px) !important; /* Mover todo el contenido ligeramente a la izquierda */
    }
}