/* ===========================
   CENTRAL - Portal CSS
   =========================== */

:root {
    --brand:       #5797E8;
    --brand-dark:  #185FA5;
    --sidebar-w:   260px;
    --topbar-h:    56px;
    --bg-body:     #f0f6ff;
    --sidebar-bg:  #0f1f38;
    --sidebar-text:#c8d8f0;
    --sidebar-hover:#ffffff12;
    --sidebar-active:#5797E820;
    --radius-card: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    margin: 0;
    color: #1e293b;
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.4rem 1.25rem 1rem;
    border-bottom: 1px solid #ffffff10;
    margin-bottom: .5rem;
}

.brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Logo de Consorcio Santa Marta: fondo claro para que la pirámide (tonos
   azul-grises) resalte sobre el menú oscuro. */
.brand-logo {
    background: #ffffff;
    padding: 5px;
}
.brand-logo img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
}

.brand-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    letter-spacing: .3px;
}

.sidebar-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #6b82a0;
    padding: .75rem 1.25rem .3rem;
    text-transform: uppercase;
}

.sidebar-nav {
    list-style: none;
    padding: 0 .75rem;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .6rem .9rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-nav .nav-link.active {
    background: var(--brand);
    color: white;
    box-shadow: 0 4px 12px rgba(87,151,232,.35);
}

/* El bloque de usuario estaba en el pie de la barra lateral, sobre fondo oscuro.
   Se movió a la cabecera para que las tres aplicaciones lo muestren en el mismo
   lugar: siempre visible, sin depender de que la barra esté abierta. */

/* ===========================
   CABECERA
   =========================== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 2rem;
    z-index: 999;
}

.topbar-toggle {
    display: none;               /* solo en pantalla chica */
    background: transparent;
    border: none;
    color: #334155;
    font-size: 1.4rem;
    padding: 0;
    line-height: 1;
}

.topbar-title {
    color: #64748b;
    font-weight: 600;
    font-size: .875rem;
    flex: 1;
}

/* ── Usuario en la cabecera ──────────────────────────────────── */
.topbar-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .5rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background .15s;
}

.topbar-user:hover { background: #f1f5f9; }
.topbar-user::after { display: none; }   /* sin el caret de Bootstrap: hay flecha propia */

.topbar-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.topbar-user-name   { font-size: .875rem; font-weight: 600; color: #16202e; line-height: 1.1; }
.topbar-user-role   { font-size: .72rem; color: #64748b; }
.topbar-user-flecha { font-size: .7rem; color: #94a3b8; }

.topbar-menu {
    min-width: 210px;
    margin-top: .5rem;
    border: none;
    border-radius: .75rem;
    padding-top: 0;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
    overflow: hidden;
}

.topbar-menu-cabecera {
    padding: .65rem .9rem;
    background: #f8fafc;
}

.topbar-menu-nombre { font-size: .875rem; font-weight: 600; color: #16202e; }
.topbar-menu-correo { font-size: .75rem; color: #64748b; word-break: break-all; }

.topbar-menu-salir {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .45rem .9rem;
    border: none;
    background: transparent;
    font-size: .875rem;
    color: #dc2626;
    cursor: pointer;
    text-align: left;
}

.topbar-menu-salir:hover { background: #fef2f2; color: #b91c1c; }

/* Cambiar de usuario: misma forma que «Cerrar sesión», en color neutro. */
.topbar-menu-salir.topbar-menu-cambiar { color: #16202e; }
.topbar-menu-salir.topbar-menu-cambiar:hover { background: #f1f5f9; color: #16202e; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}
.sidebar-overlay.visible { display: block; }

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.page-subtitle {
    color: #64748b;
    margin: .2rem 0 0;
    font-size: .9rem;
}

/* Section titles (Dashboard) */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    border-left: 3px solid var(--brand);
    padding-left: .65rem;
}

.btn-manual {
    font-size: .8rem;
    font-weight: 600;
    color: var(--app-color);
    border: 1.5px solid var(--app-color);
    background: transparent;
    border-radius: 8px;
    transition: background .18s, color .18s;
}
.btn-manual:hover {
    background: var(--app-color);
    color: #fff;
}

.btn-manual-disabled {
    font-size: .8rem;
    font-weight: 600;
    color: #cbd5e1;
    border: 1.5px solid #e2e8f0;
    background: transparent;
    border-radius: 8px;
    cursor: default;
    display: block;
    text-align: center;
}

/* ═══════════════════════════════════════
   MANUAL MODAL
═══════════════════════════════════════ */
.manual-modal-header {
    background: #0f172a;
    color: #fff;
    border-bottom: none;
    padding: .75rem 1.25rem;
}

.btn-volver-manual {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px;
    font-size: .85rem;
    padding: .3rem .8rem;
    transition: background .2s;
}
.btn-volver-manual:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
}

.manual-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
}

/* LAYOUT INTERNO DEL MANUAL */
.manual-wrap {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.manual-nav {
    width: 230px;
    min-width: 230px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 1rem 0;
    flex-shrink: 0;
}

.manual-nav-header {
    font-size: .85rem;
    font-weight: 700;
    color: #0f172a;
    padding: .5rem 1rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: .5rem;
}

.manual-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.manual-nav-list li { margin: 0; }

.manual-nav-link {
    display: block;
    padding: .45rem 1rem;
    font-size: .8rem;
    color: #475569;
    text-decoration: none;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.manual-nav-link:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.manual-nav-link.active {
    color: #185FA5;
    font-weight: 600;
    border-left-color: #185FA5;
    background: #eff6ff;
}

.manual-nav-sub .manual-nav-link {
    padding-left: 2.2rem;
    font-size: .76rem;
    color: #64748b;
}

.manual-nav-sub .manual-nav-link.active {
    color: #185FA5;
    font-weight: 600;
}

/* ÁREA DE CONTENIDO */
.manual-content {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

.manual-hero {
    padding: 2rem;
    margin-bottom: 0;
}

.manual-section {
    padding: 2rem;
    border-bottom: 1px solid #f1f5f9;
}

.manual-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.manual-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #185FA5;
    color: #fff;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.manual-list {
    padding-left: 1.25rem;
}

.manual-list li {
    margin-bottom: .4rem;
    color: #334155;
}

.manual-table {
    font-size: .85rem;
}

.manual-table thead th {
    background: #f8fafc;
    font-weight: 600;
    color: #0f172a;
}

.manual-alert {
    border-radius: 10px;
    font-size: .85rem;
    margin-top: 1rem;
}

/* MÓDULOS */
.manual-module {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    border: 1px solid #e2e8f0;
}

.manual-module-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding-bottom: .75rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid #e2e8f0;
    border-left: 4px solid #185FA5;
    padding-left: .75rem;
}

.manual-module-header i { font-size: 1.3rem; }

.manual-steps {
    padding-left: 1.25rem;
    color: #334155;
    font-size: .88rem;
}

.manual-steps li { margin-bottom: .4rem; }

.manual-flow {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin: .75rem 0;
}

.manual-flow-step {
    background: #e0f2fe;
    color: #0369a1;
    padding: .3rem .75rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
}

.manual-flow i { color: #94a3b8; }

.manual-placeholder {
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: #94a3b8;
    font-size: .85rem;
    margin-top: .75rem;
}

/* CARDS DE FEATURE */
.manual-card-feature {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.manual-card-feature i { font-size: 1.6rem; }
.manual-card-feature p { font-size: .8rem; color: #64748b; margin: 0; }

/* CARDS DE ROL */
.manual-role-card {
    border: 2px solid;
    border-radius: 10px;
    overflow: hidden;
    height: 100%;
}

.manual-role-header {
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
    padding: .6rem 1rem;
}

.manual-role-card ul {
    padding: .75rem 1rem .75rem 1.5rem;
    margin: 0;
    font-size: .82rem;
    color: #334155;
}

.manual-role-card ul li { margin-bottom: .3rem; }

@media (max-width: 768px) {
    .manual-nav { display: none; }
    .manual-wrap { flex-direction: column; }
    .manual-content { height: calc(100vh - 56px); }
}

.badge-internal {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-external {
    background: #f3e8ff;
    color: #7e22ce;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
}
.empty-state i { font-size: 4rem; opacity: .25; display: block; margin-bottom: 1.5rem; }
.empty-state h5 { font-weight: 700; color: #334155; margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* ===========================
   STAT CARDS (Admin)
   =========================== */
.stat-card {
    background: white;
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    border-left: 4px solid var(--stat-color);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--stat-color) 12%, transparent);
    color: var(--stat-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
}

.stat-label {
    font-size: .8rem;
    color: #64748b;
    margin-top: .2rem;
}

/* ===========================
   TABLE HELPERS
   =========================== */
.table-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: white;
    font-weight: 700;
    font-size: .82rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.perm-row-active { background: #f0fdf4 !important; }

/* User item in permissions list */
.user-item { transition: background .15s; color: inherit; }
.user-item:hover { background: #f1f5f9; }
.user-selected { background: #dbeafe !important; }

/* Form controls */
.form-control, .form-select {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(87,151,232,.15);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border: none;
    border-radius: 10px;
    font-weight: 600;
    transition: opacity .2s, transform .15s;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }

.btn-outline-primary {
    border-radius: 8px;
    border-color: var(--brand);
    color: var(--brand);
}
.btn-outline-primary:hover { background: var(--brand); color: white; }

.btn-success {
    background: linear-gradient(135deg, #047857, #059669);
    border: none; border-radius: 10px; font-weight: 600;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 991.98px) {
    .main-content { margin-left: 0; }
    .topbar { left: 0; padding: 0 1rem; }
    .topbar-toggle { display: block; }
    .content-inner { padding: 1.25rem 1rem; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
}

@media (max-width: 575.98px) {
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ═══════════════════════════════════════
   MOCKUPS DE PANTALLAS (MANUAL)
═══════════════════════════════════════ */
.manual-screenshot {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    font-size: .78rem;
}
.ms-bar {
    background: #1e293b;
    padding: .35rem .75rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.ms-dot { width:10px;height:10px;border-radius:50%;display:inline-block; }
.ms-dot-r{background:#ef4444;} .ms-dot-y{background:#f59e0b;} .ms-dot-g{background:#22c55e;}
.ms-url { font-size:.68rem; color:#94a3b8; margin-left:.5rem; font-family:monospace; }
.ms-body {
    background:#f1f5f9;
    padding: .75rem;
    max-height:320px;
    overflow:hidden;
}
.ms-topbar {
    background:#1a2847;
    color:#fff;
    padding:.4rem .75rem;
    font-size:.72rem;
    display:flex;
    align-items:center;
    justify-content:space-between;
    border-radius:4px;
    margin-bottom:.5rem;
}
.ms-kpi-row { display:flex; gap:.5rem; margin-bottom:.5rem; }
.ms-kpi {
    flex:1; background:#fff; border-radius:6px;
    padding:.5rem .6rem; border-left:3px solid;
}
.ms-kpi-num { font-size:1.1rem; font-weight:700; }
.ms-kpi-lbl { font-size:.65rem; color:#64748b; }
.ms-table { width:100%; border-collapse:collapse; background:#fff; border-radius:6px; overflow:hidden; }
.ms-table th { background:#f8fafc; padding:.3rem .5rem; text-align:left; font-weight:600; color:#374151; border-bottom:1px solid #e5e7eb; font-size:.7rem; }
.ms-table td { padding:.28rem .5rem; border-bottom:1px solid #f1f5f9; color:#374151; vertical-align:middle; }
.ms-table tr:last-child td { border-bottom:none; }
.ms-badge { display:inline-block; padding:.1rem .4rem; border-radius:4px; font-size:.65rem; font-weight:600; }
.ms-form { background:#fff; border-radius:6px; padding:.6rem; }
.ms-form-row { display:flex; gap:.4rem; margin-bottom:.4rem; }
.ms-field { flex:1; }
.ms-label { font-size:.65rem; color:#64748b; margin-bottom:.15rem; }
.ms-input { background:#f8fafc; border:1px solid #e2e8f0; border-radius:4px; padding:.25rem .4rem; width:100%; font-size:.72rem; color:#374151; }
.ms-btn { display:inline-block; padding:.25rem .6rem; border-radius:4px; font-size:.68rem; font-weight:600; }
.ms-btn-primary { background:#185FA5; color:#fff; }
.ms-btn-success { background:#059669; color:#fff; }
.ms-btn-danger  { background:#dc2626; color:#fff; }
.ms-stepper { display:flex; align-items:center; gap:0; margin-bottom:.6rem; }
.ms-step { flex:1; text-align:center; padding:.3rem; font-size:.65rem; font-weight:600; background:#e2e8f0; color:#64748b; }
.ms-step.active { background:#185FA5; color:#fff; }
.ms-step.done  { background:#059669; color:#fff; }
.ms-step-arrow { width:0;height:0;border-top:14px solid transparent;border-bottom:14px solid transparent; flex-shrink:0; }
.ms-step-arrow.active { border-left:8px solid #185FA5; }
.ms-step-arrow.done   { border-left:8px solid #059669; }
.ms-step-arrow.idle   { border-left:8px solid #e2e8f0; }
.ms-sidebar-mini { background:#1a2847; border-radius:6px; padding:.4rem; width:80px; flex-shrink:0; }
.ms-sidebar-item { color:#94a3b8; font-size:.6rem; padding:.2rem .3rem; border-radius:3px; margin-bottom:.15rem; }
.ms-sidebar-item.active { background:#185FA520; color:#7db3ff; }
.ms-chart-bar { display:flex; align-items:flex-end; gap:.3rem; height:60px; background:#fff; border-radius:6px; padding:.4rem .5rem; }
.ms-bar-col { flex:1; display:flex; flex-direction:column; align-items:center; gap:.15rem; }
.ms-bar-fill { width:100%; border-radius:3px 3px 0 0; }
.ms-bar-lbl { font-size:.55rem; color:#94a3b8; }

.manual-real-img {
    width: 100%;
    display: block;
    border-top: 1px solid #e2e8f0;
}

/* ═══════════════════════════════════════
   CHATBOT WIDGET v2
═══════════════════════════════════════ */

/* Botón flotante */
.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    box-shadow: 0 4px 20px rgba(87,151,232,.5);
    transition: transform .2s, box-shadow .2s;
    animation: chatPulse 3s infinite;
}
@keyframes chatPulse {
    0%,100% { box-shadow: 0 4px 20px rgba(87,151,232,.5), 0 0 0 0 rgba(87,151,232,.25); }
    50%      { box-shadow: 0 4px 24px rgba(87,151,232,.6), 0 0 0 9px rgba(87,151,232,0); }
}
.chatbot-toggle:hover { transform: scale(1.1); }

/* Panel */
.chatbot-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 375px;
    height: 560px;
    /* Pantallas bajas o con zoom: que el panel nunca se salga por arriba */
    max-height: calc(100vh - 112px);
    max-height: calc(100dvh - 112px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 16px 56px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.06);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow: hidden;
    transition: opacity .25s ease, transform .25s ease;
    transform-origin: bottom right;
}
.chatbot-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.94) translateY(12px);
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #0f1f38 0%, #1e4080 100%);
    color: white;
    padding: .9rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}
.chatbot-avatar {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.chatbot-header-title { font-weight: 700; font-size: .9rem; line-height: 1.2; }
.chatbot-status {
    display: flex; align-items: center; gap: .35rem;
    font-size: .68rem; color: rgba(255,255,255,.6); margin-top: 2px;
}
.chatbot-status-dot {
    width: 7px; height: 7px;
    background: #22c55e; border-radius: 50%;
    animation: statusBlink 2s infinite;
}
@keyframes statusBlink {
    0%,100% { opacity: 1; } 50% { opacity: .4; }
}
.chatbot-close {
    margin-left: auto;
    background: rgba(255,255,255,.1);
    border: none; color: white;
    width: 30px; height: 30px;
    border-radius: 50%; font-size: .82rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s; flex-shrink: 0;
}
.chatbot-close:hover { background: rgba(255,255,255,.22); }

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: .9rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    background: #f0f6ff;
    scroll-behavior: smooth;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Filas de mensaje (avatar + burbuja) */
.chat-row {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
    animation: bubbleIn .18s ease both;
}
.chat-row.user { justify-content: flex-end; }
@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-bot-icon {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; color: white;
    flex-shrink: 0; margin-bottom: 2px;
}

/* Burbujas */
.chat-bubble {
    max-width: 82%;
    padding: .55rem .9rem;
    border-radius: 16px;
    font-size: .83rem;
    line-height: 1.6;
    word-break: break-word;
}
.chat-bubble.user {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px rgba(87,151,232,.28);
}
.chat-bubble.assistant {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
}

/* Indicador de escritura */
.typing-bubble {
    background: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    display: flex; gap: 4px; align-items: center;
    padding: .6rem .9rem;
}
.typing-bubble span {
    display: inline-block;
    width: 7px; height: 7px;
    background: #94a3b8; border-radius: 50%;
    animation: chatBounce 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes chatBounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-5px); }
}

/* Chips de sugerencias */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 3px 0 6px 34px;
    animation: bubbleIn .22s ease both;
}
.chat-chip {
    background: white;
    border: 1.5px solid #bfdbfe;
    color: var(--brand-dark);
    border-radius: 20px;
    padding: .28rem .75rem;
    font-size: .75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
}
.chat-chip:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(87,151,232,.28);
}

/* Input */
.chatbot-input-area {
    padding: .65rem .8rem;
    border-top: 1px solid #e2e8f0;
    display: flex; gap: .5rem; align-items: center;
    background: white; flex-shrink: 0;
}
.chatbot-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: .45rem 1rem;
    font-size: .83rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
    background: #f8fafc;
}
.chatbot-input:focus {
    border-color: var(--brand);
    background: white;
    box-shadow: 0 0 0 3px rgba(87,151,232,.12);
}
.chatbot-send {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    border: none; border-radius: 50%;
    color: white; font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: opacity .15s, transform .15s;
    box-shadow: 0 2px 8px rgba(87,151,232,.3);
}
.chatbot-send:hover { opacity: .88; transform: scale(1.07); }
.chatbot-send:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }

/* Responsive */
@media (max-width: 575.98px) {
    .chatbot-panel { right: 8px; left: 8px; width: auto; bottom: 82px; height: 70vh; max-height: calc(100dvh - 96px); }
    .chatbot-toggle { bottom: 16px; right: 16px; width: 52px; height: 52px; font-size: 1.3rem; }
}

/* ── SGI HTML Cards ────────────────────────────────────────────────────────── */
.chat-bubble.html-card {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
}
.sgi-card { background: #fff; border-radius: 12px; overflow: hidden; font-size: .82rem; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,.09); }
.sgi-header { padding: .55rem 1rem; font-weight: 600; font-size: .78rem; letter-spacing: .04em; color: #fff; display: flex; align-items: center; gap: .4rem; }
.sgi-header.h-green  { background: linear-gradient(135deg, #10b981, #059669); }
.sgi-header.h-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.sgi-header.h-red    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.sgi-header.h-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.sgi-header.h-cyan   { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.sgi-header.h-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.sgi-header.h-gray   { background: linear-gradient(135deg, #64748b, #475569); }
.sgi-body { padding: .75rem 1rem; }
.sgi-stats { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: .6rem; }
.sgi-stat { background: #f1f5f9; border-radius: 8px; padding: .3rem .6rem; display: flex; flex-direction: column; align-items: center; min-width: 54px; }
.sgi-stat-val { font-size: 1.05rem; font-weight: 700; line-height: 1.1; color: #1e293b; }
.sgi-stat-lbl { font-size: .66rem; color: #64748b; text-align: center; }
.sgi-stat.danger  { background: #fef2f2; } .sgi-stat.danger  .sgi-stat-val { color: #dc2626; }
.sgi-stat.warning { background: #fffbeb; } .sgi-stat.warning .sgi-stat-val { color: #d97706; }
.sgi-stat.success { background: #f0fdf4; } .sgi-stat.success .sgi-stat-val { color: #16a34a; }
.sgi-stat.info    { background: #eff6ff; } .sgi-stat.info    .sgi-stat-val { color: #2563eb; }
.sgi-divider { border: none; border-top: 1px solid #f1f5f9; margin: .5rem 0; }
.sgi-slabel { font-size: .69rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; margin-bottom: .3rem; }
.sgi-list { list-style: none; padding: 0; margin: 0; }
.sgi-list li { padding: .28rem 0; border-bottom: 1px solid #f8fafc; }
.sgi-list li:last-child { border-bottom: none; }
.sgi-item-title { font-weight: 500; color: #1e293b; font-size: .8rem; line-height: 1.3; }
.sgi-item-meta  { font-size: .71rem; color: #64748b; margin-top: .05rem; }
.sgi-badge { display: inline-block; padding: .08rem .42rem; border-radius: 999px; font-size: .67rem; font-weight: 600; }
.sgi-badge.danger  { background: #fef2f2; color: #dc2626; }
.sgi-badge.warning { background: #fffbeb; color: #d97706; }
.sgi-badge.success { background: #f0fdf4; color: #16a34a; }
.sgi-badge.info    { background: #eff6ff; color: #2563eb; }
.sgi-badge.neutral { background: #f1f5f9; color: #475569; }
.sgi-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.sgi-table th { background: #f8fafc; color: #64748b; font-weight: 600; padding: .22rem .45rem; text-align: left; font-size: .69rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #e2e8f0; }
.sgi-table td { padding: .22rem .45rem; border-bottom: 1px solid #f8fafc; color: #334155; }
.sgi-table tr:last-child td { border-bottom: none; }
.sgi-btn { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .7rem; border-radius: 6px; font-size: .74rem; font-weight: 600; border: none; cursor: pointer; transition: opacity .15s; margin-top: .5rem; text-decoration: none; }
.sgi-btn.primary { background: var(--brand); color: #fff; }
.sgi-btn.primary:hover { opacity: .85; color: #fff; }
.sgi-resumen-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.sgi-rm { border-radius: 9px; padding: .45rem .6rem; display: flex; align-items: center; gap: .45rem; }
.sgi-rm i { font-size: 1.15rem; flex-shrink: 0; }
.sgi-rm .val { font-size: 1rem; font-weight: 700; color: #1e293b; line-height: 1.2; }
.sgi-rm .lbl { font-size: .68rem; color: #475569; }

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD — catálogo de aplicaciones
   Todo a la vista en una pantalla: los nombres se leen sin abrir nada.
   El corte principal es para qué sirve la app (Grupo); interna/externa
   queda como etiqueta.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Buscador ─────────────────────────────────────────────────────── */
.app-buscador {
    position: relative;
    max-width: 520px;
    margin-bottom: .4rem;
}

.app-buscador > i {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: .95rem;
    pointer-events: none;
}

.app-buscador input {
    padding-left: 2.4rem;
    border-radius: 10px;
    border-color: #dbe4f0;
    background: #fff;
}

.app-buscador input:focus {
    border-color: #5797E8;
    box-shadow: 0 0 0 .2rem rgba(87, 151, 232, .18);
}

.app-buscador-cuenta {
    font-size: .78rem;
    color: #94a3b8;
    margin: 0 0 1.6rem;
}

/* ── Secciones y subgrupos ────────────────────────────────────────── */
/* Cada sección va en su propia tarjeta. Antes eran bloques separados solo por
   márgenes, y con tres secciones y varios subgrupos no se veía dónde terminaba una
   y empezaba la siguiente. */
.app-seccion {
    /* Un tono apenas gris, no blanco: las tarjetas son blancas y sobre blanco solo
       las distinguiria su borde. */
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.15rem 1.25rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.app-seccion[hidden],
.app-subgrupo[hidden],
.app-tarjeta[hidden] {
    display: none !important;
}

/* El título de la sección responde "cómo se entra a estas", que es la pregunta
   principal del dashboard: iba en .78rem y se leía como una nota al pie. */
.app-seccion-titulo {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #12395f;
    margin: 0 0 .2rem;
}

.app-seccion-sub {
    font-size: .88rem;
    color: #64748b;
    margin: 0 0 1.1rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid #e6ecf5;
}

.app-subgrupo {
    margin-bottom: 1.35rem;
}

.app-subgrupo:last-child {
    margin-bottom: 0;
}

.app-subgrupo-titulo {
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: .95rem;
    font-weight: 600;
    color: #475569;
    margin: 0 0 .7rem;
}

.app-subgrupo-titulo::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e6ecf5;
}

/* ── Íconos de app ────────────────────────────────────────────────── */
/* Como el panel de un teléfono (Andrés, 06-10-2026: «muy monótona, todo igual, uno
   se pierde con los íconos»): cada app con su color y su símbolo, el nombre debajo.
   El color viene de la base (--app en el style del enlace); el degradado y el brillo
   salen de ese mismo color. */
.app-rejilla {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 1.1rem .5rem;
}

.app-tarjeta {
    --app: #475569;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .45rem;
    padding: .7rem .35rem .6rem;
    border-radius: 18px;
    text-decoration: none;
    color: #16202e;
    text-align: center;
    transition: background-color .15s ease;
}

.app-tarjeta:hover {
    background: #eef3fa;
    color: #16202e;
}

.app-tarjeta:focus-visible {
    outline: 2px solid #5797E8;
    outline-offset: 2px;
}

.app-ficha {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.75rem;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(155deg,
        color-mix(in srgb, var(--app) 68%, #fff) 0%,
        var(--app) 52%,
        color-mix(in srgb, var(--app) 80%, #000) 100%);
    box-shadow: 0 6px 14px -4px color-mix(in srgb, var(--app) 55%, transparent),
                inset 0 1px 0 rgba(255, 255, 255, .35);
    transition: transform .15s ease, box-shadow .15s ease;
}

/* Brillo de arriba, como el vidrio de un ícono. */
.app-ficha::after {
    content: "";
    position: absolute;
    inset: 0 0 50% 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.app-ficha > i {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18));
}

.app-tarjeta:hover .app-ficha {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 20px -6px color-mix(in srgb, var(--app) 60%, transparent),
                inset 0 1px 0 rgba(255, 255, 255, .35);
}

.app-tarjeta-nombre {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.25;
    color: #1e293b;
}

/* ── Etiquetas ────────────────────────────────────────────────────── */
.app-etiqueta {
    display: inline-block;
    font-size: .58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .05rem .35rem;
    border-radius: 999px;
    margin-top: -.15rem;
}

.app-etiqueta.sso {
    background: #eaf2fd;
    color: #185FA5;
}

.app-etiqueta.local {
    background: #fef3c7;
    color: #92400e;
}

/* "Externa": se abre en otra pestaña y puede pedir otra sesión. */
.app-etiqueta.externa {
    background: #edf1f6;
    color: #4b5e76;
}

/* "Próximamente": la app existe pero todavía no está desplegada. */
.app-etiqueta.proximamente {
    background: #fee2e2;
    color: #b91c1c;
}

/* App aún no disponible: atenuada, sin cursor de enlace ni hover. */
.app-tarjeta--proximamente {
    cursor: default;
    opacity: .6;
}
.app-tarjeta--proximamente:hover {
    background: none;
}
.app-ficha--proximamente {
    filter: grayscale(1);
}

/* ── Botón de manual: un globo sobre la esquina del ícono ─────────── */
.app-manual-btn {
    position: absolute;
    top: .25rem;
    left: calc(50% + 20px);
    z-index: 2;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dbe4f0;
    border-radius: 50%;
    background: #fff;
    color: #64748b;
    font-size: .7rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .12);
    opacity: 0;
    transition: background .12s ease, color .12s ease, opacity .12s ease;
}

/* Aparece al pasar el mouse: fijo en una veintena de íconos parecía un aviso. En
   pantallas táctiles no hay mouse, así que ahí se ve siempre. */
.app-tarjeta:hover .app-manual-btn,
.app-manual-btn:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .app-manual-btn {
        opacity: 1;
    }
}

.app-manual-btn:hover {
    background: #eaf2fd;
    color: #185FA5;
}

.app-manual-btn:focus-visible {
    outline: 2px solid #5797E8;
    outline-offset: 1px;
    color: #185FA5;
}

/* ── Sin resultados ───────────────────────────────────────────────── */
.app-sin-resultados {
    color: #64748b;
    font-size: .9rem;
    text-align: center;
    padding: 2.5rem 1rem;
}

.app-sin-resultados[hidden] {
    display: none;
}

.app-sin-resultados > i {
    display: block;
    font-size: 1.6rem;
    color: #cbd5e1;
    margin-bottom: .5rem;
}

@media (max-width: 575.98px) {
    .app-rejilla {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }
    .app-ficha {
        width: 56px;
        height: 56px;
        border-radius: 14px;
        font-size: 1.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-tarjeta,
    .app-ficha,
    .app-manual-btn {
        transition: none;
    }
    .app-tarjeta:hover .app-ficha {
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN — inicio de sesión con Microsoft 365
   ═══════════════════════════════════════════════════════════════════ */

.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    padding: .6rem 1rem;
    font-size: .93rem;
    font-weight: 600;
    color: #16202e;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.btn-microsoft:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #16202e;
}

.btn-microsoft:focus-visible {
    outline: 2px solid #5797E8;
    outline-offset: 2px;
}

.btn-microsoft svg {
    flex-shrink: 0;
}

/* Separador "o" entre el acceso con Microsoft y el formulario local. */
.auth-separador {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.4rem 0 .5rem;
    color: #94a3b8;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.auth-separador::before,
.auth-separador::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

@media (prefers-reduced-motion: reduce) {
    .btn-microsoft {
        transition: none;
    }
}
