* {
    box-sizing: border-box;
}

/* Paleta de la clinica: por defecto los azules de siempre. Si la clinica elige
   un color en Configuracion, header.php redefine estas variables y toda la
   interfaz toma esa familia de tonos (encabezado, menus, tablas y botones). */
:root {
    --clinica: #2196f3;
    --clinica-oscuro: #1565c0;
    --clinica-claro: #e4f2fe;
    --clinica-borde: #9bd0fa;
    --clinica-rgb: 33,150,243;
    --clinica-texto: #fff;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: #f5f7fa;
    color: #333;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 8px;
}

img, picture, video, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.main-content {
    padding: 15px 20px 5px;
    flex: 1 0 auto;
}

.navbar {
    background-color: var(--clinica);
    color: var(--clinica-texto);
    padding: 15px 0;
    /* La barra queda pegada arriba al hacer scroll. Con sticky no sale del flujo
       (nada se salta de sitio al cargar) y los submenus siguen funcionando, porque
       sticky crea el mismo contexto de posicion que relative. El z-index la deja
       encima del contenido pero debajo de los avisos, el tutor y los modales. */
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: var(--clinica-texto);
    font-size: 1.2rem;
    text-decoration: none;
    font-weight: bold;
}

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: var(--clinica-texto);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-links a:hover {
    text-decoration: underline;
}

.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--clinica-texto);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.perfil-chip span {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

h1 {
    margin-bottom: 20px;
}

.form-card {
    background: #fff;
    max-width: 400px;
    margin: 0 auto;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.btn {
    --btn-color: #247585;
    display: inline-block;
    padding: 7px 13px;
    border: 1.5px solid var(--btn-color);
    border-radius: 20px;
    text-decoration: none;
    cursor: pointer;
    font-size: 1.19rem;
    font-family: inherit;
    font-weight: bold;
    line-height: 1.2;
    background-color: var(--btn-color);
    color: #fff;
    transition: transform 0.2s, box-shadow 0.25s;
    position: relative;
    overflow: hidden;
    z-index: 0;
}

/* Al pasar el mouse: brillo con el color del encabezado y un destello de luz que cruza el botón */
.btn:hover,
.btn-primary:hover,
.btn-small.btn-primary:hover,
.btn-small:hover,
.btn-danger:hover,
.btn-small.btn-danger:hover,
.btn-guardar:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 0 8px 2px var(--clinica), 0 0 14px 3px var(--btn-color);
    background-image: linear-gradient(110deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
    background-size: 250% 100%;
    animation: destello 0.88s linear infinite;
}

@keyframes destello {
    from { background-position: 150% 0; }
    to { background-position: -50% 0; }
}

.btn-primary { --btn-color: #247585; }

.btn-danger { --btn-color: #62152d; }

.btn-guardar { --btn-color: #1565c0; }

.btn-exito { --btn-color: #27ae60; }

.btn-aviso { --btn-color: #f39c12; }

.btn-gris { --btn-color: #7f8c8d; }

.btn-small {
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* Todos los <button> del sistema en negrita (calendario, pestañas, odontograma, popups, etc.) */
button { font-weight: bold; }

.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.grid-cards.reportes-grid {
    grid-template-columns: repeat(4, 1fr);
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.big-number {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 10px 0 0;
    color: #2c3e50;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background-color: var(--clinica-claro);
    color: var(--clinica-oscuro);
    border-top: 1px solid var(--clinica-borde);
    border-bottom: 1px solid var(--clinica-borde);
}

.table thead th:first-child {
    border-left: 1px solid var(--clinica-borde);
    border-radius: 8px 0 0 8px;
}

.table thead th:last-child {
    border-right: 1px solid var(--clinica-borde);
    border-radius: 0 8px 8px 0;
}

.table tbody tr:hover {
    background-color: rgba(var(--clinica-rgb), 0.08);
    cursor: pointer;
    outline: 1px solid var(--clinica);
    outline-offset: -1px;
    transition: background-color 0.15s ease, outline-color 0.2s ease;
}

#wrap-horarios .table tbody tr:hover,
#body-horarios .table tbody tr:hover {
    background-color: transparent;
    cursor: default;
    outline: none;
    transition: none;
}

input[type="text"][placeholder*="Buscar"]:hover,
input[type="text"][name="q"]:hover,
input[type="text"][list]:hover {
    border-color: var(--clinica);
    box-shadow: 0 0 0 3px rgba(var(--clinica-rgb), 0.15);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"][placeholder*="Buscar"]:focus,
input[type="text"][name="q"]:focus,
input[type="text"][list]:focus {
    border-color: var(--clinica);
    box-shadow: 0 0 0 3px rgba(var(--clinica-rgb), 0.15);
}

.footer {
    padding: 1px 0;
    color: #777;
    font-size: 0.8rem;
    line-height: 10px;
    height: 8px;
    box-sizing: border-box;
    text-align: center;
    flex-shrink: 0;
}

.footer p {
    margin: 0;
}

body.agregar-cita .footer {
    height: 16px;
    line-height: 14px;
}

body.agregar-cita #wrap-horarios {
    height: calc(100vh - 100px);
}

.fila-acciones-movil,
.fila-cita-detalles {
    display: none;
}

.col-codigo {
    white-space: nowrap;
}

.acciones-col-movil {
    display: none !important;
}

.acciones-fila {
    flex-wrap: wrap;
    max-width: 360px;
}

@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }

    .main-content {
        padding: 20px 0;
    }

    .nav-links {
        gap: 15px;
    }

    .grid-cards {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    .table.reportes-table {
        display: table !important;
        width: 100% !important;
        overflow-x: visible !important;
    }

    .table.reportes-table th,
    .table.reportes-table td {
        white-space: normal !important;
    }

    .table-week {
        display: table !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    .table-week th,
    .table-week td {
        white-space: normal !important;
    }
    #wrap-horarios,
    #swipe-horarios {
        overflow: hidden !important;
    }
    #body-horarios {
        overflow: auto !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }

    .main-content {
        padding: 15px 0;
    }

    .nav-flex {
        flex-wrap: nowrap;
        min-height: 50px;
    }

    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--clinica);
        gap: 0;
        padding: 10px 0;
        margin: 0;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
        z-index: 1000;
    }

    .nav-links.nav-active {
        display: flex;
    }

    .nav-links li {
        text-align: center;
        padding: 10px 15px;
    }

    .nav-links a {
        display: block;
        padding: 8px 0;
    }

    .logo {
        font-size: 1rem;
    }

    .perfil-chip span {
        display: none;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .form-card,
    .card {
        max-width: 100%;
        padding: 20px 15px;
        margin: 0 0 20px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 12px;
    }

    .btn:not(.btn-small):not(.ocultar-movil):not(.btn-nuevo-paciente) {
        display: block !important;
        width: fit-content !important;
        min-width: 120px;
        text-align: center !important;
        margin: 0 auto 10px !important;
        padding: 12px 20px;
        min-height: 44px;
    }

    .form-group .btn:not(.btn-small) {
        margin-top: 6px !important;
    }

    .btn + .btn {
        margin-left: 0;
    }

    .grid-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

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

    .reportes-grid .card {
        padding: 12px;
    }

    .reportes-grid .card h2 {
        font-size: 0.9rem;
    }

    .reportes-grid .big-number {
        font-size: 1.3rem;
        margin: 5px 0 0;
    }

    .big-number {
        font-size: 1.4rem;
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        white-space: nowrap;
        padding: 10px 12px;
    }

    .table th {
        font-size: 0.85rem;
    }

    .table td {
        font-size: 0.9rem;
    }

    .alert {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 5px;
    }

    .main-content {
        padding: 10px 5px 5px;
    }

    .table-week {
        display: table !important;
        overflow-x: visible !important;
        width: 100% !important;
        min-width: 800px !important;
        font-size: 0.7rem !important;
        table-layout: fixed !important;
    }

    .table-week th,
    .table-week td {
        white-space: normal !important;
        padding: 4px 3px !important;
        font-size: 0.7rem !important;
        vertical-align: middle;
        text-align: center;
    }

    .table-week thead th small {
        display: block;
        font-size: 0.65rem;
    }

    .table-week .dia-grupo-0,
    .table-week .dia-grupo-1,
    .table-week .dia-grupo-2 {
        display: table-cell !important;
    }

    #wrap-horarios {
        min-width: 0 !important;
    }

    .ocultar-movil {
        display: none !important;
    }

    .acciones-col-movil {
        display: none !important;
    }

    .fila-acciones-movil {
        display: none !important;
    }

    .fila-acciones-movil td {
        padding: 4px 3px 8px !important;
    }

    .acciones-fila {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        max-width: none !important;
        padding-bottom: 5px;
    }

    .acciones-fila .btn-small {
        padding: 4px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .citas-table {
        display: table !important;
        width: 100% !important;
        overflow-x: visible !important;
    }

    .citas-table th,
    .citas-table td {
        white-space: normal !important;
    }

    .fila-cita-detalles {
        display: table-row !important;
    }

    .fila-cita-datos td {
        border-bottom: 0 !important;
        padding-bottom: 4px !important;
    }

    .fila-cita-detalles td {
        border-top: 0 !important;
        padding-top: 0 !important;
    }
}

/* Efecto LED al pasar el mouse o tocar citas en el calendario */
.table-week td {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.table-week td div {
    transition: box-shadow 0.2s ease;
}
.table-week td:hover > div,
.table-week td:active > div,
.table-week td.cita-activa-touch > div {
    box-shadow: 0 0 8px var(--cita-color), 0 0 16px var(--cita-color) !important;
}
.table-week td.cita-activa-touch > div {
    transition: none;
}

/* Hover en celdas libres del calendario */
.table-week td.libre:hover,
.table-week td.libre:focus {
    outline: 1px solid #2196f3;
    outline-offset: -1px;
    transition: outline-color 0.2s ease;
}

/* Popup de alerta del paciente */
.alerta-badge {
    cursor: pointer;
    box-sizing: border-box;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    padding: 0;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.alerta-badge .alerta-icono {
    font-size: 0.8rem;
    line-height: 1;
    flex: 0 0 auto;
}

/* Badges inactivos (verde "sin alerta"): el icono va en blanco y negro */
.alerta-badge:not(.alerta-activa) .alerta-icono {
    filter: grayscale(1) brightness(1.9);
}

.alerta-badge:hover {
    box-shadow:
        0 0 0 2px var(--glow, rgba(0,0,0,0.5)),
        0 0 12px var(--glow, rgba(0,0,0,0.5));
    transform: translateY(-1px);
}

/* Alertas ACTIVAS: pulso fuerte — resplandor del color que "respira" + anillo que se expande */
.alerta-badge.alerta-activa {
    animation: alerta-pulso 1.2s ease-in-out infinite;
}

.alerta-badge.alerta-activa::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid var(--glow, rgba(0,0,0,0.4));
    pointer-events: none;
    animation: alerta-anillo 1.2s ease-out infinite;
}

@keyframes alerta-pulso {
    0%, 100% { box-shadow: 0 0 0 0 var(--glow, rgba(0,0,0,0.4));   transform: scale(1); }
    50%      { box-shadow: 0 0 14px 4px var(--glow, rgba(0,0,0,0.4)); transform: scale(1.08); }
}

@keyframes alerta-anillo {
    0%   { opacity: 0.9; transform: scale(1); }
    70%  { opacity: 0;   transform: scale(1.22); }
    100% { opacity: 0;   transform: scale(1.22); }
}

/* Si el sistema pide menos movimiento, no parpadea */
@media (prefers-reduced-motion: reduce) {
    .alerta-badge.alerta-activa { animation: none; }
    .alerta-badge.alerta-activa::after { animation: none; opacity: 0; }
}

/* Cita vencida sin gestionar: badge junto a la hora + pulso en el select de estado */
.badge-vencida {
    display: inline-block;
    background: #fdf2e0;
    color: #b9770e;
    border: 1px solid #f39c12;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.72rem;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
}

select.select-vencida {
    border-color: #f39c12 !important;
    animation: vencida-pulso 1.5s ease-in-out infinite;
}

@keyframes vencida-pulso {
    0%, 100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.65); }
    50%      { box-shadow: 0 0 0 5px rgba(243, 156, 18, 0); }
}

/* Si el sistema pide menos movimiento, el select solo queda con el borde ámbar */
@media (prefers-reduced-motion: reduce) {
    select.select-vencida { animation: none; }
}

/* Popup: icono y titulo de la alerta */
.alerta-popup-icono {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.alerta-popup-icono .alerta-icono {
    font-size: 30px;
    line-height: 1;
}

.alerta-popup-titulo {
    font-weight: bold;
    margin-bottom: 6px;
    color: #2c3e50;
}

.alerta-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.alerta-overlay.activo { display: flex; }

.alerta-popup {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 10px;
    padding: 18px 20px;
    max-width: 320px;
    width: 85%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    text-align: center;
    font-size: 0.95rem;
    color: #333;
}

.alerta-popup-texto {
    margin-bottom: 14px;
    word-break: break-word;
}

.alerta-popup-btn {
    border: none;
    border-radius: 4px;
    padding: 6px 18px;
    background: var(--clinica);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}

.alerta-popup-btn:hover {
    box-shadow:
        0 0 0 2px rgba(var(--clinica-rgb),0.6),
        0 0 12px rgba(var(--clinica-rgb),0.5);
    transform: translateY(-1px);
}

/* Cursor con el favicon del sitio redimensionado */
html {
    cursor: url('../img/favicon-cursor.png'), auto;
}

/* Marca de agua: el logo de la clinica, tenue, encima del contenido (no sale al
   imprimir). La imagen la define header.php segun el logo configurado; aqui
   solo el estilo (si no hay logo, header.php la oculta). */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: min(85%, 560px);
    opacity: 0.06;
    pointer-events: none;
    z-index: 9997;
}
@media (min-width: 768px) {
    body::before {
        background-size: min(90%, 784px);
    }
}
@media print {
    body::before { display: none; }
}

/* ==================== Tutor: ayudas contextuales "?" ==================== */
.ctx-chip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%;
    background: #2c6e91; color: #fff; font-size: 0.72rem; font-weight: 700;
    line-height: 1; cursor: pointer; vertical-align: middle; font-family: inherit;
}
.ctx-chip:hover { background: #215873; }
/* Parpadeo cada 5 segundos: una pulsación breve al inicio de cada ciclo */
.ctx-chip.parpadea { animation: ctxParpadeo 5s infinite; }
.ctx-chip.visto { background: #b6c2c9; }
@keyframes ctxParpadeo {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0.55); }
    6%   { transform: scale(1.35); box-shadow: 0 0 0 7px rgba(44, 110, 145, 0); }
    12%  { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0); }
}
.ctx-pop {
    display: none; position: fixed; z-index: 3000; background: #fff;
    border: 1px solid #cfd8dd; border-radius: 8px; padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); font-size: 0.85rem;
}
.ctx-pop h4 { margin: 0 0 5px; font-size: 0.95rem; color: #2c3e50; }
.ctx-pop p { margin: 0 0 10px; color: #444; }
.ctx-pop-pie { display: flex; justify-content: flex-end; gap: 6px; }
.ctx-pop-pie .btn { padding: 5px 10px; font-size: 0.8rem; }
.ctx-toast {
    position: fixed; z-index: 3001; background: #2c3e50; color: #fff;
    font-size: 0.82rem; padding: 6px 10px; border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); opacity: 1;
    transition: opacity 0.4s; pointer-events: none; white-space: nowrap;
}
.ctx-toast.fuera { opacity: 0; }

/* ==================== Tutor: tour guiado ==================== */
/* La capa oscurece todo menos el elemento señalado (4 paneles + marco),
   así el resaltado no se recorta dentro de tablas con scroll. */
.tour-capa { position: fixed; inset: 0; z-index: 9998; pointer-events: none; }
.tour-capa > div { position: fixed; background: rgba(15, 23, 42, 0.72); }
.tour-capa .tour-marco { background: transparent; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 0 3px rgba(44, 110, 145, 0.75); }
.tour-tip {
    display: none; position: fixed; z-index: 9999; background: #fff; border-radius: 8px;
    padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); font-size: 0.9rem;
}
.tour-tip h4 { margin: 0 0 6px; font-size: 1rem; color: #2c3e50; }
.tour-tip p { margin: 0 0 4px; color: #444; }
.tour-tip-pie { margin-top: 12px; }
.tour-tip-pie small { display: block; margin-bottom: 8px; color: #7a878e; }
.tour-tip-botones { display: flex; gap: 6px; justify-content: flex-end; }
.tour-tip-botones .btn { padding: 6px 12px; font-size: 0.82rem; }

/* ==================== Menu lateral (solo PC >= 769 px) ====================
   Existe solo con sesion iniciada (header.php). En celular sigue el menu superior. */
.sidebar, .sb-notif-lista { display: none; }
@media (min-width: 769px) {
    .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; width: 235px;
        background: var(--clinica-oscuro); color: #fff; z-index: 1300;
    }
    body.con-sidebar { padding-left: 235px; }
    body.con-sidebar.sb-plegado { padding-left: 60px; }
    body.con-sidebar.sb-plegado .sidebar { width: 60px; }
    body.con-sidebar .navbar { display: none; }
    body.con-sidebar::before { left: 235px; }
    body.con-sidebar.sb-plegado::before { left: 60px; }

    .sb-marca { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .sb-logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 0.82rem; line-height: 1.25; }
    .sb-plegar { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,0.85); font-size: 1.05rem; cursor: pointer; padding: 2px 7px; border-radius: 4px; }
    .sb-plegar:hover { background: rgba(255,255,255,0.14); color: #fff; }

    .sb-perfil-fila { display: flex; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .sb-perfil { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 12px 14px; color: #fff; text-decoration: none; }
    .sb-perfil:hover { background: rgba(255,255,255,0.08); }
    .sb-notif { position: relative; flex: 0 0 auto; background: none; border: 0; color: #fff; cursor: pointer; padding: 8px; margin-right: 8px; border-radius: 50%; line-height: 0; }
    .sb-notif:hover { background: rgba(255,255,255,0.14); }
    .sb-notif .sb-ico { width: 20px; height: 20px; }
    .sb-notif .sb-badge { position: absolute; top: 0; right: 0; margin: 0; min-width: 18px; text-align: center; line-height: 1.5; }
    .sb-notif-lista { display: none; }
    .sb-notif-lista.open { display: block; }
    .sb-notif-lista { position: fixed; left: 235px; top: 70px; width: 300px; max-height: 60vh; overflow-y: auto; background: #fff; color: #333; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); padding: 10px 12px; z-index: 1310; }
    .sb-notif-lista h4 { margin: 0 0 8px; font-size: 0.95rem; border-bottom: 1px solid #eee; padding-bottom: 8px; }
    .sb-notif-lista a { display: block; padding: 8px 0; border-bottom: 1px solid #eee; color: #333; text-decoration: none; font-size: 0.85rem; }
    .sb-notif-lista a:hover { background: #f5f9ff; }
    .sb-notif-lista small { display: block; color: #666; }
    .sb-notif-lista p { margin: 0; font-size: 0.85rem; color: #666; }
    .sb-perfil img { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; object-fit: cover; }
    .sb-perfil-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
    .sb-perfil-txt strong, .sb-perfil-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sb-perfil-txt strong { font-size: 0.85rem; }
    .sb-perfil-txt small { color: rgba(255,255,255,0.7); font-size: 0.74rem; }

    .sb-nav { flex: 1; overflow-y: auto; padding: 6px 0; }
    .sb-link, .sb-grupo-t { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; color: rgba(255,255,255,0.88); text-decoration: none; font-size: 0.88rem; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }
    .sb-link:hover, .sb-grupo-t:hover { background: rgba(255,255,255,0.1); color: #fff; }
    .sb-link.activo { background: rgba(255,255,255,0.2); color: #fff; }
    .sb-grupo-t.activo { color: #fff; box-shadow: inset 3px 0 0 #fff; }
    .sb-ico { width: 18px; height: 18px; flex: 0 0 18px; }
    .sb-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sb-badge { margin-left: auto; background: #e74c3c; color: #fff; font-size: 0.7rem; padding: 2px 7px; border-radius: 10px; }
    .caret-sb { margin-left: auto; transition: transform 0.15s ease; font-size: 0.7rem; }
    .sb-grupo.open .caret-sb { transform: rotate(180deg); }
    .sb-sub { display: none; }
    .sb-grupo.open .sb-sub { display: block; }
    .sb-sub a { display: block; padding: 9px 16px 9px 44px; color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.84rem; }
    .sb-sub a:hover { background: rgba(255,255,255,0.1); color: #fff; }
    .sb-sub a.activo { background: rgba(255,255,255,0.2); color: #fff; box-shadow: inset 3px 0 0 #fff; }
    .sb-pie { border-top: 1px solid rgba(255,255,255,0.12); padding: 4px 0; }

    body.con-sidebar.sb-plegado .sb-logo,
    body.con-sidebar.sb-plegado .sb-perfil-txt,
    body.con-sidebar.sb-plegado .sb-txt,
    body.con-sidebar.sb-plegado .caret-sb { display: none; }
    body.con-sidebar.sb-plegado .sb-marca { justify-content: center; padding: 11px 0; }
    body.con-sidebar.sb-plegado .sb-plegar { margin: 0; }
    body.con-sidebar.sb-plegado .sb-perfil-fila { flex-direction: column; padding: 4px 0 6px; }
    body.con-sidebar.sb-plegado .sb-perfil { justify-content: center; flex: none; padding: 8px 0; }
    body.con-sidebar.sb-plegado .sb-notif { margin: 0; }
    body.con-sidebar.sb-plegado .sb-notif-lista { left: 60px; }
    body.con-sidebar.sb-plegado .sb-link, body.con-sidebar.sb-plegado .sb-grupo-t { justify-content: center; padding: 11px 0; }
    body.con-sidebar.sb-plegado .sb-nav { overflow: visible; }
    body.con-sidebar.sb-plegado .sb-grupo { position: relative; }
    body.con-sidebar.sb-plegado .sb-sub { position: absolute; left: 100%; top: 0; width: 215px; background: var(--clinica-oscuro); border-radius: 0 6px 6px 0; box-shadow: 0 6px 14px rgba(0,0,0,0.3); padding: 4px 0; }
    body.con-sidebar.sb-plegado .sb-sub { display: none; }
    body.con-sidebar.sb-plegado .sb-grupo:hover .sb-sub { display: block; }
    body.con-sidebar.sb-plegado .sb-sub a { padding: 9px 16px; }
}
@media print {
    .sidebar, .sb-notif-lista { display: none !important; }
    body.con-sidebar { padding-left: 0 !important; }
}

/* Páginas embebidas en las pestañas de la ficha: contenido pegado arriba y títulos al 50% */
body.embed .main-content { padding-top: 0; }
body.embed h1 { font-size: 1.375em; margin-top: 0; }
@media (max-width: 768px) {
    body.embed h1 { font-size: 1.03125rem; }
}

/* ==================== Móvil: barra inferior + menú lateral tipo app ==================== */
.tabbar-movil, .sb-velo { display: none; }
@media (max-width: 768px) {
    body.con-sidebar { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)); }
    body.con-sidebar .tabbar-movil {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--clinica-oscuro); z-index: 1600;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.18);
    }
    .tabbar-movil a, .tabbar-movil button {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; min-height: 56px; color: rgba(255,255,255,0.72); text-decoration: none;
        background: none; border: 0; font-family: inherit; font-size: 0.62rem; font-weight: 600;
        cursor: pointer; padding: 6px 2px;
    }
    .tabbar-movil svg { width: 22px; height: 22px; }
    .tabbar-movil .activo { color: #fff; }

    /* Drawer: el mismo sidebar se vuelve panel lateral deslizante */
    body.con-sidebar .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 84vw);
        background: var(--clinica-oscuro); color: #fff; z-index: 2001;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 18px rgba(0,0,0,0.3);
    }
    body.con-sidebar.sb-abierto .sidebar { transform: translateX(0); }
    body.con-sidebar .sb-velo {
        display: block; position: fixed; inset: 0; z-index: 2000;
        background: rgba(0,0,0,0.45); opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease;
    }
    body.con-sidebar.sb-abierto .sb-velo { opacity: 1; pointer-events: auto; }
    .sidebar .sb-plegar { display: none; }

    /* Estilos internos del drawer (los del menú de PC, adaptados al toque) */
    .sidebar .sb-marca { display: flex; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .sidebar .sb-logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 0.9rem; line-height: 1.25; }
    .sidebar .sb-perfil-fila { display: flex; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .sidebar .sb-perfil { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 14px; color: #fff; text-decoration: none; }
    .sidebar .sb-perfil img { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; object-fit: cover; }
    .sidebar .sb-perfil-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
    .sidebar .sb-perfil-txt strong, .sidebar .sb-perfil-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar .sb-perfil-txt strong { font-size: 0.88rem; }
    .sidebar .sb-perfil-txt small { color: rgba(255,255,255,0.7); font-size: 0.76rem; }
    .sidebar .sb-notif { position: relative; flex: 0 0 auto; background: none; border: 0; color: #fff; cursor: pointer; padding: 10px; margin-right: 8px; border-radius: 50%; line-height: 0; }
    .sidebar .sb-notif .sb-ico { width: 20px; height: 20px; }
    .sidebar .sb-notif .sb-badge { position: absolute; top: 0; right: 0; margin: 0; min-width: 18px; text-align: center; line-height: 1.5; }
    .sidebar .sb-nav { flex: 1; overflow-y: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }
    .sidebar .sb-link, .sidebar .sb-grupo-t { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 18px; color: rgba(255,255,255,0.9); text-decoration: none; font-size: 0.95rem; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }
    .sidebar .sb-link.activo { background: rgba(255,255,255,0.2); color: #fff; }
    .sidebar .sb-grupo-t.activo { color: #fff; box-shadow: inset 3px 0 0 #fff; }
    .sidebar .sb-ico { width: 20px; height: 20px; flex: 0 0 20px; }
    .sidebar .sb-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar .sb-badge { margin-left: auto; background: #e74c3c; color: #fff; font-size: 0.7rem; padding: 2px 7px; border-radius: 10px; }
    .sidebar .caret-sb { margin-left: auto; transition: transform 0.15s ease; font-size: 0.7rem; }
    .sidebar .sb-grupo.open .caret-sb { transform: rotate(180deg); }
    .sidebar .sb-sub { display: none; }
    .sidebar .sb-grupo.open .sb-sub { display: block; }
    .sidebar .sb-sub a { display: block; padding: 11px 18px 11px 48px; color: rgba(255,255,255,0.82); text-decoration: none; font-size: 0.9rem; }
    .sidebar .sb-sub a.activo { background: rgba(255,255,255,0.2); color: #fff; box-shadow: inset 3px 0 0 #fff; }
    .sidebar .sb-pie { border-top: 1px solid rgba(255,255,255,0.12); padding: 6px 0; }

    /* Campana y panel de canceladas: fuera del drawer en móvil
       (las notificaciones quedan en la campana de la barra superior) */
    .sidebar .sb-notif, .sb-notif-lista, .sb-notif-lista.open { display: none !important; }
}
@media print { .tabbar-movil, .sb-velo { display: none !important; } }

/* ==================== Móvil: pantalla Pacientes tipo app + ajustes varios ==================== */
.fab-nuevo, .icn-nuevo-paciente, .borrar-busq { display: none; }
@media (max-width: 768px) {
    /* El menú solo se abre desde la tabbar: fuera el ☰ superior */
    body.con-sidebar .nav-toggle { display: none; }

    /* Buscador tipo app: píldora redondeada con lupa; el botón se oculta (auto-envía) */
    .buscador-app { position: relative; }
    .buscador-app::before {
        content: '🔍'; position: absolute; left: 14px; top: 11px;
        font-size: 0.95rem; opacity: 0.55; pointer-events: none;
    }
    .buscador-app input[type="text"] {
        width: 100%; border-radius: 24px; padding: 11px 44px 11px 40px;
        border: 1px solid #ddd; background: #fff; font-size: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.07); box-sizing: border-box;
    }
    .borrar-busq {
        position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
        width: 28px; height: 28px; border-radius: 50%; border: 0;
        background: #e0e0e0; color: #555; font-size: 0.95rem;
        display: none; align-items: center; justify-content: center; cursor: pointer;
    }
    .buscador-app input:not(:placeholder-shown) ~ .borrar-busq { display: inline-flex; }

    /* "Nuevo paciente" como ícono persona+ junto al contador */
    .icn-nuevo-paciente {
        width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
        background: var(--clinica-oscuro); color: #fff; text-decoration: none;
        display: inline-flex; align-items: center; justify-content: center;
    }
    .icn-nuevo-paciente svg { width: 20px; height: 20px; }

    /* Lista tipo contactos: sin cabecera de tabla, renglones más altos */
    #pacientes-scroll thead { display: none; }
    #pacientes-scroll .fila-paciente td { padding: 13px 10px; font-size: 0.95rem; }

    /* "Nuevo paciente" como botón flotante (FAB) sobre la tabbar */
    .btn-nuevo-paciente { display: none !important; }
    .fab-nuevo {
        display: flex; align-items: center; justify-content: center;
        position: fixed; right: 16px;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        width: 56px; height: 56px; border-radius: 50%;
        background: var(--clinica-oscuro); color: #fff;
        font-size: 1.7rem; font-weight: 400; line-height: 1;
        text-decoration: none; z-index: 1500;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    .fab-nuevo:active { transform: scale(0.94); }
}
@media print { .fab-nuevo { display: none !important; } }

/* === Pendientes de pacientes: bloque en el menú lateral === */
.sb-pendientes { border-top: 1px solid rgba(255,255,255,0.12); padding: 6px 0; }
.sb-pend-head { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: rgba(255,255,255,0.88); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.sb-pend-head:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sb-pend-head .sb-badge { margin-left: auto; }
.sb-pend-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 16px 6px 24px; color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.78rem; line-height: 1.25; }
.sb-pend-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sb-pend-txt { min-width: 0; overflow: hidden; }
.sb-pend-txt strong { display: block; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-pend-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; }
.sb-pend-dot.imp-alta { background: #ff6b6b; box-shadow: 0 0 5px rgba(255,107,107,0.9); }
.sb-pend-dot.imp-media { background: #f5b041; }
.sb-pend-dot.imp-baja { background: #95a5a6; }
.sb-pend-vacio { margin: 2px 16px 6px; font-size: 0.75rem; color: rgba(255,255,255,0.5); }
@media (min-width: 769px) {
    body.con-sidebar.sb-plegado .sb-pendientes { display: none; }
}

/* === Importancia efectiva: colores de texto (campana, citas) === */
.imp-txt-alta { color: #c0392b; font-weight: 700; }
.imp-txt-media { color: #b9770e; font-weight: 600; }
.imp-txt-baja { color: #8a97a5; }

/* === Badge de pendientes en la lista de citas === */
.cita-pend { display: inline-block; margin-left: 6px; font-size: 0.78rem; text-decoration: none; }
.cita-pend:hover { text-decoration: underline; }

/* === Aviso de pendientes en la ficha del paciente === */
.aviso-pend { display: block; background: #fff8e1; border: 1px solid #f3e2b8; color: #b9770e; padding: 10px 14px; border-radius: 10px; margin: 10px 0 12px; font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.aviso-pend:hover { text-decoration: underline; }
.aviso-pend.alta { background: #fdeaea; border-color: #f5c6c6; color: #c0392b; }
