/* =========================================================
   MATRAZ - Portal central de resultados de Labocenter
   Colores base: azul y verde del logo. Editar solo en los dos
   bloques de variables (claro y oscuro).
   ========================================================= */

/* ---------- Variables: modo claro ---------- */
:root,
[data-bs-theme="light"] {
    --brand: #0038a0;              /* azul Labocenter */
    --brand-rgb: 0, 56, 160;
    --brand-strong: #002a78;
    --accent: #5a9a12;             /* verde Labocenter */
    --accent-rgb: 90, 154, 18;
    --violet: #7b3fa3;             /* violeta de la linea del logo */
    --on-brand: #ffffff;

    --app-bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f5f7fb;
    --line: #e1e6ee;
    --topbar-bg: rgba(255, 255, 255, .88);
    --grid-stripe: rgba(0, 56, 160, .03);
    --grid-hover: rgba(0, 56, 160, .07);
    --shadow: 0 1px 2px rgba(16, 30, 60, .04), 0 14px 34px -16px rgba(16, 30, 60, .22);

    --bs-body-font-family: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-body-color: #14213a;
    --bs-body-bg: var(--app-bg);
    --bs-border-color: #d6dde8;
    --bs-border-radius: .7rem;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 0, 56, 160;
    --bs-link-hover-color: var(--accent);
    --bs-link-hover-color-rgb: 90, 154, 18;
}

/* ---------- Variables: modo oscuro ---------- */
[data-bs-theme="dark"] {
    --brand: #86a9f2;
    --brand-rgb: 134, 169, 242;
    --brand-strong: #b3c9f7;
    --accent: #93cc52;
    --accent-rgb: 147, 204, 82;
    --violet: #c4a0e8;
    --on-brand: #08183a;

    --app-bg: #0c121c;
    --surface: #131c2a;
    --surface-2: #192436;
    --line: #24324a;
    --topbar-bg: rgba(14, 21, 33, .88);
    --grid-stripe: rgba(255, 255, 255, .025);
    --grid-hover: rgba(134, 169, 242, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px -18px rgba(0, 0, 0, .7);

    --bs-body-color: #dce4ef;
    --bs-body-bg: var(--app-bg);
    --bs-border-color: #2c3c55;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 134, 169, 242;
    --bs-link-hover-color: var(--accent);
    --bs-link-hover-color-rgb: 147, 204, 82;
}

/* ---------- Base ---------- */
html { color-scheme: light; }
[data-bs-theme="dark"] { color-scheme: dark; }

body {
    background: var(--app-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main { flex: 1 0 auto; }

.page {
    padding-top: 2rem;
    padding-bottom: 2.5rem;
}

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--topbar-bg);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 68px;
}

.brand { display: inline-flex; align-items: center; }
.brand img {
    display: block;
    height: 34px;
    width: auto;
}
.logo-dark { display: none !important; }
[data-bs-theme="dark"] .logo-light { display: none !important; }
[data-bs-theme="dark"] .logo-dark { display: block !important; }

.topbar-title {
    font-weight: 600;
    font-size: .95rem;
    color: var(--bs-secondary-color);
    padding-left: 1rem;
    border-left: 1px solid var(--line);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.topbar-actions .btn {
    height: 40px;
    padding: 0 1rem;
    font-size: .85rem;
    border-radius: 999px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--bs-border-color);
    background: var(--surface);
    color: var(--bs-body-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
.theme-toggle:focus-visible { outline: 0; box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .25); }
.theme-toggle svg { width: 18px; height: 18px; }

.icon-sun { display: none; }
[data-bs-theme="dark"] .icon-sun { display: block; }
[data-bs-theme="dark"] .icon-moon { display: none; }

/* Linea espectro: violeta, azul y verde, como la linea del logo */
.spectrum {
    height: 3px;
    background: linear-gradient(90deg, var(--violet) 0%, var(--brand) 45%, var(--accent) 100%);
}

/* ---------- Paneles ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
}
.panel + .panel,
.login-layout + .panel,
.panel + .msg-slot + .panel { margin-top: 1.5rem; }

.panel-body { padding: 1.5rem; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--line);
}
.panel-head h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

/* ---------- Estados (clases puestas por matraz.js) ---------- */
body.is-auth .guest-only { display: none !important; }
body.is-guest .auth-only { display: none !important; }
body.no-results .results-card { display: none; }
body.is-patient .search-card { display: none; }

/* Textos segun quien consulta */
.only-paciente,
.only-centro,
.only-none { display: none; }
body.mode-paciente .only-paciente,
body.mode-centro .only-centro,
body.mode-none .only-none { display: block; }
body.mode-paciente label .only-paciente,
body.mode-centro label .only-centro { display: inline; }

/* Sin elegir paciente/centro todavia: solo se ven los tabs */
body.is-guest.mode-none .session-fields { display: none; }

/* ---------- Ingreso ---------- */
body.is-guest .main { display: flex; align-items: center; }
body.is-guest .page { max-width: 480px; }
body.is-guest .session-card .panel-body { padding: 2.25rem 2rem; }

.session-head {
    position: relative;
    margin-bottom: 1.5rem;
}
.session-head h1 {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 1.35rem;
}
.session-head p {
    color: var(--bs-secondary-color);
    font-size: .9rem;
    line-height: 1.55;
    margin: 0;
}

/* Tabs Paciente / Centro de Salud (LinkButton del servidor) */
.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .25rem;
    padding: .3rem;
    border-radius: .9rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    margin-bottom: 1.5rem;
}
.mode-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: .4rem .75rem;
    border-radius: .65rem;
    font-weight: 700;
    font-size: .9rem;
    color: var(--bs-secondary-color);
    text-decoration: none;
    text-align: center;
    transition: background-color .15s, color .15s;
}
.mode-tab:hover { color: var(--brand); }
.mode-tab:focus-visible { outline: 0; box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .25); }
.mode-tab.is-active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 1px 2px rgba(16, 30, 60, .08), inset 0 -2px 0 var(--accent);
    cursor: default;
}

.mode-hint {
    margin: -.5rem 0 0;
    text-align: center;
    font-size: .875rem;
    color: var(--bs-secondary-color);
}

.session-fields {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.field-help {
    margin: .4rem 0 0;
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

/* Terminos */
.terms {
    padding: .8rem .9rem;
    border-radius: .7rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: .875rem;
    line-height: 1.5;
}
.terms-check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0 .5rem 0 0;
    vertical-align: -.2rem;
    accent-color: var(--brand);
    cursor: pointer;
}
.terms-check label { cursor: pointer; }
.terms-link {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-login {
    width: 100%;
    padding: .75rem 1rem;
}
.btn-login:disabled { opacity: .45; }

/* ---------- Ayuda de ingreso ---------- */
/* Escritorio: tarjeta a la derecha del ingreso */
@media (min-width: 992px) {
    body.is-guest .page { max-width: 880px; }
    body.is-guest .login-layout {
        display: grid;
        grid-template-columns: 480px 340px;
        justify-content: center;
        gap: 1.5rem;
        align-items: start;
    }
}
/* Escritorio grande: ayuda mas ancha, paciente y centro lado a lado */
@media (min-width: 1200px) {
    body.is-guest .page { max-width: 1080px; }
    body.is-guest .login-layout { grid-template-columns: 480px 560px; }
    #helpContent {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 1.5rem;
    }
    .help-card .help-intro,
    .help-card .help-foot { grid-column: 1 / -1; }
    .help-card .help-block + .help-block {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
        padding-left: 1.5rem;
        border-left: 1px solid rgba(var(--brand-rgb), .18);
    }
}

.help-card {
    background: rgba(var(--brand-rgb), .05);
    border: 1px solid rgba(var(--brand-rgb), .18);
    border-radius: 1.1rem;
    padding: 1.5rem;
}
.help-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 .9rem;
    color: var(--brand);
}
.help-title svg { width: 20px; height: 20px; flex: none; }

.help-intro {
    margin: 0 0 1.1rem;
    font-size: .875rem;
    line-height: 1.5;
}
.help-block + .help-block {
    margin-top: 1.1rem;
    padding-top: 1.1rem;
    border-top: 1px solid rgba(var(--brand-rgb), .18);
}
.help-block h3 {
    font-size: .9rem;
    font-weight: 800;
    margin: 0 0 .6rem;
    padding-left: .6rem;
    border-left: 3px solid var(--accent);
}
.help-list { margin: 0; }
.help-list dt {
    font-size: .8rem;
    font-weight: 800;
    color: var(--bs-body-color);
    margin-bottom: .1rem;
}
.help-list dd { font-size: .875rem; line-height: 1.5; margin: 0 0 .6rem; }
.help-list dd:last-child { margin-bottom: 0; }
.help-eg {
    display: block;
    font-size: .8rem;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}
.help-foot { margin: 1.1rem 0 0; font-size: .8rem; color: var(--bs-secondary-color); }

/* Boton "?" junto al titulo (tablet y celular) */
.help-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(var(--brand-rgb), .25);
    background: rgba(var(--brand-rgb), .07);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.help-btn:hover { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.help-btn:focus-visible { outline: 0; box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .25); }
.help-btn svg { width: 18px; height: 18px; }
@media (max-width: 991.98px) {
    .session-head h1 { padding-right: 3rem; }
}

/* ---------- Dentro: franja del usuario (sin tarjeta) ---------- */
body.is-auth .session-card {
    background: transparent;
    border: 0;
    box-shadow: none;
}
body.is-auth .session-card .panel-body { padding: 0 0 .5rem; }
body.is-auth .session-user { max-width: 460px; }

/* Mensaje del servidor (LMsg): solo aparece si trae texto */
.res-msg {
    display: block;
    margin-top: 1rem;
    padding: .7rem .9rem;
    border-radius: .7rem;
    font-size: .875rem;
    text-align: center;
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
    border: 1px solid var(--bs-danger-border-subtle);
}
.res-msg:empty { display: none; }
.msg-slot .res-msg { margin: 1.5rem 0 0; }

/* ---------- Formularios y botones ---------- */
.form-label {
    font-weight: 700;
    font-size: .85rem;
    margin-bottom: .45rem;
}

.form-control,
.form-select { padding-top: .55rem; padding-bottom: .55rem; }
.form-control:focus,
.form-select:focus {
    border-color: rgba(var(--brand-rgb), .65);
    box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .18);
}
.form-control:disabled,
.form-control[readonly] {
    background: var(--surface-2);
    font-weight: 700;
    opacity: 1;
}

.input-group-text {
    background: var(--surface-2);
    color: var(--bs-secondary-color);
}

.btn { font-weight: 700; }

.btn-primary {
    --bs-btn-color: var(--on-brand);
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: var(--on-brand);
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: var(--brand-strong);
    --bs-btn-active-color: var(--on-brand);
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-disabled-color: var(--on-brand);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: var(--on-brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-color: var(--on-brand);
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}

.btn-soft {
    --bs-btn-color: var(--brand);
    --bs-btn-bg: rgba(var(--brand-rgb), .1);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--on-brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-color: var(--on-brand);
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}

/* ---------- Busqueda (centros): por mes, por dia, por paciente ---------- */
.col-title {
    display: block;
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: .9rem;
}

/* Celular: paciente, dia, mes (uno bajo otro) */
.search-grid {
    display: grid;
    gap: 1.75rem;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "pac" "dia" "mes";
}
.s-mes { grid-area: mes; }
.s-dia { grid-area: dia; }
.s-pac { grid-area: pac; }

/* Tablet: calendario a la izquierda; paciente y mes a la derecha */
@media (min-width: 768px) {
    .search-grid {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "dia pac" "dia mes";
        column-gap: 2rem;
        align-items: start;
    }
    .s-pac,
    .s-mes { border-left: 1px solid var(--line); padding-left: 2rem; }
}

/* Escritorio: mes | dia | paciente, como el orden original */
@media (min-width: 1200px) {
    .search-grid {
        grid-template-columns: minmax(0, .8fr) auto minmax(0, 1.2fr);
        grid-template-areas: "mes dia pac";
        column-gap: 2.5rem;
    }
    .s-mes { border-left: 0; padding-left: 0; }
    .s-dia,
    .s-pac { border-left: 1px solid var(--line); padding-left: 2.5rem; }
}

@media (min-width: 576px) {
    .input-rut { max-width: 360px; }
}

/* ---------- Calendario (asp:Calendar) ---------- */
.cal-wrap {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: .9rem;
    padding: .75rem .75rem .5rem;
}

.cal {
    width: 300px !important;
    max-width: 100%;
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 2px !important;
    font-size: .85rem;
    background: transparent !important;
}
.cal table { border-spacing: 0 !important; border: 0 !important; }
.cal td,
.cal th {
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    text-align: center;
}

.cal .cal-title,
.cal .cal-title td {
    color: var(--bs-body-color) !important;
    font-weight: 700;
    font-size: .95rem;
}
.cal .cal-title td { padding-bottom: .5rem !important; }
.cal .cal-title td:nth-child(2)::first-letter { text-transform: uppercase; }

.cal .cal-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--bs-border-color);
    background: var(--surface);
    color: var(--bs-body-color) !important;
    text-decoration: none;
    font-size: 1.15rem;
    line-height: 1;
}
.cal .cal-nav a:hover { border-color: var(--brand); color: var(--brand) !important; }

.cal th,
.cal .cal-dow {
    color: var(--bs-secondary-color) !important;
    font-size: .75rem;
    font-weight: 700;
    padding: .3rem 0 !important;
}

.cal td.cal-day a,
.cal td.cal-weekend a,
.cal td.cal-today a,
.cal td.cal-selected a,
.cal td.cal-other a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    border-radius: .6rem;
    color: var(--bs-body-color) !important;
    text-decoration: none;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background-color .12s;
}
.cal td a:hover { background: rgba(var(--brand-rgb), .12); }
.cal td a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.cal td.cal-weekend a { color: var(--violet) !important; }
.cal td.cal-other a { opacity: .3; }
.cal td.cal-today a {
    box-shadow: inset 0 0 0 2px var(--accent);
    font-weight: 800;
}
.cal td.cal-selected a {
    background: var(--brand);
    color: var(--on-brand) !important;
    font-weight: 800;
    box-shadow: 0 6px 14px -6px rgba(var(--brand-rgb), .8);
}

/* Selector de mes/anio en el titulo del calendario */
.cal-picker {
    display: flex;
    justify-content: center;
    gap: .25rem;
}
.cal-picker .form-select {
    width: auto;
    font-weight: 700;
    font-size: .9rem;
    padding: .2rem 1.75rem .2rem .55rem;
    background-color: transparent;
    border-color: transparent;
    background-position: right .4rem center;
    cursor: pointer;
}
.cal-picker .form-select:hover { border-color: var(--bs-border-color); background-color: var(--surface); }

/* ---------- Grilla de informes ---------- */
.results-scroll {
    max-height: 68vh;
    overflow: auto;
    border-radius: 0 0 1.1rem 1.1rem;
}

.grid {
    --bs-table-bg: transparent;
    --bs-table-color: var(--bs-body-color);
    --bs-table-border-color: var(--line);
    width: 100%;
    font-size: .85rem;
}

.grid th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    color: var(--bs-secondary-color);
    font-size: .78rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    padding: .7rem .85rem;
    border-bottom: 1px solid var(--bs-border-color);
}
.grid th.text-center { text-align: center; }

.grid td {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--line);
}

.grid > tbody > tr:nth-child(even) > td { --bs-table-bg-type: var(--grid-stripe); }
.grid > tbody > tr:hover > td { --bs-table-bg-state: var(--grid-hover); }
.grid > tbody > tr:last-child > td { border-bottom: 0; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-strong { font-weight: 800; }
.cell-patient { font-weight: 700; min-width: 14rem; }
.cell-muted { color: var(--bs-secondary-color); font-size: .8rem; }

.grid input[type="submit"] { white-space: nowrap; }

.link-report {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.link-report::before {
    content: "";
    width: 1rem;
    height: 1rem;
    flex: none;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.link-report:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- DataTables ---------- */
.results-scroll.has-dt {
    max-height: none;
    overflow-x: auto;
}
.results-scroll.has-dt .grid th { position: relative; }

.dt-container { padding: .5rem 1.25rem 1.1rem; }
.dt-container .dt-search input {
    width: 17rem;
    max-width: 100%;
    margin-left: 0 !important;
}
.dt-container .dt-length select { width: auto; display: inline-block; margin: 0 .35rem; }
.dt-container .dt-info,
.dt-container .dt-length { color: var(--bs-secondary-color); font-size: .85rem; }
.dt-container table.grid { margin: .5rem 0 !important; }

table.grid.dataTable th.dt-type-numeric,
table.grid.dataTable td.dt-type-numeric { text-align: left; }

.pagination {
    --bs-pagination-color: var(--brand);
    --bs-pagination-bg: var(--surface);
    --bs-pagination-border-color: var(--bs-border-color);
    --bs-pagination-hover-color: var(--brand);
    --bs-pagination-hover-bg: rgba(var(--brand-rgb), .1);
    --bs-pagination-hover-border-color: var(--bs-border-color);
    --bs-pagination-focus-color: var(--brand);
    --bs-pagination-focus-bg: rgba(var(--brand-rgb), .1);
    --bs-pagination-focus-box-shadow: 0 0 0 .22rem rgba(var(--brand-rgb), .2);
    --bs-pagination-active-color: var(--on-brand);
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-font-size: .85rem;
    margin-bottom: 0;
}

/* ---------- Modal de terminos ---------- */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
}
.modal-header,
.modal-footer { border-color: var(--line); }
.modal-title { font-size: 1rem; font-weight: 800; color: var(--brand); }

.terms-body { padding: 0; }
.terms-frame {
    display: block;
    width: 100%;
    height: 70vh;
    border: 0;
    background: #fff;
}
.terms-fallback {
    display: none;
    padding: 1.5rem;
    text-align: center;
    color: var(--bs-secondary-color);
}
#termsModal.no-pdf .terms-frame { display: none; }
#termsModal.no-pdf .terms-fallback { display: block; }

/* ---------- Indicador de carga ---------- */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 245, 249, .6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
}
[data-bs-theme="dark"] .page-loader { background: rgba(12, 18, 28, .6); }
.page-loader.is-visible { opacity: 1; visibility: visible; }

.loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
    font-size: .85rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
}

/* Tres puntos con los colores de la linea del logo */
.loader-dots { display: flex; gap: .45rem; }
.loader-dots i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: dot-bounce 1s ease-in-out infinite;
}
.loader-dots i:nth-child(1) { background: var(--violet); }
.loader-dots i:nth-child(2) { background: var(--brand); animation-delay: .15s; }
.loader-dots i:nth-child(3) { background: var(--accent); animation-delay: .3s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-7px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .loader-dots i { animation: none; opacity: 1; }
}

/* ---------- Pie ---------- */
.site-footer {
    padding: 1.25rem 0;
    font-size: .8rem;
    color: var(--bs-secondary-color);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}

/* ---------- Movil ---------- */
@media (max-width: 575.98px) {
    .page { padding-top: 1.25rem; }
    .panel-body { padding: 1.15rem; }
    body.is-guest .session-card .panel-body { padding: 1.75rem 1.25rem; }
    .brand img { height: 26px; }
    .dt-container { padding: .5rem .75rem 1rem; }
    .dt-container .dt-search input { width: 100%; }
    .cal-wrap { display: block; }
    .cal { width: 100% !important; }

    /* "Terminar Consulta" como icono */
    .topbar-actions .js-logout {
        width: 40px;
        padding: 0;
        color: transparent;
        text-indent: -999px;
        overflow: hidden;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / 18px no-repeat;
    }
    [data-bs-theme="dark"] .topbar-actions .js-logout {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23adb5bd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E");
    }
}
