body {
    background-color: #f5f6f8;
}
.card {
    border: none;
    border-radius: 10px;
}
.mermaid {
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

/* Comparador de cambios (estilo Draftable) */
.diff-ins {
    background-color: #d4f7d4;
    color: #1b5e20;
    text-decoration: none;
    padding: 0 2px;
    border-radius: 2px;
}
.diff-del {
    background-color: #fddede;
    color: #a33;
    text-decoration: line-through;
    padding: 0 2px;
    border-radius: 2px;
}
.diff-row {
    padding: 10px 12px;
    border-left: 4px solid transparent;
    border-bottom: 1px solid #eee;
}
.diff-row-agregado { background-color: #eafbea; border-left-color: #2e7d32; }
.diff-row-eliminado { background-color: #fdecec; border-left-color: #c62828; }
.diff-row-modificado { background-color: #fffbea; border-left-color: #f9a825; }
.diff-row-igual { color: #777; }
.diff-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
}
.diff-badge-agregado { background: #2e7d32; color: #fff; }
.diff-badge-eliminado { background: #c62828; color: #fff; }
.diff-badge-modificado { background: #f9a825; color: #333; }
.diff-side-col { border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden; }
.diff-side-header {
    background: #333; color: #fff; padding: 8px 12px; font-weight: 600; font-size: .9rem;
}
.diff-side-header.propuesto { background: #1a5276; }

/* ===== Menú lateral ===== */
.navbar-sistema { min-height: 56px; }

#sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}
#sidebar-backdrop.visible { opacity: 1; visibility: visible; }

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    overflow-y: auto;
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .35);
}
#sidebar.abierto { transform: translateX(0); }

/* El sidebar ocupa su propia columna y empuja el contenido, sin superponerse.
   En pantallas angostas no hay espacio para desplazar, así que sigue
   funcionando como panel deslizante sobre un fondo oscurecido. */
body.menu-abierto { transition: padding-left .25s ease; }

@media (min-width: 992px) {
    body.menu-abierto { padding-left: 280px; }
    body.menu-abierto #sidebar-backdrop { display: none; }
}

.btn-perfil {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    text-decoration: none;
    line-height: 0;
}
.btn-perfil:hover .sidebar-avatar,
.btn-perfil:focus .sidebar-avatar {
    outline: 2px solid rgba(255, 255, 255, .75);
    outline-offset: 2px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-logo { display: flex; align-items: center; gap: .5rem; font-weight: 600; }

/* Marca del sistema: nombre (SISPRO) arriba, empresa debajo. */
.marca-bloque { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marca-sistema { font-weight: 700; letter-spacing: .04em; }
.marca-empresa {
    font-weight: 400;
    font-size: .72em;
    opacity: .65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.sidebar-header button {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
}
.sidebar-header button:hover { color: #fff; }

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-profile-info { display: flex; flex-direction: column; gap: .2rem; line-height: 1.2; min-width: 0; }
.sidebar-profile-info strong { font-size: .95rem; }

.sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex: none;
}
.sidebar-avatar-grande { width: 46px; height: 46px; font-size: 1rem; }

.sidebar-nav { flex: 1; padding: .6rem 0; }
.sidebar-titulo {
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .68rem;
    color: #94a3b8;
    padding: .8rem 1.2rem .3rem;
}
.sidebar-nav a, .sidebar-footer a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1.2rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .92rem;
}
.sidebar-nav a:hover, .sidebar-footer a:hover { background: #334155; color: #fff; }
.sidebar-nav a.activo { background: #0d6efd; color: #fff; }
.sidebar-icon { width: 1.2rem; text-align: center; font-size: 1rem; }
.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, .08); padding: .4rem 0; }

/* ===== Dashboard ===== */
.kpi-card { text-decoration: none; display: block; }
.kpi-card .card { transition: transform .15s ease, box-shadow .15s ease; }
.kpi-card:hover .card { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex: none;
}
.kpi-num { line-height: 1.1; }
.min-w-0 { min-width: 0; }
.dash-titulo { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.dash-titulo .emoji { font-size: 1.2rem; }
.barra-track { background: #eef1f5; border-radius: 8px; height: 16px; overflow: hidden; }
.barra-fill {
    height: 100%;
    border-radius: 8px;
    min-width: 6px;
    transition: width .6s ease;
}
.donut-punto {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 6px;
    flex: none;
}

/* ===== Inicio de sesión ===== */
.login-page {
    min-height: 100vh;
    background:
        radial-gradient(1100px 600px at 15% -10%, rgba(13, 110, 253, .22), transparent 60%),
        radial-gradient(900px 520px at 95% 110%, rgba(138, 132, 253, .18), transparent 60%),
        linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #26334d 100%);
}
.login-emoji {
    position: fixed;
    pointer-events: none;
    user-select: none;
    opacity: .12;
    filter: saturate(.7);
    z-index: 0;
    text-shadow: 0 4px 24px rgba(0, 0, 0, .4);
}
.login-wrap { position: relative; z-index: 1; }
.login-card { border: 0; border-radius: 14px; }
.login-card .card-body { background: rgba(255, 255, 255, .96); border-radius: 14px; }

/* Presencia, chat y monitoreo en vivo */
#monitor-vivo-bar {
    position: fixed; left: 16px; bottom: 20px; z-index: 1080;
    background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca;
    border-radius: 12px; padding: 12px 16px; font-size: 14px;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    max-width: 460px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    animation: monEntrada .35s ease;
}
#monitor-vivo-bar button {
    background: #dc2626; color: #fff; border: none; border-radius: 8px;
    padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
    white-space: nowrap;
}
#monitor-solicitud {
    position: fixed; left: 16px; bottom: 20px; z-index: 1090;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    padding: 14px 16px; font-size: 14px; width: 380px; max-width: calc(100vw - 32px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
    animation: monEntrada .35s ease;
}
.monitor-solicitud-titulo { font-weight: 700; margin-bottom: 6px; }
#monitor-solicitud p { margin-bottom: 10px; color: #4b5563; font-size: 13px; }
.monitor-solicitud-botones { display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes monEntrada { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.menu-chat-unread { background: #ff4757; color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 6px; margin-left: 6px; vertical-align: middle; display: none; }

/* Lanzador flotante para abrir el chat en ventana modal (solo con otros en línea).
   Vive en la esquina inferior derecha, apilado encima del asistente de ayuda
   (botón de 56 px con 20 px de margen), porque abajo a la izquierda tapaba las
   últimas opciones del menú lateral. */
#chat-launcher {
    position: fixed; right: 20px; bottom: 92px; z-index: 1060;
    width: 56px; height: 56px; border-radius: 50%; border: none; padding: 0;
    background: #0d6efd; color: #fff; font-size: 24px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
#chat-launcher:hover { background: #0b5ed7; }

/* En pantallas angostas el menú se desliza sobre el contenido, así que el
   lanzador se esconde mientras esté abierto: el chat ya está en el menú. */
@media (max-width: 991.98px) {
    body.menu-abierto #chat-launcher { display: none !important; }
}
.chat-launcher-badge {
    position: absolute; top: -5px; right: -7px;
    background: #ff4757; color: #fff; font-size: 11px; font-weight: 700;
    border-radius: 10px; line-height: 1.5; padding: 0 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
/* Ventana modal genérica (chat, Nuevo Proceso, Reportes) */
#modal-pagina { position: fixed; inset: 0; z-index: 1070; }
#modal-pagina-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
#modal-pagina-panel {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(96vw, 1000px); height: min(94vh, 760px);
    background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    display: flex; flex-direction: column;
}
#modal-pagina-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; background: #0f172a; color: #fff; font-weight: 600;
}
#modal-pagina-bar button { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; padding: 0 6px; }
#modal-pagina-frame { flex: 1; border: 0; width: 100%; min-height: 0; }
/* Las páginas que necesitan más espacio añaden su propia clase desde MODALES
   (includes/footer.php). Reportes ya no la usa: se ajusta a la altura del contenido. */
#modal-pagina-panel.modal-panel-medio {
    width: min(96vw, 1200px); height: min(94vh, 820px);
    max-width: 96vw;
}
/* Página mostrada dentro de la ventana modal */
.embed-body { padding: 16px; background: #fff; }
.embed-cabecera { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.embed-cabecera h1 { font-size: 1.4rem; margin: 0; }
/* Vista embed del chat (dentro del modal) */
.chat-embed-body { background: #fff; }
/* Filtros del reporte: Departamento/Gerencia y Área siempre en la misma línea */
.filtros-reporte { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.filtros-reporte .filtro-reporte { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; min-width: 260px; max-width: 620px; }
/* Dentro de la ventana modal de Reportes los filtros quedan siempre en una sola linea */
.embed-body .filtros-reporte { flex-wrap: nowrap; }
.embed-body .filtros-reporte .filtro-reporte { min-width: 0; max-width: none; }
@media (max-width: 720px) {
.embed-body .filtros-reporte { flex-wrap: wrap; }
}
.filtros-reporte .form-label { margin: 0; font-size: .875rem; color: #475569; }
.chat-embed-wrap { padding: 12px 14px 0; }
.chat-embed-wrap .chat-layout { height: calc(100vh - 150px); min-height: 0; }
@media (max-width: 820px) {
    .chat-embed-wrap .chat-layout { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
}
/* ------------------------------------------------------------------
   Hoja del procedimiento (process_view.php): los pasos se presentan
   como una hoja de documento, no como un panel con tarjetas.
   Los pasos nota/requisito (es_detalle) son viñetas subordinate.
   ------------------------------------------------------------------ */
.hoja-acciones { margin-bottom: 14px; }

.hoja-proceso {
    background: #fff;
    border: 1px solid #d8dde5;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
    max-width: 900px;
    margin: 0 auto;
    padding: 46px 54px 38px;
    color: #1a1a1a;
}

.hoja-cabecera { text-align: center; margin-bottom: 30px; }
.hoja-titulo {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.hoja-titulo .badge { font-size: .7rem; text-transform: none; letter-spacing: 0; vertical-align: middle; }
.hoja-subtitulo { color: #555; font-size: .95rem; margin: 0; }

.hoja-seccion {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 2px solid #1a1a1a;
    padding-bottom: 6px;
    margin: 0 0 18px;
}

.lista-pasos {
    list-style: none;
    counter-reset: paso-doc;
    margin: 0;
    padding: 0;
}

.paso-item {
    counter-increment: paso-doc;
    position: relative;
    padding: 0 0 14px 40px;
    margin: 0 0 14px;
    border-bottom: 1px dotted #d7d7d7;
}
.paso-item:last-child { border-bottom: 0; margin-bottom: 0; }

/* Numeración tipo "1." al inicio de la línea, como en una hoja de Word. */
.paso-item::before {
    content: counter(paso-doc) ".";
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    text-align: right;
    font-weight: 700;
    color: #1a1a1a;
}

/* Las notas/requisitos son viñetas subordinate: no se numeran. */
.lista-pasos > .paso-item.paso-detalle { counter-increment: none; padding-left: 54px; }
.lista-pasos > .paso-item.paso-detalle::before {
    content: "•" !important;
    left: 30px;
    width: 14px;
    text-align: center;
    color: #666;
    font-style: normal;
}
.lista-pasos > .paso-item.paso-detalle .paso-texto { font-style: italic; color: #444; }

.paso-cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.paso-texto { flex: 1; font-size: 1rem; line-height: 1.6; word-break: break-word; overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.paso-texto .badge { font-size: .7rem; vertical-align: middle; word-break: break-word; overflow-wrap: anywhere; display: inline-block; max-width: 100%; white-space: normal; }

.paso-item form { background: #f6f7f9; border: 1px solid #e2e6ec; border-radius: 6px; padding: 12px; }

.hoja-pie {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-width: 900px; margin: 16px auto 0;
    padding-top: 14px; border-top: 1px solid #e2e6ec;
}

@media (max-width: 720px) {
    .hoja-proceso { padding: 26px 20px 22px; }
    .hoja-titulo { font-size: 1.3rem; }
    .paso-item { padding-left: 32px; }
    .lista-pasos > .paso-item.paso-detalle { padding-left: 44px; }
    .lista-pasos > .paso-item.paso-detalle::before { left: 24px; }
}

/* Flujograma en su propia ventana (process_flujograma.php) */
.flujo-titulo { text-align: center; margin-bottom: 16px; }
.flujo-titulo h2 { font-weight: 700; }
.flujo-lienzo { overflow: auto; }
.flujo-lienzo .mermaid { display: flex; justify-content: center; min-width: 0; }
.flujo-lienzo .mermaid svg { max-width: 100%; height: auto; }
