:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --secondary: #2563EB;
    --success: #22A06B;
    --warning: #F59E0B;
    --error: #EF4444;
    --text: #1E293B;
    --text-secondary: #64748B;
    --body-bg: #DCE6F2;
    --input-border: #E2E8F0;
    --input-bg: #F8FAFC;
    --card-bg: #FFFFFF;
    --shadow-card: 0 6px 18px rgba(0,0,0,0.08);
    --focus-ring: 0 0 0 2px rgba(37,99,235,0.2);
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--body-bg);
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    font-size: 14px;
    color: var(--text);
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
}

/* --- BOTÓN DASHBOARD --- */
/* --- ENCABEZADO SUPERIOR (fondo claro) --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    /* min-height: fila + safe area; sin height fija para que el botón táctil (48px) no quede apretado */
    min-height: calc(64px + env(safe-area-inset-top, 0px));
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    background: #F1F5F9;
    border-bottom: 1px solid #E2E8F0;
    box-sizing: border-box;
    transition: margin-left 0.3s ease;
}
.app-header .btn-menu-toggle {
    position: relative;
    z-index: 2300; /* por encima del sidebar para seguir visible y clickeable */
    top: auto;
    left: auto;
    margin-top: 8px; /* baja el MENÚ respecto al borde superior del header */
    background: transparent;
    color: #2563EB;
    border: 1px solid rgba(37, 99, 235, 0.25);
    padding: 10px 22px;
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: none;
}
.app-header .btn-menu-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.35);
    color: #1D4ED8;
}
.app-header-branding {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}
.app-header-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2563EB;
    line-height: 1.3;
}
.app-header-subtitle {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2563EB;
    line-height: 1.2;
}
.app-header-org {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6B7280;
    line-height: 1.2;
    margin-top: 2px;
}

/* --- SIDEBAR MODERNO CLARO (Fondo Claro) --- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background-color: #F1F5F9;
    border-right: 1px solid #E2E8F0;
    z-index: 2200;
    padding: calc(56px + env(safe-area-inset-top, 0px)) 14px calc(24px + env(safe-area-inset-bottom, 0px)) 14px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    box-shadow: 2px 0 12px rgba(0,0,0,0.04);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: block !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.sidebar.active {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar.hidden {
    transform: translateX(-100%);
}

/* Botón MENÚ dentro del sidebar: mismo tamaño, diseño y posición que el del encabezado */
.sidebar .btn-menu-toggle {
    position: fixed;
    top: calc(11px + env(safe-area-inset-top, 0px));
    left: max(16px, env(safe-area-inset-left, 0px));
    z-index: 2300;
    width: auto;
    margin: 0;
    background: transparent;
    color: #2563EB;
    border: 1px solid rgba(37, 99, 235, 0.25);
    padding: 10px 22px;
    height: 42px;
    min-height: 42px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: none;
    box-sizing: border-box;
}
.sidebar .btn-menu-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.35);
    color: #1D4ED8;
}

.sidebar-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid #E2E8F0;
}
.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2563EB;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
    text-align: left;
    line-height: 1.3;
}
.logo-subtitle {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2563EB;
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 0;
    text-align: left;
}
.logo-org {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6B7280;
    display: block;
    margin-top: 4px;
    text-align: left;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    text-decoration: none;
    color: #2563EB;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.04);
}

.nav-item:hover {
    background: #E2E8F0;
    color: #2563EB;
}

.nav-item.active {
    background: #2563EB;
    color: white;
}

/* --- CONTENIDO PRINCIPAL CENTRADO --- */
.main-content {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    /* 64px barra + safe top + padding inferior cabecera (10px) + separación con contenido (24px) */
    padding: calc(98px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) calc(60px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* Cada vista a ancho completo; stretch alinea tarjetas y barras (center las dejaba desalineadas) */
.main-content > div {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
}
/* El sidebar se superpone; la página no se contrae */
body.sidebar-open .app-header {
    margin-left: 0;
}
body.sidebar-open .main-content {
    margin-left: 0;
}

.top-bar {
    text-align: center;
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 32px;
}

.top-bar h1 {
    font-size: 28px;
    margin: 0;
    color: #1E293B;
    font-weight: 600;
}

.top-bar p {
    font-size: 16px;
    color: #64748B;
    margin-top: 8px;
}

/* --- TARJETAS Y FORMULARIO --- */
.card-glass {
    background: #FFFFFF;
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 1560px;
    margin: 32px auto;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Botones de área: fila alineada (Guardar / Eliminar / Cancelar al mismo nivel) */
.acciones-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.acciones-area .btn-edit,
.acciones-area .btn-borrar,
.acciones-area .btn-cancelar {
    min-width: 130px;
}
.acciones-area .btn-cancelar {
    margin-top: 0; /* anula el margin-top global para quedar al nivel de los otros dos */
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
/* Ajustes de cuenta: alinear inputs en la misma fila (labels con altura mínima) */
#form-ajustes .field {
    align-items: stretch;
}
#form-ajustes .field label {
    min-height: auto;
    display: block;
}
#form-ajustes .field input {
    flex: 0 0 auto;
}

.field {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

input, select, textarea {
    border: 1px solid #CBD5E1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    background: #F8FAFC;
    height: 38px;
    min-height: 38px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
/* Fondo claro: date/time pickers con fondo blanco y texto negro */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    background: #FFFFFF;
    color: #000000;
}
input[type="date"]::placeholder,
input[type="datetime-local"]::placeholder {
    color: #64748B;
}

textarea {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: var(--focus-ring);
    background-color: #fff;
}

/* Date y datetime pickers: borde resaltado (fondo claro) */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    border: 1px solid #CBD5E1;
}
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus {
    border-color: #2563EB;
    box-shadow: var(--focus-ring);
}
#fecha-calendario {
    background: #FFFFFF !important;
    color: #000000 !important;
}

/* Calendario: selector de fecha + área de agenda en bloque legible en móvil */
.calendar-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}
.calendar-controls #fecha-calendario {
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.calendar-controls .super-contenedor-calendario {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    width: 100%;
}

.btn-primary {
    grid-column: span 3;
    background: #2563EB;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    min-height: 40px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-primary:hover {
    background: #1D4ED8;
}

.btn-cancelar {
    grid-column: span 3;
    background: var(--text-secondary);
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    min-height: 40px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-cancelar:hover {
    background: #475569;
}

/* Registro de usuarios: botones Registrar/Actualizar + Cancelar en fila */
.form-registro-acciones {
    grid-column: span 3;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.form-registro-acciones .btn-primary,
.form-registro-acciones .btn-cancelar {
    grid-column: unset;
    margin-top: 0;
}

/* --- LOGIN --- */
.vista-login {
    position: fixed;
    inset: 0;
    background: var(--body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.vista-login .login-card {
    max-width: 400px;
    width: 90%;
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    padding: 32px 24px;
}
.login-card {
    max-width: 400px;
    width: 90%;
}
.login-card h1 {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    color: #2563EB;
    margin-bottom: 8px;
}
.login-subtitle {
    text-align: center;
    font-size: 16px;
    color: #64748B;
    margin-bottom: 24px;
}
.form-login .field {
    margin-bottom: 16px;
}
.field-password-with-toggle {
    position: relative;
    display: block;
}
.field-password-with-toggle input {
    width: 100%;
    padding-right: 2.5rem;
    box-sizing: border-box;
}
.field-password-with-toggle .btn-toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #64748B;
    -webkit-tap-highlight-color: transparent;
}
.field-password-with-toggle .btn-toggle-password:hover {
    color: #2563EB;
    background: rgba(37, 99, 235, 0.08);
}
.field-password-with-toggle .btn-toggle-password:active {
    background: rgba(37, 99, 235, 0.15);
}
.field-password-with-toggle .icon-eye {
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
    pointer-events: none;
}
.login-error {
    color: var(--error);
    font-size: 14px;
    text-align: center;
    margin-top: 12px;
}

.nav-item-salir {
    margin-top: auto;
    color: #DC2626 !important;
}
.nav-item-salir:hover {
    background: #FEE2E2 !important;
    color: #B91C1C !important;
}

.ajustes-subtitulo {
    font-size: 18px;
    font-weight: 600;
    color: #1E293B;
    margin-bottom: 8px;
}
.ajustes-desc {
    color: #64748B;
    font-size: 14px;
    margin-bottom: 20px;
}
.ajustes-cuenta-grid {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}
.ajustes-form-bloque {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}
.ajustes-form-bloque .ajustes-desc {
    margin-bottom: 12px;
    font-weight: 500;
}
.ajustes-form-bloque .field {
    margin-bottom: 12px;
}
.btn-small {
    padding: 10px 20px !important;
    font-size: 13px !important;
    min-height: auto !important;
    height: auto !important;
    width: auto !important;
}

/* --- TABLA --- */
.tabla-quirurgica {
    width: 100%;
    border-collapse: collapse;
    min-width: 1120px;
    table-layout: fixed;
    background: #FFFFFF;
    border-radius: 10px;
    overflow: hidden;
}

.tabla-quirurgica th {
    text-align: center;
    vertical-align: middle;
    padding: 14px 18px;
    min-height: 48px;
    line-height: 1.35;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--input-border);
    box-sizing: border-box;
}

.tabla-quirurgica td {
    text-align: center;
    vertical-align: middle;
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.tabla-quirurgica tbody tr {
    min-height: 56px;
}

.tabla-quirurgica tbody tr:hover {
    background: #F1F5F9;
}

/* ── Tabla clásica refinada + cabecera tipo data table (listado, pendientes, bitácora) ── */
.tabla-quirurgica.tabla-data-refinada {
    border-collapse: collapse;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
    background: #ffffff;
}
.tabla-quirurgica.tabla-data-refinada thead th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 13px 14px;
    min-height: 46px;
    line-height: 1.3;
    text-align: center;
    vertical-align: middle;
    border-bottom: 2px solid #cbd5e1;
    border-right: 1px solid #e2e8f0;
    box-sizing: border-box;
}
.tabla-quirurgica.tabla-data-refinada thead th:last-child {
    border-right: none;
}
.tabla-quirurgica.tabla-data-refinada tbody td {
    padding: 12px 14px;
    font-size: 14px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid #e8eef4;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    box-sizing: border-box;
}
.tabla-quirurgica.tabla-data-refinada tbody td:last-child {
    border-right: none;
}
.tabla-quirurgica.tabla-data-refinada tbody tr:nth-child(even) td {
    background: #f8fafc;
}
.tabla-quirurgica.tabla-data-refinada tbody tr:hover td {
    background: #eff6ff;
}
.tabla-quirurgica.tabla-data-refinada tbody tr:last-child td {
    border-bottom: none;
}
.tabla-quirurgica.tabla-data-refinada tbody tr:hover {
    background: transparent;
}

/* Ajuste del texto interno para que no se desfase */
.cita-calendario {
    position: absolute;
    /* ... tus otros estilos (colores, bordes) ... */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Alinea el texto al inicio del bloque */
    padding: 10px;
    overflow: hidden; /* Evita que el texto se salga si la cirugía es muy corta */
    min-height: 20px; /* Evita que desaparezca si la duración es casi cero */
}

.cita-paciente {
    font-weight: bold;
    font-size: 14px; /* Un poco más grande para que sea legible */
    margin-bottom: 4px;
}
.cita-medico { font-size: 0.85rem; color: #f0f9ff; }
.cita-proc { font-size: 0.75rem; opacity: 0.9; }
.cita-duracion { font-size: 0.7rem; font-weight: bold; }

.quirofano-col {
    display: flex;
    flex-direction: column;
    /* Usamos el mismo color #eee o #ddd de las líneas horizontales */
    border-right: 1px solid #eee; 
    background-color: white;
}

/* Quitamos cualquier borde especial del último hijo para que sea uniforme */
.quirofano-col:last-child {
    border-left: 1px solid #eee; 
    border-right: none;
}

/* Unificamos el color de los encabezados para que no se vea el corte */
.quirofano-col h3 {
    border-left: 1px solid rgba(255,255,255,0.1); /* Línea casi invisible en el azul */
}

.time-column-header {
    background: var(--input-bg);
    height: 55px;
    position: sticky;
    top: 0;
    z-index: 101;
    border-bottom: 2px solid var(--input-border);
}

/* Columna de Horas */
.time-slot span { font-size: 1.2rem; font-weight: bold; color: var(--primary); }
.time-slot small { font-size: 0.7rem; color: #64748b; }

/* Contenedor de las Cajitas Azules */
.slots-container {
    position: relative;
    height: 2880px; /* 24 horas * 120px */
    background-color: white;
    background-image: 
        linear-gradient(#eee 1px, transparent 1px), 
        linear-gradient(rgba(238, 238, 238, 0.5) 1px, transparent 1px);
    background-size: 100% 120px, 100% 60px;
    background-position: top;
    width: 100%;
}

/* Estilo de la Cirugía (Caja Azul) */
.cita-calendario:hover {
    transform: scale(1.01);
    z-index: 20;
    filter: brightness(1.1);
}

/* Fuentes internas de la cita */
.cita-paciente {
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cita-medico, .cita-proc {
    font-size: 9px;
    opacity: 0.9;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.cita-proc { font-size: 0.8rem; opacity: 0.9; font-style: italic; }
.cita-duracion { font-size: 0.75rem; font-weight: bold; background: rgba(0,0,0,0.2); width: fit-content; padding: 2px 6px; border-radius: 4px; margin-top: auto; }
.quirofano-header {
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 101;
    height: 55px;
    box-sizing: border-box;
    border-bottom: 2px solid rgba(0,0,0,0.1);
    border-right: 1px solid rgba(255,255,255,0.15);
}
/* Fondo oscuro translúcido */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Contenedor de la info */
.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: min(85vh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
    animation: aparecer 0.3s ease-out;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 16px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.btn-cerrar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
}
.btn-cerrar:hover {
    color: var(--text);
}

@keyframes aparecer {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.btn-edit {
    background-color: #F59E0B;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    min-height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    box-sizing: border-box;
}

.btn-edit:hover {
    background-color: #d97706;
}
.acciones-celda {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.tabla-quirurgica .acciones-celda {
    flex-wrap: nowrap;
    white-space: nowrap;
    justify-content: center;
    min-width: 100%;
    box-sizing: border-box;
}
.tabla-quirurgica .acciones-celda .btn-cedula,
.tabla-quirurgica .acciones-celda .btn-edit,
.tabla-quirurgica .acciones-celda .btn-borrar,
.tabla-quirurgica .acciones-celda .btn-restablecer-contrasena {
    flex-shrink: 0;
}
/* Columna "Agendado por" (6.ª): ancho mínimo para que no se superponga con Acciones */
.tabla-quirurgica th:nth-child(6),
.tabla-quirurgica td:nth-child(6) {
    min-width: 160px;
    max-width: 200px;
    box-sizing: border-box;
}
/* Columna "Acciones" (7.ª): ancho fijo para que todas las filas se vean igual y sin recorte */
.tabla-quirurgica th:last-child,
.tabla-quirurgica td:last-child {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
    box-sizing: border-box;
    overflow: visible;
}
.tabla-quirurgica .col-cedula {
    min-width: 140px;
}
.tabla-quirurgica .col-acciones {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
    text-align: center;
    box-sizing: border-box;
    overflow: visible;
}
.tabla-quirurgica td.col-acciones {
    text-align: center;
}
.tabla-quirurgica .acciones-celda {
    justify-content: center;
}
/* Cirugías agendadas (escritorio): alineación original */
#vista-listado .tabla-quirurgica .acciones-celda {
    justify-content: center;
    padding-left: 0;
    box-sizing: border-box;
    transform: translateY(15px);
}

/* Cirugías por confirmar (escritorio) */
#vista-pendientes .tabla-quirurgica .acciones-celda {
    transform: none;
    justify-content: center;
}

/* Registro de usuarios (escritorio) */
#seccion-registro-usuarios .table-container-bitacora.tabla-scroll-container {
    display: block;
    overflow-x: auto;
}
#seccion-registro-usuarios .tabla-quirurgica {
    width: 100%;
    min-width: 620px;
    table-layout: fixed;
}
#seccion-registro-usuarios .tabla-quirurgica th,
#seccion-registro-usuarios .tabla-quirurgica td {
    padding: 10px 12px 10px 14px;
    text-align: center;
}
#seccion-registro-usuarios .tabla-quirurgica th {
    text-align: center;
}
#seccion-registro-usuarios .tabla-quirurgica th:first-child,
#seccion-registro-usuarios .tabla-quirurgica td:first-child {
    padding-left: 14px;
}
#seccion-registro-usuarios .tabla-quirurgica th:nth-child(1),
#seccion-registro-usuarios .tabla-quirurgica td:nth-child(1) {
    width: 18%;
}
#seccion-registro-usuarios .tabla-quirurgica th:nth-child(2),
#seccion-registro-usuarios .tabla-quirurgica td:nth-child(2) {
    width: 25%;
}
#seccion-registro-usuarios .tabla-quirurgica th:nth-child(3),
#seccion-registro-usuarios .tabla-quirurgica td:nth-child(3) {
    width: 12%;
}
#seccion-registro-usuarios .tabla-quirurgica th.th-acciones,
#seccion-registro-usuarios .tabla-quirurgica th:last-child,
#seccion-registro-usuarios .tabla-quirurgica td:last-child {
    width: 45%;
    padding-right: 14px;
    overflow: visible;
}
#seccion-registro-usuarios .tabla-quirurgica td:last-child .acciones-celda {
    overflow: visible;
}
#seccion-registro-usuarios .acciones-celda {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 4px;
}
.btn-borrar {
    background-color: #EF4444;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    min-height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.btn-borrar:hover {
    background: #dc2626;
}
.btn-autorizar {
    background: #16a34a;
    color: white;
    border: none;
    padding: 8px 14px;
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.btn-autorizar:hover {
    background: #15803d;
}
.btn-no-autorizar {
    background: #fecaca;
    color: #b91c1c;
    border: 1px solid #f87171;
    padding: 8px 14px;
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.btn-no-autorizar:hover {
    background: #fca5a5;
    color: #991b1b;
}
/* Badges / etiquetas de estado */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge.programado { background: #2A9BD8; color: white; }
.badge.finalizado { background: #22A06B; color: white; }
.badge.cancelado { background: #E5484D; color: white; }
.badge.expirado { background: var(--text-secondary); color: white; }
.badge.realizado { background: var(--success); color: white; }
.badge.admin { background: var(--primary); color: white; }
.badge.director { background: #7c3aed; color: white; }
.badge.director-general { background: #0f766e; color: white; }
.badge.user { background: var(--text-secondary); color: white; }
/* En proceso por si se usa en bitácora/futuro */
.badge.en.proceso,
.badge.en-proceso { background: #F59E0B; color: white; }
.badge.no-autorizado { background: #b91c1c; color: white; }

.input-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-item input {
    padding: 8px 12px;
    height: 38px;
    min-height: 38px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #F8FAFC;
    font-size: 14px;
}
.input-item input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    outline: none;
}

/* Botón PDF elegante */
.btn-pdf {
    background: var(--error);
    color: white;
    border: none;
    padding: 6px 14px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-pdf:hover {
    background: #c73e47;
}

/* Asegura que las vistas no se encimen */
.view-section {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Bitácora: mismo ancho que el resto de vistas */
#vista-bitacora {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}
#vista-bitacora .top-bar {
    margin-left: auto;
    margin-right: auto;
}
#vista-bitacora .card-glass {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 1280px;
    box-sizing: border-box;
}
#vista-bitacora .toolbar-bitacora {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
}
#vista-bitacora .filtros-bitacora {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}
#vista-bitacora #tabla-logs-dinamica {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 0 12px;
    box-sizing: border-box;
}
#vista-bitacora #tabla-logs-dinamica .tabla-quirurgica {
    margin: 0 auto;
    flex-shrink: 0;
}
.tabla-bitacora-seleccion .th-checkbox-bitacora,
.tabla-bitacora-seleccion .td-checkbox-bitacora {
    width: 44px;
    min-width: 44px;
    text-align: center;
    vertical-align: middle;
}
.tabla-bitacora-seleccion .bitacora-check-row {
    cursor: pointer;
}

/* Bitácora: misma tabla refinada; anchos uniformes (checkbox + 8 columnas) */
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada {
    table-layout: fixed;
    width: 100%;
    min-width: 1100px;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    font-size: 13px;
    box-sizing: border-box;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada tbody td strong {
    font-weight: 700;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td {
    font-size: 13px;
}
/* Checkbox ~4%; las otras 8 columnas 12% cada una */
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th:nth-child(1),
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(1) {
    width: 4%;
    min-width: 44px;
    max-width: 56px;
    padding-left: 6px;
    padding-right: 6px;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th:nth-child(n+2),
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(n+2) {
    width: 12%;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th:nth-child(9) {
    white-space: normal;
    line-height: 1.2;
    font-size: 10px;
    letter-spacing: 0.02em;
    word-break: break-word;
    hyphens: auto;
    text-align: center;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(9) {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: normal;
    line-height: 1.35;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(9) small {
    font-size: inherit;
    font-variant-numeric: tabular-nums;
    display: inline-block;
    text-align: center;
    white-space: normal;
    line-height: 1.35;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(4),
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(7) {
    word-break: break-word;
    text-align: center;
}
#vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada .badge {
    display: inline-block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Paginación bitácora: controles centrados y alineados */
#vista-bitacora #bitacora-paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 8px 4px;
}
#vista-bitacora #bitacora-paginacion .bitacora-pag-label {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary, #64748b);
    min-width: 7em;
}
#vista-bitacora #bitacora-paginacion .btn-bitacora-pag-prev,
#vista-bitacora #bitacora-paginacion .btn-bitacora-pag-next {
    min-width: 44px;
    min-height: 40px;
    padding: 8px 14px;
    font-size: 18px;
    line-height: 1;
    border-radius: 8px;
    border: 1px solid var(--input-border, #e2e8f0);
    background: var(--input-bg, #fff);
    color: var(--text-primary, #1e293b);
    cursor: pointer;
    vertical-align: middle;
}
#vista-bitacora #bitacora-paginacion .btn-bitacora-pag-prev:disabled,
#vista-bitacora #bitacora-paginacion .btn-bitacora-pag-next:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#vista-bitacora .search-box-bitacora {
    min-width: 0;
    flex: 1 1 220px;
    max-width: 100%;
    border: 1px solid #E2E8F0;
    box-shadow: none;
    box-sizing: border-box;
}
#vista-bitacora .search-box-bitacora:focus-within {
    border-color: #CBD5E1;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}
#vista-bitacora .search-box-bitacora input {
    width: 100%;
    padding: 8px 12px;
    height: 38px;
    min-height: 38px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: #F8FAFC;
    font-size: 14px;
}
#vista-bitacora .search-box-bitacora input:focus {
    border-color: #E2E8F0;
    box-shadow: none;
    outline: none;
}
#vista-bitacora .btn-pdf-bitacora {
    background-color: #EF4444;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
#vista-bitacora .btn-eliminar-bitacora {
    background-color: #7f1d1d;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
#vista-bitacora .btn-eliminar-bitacora:hover {
    background-color: #991b1b;
}
#vista-bitacora .card-bitacora {
    margin-bottom: 20px;
}

/* Vista Estadísticas de procedimientos */
.card-estadisticas {
    margin-bottom: 20px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
    flex-wrap: wrap;
}
.contenedor-barras-verticales {
    flex: 1;
    min-width: 280px;
    min-height: 280px;
}
.estadisticas-controles-derecha {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    flex-shrink: 0;
    width: 200px;
}
.estadisticas-fechas-fila {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: flex-end;
}
.estadisticas-fechas-fila .fecha-grupo {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.estadisticas-controles-derecha .fecha-grupo label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.estadisticas-controles-derecha .fecha-grupo input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 12px;
    min-height: 34px;
}
.btn-generar-pdf-estadisticas {
    background: #EF4444;
    color: #fff !important;
    border: none;
    padding: 8px 18px;
    height: 40px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-generar-pdf-estadisticas:hover {
    background: #c73e47;
}
.contenedor-barras-verticales {
    width: 100%;
    min-height: 280px;
}
.barras-verticales {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 48px;
    padding: 20px 0 40px;
    min-height: 320px;
}
.barra-vertical-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    flex-basis: 0;
    max-width: 220px;
    min-width: 0;
    cursor: pointer;
    transition: transform 0.2s;
}
.barra-vertical-item:hover {
    transform: translateY(-4px);
}
.barra-vertical-valor {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    flex-shrink: 0;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.barra-vertical-fondo {
    width: 100%;
    height: 200px;
    flex-shrink: 0;
    background: #f1f5f9;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}
.barra-vertical-fill {
    width: 100%;
    min-height: 8px;
    border-radius: 12px 12px 0 0;
    transition: height 0.4s ease;
}
.barra-vertical-fill.barra-realizados {
    background: var(--success);
}
.barra-vertical-fill.barra-cancelacion-medico {
    background: var(--warning);
}
.barra-vertical-fill.barra-otros-motivos {
    background: var(--error);
}
.barra-vertical-fill.barra-no-autorizado {
    background: #b91c1c;
}
.barra-vertical-label {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    flex: 1;
    min-height: 2.8em;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.estadisticas-sin-datos {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-detalle-estadisticas .modal-body {
    padding: 12px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.modal-detalle-estadisticas #modal-estadisticas-tabla {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 4px;
}
.modal-detalle-estadisticas #modal-estadisticas-tabla .tabla-quirurgica {
    font-size: 0.85rem;
}
.modal-detalle-estadisticas #modal-estadisticas-tabla .estadisticas-sin-datos {
    padding: 24px;
}

/* Barra de filtros alineada */
.toolbar-bitacora {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
}

.filter-group {
    display: flex;
    gap: 15px;
}

.table-container-bitacora {
    overflow-x: auto;
    border-radius: 15px;
    padding: 10px;
}

/* Contenedores con scroll para tablas (cirugías agendadas, bitácora, registro usuarios) - scroll vertical */
.tabla-scroll-container {
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
}
.tabla-scroll-container .tabla-quirurgica thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #F8FAFC;
    box-shadow: 0 2px 0 #E2E8F0;
}
.tabla-scroll-container .tabla-quirurgica.tabla-data-refinada thead th {
    background: linear-gradient(180deg, #f1f5f9 0%, #e8edf3 100%);
    color: #475569;
    border-bottom: 2px solid #94a3b8;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06);
}

/* Agendar Cirugía: scroll vertical del formulario cuando el contenido es largo */
.form-agendar-scroll {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.search-container {
    margin: 0 0 24px 0;
    display: flex;
    justify-content: center;
}

.search-box {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    padding: 10px 16px;
    border-radius: 8px;
    background: #FFFFFF !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    border: 2px solid #94A3B8;
}

.search-icon {
    margin-right: 12px;
    font-size: 1rem;
    color: var(--text-secondary);
}

#buscador-paciente {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text);
    padding: 8px 0;
}
#buscador-paciente:focus {
    outline: none;
}
.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

#buscador-paciente::placeholder {
    color: var(--text-secondary);
}
/* El contenedor permite el scroll lateral */
/* Contenedor con scroll para que la tabla respire */
/* Contenedor con scroll horizontal */
.contenedor-scroll-excel {
    width: 100%;
    max-height: 70vh; /* Ajusta la altura a tu gusto */
    overflow: auto;   /* Un solo scroll para todo */
    border: 1px solid #ddd;
    position: relative;
    background: #fff;
}

/* Forzamos un ancho mínimo grande para que las horas no se aplasten */
.tabla-excel-quirurgica {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed; /* Esto es clave para que los anchos se respeten */
    width: max-content;  /* Se expande según el contenido */
}

/* Fijar columnas de Fecha y Quirófano */
.col-fija-fecha, .celda-fecha-label {
    width: 130px; 
    min-width: 130px;
    position: sticky;
    left: 0;
    z-index: 10;
    background: #fdfdfd;
    border-right: 2px solid #ccc !important;
}

.col-fija-sala, .sala-amarilla, .sala-verde {
    width: 150px;
    min-width: 150px;
    position: sticky;
    left: 130px; /* Exactamente el ancho de la columna Fecha */
    z-index: 9;
    background: inherit;
    border-right: 2px solid #ccc !important;
    font-weight: 600; /* Nombres de salas en negritas */
}

/* Estética de las cabeceras */
.tabla-excel-quirurgica th {
    position: sticky;
    top: 0;
    z-index: 20; /* Por encima de todo */
    background: #eee;
    padding: 8px;
    border-bottom: 2px solid #ccc;
    border-right: 1px solid #ddd;
}

.tabla-excel-quirurgica {
    border-collapse: separate; /* Cambiado a separate para que funcione sticky */
    border-spacing: 0;
    min-width: 3500px; /* Suficiente espacio para las 48 celdas de 30min */
}

.tabla-excel-quirurgica th, .tabla-excel-quirurgica td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: center;
    min-width: 100px; /* Tamaño de cada bloque de hora */
}

/* Colores de Quirófanos (image_095561.png) */
.sala-amarilla,
.sala-verde {
    background-color: var(--body-bg) !important;
}

.celda-fecha-label {
    background-color: #f8fafc;
    font-weight: bold;
    text-transform: capitalize;
    border-right: 2px solid #333 !important;
    border-bottom: 1px solid #333 !important; /* Línea que separa por fecha */
}

/* Fila final de cada bloque de fecha: línea que separa por fecha (menos gruesa) */
.tabla-excel-quirurgica tr.fila-fecha-fin td {
    border-bottom: 1px solid #333 !important;
}

/* --- Reemplaza o modifica tu clase existente con esto --- */
/* 1. Estilo base para todas las celdas ocupadas */
.tabla-excel-quirurgica {
    border-collapse: collapse !important; /* Une las líneas de las celdas */
    border-spacing: 0 !important;        /* Elimina cualquier espacio interno */
}
.celda-excel-ocupada {
    background-color: var(--primary) !important;
    color: white !important;
    border-left: none !important;
    border-right: none !important;
    border-top: 1px solid rgba(0,0,0,0.1) !important;
    border-bottom: 1px solid rgba(0,0,0,0.1) !important;
    position: relative;
    z-index: 1;
}

/* 2. Redondear solo el inicio de la tira (Extremo izquierdo) */
/* Redondea solo el inicio de la cirugía y le devuelve el borde izquierdo si quieres */
.celda-excel-ocupada:first-of-type, 
td.celda-excel-ocupada:not(+ .celda-excel-ocupada) {
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
    border-left: 1px solid rgba(0,0,0,0.1) !important;
}

.celda-excel-ocupada.fin-bloque {
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    border-right: 1px solid rgba(0,0,0,0.1) !important;
}

/* Efecto opcional al pasar el mouse para que resalte aún más */
.celda-excel-ocupada:hover {
    transform: translateY(-2px); /* Se levanta un poco */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3) !important;
}

.pildora-paciente {
    line-height: 1.2;
}
/* Contenedor principal del calendario */
.super-contenedor-calendario {
    width: 100%;
    margin-top: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
}

/* Forzamos a la tabla a ser ancha para que parezca Excel */
.tabla-estilo-excel {
    width: 2500px; /* Ancho suficiente para todas las horas */
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
}

/* Fijar la columna de fecha y quirófano a la izquierda */
.col-fija-izq {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #f8f9fa !important;
    border-right: 2px solid #ddd !important;
    font-weight: bold;
}

.col-fija-sala {
    position: sticky;
    left: 120px; /* Se pega justo después de la fecha */
    z-index: 9;
    border-right: 2px solid #ddd !important;
}

/* Estilo de las celdas de hora */
.celda-hora-excel {
    border: 1px solid #e2e8f0;
    height: 60px;
    transition: all 0.2s;
}

.celda-hora-excel:hover {
    background-color: #f0f7ff;
}
/* 2. La Tabla: Quitamos el min-width excesivo y usamos uno real */
.tabla-excel-quirurgica {
    border-collapse: separate; /* Obligatorio para sticky */
    border-spacing: 0;
}

/* 3. Definición de anchos de columna (Ajuste milimétrico) */
.col-fija-fecha, .celda-fecha-label {
    position: sticky;
    left: 0;
    z-index: 20; /* Mayor que el quirófano */
    background-color: #f8f9fa !important;
    width: 130px;
    min-width: 130px;
    border-right: 2px solid #bbb !important;
    font-weight: bold;
}

.col-fija-sala, .sala-amarilla, .sala-verde {
    position: sticky;
    left: 130px; /* Exactamente el ancho de la columna fecha */
    z-index: 10;
    width: 150px;
    min-width: 150px;
    border-right: 2px solid #bbb !important;
    white-space: nowrap;
}

/* 4. Cabeceras (Sticky arriba y a la izquierda) */
.tabla-excel-quirurgica th {
    position: sticky;
    top: 0;
    z-index: 30; /* El más alto */
    background-color: #e9ecef;
    border-bottom: 2px solid #bbb;
}

/* Cabeceras específicas que no se mueven */
th.col-fija-fecha { left: 0; z-index: 40; }
th.col-fija-sala { left: 130px; z-index: 40; }

/* 5. Celdas de tiempo */
.celda-excel {
    width: 100px;
    min-width: 100px;
    height: 60px;
    text-align: center;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
}
.modal-detalle {
    display: none; 
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
}
.modal-contenido {
    background-color: #fff;
    margin: 10% auto;
    padding: 25px;
    border-radius: 12px;
    width: 450px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.btn-cerrar-modal {
    position: absolute;
    top: 15px; right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
.btn-cerrar-modal:hover { color: #f00; }

.detalle-item { margin-bottom: 12px; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.detalle-label { font-weight: bold; color: #4682B4; display: block; font-size: 12px; }

/* Forzar visibilidad del texto en la barra azul */
.celda-excel-ocupada {
    background-color: var(--primary) !important;
    color: white !important;
    vertical-align: top !important;
    min-width: 160px !important;
    height: 80px !important;
    padding: 0 !important;
    overflow: visible !important;
}

/* Celda que contiene timeline con bloque posicionado exacto (ej. 16:17) */
.celda-excel-contenedor {
    padding: 0 !important;
    vertical-align: top !important;
    min-height: 80px !important;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.timeline-slot {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 80px;
    overflow: hidden;
}
.timeline-slot .bloque-cirugia {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    min-height: 80px;
    box-sizing: border-box;
    background-color: var(--primary) !important;
    border-radius: 8px;
    cursor: pointer;
}

.bloque-cirugia {
    display: flex !important;
    flex-direction: column !important;
    padding: 8px !important;
    color: #ffffff !important;
    text-align: left !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
}

.paciente-tag {
    font-weight: bold !important;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.4);
    margin-bottom: 3px;
    display: block;
}

.medico-tag {
    color: #e0f2fe !important; /* Azul muy clarito */
    display: block;
}

.proc-tag {
    color: #bae6fd !important;
    font-style: italic;
    display: block;
}

.bloque-cirugia strong {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bloque-cirugia.prioridad-programada {
    background-color: #2563eb !important;
}
.bloque-cirugia.prioridad-urgente {
    background-color: #ea580c !important;
}
.bloque-cirugia.prioridad-emergencia {
    background-color: #b91c1c !important;
}

/* Admin: barra ocupada sin texto ni datos clínicos */
.bloque-cirugia.bloque-cirugia--admin-sin-detalles {
    padding: 0 !important;
    cursor: default;
}
.timeline-slot .bloque-cirugia.bloque-cirugia--admin-sin-detalles {
    cursor: default;
}
.btn-finalizar-procedimiento {
    background-color: #16a34a;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    min-width: 32px;
}
.btn-finalizar-procedimiento:hover {
    background-color: #15803d;
}
/* Dropdown Sala en modo Emergencia: mantener color al pasar o quitar el cursor */
#sala option.sala-emergencia-libre,
#sala option.sala-emergencia-libre:hover,
#sala option.sala-emergencia-libre:focus {
    background-color: #16a34a !important;
    color: #fff !important;
}
#sala option.sala-emergencia-programada,
#sala option.sala-emergencia-programada:hover,
#sala option.sala-emergencia-programada:focus {
    background-color: #3b82f6 !important;
    color: #fff !important;
}
#sala option.sala-emergencia-urgente,
#sala option.sala-emergencia-urgente:hover,
#sala option.sala-emergencia-urgente:focus {
    background-color: #ea580c !important;
    color: #fff !important;
}

/* Dropdown personalizado Sala en Emergencia (evita que el hover nativo cambie el color) */
.sala-emergencia-dropdown {
    position: relative;
    width: 100%;
    min-height: 38px;
}
.sala-emergencia-display {
    position: relative;
    z-index: 1;
    border: 1px solid #CBD5E1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    background: #F8FAFC;
    min-height: 38px;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.sala-emergencia-display:hover {
    border-color: #94A3B8;
}
.sala-emergencia-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    border-radius: 8px;
    border: 1px solid #CBD5E1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
}
.sala-emergencia-option {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: filter 0.15s;
}
.sala-emergencia-option:hover {
    filter: brightness(0.9);
}

/* Colores de prioridad en tablas (tema claro: badge redondeado solo alrededor del texto) */
.celda-prioridad.prioridad-programada .badge-prioridad {
    background-color: #2563eb;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}
.celda-prioridad.prioridad-urgente .badge-prioridad {
    background-color: #ea580c;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}
.celda-prioridad.prioridad-emergencia .badge-prioridad {
    background-color: #b91c1c;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}

.modal-contenido-elegante {
    background: #FFFFFF;
    margin: 5% auto;
    padding: 24px;
    border-radius: 14px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.header-modal h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 12px;
}

.item-detalle {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    font-size: 15px;
    color: #444;
}

.item-detalle span.icon {
    margin-right: 15px;
    font-size: 20px;
    width: 25px;
    text-align: center;
}

.item-detalle b {
    color: #333;
    margin-right: 8px;
}
/* 1. El contenedor principal debe ajustarse al contenido (la tabla) */
.seccion-tabla-quirofano {
    display: inline-block; /* O block con un ancho definido */
    width: 100%;           /* Ocupa el ancho de la tarjeta blanca */
    text-align: center;    /* Centra todo el contenido hijo */
}

/* 2. El bloque de títulos */
.encabezado-centrado {
    display: inline-block;
    margin-bottom: 32px;
    width: 100%;
}

.encabezado-centrado h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #1E293B;
    padding: 0;
}

.encabezado-centrado p {
    font-size: 16px;
    color: #64748B;
    margin-top: 8px;
}
#vista-inicio .card-glass {
    margin-top: 0;
    max-width: 1280px;
}
#vista-calendario .card-glass {
    max-width: 1280px;
}
#vista-estadisticas .card-glass {
    max-width: 1280px;
}
#vista-ajustes .card-glass {
    max-width: 1280px;
}
#vista-agendar .card-glass {
    max-width: 1280px;
}
#vista-listado .card-glass {
    max-width: 1280px;
}
#vista-listado .search-container {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
}
#vista-listado .search-container .search-box {
    margin: 0 auto;
}
/* Vista Inicio: contenido centrado horizontal y verticalmente */
#vista-inicio {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: calc(100dvh - 98px - 60px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 24px 0;
    box-sizing: border-box;
}
.inicio-bienvenida-simple {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
    text-align: center;
    padding: 24px;
    width: 100%;
}
.encabezado-centrado-grande {
    text-align: center;
}
.dashboards-inicio {
    display: grid;
    grid-template-columns: repeat(auto-fill, 240px);
    justify-content: center;
    align-items: stretch;
    gap: 16px;
    margin-top: 32px;
    width: 100%;
    max-width: 100%;
}
.dashboard-card {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 280px;
    text-align: center;
    box-shadow: var(--shadow-card);
}
.dashboards-inicio .dashboard-card {
    width: 100%;
    max-width: 240px;
    min-width: 240px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}
.dashboard-card {
    cursor: pointer;
}
.dashboard-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}
.dashboard-valor {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
}
.dashboard-valor-texto {
    font-size: 1.15rem;
    font-weight: 600;
}
.dashboard-label {
    font-size: 0.9rem;
    opacity: 0.95;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Próxima cirugía por sala: mismos tamaño y alineación que el resto de dashboards */
.dashboards-proxima-por-sala {
    display: contents;
}
.dashboards-inicio .dashboard-proxima-sala-card {
    min-width: 240px;
    max-width: 240px;
    width: 100%;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}
.dashboard-proxima-sala-card .dashboard-proxima-sala-titulo {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.dashboard-proxima-sala-card .dashboard-proxima-sala-info {
    font-size: 0.85rem;
    opacity: 0.95;
}

/* Salas en inicio con LED de estado */
.dashboards-salas-inicio {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 16px;
    margin-top: 36px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}
.dashboards-salas-sin-areas {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 16px;
}
.dashboard-sala-card {
    flex: 0 0 auto;
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 20px 24px;
    min-width: 160px;
    text-align: center;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.dashboard-sala-led {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1), inset 0 1px 2px rgba(255,255,255,0.3);
}
.led.led-ocupada {
    background: #dc2626;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.6), 0 0 0 2px rgba(0,0,0,0.1);
}
.led.led-preparacion {
    background: #ea580c;
    box-shadow: 0 0 8px rgba(234, 88, 12, 0.6), 0 0 0 2px rgba(0,0,0,0.1);
}
.led.led-libre {
    background: #16a34a;
    box-shadow: 0 0 8px rgba(22, 163, 74, 0.5), 0 0 0 2px rgba(0,0,0,0.1);
}
.dashboard-sala-nombre {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}
.dashboard-sala-estado {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.encabezado-centrado-grande h1 {
    font-size: 28px;
    font-weight: 600;
    color: #1E293B;
    margin-bottom: 8px;
}

.encabezado-centrado-grande p {
    font-size: 16px;
    color: #64748B;
}

/* Modal cancelar procedimiento */
.modal-cancelar .modal-body { padding: 0 0 20px; }
.modal-cancelar-encabezado {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--input-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}
.modal-cancelar .field { margin-bottom: 16px; }
.modal-cancelar textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--input-border);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--input-bg);
}
.modal-cancelar textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    outline: none;
}
.modal-footer-cancelar {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--input-border);
}
.modal-footer-cancelar .btn-cancelar,
.modal-footer-cancelar .btn-primary {
    min-height: 40px;
    padding: 8px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Fondo claro: bordes un poco más visibles (modal cancelar + tarjetas de sala en inicio) */
body:not([data-tema="oscuro"]) .modal-cancelar-encabezado {
    border: 1px solid #CBD5E1;
    border-left: 4px solid var(--primary);
}
body:not([data-tema="oscuro"]) .modal-cancelar textarea,
body:not([data-tema="oscuro"]) .modal-cancelar input[type="datetime-local"] {
    border-color: #CBD5E1;
}
body:not([data-tema="oscuro"]) .modal-cancelar textarea:focus,
body:not([data-tema="oscuro"]) .modal-cancelar input[type="datetime-local"]:focus {
    border-color: var(--primary);
}
body:not([data-tema="oscuro"]) .dashboard-sala-card {
    border-color: #CBD5E1;
    box-shadow: var(--shadow-card), 0 0 0 1px rgba(15, 23, 42, 0.05);
}

/* Modal WhatsApp */
.modal-whatsapp-desc {
    color: #64748b;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

/* Modal aceptación de términos legales: solo fondo claro */
body:not([data-tema="oscuro"]) #modalLegalAcceptance .modal-whatsapp-desc,
body:not([data-tema="oscuro"]) #modalLegalAcceptance label {
    color: #111827;
}
#modalWhatsApp #whatsapp-numero {
    border: 1px solid #E2E8F0;
    padding: 8px 12px;
    height: 38px;
    min-height: 38px;
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: #000000;
    width: 100%;
    box-sizing: border-box;
}
#modalWhatsApp #whatsapp-numero::placeholder {
    color: #6B7280;
}
#modalWhatsApp #whatsapp-numero:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background: #fff;
}
.modal-footer-whatsapp {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--input-border);
}
.modal-footer-whatsapp .btn-cancelar,
.modal-footer-whatsapp .btn-whatsapp {
    min-height: 40px;
    padding: 8px 18px;
    font-size: 14px;
}
.btn-whatsapp {
    background: #25d366;
    color: white;
    border: none;
    padding: 8px 18px;
    height: 40px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}
.btn-whatsapp:hover {
    background: #20bd5a;
}

/* Botón Generar Cédula en tabla */
.btn-cedula {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 6px 14px;
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    box-sizing: border-box;
}
.btn-cedula:hover {
    background: var(--primary-hover);
}

/* Modal Generar Cédula: no cerrar con clic fuera */
.modal-cedula-no-close.modal-overlay {
    cursor: default;
}
.modal-cedula-no-close .modal-content {
    cursor: default;
}
.modal-cedula-content {
    max-width: 520px;
    width: 95%;
}
.modal-cedula-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 0;
}
.modal-cedula-scroll {
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
}
.tabla-cedula-datos {
    width: 100%;
    border-collapse: collapse;
    min-width: 280px;
}
.tabla-cedula-datos th,
.tabla-cedula-datos td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--input-border);
}
.tabla-cedula-datos th {
    background: #F1F5F9;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}
.tabla-cedula-datos .label-dato-cedula {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}
.tabla-cedula-datos .input-dato-cedula {
    width: 100%;
    min-width: 140px;
    box-sizing: border-box;
}
.modal-cedula-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--input-border);
}
.modal-cedula-footer .btn-cancelar,
.modal-cedula-footer .btn-primary {
    min-height: 40px;
    padding: 8px 18px;
}

.calendario-sin-areas {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 1.1rem;
}

/* ========== RESPONSIVE: TABLET ========== */
@media (max-width: 1024px) {
    .grid-layout {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .btn-primary,
    .btn-cancelar {
        grid-column: span 2;
    }
    .form-registro-acciones {
        grid-column: span 2;
    }
    .main-content {
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .card-glass {
        width: 100%;
        max-width: 100%;
    }
    /* Misma anchura que tarjetas (evita caja de búsqueda más estrecha) */
    .search-box {
        max-width: 100%;
    }
    #vista-listado .search-container .search-box {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

/* ========== RESPONSIVE: MÓVIL Y TABLET ========== */
@media (max-width: 768px) {
    .encabezado-centrado-grande h1 {
        font-size: 2rem;
    }
    .encabezado-centrado-grande p {
        font-size: 1.1rem;
    }
    .dashboards-inicio {
        flex-wrap: wrap;
        gap: 16px;
    }
    .dashboard-card {
        max-width: 100%;
        padding: 20px 24px;
    }
    .dashboard-valor {
        font-size: 2rem;
    }
    .dashboard-valor-texto {
        font-size: 1rem;
    }

    /* Contenido principal: offset bajo cabecera (98px = 64 + 10 padding barra + 24 hueco) */
    .main-content {
        padding: calc(98px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
        overflow-x: hidden;
    }
    body.sidebar-open .main-content,
    body.sidebar-open .app-header {
        margin-left: 0;
    }

    /* Cabecera app: texto largo con elipsis, botón siempre usable */
    .app-header .btn-menu-toggle {
        flex-shrink: 0;
    }
    .app-header-branding {
        align-items: flex-end;
    }
    .app-header-title,
    .app-header-subtitle,
    .app-header-org {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .view-section {
        width: 100%;
        max-width: 100%;
        padding: 0;
        overflow-x: hidden;
    }

    /* Buscador al mismo ancho que las tarjetas en listado */
    #vista-listado .search-container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin-bottom: 0;
    }
    #vista-listado .search-container .search-box {
        max-width: 100%;
        width: 100%;
        margin: 0;
    }

    .search-box {
        max-width: 100%;
    }

    .encabezado-centrado {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .encabezado-centrado h1 {
        font-size: 1.35rem;
        line-height: 1.25;
        word-break: break-word;
    }
    .encabezado-centrado p {
        font-size: 0.9rem;
    }

    /* Títulos de sección */
    .top-bar {
        margin-bottom: 24px;
        padding: 0 8px;
    }
    .top-bar h1 {
        font-size: 24px;
        font-weight: 600;
    }
    .top-bar p {
        font-size: 14px;
    }

    /* Tarjetas: más estrechas en móvil */
    .card-glass {
        width: 100%;
        max-width: 100%;
        padding: 20px;
        border-radius: 14px;
        margin: 16px 0;
    }

    /* Formularios: una sola columna */
    .grid-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .btn-primary,
    .btn-cancelar {
        grid-column: 1;
        min-height: 40px;
        padding: 8px 18px;
        font-size: 14px;
    }
    .btn-cancelar {
        min-height: 40px;
        padding: 8px 18px;
    }

    /* Inputs y labels: tamaño táctil y evitar zoom iOS */
    input, select, textarea {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
        box-sizing: border-box;
    }
    textarea {
        min-height: 80px;
    }
    label {
        font-size: 0.7rem;
    }

    /* Botón MENÚ: área táctil */
    .btn-menu-toggle {
        min-height: 48px;
        padding: 12px 20px;
        font-size: 1rem;
    }

    /* Sidebar: casi ancho completo; 56px arriba alinea con hueco del botón MENÚ fijo */
    .sidebar {
        width: min(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px), 360px);
        max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        padding: calc(56px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    }
    .nav-item {
        min-height: 48px;
        padding: 16px 20px;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
    }

    /* ── Solo móvil (≤768px): tablas listado / pendientes / registro / bitácora más legibles ── */
    #vista-listado .tabla-quirurgica .acciones-celda {
        justify-content: flex-start;
        align-items: center;
        align-content: center;
        padding: 10px 12px;
        box-sizing: border-box;
        transform: none;
        flex-wrap: wrap;
        gap: 10px;
        row-gap: 10px;
        white-space: normal;
    }
    #vista-pendientes .tabla-quirurgica .acciones-celda {
        transform: none;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
        row-gap: 10px;
        padding: 10px 12px;
        white-space: normal;
    }
    #vista-listado .tabla-quirurgica,
    #vista-pendientes .tabla-quirurgica {
        table-layout: auto;
        min-width: 1580px;
    }
    #vista-listado .tabla-quirurgica th,
    #vista-pendientes .tabla-quirurgica th,
    #vista-listado .tabla-quirurgica td,
    #vista-pendientes .tabla-quirurgica td {
        padding: 16px 20px;
        line-height: 1.5;
        box-sizing: border-box;
    }
    #vista-listado .tabla-quirurgica th,
    #vista-pendientes .tabla-quirurgica th {
        font-size: 13px;
        padding: 18px 16px;
    }
    #vista-listado .tabla-quirurgica td,
    #vista-pendientes .tabla-quirurgica td {
        font-size: 15px;
    }
    #vista-listado .tabla-quirurgica td:not(.col-acciones),
    #vista-pendientes .tabla-quirurgica td:not(.col-acciones) {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        hyphens: auto;
    }
    #vista-listado .tabla-quirurgica td.celda-prioridad,
    #vista-pendientes .tabla-quirurgica td.celda-prioridad {
        white-space: nowrap;
        word-break: normal;
    }
    #vista-listado .tabla-quirurgica th:nth-child(1),
    #vista-listado .tabla-quirurgica td:nth-child(1),
    #vista-pendientes .tabla-quirurgica th:nth-child(1),
    #vista-pendientes .tabla-quirurgica td:nth-child(1) {
        min-width: 210px;
    }
    #vista-listado .tabla-quirurgica th:nth-child(2),
    #vista-listado .tabla-quirurgica td:nth-child(2),
    #vista-pendientes .tabla-quirurgica th:nth-child(2),
    #vista-pendientes .tabla-quirurgica td:nth-child(2) {
        min-width: 180px;
    }
    #vista-listado .tabla-quirurgica th:nth-child(3),
    #vista-listado .tabla-quirurgica td:nth-child(3),
    #vista-pendientes .tabla-quirurgica th:nth-child(3),
    #vista-pendientes .tabla-quirurgica td:nth-child(3) {
        min-width: 260px;
    }
    #vista-listado .tabla-quirurgica th:nth-child(4),
    #vista-listado .tabla-quirurgica td:nth-child(4),
    #vista-pendientes .tabla-quirurgica th:nth-child(4),
    #vista-pendientes .tabla-quirurgica td:nth-child(4) {
        min-width: 140px;
    }
    #vista-listado .tabla-quirurgica th:nth-child(5),
    #vista-listado .tabla-quirurgica td:nth-child(5),
    #vista-pendientes .tabla-quirurgica th:nth-child(5),
    #vista-pendientes .tabla-quirurgica td:nth-child(5) {
        min-width: 130px;
    }
    #vista-listado .tabla-quirurgica th:nth-child(6),
    #vista-listado .tabla-quirurgica td:nth-child(6),
    #vista-pendientes .tabla-quirurgica th:nth-child(6),
    #vista-pendientes .tabla-quirurgica td:nth-child(6) {
        min-width: 200px;
        max-width: none;
    }
    #vista-listado .tabla-quirurgica th:nth-child(7),
    #vista-listado .tabla-quirurgica td:nth-child(7),
    #vista-pendientes .tabla-quirurgica th:nth-child(7),
    #vista-pendientes .tabla-quirurgica td:nth-child(7) {
        min-width: 200px;
        max-width: none;
    }
    #vista-listado .tabla-quirurgica th:last-child,
    #vista-listado .tabla-quirurgica td:last-child,
    #vista-pendientes .tabla-quirurgica th:last-child,
    #vista-pendientes .tabla-quirurgica td:last-child {
        width: auto;
        min-width: 420px;
        max-width: none;
    }

    #seccion-registro-usuarios .table-container-bitacora.tabla-scroll-container {
        -webkit-overflow-scrolling: touch;
    }
    #seccion-registro-usuarios .tabla-quirurgica {
        min-width: 920px;
        table-layout: auto;
    }
    #seccion-registro-usuarios .tabla-quirurgica th,
    #seccion-registro-usuarios .tabla-quirurgica td {
        padding: 14px 18px;
        line-height: 1.45;
        font-size: 15px;
        box-sizing: border-box;
    }
    #seccion-registro-usuarios .tabla-quirurgica th {
        font-size: 13px;
    }
    #seccion-registro-usuarios .tabla-quirurgica th:first-child,
    #seccion-registro-usuarios .tabla-quirurgica td:first-child {
        padding-left: 18px;
    }
    #seccion-registro-usuarios .tabla-quirurgica th:nth-child(1),
    #seccion-registro-usuarios .tabla-quirurgica td:nth-child(1) {
        min-width: 220px;
        width: auto;
    }
    #seccion-registro-usuarios .tabla-quirurgica th:nth-child(2),
    #seccion-registro-usuarios .tabla-quirurgica td:nth-child(2) {
        min-width: 280px;
        width: auto;
    }
    #seccion-registro-usuarios .tabla-quirurgica th:nth-child(3),
    #seccion-registro-usuarios .tabla-quirurgica td:nth-child(3) {
        min-width: 140px;
        width: auto;
    }
    #seccion-registro-usuarios .tabla-quirurgica th.th-acciones,
    #seccion-registro-usuarios .tabla-quirurgica th:last-child,
    #seccion-registro-usuarios .tabla-quirurgica td:last-child {
        min-width: 360px;
        width: auto;
        max-width: none;
        padding-right: 18px;
    }
    #seccion-registro-usuarios .tabla-quirurgica td:not(:last-child) {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    #seccion-registro-usuarios .acciones-celda {
        flex-wrap: wrap;
        gap: 8px;
        row-gap: 8px;
        white-space: normal;
    }

    #vista-bitacora #tabla-logs-dinamica {
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }
    #vista-bitacora #tabla-logs-dinamica .tabla-quirurgica {
        margin: 0;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada {
        table-layout: fixed;
        min-width: 1180px;
        max-width: none;
        font-size: 14px;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th,
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td {
        padding: 12px 12px;
        line-height: 1.5;
        box-sizing: border-box;
        text-align: center;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th {
        font-size: 12px;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td {
        font-size: 14px;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada th:nth-child(n+2),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(n+2) {
        min-width: 132px;
        width: 12%;
    }
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(2),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(3),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(4),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(5),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(7),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(8),
    #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada td:nth-child(9) {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* Tablas genéricas (modales, etc.) */
    .tabla-quirurgica {
        min-width: 560px;
        font-size: 0.9rem;
    }
    .tabla-quirurgica th,
    .tabla-quirurgica td {
        padding: 12px 12px;
    }
    /* Otras tablas: columna acciones sin ancho fijo de escritorio */
    .tabla-quirurgica th:last-child,
    .tabla-quirurgica td:last-child {
        width: auto;
        min-width: 200px;
        max-width: none;
    }
    .tabla-quirurgica .col-acciones {
        width: auto;
        min-width: 200px;
        max-width: none;
    }
    .tabla-scroll-container {
        max-height: min(55vh, 70dvh);
        margin: 0 -4px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .table-container-bitacora {
        padding: 8px;
    }

    /* Botones de acción en tablas: touch */
    .btn-edit,
    .btn-borrar,
    .btn-cedula,
    .btn-finalizar-procedimiento,
    .btn-autorizar,
    .btn-no-autorizar {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    .acciones-celda {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
    }

    /* Búsqueda */
    .search-container {
        margin: 12px 0;
    }
    .search-box {
        padding: 12px 16px;
    }
    #buscador-paciente {
        font-size: 16px;
    }

    /* Bitácora: toolbar en columna */
    #vista-bitacora .toolbar-bitacora,
    #vista-bitacora .filtros-bitacora {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }
    #vista-bitacora .search-box-bitacora {
        min-width: 0;
    }
    #vista-bitacora .fecha-grupo {
        width: 100%;
    }
    #vista-bitacora .fecha-grupo input {
        width: 100%;
    }
    #vista-bitacora .btn-pdf-bitacora,
    #vista-bitacora .btn-eliminar-bitacora {
        width: 100%;
        min-height: 42px;
    }

    /* Estadísticas: barras en columna */
    .card-estadisticas {
        flex-direction: column;
    }
    .estadisticas-controles-derecha {
        width: 100%;
        flex-direction: column;
        gap: 12px;
    }
    .estadisticas-fechas-fila {
        width: 100%;
    }
    .estadisticas-fechas-fila .fecha-grupo input {
        min-height: 38px;
        font-size: 14px;
    }
    .btn-generar-pdf-estadisticas {
        width: 100%;
        min-height: 42px;
    }
    .barras-verticales {
        flex-direction: column;
        align-items: center;
        gap: 28px;
        padding: 16px 0 24px;
    }
    .barra-vertical-item {
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }
    .barra-vertical-fondo {
        height: 160px;
    }

    /* Formulario Agendar: scroll vertical */
    .form-agendar-scroll {
        max-height: min(65vh, 75dvh);
        -webkit-overflow-scrolling: touch;
    }

    /* Modales: alinear arriba para poder desplazarse en pantallas bajas */
    .modal-overlay {
        align-items: flex-start;
        padding-top: max(16px, env(safe-area-inset-top, 0px));
    }

    /* Modales */
    .modal-content,
    .modal-contenido-elegante,
    .modal-contenido {
        width: 95%;
        max-width: 95%;
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
        margin: 0 auto 16px;
        padding: 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    .modal-contenido {
        width: min(92vw, 500px);
        margin-top: 12px;
    }
    .modal-header h2 {
        font-size: 1.25rem;
    }
    .modal-footer-cancelar,
    .modal-footer-whatsapp {
        flex-direction: column;
    }
    .modal-footer-cancelar .btn-cancelar,
    .modal-footer-cancelar .btn-primary,
    .modal-footer-whatsapp .btn-cancelar,
    .modal-footer-whatsapp .btn-whatsapp {
        width: 100%;
        min-height: 40px;
    }
    .modal-detalle-estadisticas .modal-body {
        max-height: 60vh;
    }

    /* Ajustes / Registro usuarios: formularios en 1 columna */
    #vista-ajustes .grid-layout {
        grid-template-columns: 1fr;
    }
    .form-registro-acciones {
        grid-column: 1;
        flex-direction: column;
        align-items: stretch;
    }
    .form-registro-acciones .btn-primary,
    .form-registro-acciones .btn-cancelar {
        width: 100%;
    }
    .ajustes-subtitulo {
        font-size: 1.1rem;
    }

    /* Calendario: contenedor con scroll */
    .contenedor-scroll-excel {
        max-height: 55vh;
        -webkit-overflow-scrolling: touch;
    }
    /* En movil el calendario debe desplazarse completo (sin columnas fijas). */
    .tabla-excel-quirurgica .col-fija-fecha,
    .tabla-excel-quirurgica .celda-fecha-label,
    .tabla-excel-quirurgica .col-fija-sala,
    .tabla-excel-quirurgica .sala-amarilla,
    .tabla-excel-quirurgica .sala-verde {
        position: static !important;
        left: auto !important;
        z-index: auto !important;
    }
    .super-contenedor-calendario {
        margin-top: 12px;
    }
    .calendar-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .calendar-controls input[type="date"] {
        width: fit-content;
        max-width: 100%;
        min-height: 48px;
    }

    /* Inicio (movil): permitir scroll horizontal completo de LEDs de salas. */
    .dashboards-salas-inicio {
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        overscroll-behavior-x: contain;
    }

    /* Login */
    .vista-login .login-card {
        width: 95%;
        padding: 24px 20px;
    }
    .login-card h1 {
        font-size: 1.75rem;
    }
}

/* Móviles muy pequeños */
@media (max-width: 480px) {
    .main-content {
        padding: calc(98px + env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    }
    .top-bar h1 {
        font-size: 1.35rem;
    }
    .card-glass {
        padding: 12px;
    }
    .tabla-quirurgica {
        min-width: 480px;
        font-size: 0.88rem;
    }
    .tabla-quirurgica th,
    .tabla-quirurgica td {
        padding: 10px 10px;
    }
    .encabezado-centrado-grande h1 {
        font-size: 1.75rem;
    }
    .dashboard-card {
        padding: 16px 20px;
    }
    .dashboards-inicio .dashboard-card,
    .dashboards-inicio .dashboard-proxima-sala-card {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    .dashboards-inicio {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }
    .app-header-title {
        font-size: 1rem;
    }
    .app-header-subtitle {
        font-size: 0.65rem;
    }
}

/* ========== TEMA OSCURO (solo colores) ========== */
body[data-tema="oscuro"] {
    background-color: #1E293B;
}
body[data-tema="oscuro"] .main-content {
    background-color: #1E293B;
}
body[data-tema="oscuro"] .sidebar {
    background-color: #1E293B;
    border-right-color: #334155;
}
body[data-tema="oscuro"] .sidebar-header {
    border-bottom-color: #334155;
}
/* Tema oscuro: mismo azul que fondo claro para marca y botones MENÚ */
body[data-tema="oscuro"] .logo-text,
body[data-tema="oscuro"] .logo-subtitle {
    color: #2563EB;
}
body[data-tema="oscuro"] .app-header {
    background: #1E293B;
    border-bottom-color: #334155;
}
body[data-tema="oscuro"] .app-header .btn-menu-toggle {
    background: transparent;
    color: #2563EB;
    border: 1px solid rgba(37, 99, 235, 0.25);
}
body[data-tema="oscuro"] .app-header .btn-menu-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.35);
    color: #1D4ED8;
}
body[data-tema="oscuro"] .sidebar .btn-menu-toggle {
    background: transparent;
    color: #2563EB;
    border: 1px solid rgba(37, 99, 235, 0.25);
}
body[data-tema="oscuro"] .sidebar .btn-menu-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.35);
    color: #1D4ED8;
}
body[data-tema="oscuro"] .app-header-title,
body[data-tema="oscuro"] .app-header-subtitle {
    color: #2563EB;
}
body[data-tema="oscuro"] .nav-item {
    color: #E2E8F0;
    background: rgba(255, 255, 255, 0.06);
}
body[data-tema="oscuro"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
body[data-tema="oscuro"] .nav-item.active {
    background: #2563EB;
    color: white;
}
body[data-tema="oscuro"] .nav-item-salir {
    color: #fca5a5 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}
body[data-tema="oscuro"] .nav-item-salir:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fecaca !important;
}
body[data-tema="oscuro"] .card-glass {
    background: #2D3748;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
body[data-tema="oscuro"] .top-bar h1,
body[data-tema="oscuro"] .ajustes-subtitulo {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .top-bar p,
body[data-tema="oscuro"] .ajustes-desc,
body[data-tema="oscuro"] label {
    color: #CBD5F5;
}
body[data-tema="oscuro"] input,
body[data-tema="oscuro"] select,
body[data-tema="oscuro"] textarea {
    background: #1E293B;
    border-color: #4A5568;
    color: #E2E8F0;
}
body[data-tema="oscuro"] #modalWhatsApp #whatsapp-numero {
    background: #FFFFFF;
    border-color: #CBD5E1;
    color: #000000;
}
body[data-tema="oscuro"] #modalWhatsApp #whatsapp-numero::placeholder {
    color: #6B7280;
}
body[data-tema="oscuro"] #fecha-calendario {
    background: #FFFFFF !important;
    color: #000000 !important;
    border-color: #CBD5E1;
}
body[data-tema="oscuro"] input::placeholder,
body[data-tema="oscuro"] textarea::placeholder {
    color: #94A3B8;
}
body[data-tema="oscuro"] input:focus,
body[data-tema="oscuro"] select:focus,
body[data-tema="oscuro"] textarea:focus {
    background: #2D3748;
    border-color: #2563EB;
}
body[data-tema="oscuro"] .sala-emergencia-display {
    background: #1E293B;
    border-color: #4A5568;
    color: #E2E8F0;
}
body[data-tema="oscuro"] .sala-emergencia-display:hover {
    border-color: #94A3B8;
}
body[data-tema="oscuro"] .sala-emergencia-list {
    background: #2D3748;
    border-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-quirurgica {
    background: #2D3748;
}
body[data-tema="oscuro"] .tabla-quirurgica th {
    color: #CBD5F5;
    border-bottom-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-quirurgica th {
    color: #CBD5F5;
    border-bottom-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-quirurgica td {
    border-bottom-color: #4A5568;
    color: #E2E8F0;
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada {
    background: #1e293b;
    border-color: #475569;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada thead th {
    background: linear-gradient(180deg, #334155 0%, #293548 100%);
    color: #e2e8f0;
    border-bottom-color: #64748b;
    border-right-color: #475569;
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada tbody td {
    background: #1e293b;
    color: #e2e8f0;
    border-bottom-color: #334155;
    border-right-color: #334155;
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada tbody tr:nth-child(even) td {
    background: #243148;
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada tbody tr:hover td {
    background: #2c3f59;
}
body[data-tema="oscuro"] .tabla-quirurgica.tabla-data-refinada tbody tr:hover {
    background: transparent;
}
body[data-tema="oscuro"] .tabla-scroll-container .tabla-quirurgica.tabla-data-refinada thead th {
    background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
    border-bottom-color: #64748b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
body[data-tema="oscuro"] #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada thead th,
body[data-tema="oscuro"] #vista-bitacora .tabla-bitacora-seleccion.tabla-data-refinada tbody td {
    text-align: center;
}
body[data-tema="oscuro"] #vista-bitacora #bitacora-paginacion .bitacora-pag-label {
    color: #CBD5F5;
}
body[data-tema="oscuro"] #vista-bitacora #bitacora-paginacion .btn-bitacora-pag-prev,
body[data-tema="oscuro"] #vista-bitacora #bitacora-paginacion .btn-bitacora-pag-next {
    background: #374151;
    border-color: #4A5568;
    color: #E2E8F0;
}
body[data-tema="oscuro"] .celda-prioridad.prioridad-programada .badge-prioridad {
    background-color: #2563eb;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}
body[data-tema="oscuro"] .celda-prioridad.prioridad-urgente .badge-prioridad {
    background-color: #ea580c;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}
body[data-tema="oscuro"] .celda-prioridad.prioridad-emergencia .badge-prioridad {
    background-color: #b91c1c;
    color: #fff;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    display: inline-block;
}
body[data-tema="oscuro"] .tabla-quirurgica tbody tr:hover {
    background: #374151;
}
body[data-tema="oscuro"] .tabla-scroll-container {
    background: #2D3748;
    border-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-scroll-container .tabla-quirurgica thead th {
    background: #374151;
    border-bottom-color: #4A5568;
}
body[data-tema="oscuro"] .search-box {
    background: #2D3748 !important;
    border-color: #4A5568;
}
body[data-tema="oscuro"] #buscador-paciente {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .search-box:focus-within {
    border-color: #2563EB;
}
body[data-tema="oscuro"] .encabezado-centrado h1,
body[data-tema="oscuro"] .encabezado-centrado-grande h1 {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .encabezado-centrado p,
body[data-tema="oscuro"] .encabezado-centrado-grande p {
    color: #CBD5F5;
}
body[data-tema="oscuro"] .dashboard-card {
    background: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
}
body[data-tema="oscuro"] .dashboard-sala-card {
    background: #2D3748;
    border-color: #4A5568;
}
body[data-tema="oscuro"] .dashboard-sala-nombre {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .dashboard-sala-estado,
body[data-tema="oscuro"] .dashboards-salas-sin-areas {
    color: #94A3B8;
}
body[data-tema="oscuro"] .vista-login {
    background: #1E293B;
}
body[data-tema="oscuro"] .vista-login .login-card {
    background: #2D3748 !important;
    border-color: #4A5568;
}
/* Login: mismo azul y gris que en fondo claro */
body[data-tema="oscuro"] .login-card h1 {
    color: #2563EB;
}
body[data-tema="oscuro"] .login-subtitle {
    color: #64748B;
}
body[data-tema="oscuro"] .modal-content,
body[data-tema="oscuro"] .modal-contenido-elegante {
    background: #2D3748;
}
body[data-tema="oscuro"] .modal-header h2,
body[data-tema="oscuro"] .header-modal h2 {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .modal-body,
body[data-tema="oscuro"] .modal-whatsapp-desc {
    color: #CBD5F5;
}
body[data-tema="oscuro"] .modal-cancelar-encabezado {
    color: #CBD5F5;
    background: #1E293B;
    border: 1px solid #4A5568;
    border-left: 4px solid var(--primary);
}
body[data-tema="oscuro"] .modal-footer-cancelar,
body[data-tema="oscuro"] .modal-footer-whatsapp {
    border-top-color: #4A5568;
}
body[data-tema="oscuro"] .modal-cedula-scroll {
    background: #1E293B;
    border-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-cedula-datos th {
    background: #374151;
    color: #CBD5F5;
    border-bottom-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-cedula-datos td {
    border-bottom-color: #4A5568;
}
body[data-tema="oscuro"] .tabla-cedula-datos .label-dato-cedula {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .modal-cedula-footer {
    border-top-color: #4A5568;
}
body[data-tema="oscuro"] .btn-cerrar,
body[data-tema="oscuro"] .btn-cerrar-modal {
    color: #CBD5F5;
}
body[data-tema="oscuro"] .quirofano-header {
    background: #2563EB;
}
body[data-tema="oscuro"] .time-column-header {
    background: #374151;
}
body[data-tema="oscuro"] .time-slot span {
    color: #60A5FA;
}
body[data-tema="oscuro"] .slots-container {
    background: #2D3748;
}
body[data-tema="oscuro"] .quirofano-col {
    background: #2D3748;
}
body[data-tema="oscuro"] #vista-bitacora .toolbar-bitacora,
body[data-tema="oscuro"] .toolbar-bitacora {
    background: #2D3748;
}
body[data-tema="oscuro"] .estadisticas-sin-datos,
body[data-tema="oscuro"] .calendario-sin-areas {
    color: #CBD5F5;
}
body[data-tema="oscuro"] .barra-vertical-label {
    color: #E2E8F0;
}
body[data-tema="oscuro"] .barra-vertical-fondo {
    background: #374151;
}
body[data-tema="oscuro"] .item-detalle,
body[data-tema="oscuro"] .detalle-label {
    color: #CBD5F5;
}
/* Modal Detalles del Procedimiento (calendario): mismo color que el título para que se vean los datos en tema oscuro */
body[data-tema="oscuro"] #modalDetalles .item-detalle,
body[data-tema="oscuro"] #modalDetalles .item-detalle b {
    color: #E2E8F0;
}
body[data-tema="oscuro"] #modalDetalles .modal-body p {
    color: #E2E8F0 !important;
}
body[data-tema="oscuro"] .detalle-item {
    border-bottom-color: #4A5568;
}

/* Scrollbars en tema oscuro: integrados con el fondo */
body[data-tema="oscuro"] ::-webkit-scrollbar {
    height: 8px;
    width: 8px;
    background-color: #1E293B; /* mismo tono del fondo oscuro */
}
body[data-tema="oscuro"] ::-webkit-scrollbar-track {
    background-color: #1E293B;
}
body[data-tema="oscuro"] ::-webkit-scrollbar-thumb {
    background-color: #4B5563; /* un poco más claro para que se vea */
    border-radius: 999px;
}
body[data-tema="oscuro"] ::-webkit-scrollbar-thumb:hover {
    background-color: #6B7280;
}
