/* ============================================
   DX Portal de Médicos - misma identidad que DX.Frontend
   Teal clínico + navy profundo + acento coral, Figtree.
   ============================================ */
:root {
    --dx-font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --dx-primary: #0f766e;
    --dx-primary-dark: #115e59;
    --dx-primary-light: #14b8a6;
    --dx-primary-soft: #e6f4f1;
    --dx-navy: #0b2540;
    --dx-navy-2: #0a1f36;
    --dx-coral: #e8573f;
    --dx-sidebar-text: #b6c4d2;
    --dx-sidebar-title: #8aa0b8;
    --dx-sidebar-width: 256px;
    --dx-body-bg: #f3f6f6;
    --dx-border: #e2e8e8;
    --dx-text: #0e1b24;
    --dx-text-muted: #4b5b63;

    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
    --bs-link-hover-color-rgb: 17, 94, 89;
    --bs-body-font-family: var(--dx-font);
    --bs-body-color: #0e1b24;
    --bs-border-color: #e2e8e8;
    --bs-focus-ring-color: rgba(20, 184, 166, 0.3);
}

body {
    background: var(--dx-body-bg);
    font-family: var(--dx-font);
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--dx-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--dx-text);
}

:focus-visible {
    outline: 3px solid rgba(20, 184, 166, 0.55);
    outline-offset: 2px;
}

/* ---------- Botones ---------- */
.btn {
    font-weight: 600;
    border-radius: 10px;
    transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.btn-primary {
    --bs-btn-bg: var(--dx-primary);
    --bs-btn-border-color: var(--dx-primary);
    --bs-btn-hover-bg: var(--dx-primary-dark);
    --bs-btn-hover-border-color: var(--dx-primary-dark);
    --bs-btn-active-bg: #134e4a;
    --bs-btn-active-border-color: #134e4a;
    --bs-btn-disabled-bg: var(--dx-primary);
    --bs-btn-disabled-border-color: var(--dx-primary);
    box-shadow: 0 1px 2px rgba(15, 118, 110, 0.25);
}

.btn-primary:hover { box-shadow: 0 4px 12px rgba(15, 118, 110, 0.28); }

.btn-outline-primary {
    --bs-btn-color: var(--dx-primary);
    --bs-btn-border-color: rgba(15, 118, 110, 0.45);
    --bs-btn-hover-bg: var(--dx-primary);
    --bs-btn-hover-border-color: var(--dx-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--dx-primary-dark);
    --bs-btn-active-border-color: var(--dx-primary-dark);
}

.btn-sm { border-radius: 8px; }

/* ---------- Formularios ---------- */
.form-control,
.form-select {
    border-radius: 10px;
    border-color: #c7d1d2;
}

.form-control:not(.form-control-sm),
.form-select:not(.form-select-sm) { min-height: 42px; }

.form-control:focus,
.form-select:focus {
    border-color: var(--dx-primary-light);
    box-shadow: 0 0 0 0.25rem rgba(20, 184, 166, 0.22);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--dx-text-muted);
}

/* ---------- Marca ---------- */
.brand-mark {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    background: linear-gradient(140deg, #14b8a6 0%, #0f766e 60%, #0b5f59 100%);
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-mark::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dx-coral);
    border: 2px solid var(--dx-navy);
}

.auth-card .brand-mark {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 16px;
    font-size: 1.2rem;
}

.auth-card .brand-mark::after {
    width: 13px;
    height: 13px;
    border: 3px solid #fff;
}

/* ---------- Layout principal ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--dx-sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--dx-navy) 0%, var(--dx-navy-2) 100%);
    color: var(--dx-sidebar-text);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(6, 16, 25, 0.12);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.25rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand:hover { color: #fff; }

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.15;
}

.sidebar-brand .brand-text small {
    font-weight: 500;
    font-size: 0.72rem;
    color: var(--dx-sidebar-title);
}

.sidebar-nav {
    padding: 0.75rem;
}

.sidebar-nav .nav-title {
    padding: 0.75rem 0.75rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dx-sidebar-title);
}

.sidebar-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 42px;
    padding: 0.6rem 0.75rem;
    margin: 1px 0;
    border-radius: 10px;
    color: var(--dx-sidebar-text);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(45, 212, 191, 0.14);
    color: #5eead4;
    font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #2dd4bf;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--dx-border);
}

.app-topbar .btn-link {
    min-height: 40px;
    border-radius: 10px;
}

.app-topbar .btn-link:hover {
    background: var(--dx-primary-soft);
}

.app-content {
    flex: 1;
    padding: 1.75rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

/* ---------- Cards / tablas ---------- */
.card {
    border: 1px solid var(--dx-border) !important;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(11, 37, 64, 0.06), 0 1px 2px rgba(11, 37, 64, 0.04) !important;
}

.table {
    --bs-table-hover-bg: rgba(15, 118, 110, 0.05);
}

.table thead th {
    background: #f6f8f8;
    color: #5c6b73;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--dx-border);
    white-space: nowrap;
}

.table > tbody > tr > td {
    vertical-align: middle;
    border-color: #eef2f2;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 10px;
    border: 1px solid #c7d1d2;
}

.page-item.active .page-link {
    background: var(--dx-primary);
    border-color: var(--dx-primary);
}

.page-link { color: var(--dx-primary); }

/* ---------- Badges (tintes suaves) ---------- */
.badge {
    font-weight: 600;
    border-radius: 999px;
    padding: 0.35em 0.7em;
}

.badge.bg-success   { background-color: #dcfce7 !important; color: #166534 !important; }
.badge.bg-danger    { background-color: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-warning   { background-color: #fef3c7 !important; color: #92400e !important; }
.badge.bg-info      { background-color: #fdece8 !important; color: #b0321e !important; }
.badge.bg-primary   { background-color: var(--dx-primary-soft) !important; color: var(--dx-primary) !important; }
.badge.bg-secondary { background-color: #eef2f2 !important; color: #33424a !important; }

.alert { border-radius: 12px; }

.dropdown-menu {
    border: 1px solid var(--dx-border);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(11, 37, 64, 0.1);
    padding: 0.35rem;
}

.dropdown-item { border-radius: 8px; }
.dropdown-item:hover,
.dropdown-item:focus { background: var(--dx-primary-soft); }

.swal2-popup { border-radius: 16px !important; font-family: var(--dx-font) !important; }
.swal2-styled.swal2-confirm { background-color: var(--dx-primary) !important; border-radius: 10px !important; }

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-content {
        padding: 1rem;
    }
}

/* ---------- Login ---------- */
html:has(.auth-body) { background-color: #061321; }

.auth-body {
    min-height: 100vh;
    background-attachment: fixed;
    background-color: #061321;
    background-image:
        radial-gradient(60rem 40rem at 10% -10%, rgba(20, 184, 166, 0.28), transparent 60%),
        radial-gradient(45rem 35rem at 110% 110%, rgba(232, 87, 63, 0.2), transparent 60%),
        linear-gradient(160deg, #0b2540 0%, #061321 100%);
}

.auth-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    border: 0 !important;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(2, 8, 15, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06) !important;
}

/* ---------- Logo ---------- */
.sidebar-brand {
    justify-content: center;
}

.sidebar-brand .brand-logo {
    display: block;
    width: 100%;
    max-width: 190px;
    height: auto;
}

.auth-logo {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    margin: 0 auto 1.25rem;
}

/* ---------- Select2 (todo <select> es Select2) ---------- */
.select2-container--bootstrap-5 .select2-selection { border-radius: 10px; border-color: #c7d1d2; min-height: 42px; }
.select2-container--bootstrap-5 .select2-selection.select2--small { min-height: 32px; border-radius: 8px; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: var(--dx-primary-light); box-shadow: 0 0 0 0.25rem rgba(20, 184, 166, 0.22); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option--highlighted { background-color: var(--dx-primary-soft); color: var(--dx-text); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option--selected { background-color: var(--dx-primary); color: #fff; }
.col-auto > .select2-container, .d-flex > .select2-container { min-width: 12rem; }

/* =====================================================================
   RESPONSIVE: celular (< 768px) y tablet (768–991px)
   ===================================================================== */

/* Fondo del menú lateral abierto en celular/tablet */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(6, 16, 25, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s;
}

.sidebar-backdrop.show { opacity: 1; visibility: visible; }
body.sidebar-abierto { overflow: hidden; }

/* Tablas: botón +/- de la extensión Responsive y fila desplegable */
table.dataTable.dtr-column > tbody > tr > td.dtr-control,
table.dataTable.dtr-column > tbody > tr > th.dtr-control {
    position: relative;
    padding-left: 2.1rem !important;
    cursor: pointer;
}

table.dataTable.dtr-column > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-column > tbody > tr > th.dtr-control::before {
    content: '+';
    position: absolute;
    left: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.3rem;
    height: 1.3rem;
    line-height: 1.25rem;
    border-radius: 50%;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    background: #0f766e;
    box-shadow: none;
    border: 0;
    margin: 0;
}

table.dataTable.dtr-column > tbody > tr.parent > td.dtr-control::before,
table.dataTable.dtr-column > tbody > tr.parent > th.dtr-control::before {
    content: '−';
    background: #e8573f;
}

/* Sin columnas ocultas no se muestra el botón */
table.dataTable.dtr-column:not(.collapsed) > tbody > tr > td.dtr-control,
table.dataTable.dtr-column:not(.collapsed) > tbody > tr > th.dtr-control { padding-left: 0.75rem !important; cursor: auto; }
table.dataTable.dtr-column:not(.collapsed) > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-column:not(.collapsed) > tbody > tr > th.dtr-control::before { display: none; }

table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details > li { padding: 0.5rem 0; border-bottom-color: #eef2f2; }
table.dataTable > tbody > tr.child span.dtr-title {
    min-width: 7.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #5c6b73);
}

@media (max-width: 991.98px) {
    .sidebar { width: min(85vw, 300px); }
}

@media (max-width: 767.98px) {
    /* iOS hace zoom en campos con texto < 16px */
    input.form-control, select.form-select, textarea.form-control, .dataTables_filter input,
    .select2-container .select2-selection, .select2-search__field { font-size: 16px !important; }

    /* Objetivos táctiles */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }

    /* En celular el texto de las celdas no se parte: así Responsive pasa columnas a la fila desplegable */
    table.dataTable > tbody > tr > td, table.dataTable > thead > tr > th { white-space: nowrap; }
    table.dataTable > tbody > tr.child td { white-space: normal; }
    table.dataTable > tbody > tr.child span.dtr-data { white-space: normal; word-break: break-word; }

    /* Controles de DataTables: mostrar/buscar a lo ancho, paginación centrada */
    .dataTables_wrapper .row > div[class*="col-"] { width: 100%; }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info { text-align: left !important; }
    .dataTables_wrapper .dataTables_filter label { display: flex; align-items: center; gap: 0.5rem; width: 100%; }
    .dataTables_wrapper .dataTables_filter input { flex: 1; width: auto !important; margin-left: 0 !important; }
    .dataTables_wrapper .dataTables_length { margin-bottom: 0.5rem; }
    .dataTables_wrapper .dataTables_paginate { margin-top: 0.5rem; }
    .dataTables_wrapper .dataTables_paginate .pagination { justify-content: center !important; flex-wrap: wrap; }
    .dataTables_wrapper .dt-buttons { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }

    /* Modales: pantalla completa con botones siempre visibles abajo (los pequeños de confirmación no) */
    .modal-dialog:not(.modal-sm) { max-width: none !important; width: 100%; margin: 0 !important; min-height: 100%; }
    .modal-dialog:not(.modal-sm) .modal-content { min-height: 100vh; min-height: 100dvh; border-radius: 0 !important; border: 0; }
    .modal-dialog:not(.modal-sm) .modal-body { flex: 1 1 auto; }
    .modal-dialog:not(.modal-sm) .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        flex-wrap: wrap;
        gap: 0.5rem;
        box-shadow: 0 -4px 12px rgba(11, 37, 64, 0.08);
    }
    .modal-dialog:not(.modal-sm) .modal-footer > * { margin: 0; }
    .modal-dialog:not(.modal-sm) .modal-footer > .btn { flex: 1 1 auto; }
    .modal-dialog:not(.modal-sm) .modal-footer > .me-auto { flex-basis: 100%; }

    /* SweetAlert dentro de la pantalla */
    .swal2-popup { width: calc(100vw - 2rem) !important; }
}

@media (max-width: 991.98px) {
    .app-sidebar { z-index: 1040; width: min(85vw, 280px); }
}

@media (max-width: 767.98px) {
    .app-topbar { padding: 0 0.75rem; }
    .app-content { padding: 0.85rem; }
    .page-header h1 { font-size: 1.35rem; }
    /* Filtros del encabezado a lo ancho */
    .page-header > .d-flex { width: 100%; flex-wrap: wrap; }
    .page-header > .d-flex > select, .page-header > .d-flex > .select2-container { flex: 1 1 140px; width: auto !important; min-width: 0 !important; }
    .auth-card .card-body { padding: 1.75rem 1.25rem !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Portal: bienvenida ---------- */
/* d-flex y demás utilidades de Bootstrap ganarían al atributo hidden */
[hidden] { display: none !important; }

.min-w-0 { min-width: 0; }

.portal-stat {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    height: 100%;
    padding: 1rem 1.15rem;
    background: #fff;
    border: 1px solid var(--dx-border);
    border-radius: 14px;
    color: var(--dx-text-muted);
    text-decoration: none;
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.portal-stat:hover { border-color: var(--dx-primary-light); box-shadow: 0 4px 14px rgba(11, 37, 64, 0.08); color: var(--dx-text-muted); }
.portal-stat > i {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--dx-primary-soft);
    color: var(--dx-primary);
    font-size: 1.1rem;
}
.portal-stat strong { display: block; font-size: 1.5rem; line-height: 1.15; font-weight: 800; color: var(--dx-text); }

.portal-tarjeta {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: #fff;
    border: 1.5px solid var(--dx-border);
    border-radius: 14px;
    transition: border-color 0.15s ease-out, background-color 0.15s ease-out;
}
.portal-tarjeta.seleccionada { border-color: var(--dx-primary); background: #f7fbfa; }
.portal-tarjeta .form-check-input { flex: none; width: 1.3rem; height: 1.3rem; }
.form-check-input:checked { background-color: var(--dx-primary); border-color: var(--dx-primary); }
.portal-tarjeta-titulo { display: block; font-weight: 700; color: var(--dx-text); overflow-wrap: anywhere; cursor: pointer; }
.portal-tarjeta-diagnostico {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--dx-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.portal-tarjeta fieldset { margin-top: auto !important; padding-top: 0.6rem; }
.portal-aviso { color: #92400e; margin-top: 0.4rem; }
.portal-leyenda { float: none; width: auto; margin-bottom: 0.3rem; font-size: 0.78rem; font-weight: 700; color: var(--dx-text-muted); }

.portal-chip {
    padding: 0.28rem 0.65rem;
    border: 1.5px solid #c7d1d2;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #33424a;
    cursor: pointer;
    transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.portal-chip:hover { border-color: var(--dx-primary); }
.btn-check:checked + .portal-chip { background: var(--dx-primary); border-color: var(--dx-primary); color: #fff; }
.btn-check:focus-visible + .portal-chip { outline: 3px solid rgba(20, 184, 166, 0.55); outline-offset: 2px; }

.portal-vacio { padding: 2.5rem 1rem; text-align: center; color: var(--dx-text-muted); background: #fff; border: 1px dashed #c7d1d2; border-radius: 14px; }
.portal-vacio > i { display: block; margin-bottom: 0.5rem; font-size: 1.75rem; color: var(--dx-primary); }

.portal-acciones {
    position: sticky;
    bottom: 0.75rem;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--dx-navy);
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(11, 37, 64, 0.3);
}
.portal-acciones[hidden] { display: none; }
.portal-acciones .btn-outline-primary { color: #fff; border-color: rgba(255, 255, 255, 0.55); background: transparent; }
.portal-acciones .btn-outline-primary:hover { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: #fff; }

/* ---------- Calendario ---------- */
.dxcal-encabezado { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.dxcal-encabezado strong { display: inline-block; }
.dxcal-encabezado strong::first-letter { text-transform: uppercase; }
.dxcal-nav { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--dx-primary); }
.dxcal-nav:hover:not(:disabled) { background: var(--dx-primary-soft); }
.dxcal-nav:disabled { color: #b6c0c2; }
.dxcal-semana, .dxcal-dias { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dxcal-semana span { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--dx-text-muted); padding-bottom: 0.25rem; }
.dxcal-dia {
    position: relative;
    aspect-ratio: 1;
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--dx-text);
    font-weight: 600;
}
.dxcal-dia:hover:not(:disabled) { background: var(--dx-primary-soft); }
.dxcal-dia:disabled { color: #a9b5b7; font-weight: 400; }
.dxcal-dia.hoy { box-shadow: inset 0 0 0 1.5px var(--dx-primary-light); }
.dxcal-dia.elegido { background: var(--dx-primary); color: #fff; }
.dxcal-marca {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--dx-coral);
    color: #fff;
    font-size: 0.66rem;
    line-height: 16px;
}

/* ---------- Enlace público de la paciente ---------- */
.elegir-card { max-width: 440px; width: 100%; }
.elegir-contacto {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--dx-border);
    font-size: 0.875rem;
}
.elegir-contacto dt { font-weight: 600; color: var(--dx-text-muted); }
.elegir-contacto dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Historial ---------- */
.consulta.ultima { box-shadow: inset 3px 0 0 var(--dx-primary), 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; }
.consulta-seccion { padding: 0.6rem 0; border-top: 1px solid #eef2f2; }
.consulta-seccion h4 { margin-bottom: 0.2rem; font-size: 0.8rem; font-weight: 700; color: var(--dx-primary-dark); letter-spacing: 0; }
.consulta-seccion p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.consulta-fotos { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.consulta-seccion .consulta-fotos { margin-top: 0.5rem; }
.consulta-fotos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: #eef2f2; }
.consulta-foto { position: relative; display: inline-block; }
.consulta-foto button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--dx-navy);
    color: #fff;
    font-size: 0.8rem;
}

/* ---------- Barra inferior (celular y tablet) ---------- */
.portal-tabbar { display: none; }

@media (max-width: 991.98px) {
    .portal-tabbar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 1030;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
        background: #fff;
        border-top: 1px solid var(--dx-border);
    }
    .portal-tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 56px;
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--dx-text-muted);
        text-decoration: none;
    }
    .portal-tabbar a i { font-size: 1.1rem; }
    .portal-tabbar a.active { color: var(--dx-primary); }
    .app-content { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
    .portal-acciones { bottom: calc(64px + env(safe-area-inset-bottom)); }
}

@media (max-width: 575.98px) {
    .portal-acciones { gap: 0.4rem 0.75rem; padding: 0.6rem 0.75rem; }
    .portal-acciones .btn { flex: 1 1 40%; padding-left: 0.4rem; padding-right: 0.4rem; }
    .portal-acciones > div { width: 100%; }
    .portal-stat { flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0.7rem; font-size: 0.78rem; line-height: 1.25; }
    .portal-stat > i { display: none; }
    .portal-acciones .select2-container { flex: 1; }
    .btn-group[aria-label="Periodo"] { display: flex; }
    .btn-group[aria-label="Periodo"] .btn { flex: 1; padding-left: 0.35rem; padding-right: 0.35rem; font-size: 0.82rem; }
}
