        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f7f7f7;
        }

        header {
            background-color: #0078D4;
            color: white;
            padding: 10px 20px;
            font-size: 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
        }

        .brand-logo {
            position: relative;
            display: block;
            width: 56px;
            height: 56px;
            flex: 0 0 56px;
            overflow: hidden;
            border-radius: 12px;
            background: #ffffff;
        }

        .brand-logo img {
            position: absolute;
            width: 120px;
            max-width: none;
            height: auto;
            left: -31px;
            top: -47px;
        }

        .brand-name {
            white-space: nowrap;
        }

        nav {
            display: flex;
            justify-content: center;
            background: #004085;
            padding: 10px;
            position: relative;
        }

        nav a {
            margin: 0 15px;
            color: white;
            text-decoration: none;
            font-size: 18px;
            padding: 5px 10px;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }

        nav a:hover {
            background-color: #016db3;
        }

        .nav-dropdown {
            position: relative;
        }

        .nav-dropdown > a {
            display: block;
            margin: 0;
        }

        .nav-chevron {
            display: inline-block;
            margin-left: 3px;
            font-size: 0.9em;
            transition: transform 0.2s ease;
        }

        .nav-dropdown:has(.derivaciones-options:not(.hidden)) .nav-chevron {
            transform: rotate(180deg);
        }

        .derivaciones-options {
            position: absolute;
            top: calc(100% + 5px);
            left: 0;
            z-index: 20;
            min-width: 220px;
            padding: 6px;
            border-radius: 6px;
            background: #ffffff;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .derivaciones-options button {
            display: block;
            width: 100%;
            padding: 9px 10px;
            border: 0;
            border-radius: 4px;
            background: transparent;
            color: #004085;
            text-align: left;
            font: inherit;
            cursor: pointer;
        }

        .derivaciones-options button:hover {
            background: #eaf4fc;
        }

        section {
            padding: 20px;
        }

        .hidden {
            display: none;
        }

        .fecha-display {
            text-align: center;
            margin: 20px 0;
            padding: 15px;
            background: white;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            font-size: 1.2em;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .fecha-display span {
            margin: 0 10px;
            font-weight: bold;
            color: #004085;
        }

        .turnos {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 20px;
            padding: 15px;
        }

        .turno {
            background-color: #e0e0e0;
            text-align: left;
            padding: 15px;
            border-radius: 5px;
            cursor: pointer;
        }

        .turno.libre {
            background-color: #8bc34a;
        }

        .turno.ocupado {
            background-color: #ff5252;
            color: white;
            cursor: not-allowed;
        }

        .turno:hover:not(.ocupado) {
            background-color: #afe2af;
        }
        
        .turno.ocupado:hover {
            background-color: #e53935; /* Slightly darker red for hover on occupied */
        }


        .especialistas, .farmacias {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 15px;
        }

        .card {
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 15px;
            background: white;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .contador {
            margin-top: 10px;
            font-size: 18px;
        }
        
        .auth-modal { /* Generic class for login and registration modals */
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: white;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            padding: 20px;
            border-radius: 5px;
            display: none;
            z-index: 1000;
            width: 320px; /* Ensure consistent width */
        }
        
        .auth-modal.show {
            display: block;
        }

        #overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            display: none;
            z-index: 999;
        }

        #overlay.show {
            display: block;
        }

        .auth-modal input, .auth-modal select, .auth-modal button {
            width: calc(100% - 22px); /* Account for padding and border */
            margin: 8px 0;
            padding: 10px;
            box-sizing: border-box; /* Add box-sizing */
        }
        
        .auth-modal button {
            background-color: #0078D4;
            color: white;
            border: none;
            cursor: pointer;
        }
        .auth-modal button:hover {
            background-color: #016db3;
        }
        .auth-modal .secondary-action {
            background-color: #6c757d;
        }
        .auth-modal .secondary-action:hover {
            background-color: #5a6268;
        }
        .auth-modal a {
            display: block;
            text-align: center;
            margin-top: 10px;
            color: #0078D4;
            cursor: pointer;
            font-size: 0.9em;
        }
        .auth-modal a:hover {
            text-decoration: underline;
        }
        .auth-modal h2 {
            margin-top: 0;
            color: #004085;
            text-align: center;
        }

        #registrationModal { 
            background-color: #f0f0f0; 
            max-height: calc(100vh - 24px);
            overflow-y: auto;
        }

        .terms-container {
            margin: 12px 0 8px;
            padding: 10px;
            border: 1px solid #b8cbe0;
            border-radius: 5px;
            background: #ffffff;
        }

        .terms-container legend {
            padding: 0 5px;
            color: #004085;
            font-size: 0.95em;
            font-weight: bold;
        }

        .terms-content {
            max-height: 150px;
            overflow-y: auto;
            padding: 4px 8px;
            border: 1px solid #e1e6eb;
            border-radius: 4px;
            background: #f8fbff;
            color: #333;
            font-size: 0.82em;
            line-height: 1.4;
        }

        .terms-content p {
            margin: 4px 0 8px;
        }

        .terms-content ul {
            margin: 0;
            padding-left: 18px;
        }

        .terms-content li {
            margin-bottom: 7px;
        }

        .terms-acceptance {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            margin: 10px 0 0;
            color: #333;
            font-size: 0.85em;
            line-height: 1.35;
            cursor: pointer;
        }

        .auth-modal .terms-acceptance input[type="checkbox"] {
            width: auto;
            flex: 0 0 auto;
            margin: 2px 0 0;
            padding: 0;
        }

        .terms-validation-message {
            margin: 8px 0 0;
            color: #b02a37;
            font-size: 0.8em;
        }

        .terms-container.invalid {
            border-color: #dc3545;
        }

        #passwordRecoveryEmailModal, #passwordResetModal { /* Style for new recovery modals */
            background-color: #f0f0f0;
        }
        .password-requirements {
            font-size: 0.8em;
            color: #555;
            margin-top: 5px;
            margin-bottom: 10px;
            text-align: left;
            padding-left: 2px; 
        }

        /* User Profile Menu Styles */
        #user-profile-menu {
            position: relative;
            cursor: pointer;
            font-size: 16px;
        }
        #user-info-display {
            padding: 5px 10px;
            border: 1px solid #016db3;
            border-radius: 5px;
            background-color: #0062a8;
            text-align: right;
        }
        #user-info-display:hover {
            background-color: #016db3;
        }
        #user-profile-role {
            font-size: 0.8em;
            font-style: italic;
            display: block;
            color: #e0e0e0;
        }
        #user-profile-specialty {
            font-size: 0.85em;
            font-weight: bold;
            display: block;
            color: #ffffff;
        }
        #user-profile-dropdown {
            position: absolute;
            right: 0;
            top: 100%;
            margin-top: 5px;
            background-color: white;
            border: 1px solid #ddd;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.15);
            z-index: 1002;
            width: 200px;
            overflow: hidden;
        }
        #user-profile-dropdown a {
            display: block;
            padding: 10px 15px;
            color: #333;
            text-decoration: none;
            font-size: 14px;
        }
        #user-profile-dropdown a:hover {
            background-color: #f0f0f0;
        }

        /* Profile Info Modal Styles */
        #profileInfoModal p {
            margin: 10px 0;
            font-size: 1em;
            color: #333;
        }
        #profileInfoModal p strong {
            color: #004085;
        }

        .medicos-disponibles {
            margin-top: 20px;
            padding: 15px;
            background: white;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }

        .medicos-disponibles h3 {
            color: #004085;
            margin-bottom: 15px;
        }

        .medicos-semana {
            border-left: 1px solid #ddd;
            padding-left: 20px;
        }

        .dia-medicos {
            margin-bottom: 15px;
        }

        .dia-medicos h4 {
            color: #0078D4;
            margin: 5px 0;
        }

        .dia-medicos p {
            margin: 3px 0;
            font-size: 0.9em;
        }

        .turno-info {
            display: none;
            margin-top: 10px;
        }

        .turno.ocupado .turno-info {
            display: block;
        }

        .turno-info input {
            width: 100%;
            margin: 5px 0;
            padding: 5px;
            border: 1px solid #ddd;
            border-radius: 3px;
            box-sizing: border-box;
        }

        .turno-info-content {
            padding-top: 5px;
            font-size: 0.85em;
            line-height: 1.3;
            text-align: center;
        }
        .turno-info-content p {
            margin: 2px 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .turno.ocupado .turno-info-content p {
            color: white;
        }
        .turno.ocupado .turno-info-content em {
            color: #f0f0f0;
        }

        .turno-hora {
            font-weight: bold;
            color: #004085;
        }

        .dia-columna {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .dia-header {
            background-color: #004085;
            color: white;
            padding: 10px;
            text-align: center;
            border-radius: 5px;
            margin-bottom: 5px;
        }

        .turno-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            z-index: 1001; /* Higher than auth modals */
            display: none;
            width: 300px;
        }

        .turno-modal.show {
            display: block;
        }

        .turno-modal input {
            width: calc(100% - 18px); /* Account for padding and border */
            margin: 10px 0;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .turno-modal button {
            width: 100%;
            padding: 10px;
            background: #0078D4;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 10px;
        }

        .turno-modal button:hover {
            background: #016db3;
        }

        .turno-modal h3 {
            margin-top: 0;
            color: #004085;
        }

        .turno-modal label { 
            display: block;
            margin-top: 10px;
            margin-bottom: 3px;
            font-weight: bold;
            color: #004085;
        }

        .turno-modal textarea { 
            width: calc(100% - 18px);
            margin: 5px 0 10px 0;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            resize: vertical;
            min-height: 80px; 
        }

        .modal-buttons {
            display: flex;
            gap: 10px;
        }

        .modal-buttons button {
            flex: 1;
        }

        .payment-amount-input {
            display: flex;
            align-items: center;
            width: 100%;
            margin: 8px 0 2px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            background: white;
        }

        .payment-amount-input span {
            padding-left: 10px;
            color: #555;
            font-weight: bold;
        }

        .payment-amount-input input {
            flex: 1;
            width: auto;
            margin: 0;
            border: 0;
            outline: 0;
        }

        #payment-amount-help {
            display: block;
            margin-bottom: 12px;
            color: #666;
        }

        .pharmacy-payment-info {
            margin-bottom: 15px;
            padding: 10px;
            background: #f0f8ff;
            border: 1px solid #b8daff;
            border-radius: 4px;
            font-size: 0.9em;
        }

        .pharmacy-payment-info h4 {
            margin: 0 0 8px;
            color: #004085;
        }

        .pharmacy-payment-info p {
            margin: 5px 0;
            overflow-wrap: anywhere;
        }

        .pharmacy-payment-info #payment-pharmacy-empty {
            color: #856404;
            font-style: italic;
        }

        .cancelar-btn {
            background: #dc3545 !important;
        }

        .cancelar-btn:hover {
            background: #c82333 !important;
        }

        /* Estilos para el Log de Actividades */
        #section-log {
            background: white;
            padding: 20px;
            margin: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        #section-log h2 {
            color: #004085;
            text-align: center;
        }
        #log-container {
            max-height: 70vh;
            overflow-y: auto;
            border: 1px solid #ddd;
        }
        #log-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.9em;
        }
        #log-table th, #log-table td {
            border-bottom: 1px solid #ddd;
            padding: 8px 12px;
            text-align: left;
            word-break: break-word;
        }
        #log-table th {
            background-color: #f2f2f2;
            position: sticky;
            top: 0;
            color: #004085;
        }
        #log-table tbody tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        #log-table tbody tr:hover {
            background-color: #e9ecef;
        }

        #clearLogBtn {
            display: block;
            margin: -10px auto 15px;
            padding: 8px 16px;
            background-color: #dc3545;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9em;
        }
        #clearLogBtn:hover {
            background-color: #c82333;
        }

        /* Estilos para la mensajería */
        #section-mensajeria h2 {
            color: #004085;
            text-align: center;
            margin-bottom: 20px;
        }
        .mensajeria-container {
            display: flex;
            gap: 20px;
            height: 60vh; /* Altura fija para el contenedor de mensajería */
            background: white;
            padding: 15px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        .lista-contactos {
            flex: 1;
            border-right: 1px solid #ddd;
            padding-right: 15px;
            overflow-y: auto;
        }
        .lista-contactos h3 {
            color: #0078D4;
            margin-top: 0;
        }
        #contactList {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        #contactList li {
            padding: 10px;
            cursor: pointer;
            border-bottom: 1px solid #eee;
            border-radius: 3px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        #contactList li:hover, #contactList li.active {
            background-color: #e9ecef;
        }
        .delete-contact-btn {
            background-color: #dc3545;
            color: white;
            border: none;
            border-radius: 3px;
            padding: 4px 8px;
            font-size: 0.8em;
            cursor: pointer;
            opacity: 0.7;
            transition: opacity 0.2s;
        }
        .delete-contact-btn:hover {
            background-color: #bd2130;
            opacity: 1;
        }
        .area-chat {
            flex: 3;
            display: flex;
            flex-direction: column;
        }
        .area-chat h3 {
            color: #0078D4;
            margin-top: 0;
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid #ddd;
        }
        .message-display {
            flex-grow: 1;
            overflow-y: auto;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-bottom: 10px;
            background-color: #f9f9f9;
        }
        .message-item {
            padding: 8px 12px;
            margin-bottom: 8px;
            border-radius: 15px;
            max-width: 70%;
            word-wrap: break-word;
        }
        .message-item strong {
            display: block;
            font-size: 0.8em;
            margin-bottom: 3px;
            color: #555;
        }
        .message-item.sent {
            background-color: #0078D4;
            color: white;
            margin-left: auto;
            border-bottom-right-radius: 5px;
        }
        .message-item.sent strong {
            color: #e0e0e0;
        }
        .message-item.received {
            background-color: #e0e0e0;
            color: #333;
            margin-right: auto;
            border-bottom-left-radius: 5px;
        }
        .message-item.receta {
            border-left: 4px solid #ffc107; 
            font-style: italic;
        }
        .message-item.archivo { 
            border-left: 4px solid #28a745; 
            background-color: #f0fff0; 
        }
        .message-item.archivo::before { 
            content: "📄 ";
            font-weight: bold;
            padding-right: 5px;
        }
        .message-input-area {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        #messageInput {
            width: calc(100% - 20px); /* Full width minus padding */
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            resize: vertical;
            min-height: 60px;
            box-sizing: border-box;
        }
        .message-buttons {
            display: flex;
            gap: 10px;
        }
        .message-buttons button {
            flex: 1;
            padding: 10px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            background-color: #0078D4;
            color: white;
        }
        .message-buttons button:hover {
            background-color: #016db3;
        }
        #sendRecetaBtn {
            background-color: #ffc107;
            color: #333;
        }
        #sendRecetaBtn:hover {
            background-color: #e0a800;
        }
        #sendArchivoBtn { 
            background-color: #17a2b8; 
            color: white;
        }
        #sendArchivoBtn:hover {
            background-color: #138496;
        }

        #fileInput {
            display: none;
        }

        /* Gestión del perfil Hospital */
        .hospital-management {
            margin-top: 24px;
            padding: 20px;
            background: #eef7ff;
            border: 1px solid #c9e5fb;
            border-radius: 8px;
        }

        .hospital-management-heading {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 16px;
        }

        .hospital-management-actions {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .hospital-management h3 {
            color: #004085;
            margin: 0 0 6px;
        }

        .hospital-management p {
            color: #4b6175;
            margin: 0 0 16px;
        }

        .management-count {
            background: #0078D4;
            color: white;
            border-radius: 999px;
            padding: 5px 10px;
            font-size: 0.85em;
            white-space: nowrap;
        }

        .open-add-specialist-btn,
        .save-specialist-btn,
        .cancel-add-specialist-btn {
            border: 0;
            border-radius: 4px;
            color: white;
            cursor: pointer;
            font-weight: bold;
            padding: 9px 12px;
        }

        .open-add-specialist-btn,
        .save-specialist-btn {
            background: #0078D4;
        }

        .open-add-specialist-btn:hover,
        .save-specialist-btn:hover {
            background: #016db3;
        }

        .cancel-add-specialist-btn {
            background: #6c757d;
        }

        .cancel-add-specialist-btn:hover {
            background: #5a6268;
        }

        .add-specialist-form {
            margin: 4px 0 20px;
            padding: 16px;
            background: white;
            border: 1px solid #c9e5fb;
            border-radius: 6px;
        }

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

        .add-specialist-fields label {
            display: flex;
            flex-direction: column;
            gap: 6px;
            color: #004085;
            font-weight: bold;
            font-size: 0.9em;
        }

        .add-specialist-fields input {
            width: 100%;
            padding: 10px;
            border: 1px solid #cbd5df;
            border-radius: 4px;
            box-sizing: border-box;
            color: #333;
            font: inherit;
            font-weight: normal;
        }

        .add-specialist-form-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 14px;
        }

        .management-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 12px;
        }

        .management-list:empty::after {
            content: "No hay médicos en esta lista.";
            color: #6c757d;
            font-size: 0.9em;
            padding: 8px 0;
        }

        .management-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 12px;
            background: white;
            border: 1px solid #d8e4ee;
            border-radius: 6px;
        }

        .management-card strong,
        .management-card span {
            display: block;
        }

        .management-card span {
            color: #657786;
            font-size: 0.88em;
            margin-top: 3px;
        }

        .management-card button,
        .derivacion-actions button {
            border: 0;
            border-radius: 4px;
            color: white;
            cursor: pointer;
            padding: 8px 10px;
            white-space: nowrap;
        }

        .management-card .remove-specialist-btn {
            background: #dc3545;
        }

        .management-card .add-specialist-btn {
            background: #28a745;
        }

        .management-card button:hover {
            filter: brightness(0.92);
        }

        .registered-doctors-title {
            margin-top: 22px !important;
        }

        .derivaciones-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 16px;
        }

        .derivacion-card {
            background: white;
            border: 1px solid #ddd;
            border-radius: 7px;
            padding: 16px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
        }

        .derivacion-card h3 {
            color: #004085;
            margin: 0 0 10px;
        }

        .derivacion-card p {
            margin: 7px 0;
        }

        .derivacion-status {
            display: inline-block;
            margin-top: 6px;
            padding: 4px 8px;
            border-radius: 999px;
            background: #fff3cd;
            color: #856404;
            font-size: 0.82em;
            font-weight: bold;
        }

        .derivacion-status.aceptada {
            background: #d4edda;
            color: #155724;
        }

        .derivacion-status.rechazada {
            background: #f8d7da;
            color: #721c24;
        }

        .derivacion-actions {
            display: flex;
            gap: 8px;
            margin-top: 14px;
        }

        .derivacion-actions .accept-derivacion-btn {
            background: #28a745;
        }

        .derivacion-actions .reject-derivacion-btn {
            background: #dc3545;
        }

        @media (max-width: 700px) {
            nav {
                flex-wrap: wrap;
                gap: 4px;
            }

            nav a {
                margin: 0;
                font-size: 0.95em;
            }

            .derivaciones-options {
                left: auto;
                right: 0;
            }

            .hospital-management-heading {
                flex-direction: column;
            }

            .hospital-management-actions {
                justify-content: flex-start;
            }

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

            .medicos-disponibles {
                grid-template-columns: 1fr;
            }

            .medicos-semana {
                border-left: 0;
                border-top: 1px solid #ddd;
                padding: 20px 0 0;
            }
        }
