/* =====================================================================
   Administración · tema CTI sobre Bootstrap 5
   ===================================================================== */
:root {
    --cti-navy: #061634;
    --cti-navy-2: #0a2350;
    --cti-blue: #1f6bff;
    --cti-blue-600: #1557d6;
    --cti-bg: #eef2f8;
    --cti-line: #dfe6f1;
    --cti-green: #16a34a;
    --cti-amber: #f5a524;
    --cti-red: #e02424;
    --bs-primary: #1f6bff;
    --bs-primary-rgb: 31, 107, 255;
    --bs-body-font-family: 'Barlow', 'Segoe UI', system-ui, Arial, sans-serif;
    --bs-body-color: #0f1c33;
    --bs-border-radius: .6rem;
}
body { background: var(--cti-bg); font-family: var(--bs-body-font-family); }
.btn-cti { background: var(--cti-blue); border-color: var(--cti-blue); color: #fff; font-weight: 600; }
.btn-cti:hover, .btn-cti:focus { background: var(--cti-blue-600); border-color: var(--cti-blue-600); color: #fff; }
.card { border-color: var(--cti-line); border-radius: .9rem; box-shadow: 0 1px 2px rgba(15, 28, 51, .04); }
.card-header { border-color: var(--cti-line); }
.form-label { font-weight: 600; font-size: .9rem; }

/* --- Estructura --------------------------------------------------------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex: none;
    background: linear-gradient(180deg, var(--cti-navy) 0%, var(--cti-navy-2) 100%);
    color: #fff;
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; }
}
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--cti-navy); }
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.2rem 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.sidebar-logo { height: 2.4rem; width: auto; color: #fff; }
.sidebar-app { font-weight: 800; font-size: 1.15rem; line-height: 1; }
.sidebar-sub { font-size: .78rem; opacity: .7; }
.sidebar-nav { padding: .8rem .6rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .8rem; border-radius: .6rem;
    color: rgba(255, 255, 255, .78); text-decoration: none; font-weight: 600;
}
.sidebar-link i { font-size: 1.1rem; }
.sidebar-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-link.active { background: var(--cti-blue); color: #fff; box-shadow: 0 4px 14px rgba(31, 107, 255, .35); }
.sidebar-grupo { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; }
.sidebar-grupo.is-open, .sidebar-grupo:not(.collapsed) { color: #fff; }
.sidebar-chevron { margin-left: auto; font-size: .8rem !important; transition: transform .2s; }
.sidebar-grupo:not(.collapsed) .sidebar-chevron { transform: rotate(180deg); }
.sidebar-sub-lista { display: flex; flex-direction: column; gap: .1rem; margin: .15rem 0 .35rem 2.4rem; border-left: 1px solid rgba(255, 255, 255, .15); }
.sidebar-sublink { padding: .4rem .75rem; border-radius: .5rem; color: rgba(255, 255, 255, .7); text-decoration: none; font-size: .9rem; font-weight: 600; }
.sidebar-sublink:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.sidebar-sublink.active { color: #fff; background: rgba(31, 107, 255, .55); }
.sidebar-foot { padding: 1rem 1.2rem; font-size: .78rem; opacity: .55; border-top: 1px solid rgba(255, 255, 255, .1); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .8rem;
    padding: .75rem 1.5rem; background: #fff; border-bottom: 1px solid var(--cti-line);
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 1.35rem; font-weight: 800; margin: 0; color: var(--cti-navy-2); }
.topbar-user { display: flex; align-items: center; gap: .6rem; border: 0; }
.avatar-sm {
    width: 2.2rem; height: 2.2rem; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--cti-navy-2); color: #fff; font-weight: 700; font-size: .85rem;
}
.admin-content { padding: 1.5rem; }
@media (max-width: 575.98px) { .admin-content { padding: 1rem; } .topbar { padding: .6rem 1rem; } }

/* --- Tickets ----------------------------------------------------------- */
.tickets-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6e88; background: #f6f8fc; white-space: nowrap; }
.tickets-table tbody tr[data-href] { cursor: pointer; }
.tickets-table tr.row-vencido > td { background: #fdf0f0; }
.tickets-table tr.row-por_vencer > td { background: #fff9ea; }

.badge.estado-ABIERTO { background: #e8f0ff; color: #1557d6; }
.badge.estado-SIN_ASIGNAR { background: #e3e9f4; color: #0d2f6b; }
.badge.estado-EN_PROCESO { background: #dbe7ff; color: #1557d6; }
.badge.estado-ESPERANDO_CLIENTE { background: #edf1f7; color: #3d5884; }
.badge.estado-CERRADO { background: #e8f7ee; color: #0f7a37; }
.badge-sinresp { background: var(--cti-navy-2); color: #fff; }

.sla-pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.sla-green { background: #e8f7ee; color: #0f7a37; }
.sla-amber { background: #fff3d1; color: #8a5200; }
.sla-red { background: var(--cti-red); color: #fff; }

.ticket-number { font-size: 1.6rem; font-weight: 800; color: var(--cti-navy-2); }
.detail-list dt { color: #5e6e88; font-weight: 600; }
.detail-list dd { margin-bottom: .6rem; }

.sla-card { border-width: 2px; }
.sla-card.sla-green { background: #f3fbf6; color: inherit; border-color: #bfe8cf; }
.sla-card.sla-amber { background: #fffaf0; color: inherit; border-color: #f4d78f; }
.sla-card.sla-red { background: #fff4f4; color: inherit; border-color: #f2b0b0; }
.sla-status { font-size: 1.8rem; font-weight: 800; }
.sla-card.sla-green .sla-status { color: #0f7a37; }
.sla-card.sla-amber .sla-status { color: #a86300; }
.sla-card.sla-red .sla-status { color: #c01818; }
.sla-progress { height: .7rem; background: #e3e9f4; }
.sla-card.sla-green .progress-bar { background: var(--cti-green); }
.sla-card.sla-amber .progress-bar { background: var(--cti-amber); }
.sla-card.sla-red .progress-bar { background: var(--cti-red); }
.sla-num { font-size: 1.15rem; font-weight: 800; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.2rem; border-left: 2px solid var(--cti-line); }
.timeline li { position: relative; padding: 0 0 1rem .9rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.timeline li::before {
    content: ''; position: absolute; left: -1.62rem; top: .3rem;
    width: .8rem; height: .8rem; border-radius: 50%; background: var(--cti-blue); border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--cti-blue);
}
.timeline-date { color: #5e6e88; font-size: .88rem; min-width: 8.5rem; }

.sla-legend li { display: flex; gap: .6rem; align-items: center; margin-bottom: .5rem; font-size: .92rem; }

/* --- Login ------------------------------------------------------------- */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero {
    color: #fff; display: flex; align-items: center; padding: 3rem;
    background:
        radial-gradient(40rem 20rem at 80% 0%, rgba(64, 140, 255, .45), transparent 65%),
        linear-gradient(140deg, var(--cti-navy) 0%, var(--cti-navy-2) 60%, #0c3b8f 100%);
}
.login-hero-inner { max-width: 30rem; margin: 0 auto; }
.login-logo { height: 4rem; width: auto; color: #fff; margin-bottom: 2rem; }
.login-hero h1 { font-size: 3.2rem; font-weight: 800; margin: 0; }
.login-hero .lead { font-size: 1.4rem; opacity: .9; }
.login-points { list-style: none; padding: 0; margin: 2rem 0; }
.login-points li { display: flex; gap: .75rem; align-items: center; padding: .4rem 0; font-size: 1.1rem; }
.login-points i { color: #7fb0ff; font-size: 1.3rem; }
.login-tagline { opacity: .6; margin: 0; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; }
.login-card { width: 100%; max-width: 26rem; background: #fff; border-radius: 1.1rem; padding: 2.2rem; box-shadow: 0 10px 40px rgba(15, 28, 51, .1); }
.login-card h2 { font-weight: 800; color: var(--cti-navy-2); }
.login-foot { margin-top: 1.5rem; font-size: .82rem; color: #5e6e88; }
@media (max-width: 991.98px) {
    .login { grid-template-columns: 1fr; }
    .login-hero { padding: 2rem 1.5rem; }
    .login-hero h1 { font-size: 2.2rem; }
    .login-points, .login-tagline { display: none; }
    .login-logo { height: 3rem; margin-bottom: 1rem; }
}

/* --- Tickets por técnico ---------------------------------------------- */
.tec-kpi .card-body { line-height: 1.2; }
.tec-kpi-num { font-size: 1.9rem; font-weight: 800; color: var(--cti-navy-2); }
.tec-matriz thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6e88; background: #f6f8fc; white-space: nowrap; }
.tec-fila { cursor: pointer; }
.tec-fila.is-sel > td { background: #eef4ff; }
.tec-fila.is-sel > td:first-child { box-shadow: inset .25rem 0 0 var(--cti-blue); }
.tec-sin > td { background: #fbfcfe; }
.tec-av-sin { background: #e3e9f4 !important; color: var(--cti-navy-2) !important; }
.tec-dot { position: absolute; right: -.1rem; bottom: -.1rem; width: .7rem; height: .7rem; border-radius: 50%; border: 2px solid #fff; }
.tec-num {
    min-width: 2.4rem; padding: .2rem .55rem; border: 0; border-radius: .5rem;
    font-weight: 800; font-size: 1rem; background: transparent; cursor: pointer;
}
.tec-num:hover { outline: 2px solid var(--cti-blue); }
.tec-num.is-zero { color: #b6c2d6; font-weight: 600; }
.tec-num.is-navy { background: #e8edf7; color: var(--cti-navy-2); }
.tec-num.is-blue { background: #e3edff; color: var(--cti-blue-600); }
.tec-num.is-slate { background: #edf1f7; color: #3d5884; }
.tec-num.is-amber { background: #fff3d1; color: #8a5200; }
.tec-num.is-red { background: var(--cti-red); color: #fff; }
.tec-num.is-green { background: #e8f7ee; color: #0f7a37; }
.tec-carga { height: .45rem; border-radius: 999px; background: #edf1f7; overflow: hidden; }
.tec-carga span { display: block; height: 100%; background: var(--cti-blue); border-radius: inherit; transition: width .5s; }
.tec-filtros { display: flex; flex-wrap: wrap; gap: .35rem; }
.tec-filtro { border: 1px solid var(--cti-line); background: #fff; color: #33415c; font-weight: 600; }
.tec-filtro .badge { background: #edf1f7; color: #33415c; }
.tec-filtro.active { background: var(--cti-navy-2); border-color: var(--cti-navy-2); color: #fff; }
.tec-filtro.active .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.tec-tickets thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6e88; background: #f6f8fc; }
.tec-tickets tr.row-vencido > td { background: #fdf0f0; }
.tec-tickets tr.row-por_vencer > td { background: #fff9ea; }
.tec-live { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--cti-green); margin-right: .2rem; }

/* --- Clientes Microsip -------------------------------------------------- */
.ms-num { font-size: 1.8rem; font-weight: 800; color: var(--cti-navy-2); line-height: 1.1; }
.ms-num-sm { font-size: 1.15rem; padding-top: .45rem; }
.ms-tabla thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6e88; background: #f6f8fc; }
.ms-celda { max-width: 26rem; }
.ms-vinculo code, .ms-celda code { color: var(--cti-navy-2); background: #eef2f8; padding: .05rem .35rem; border-radius: .3rem; }

/* --- Reportes: productividad por técnico ------------------------------ */
.rep-filtros .form-control, .rep-filtros .form-select { width: auto; }
.rep-kpi-num { font-size: 1.7rem; font-weight: 800; color: var(--cti-navy-2); line-height: 1.15; }
.rep-tabla thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6e88; background: #f6f8fc; white-space: nowrap; }
.rep-tabla thead th[data-dir="asc"]::after { content: ' ▲'; }
.rep-tabla thead th[data-dir="desc"]::after { content: ' ▼'; }
.rep-tabla tbody tr[data-href] { cursor: pointer; }
.rep-tabla tbody tr.is-sel > td { background: #eef4ff; }
.rep-tabla td { font-variant-numeric: tabular-nums; }
.rep-total td { font-weight: 800; background: #f6f8fc; border-top: 2px solid var(--cti-line); }
.rep-celda-barra { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; min-width: 7rem; }
.rep-celda-barra .rep-barra { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: .55rem; max-width: calc(100% - 2.5rem);
    background: #2a78d6; border-radius: 0 4px 4px 0; }
.rep-celda-barra b { position: relative; }
.rep-vencidos { color: #b91c1c; font-weight: 700; }
.rep-leyenda { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .8rem; color: #52514e; }
.rep-leyenda i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.rep-dist-fila { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr 2.5rem; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.rep-dist-nombre { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-dist-barra { display: flex; gap: 2px; height: 1rem; }
.rep-seg { min-width: 3px; }
.rep-seg:first-child { border-radius: 0; }
.rep-seg:last-child { border-radius: 0 4px 4px 0; }
.rep-dist-total { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.rep-serie { display: flex; align-items: flex-end; gap: 2px; height: 11rem; border-bottom: 1px solid #c3c2b7; padding-bottom: 0; }
.rep-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 4px; }
.rep-col:hover .rep-col-barra { background: #1c5cab; }
.rep-col-barra { display: block; background: #2a78d6; border-radius: 4px 4px 0 0; min-height: 0; }
.rep-col-dia { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: .2rem; font-size: .68rem; color: #898781; white-space: nowrap; }
.rep-serie + div { margin-top: 1.3rem !important; }
.rep-calor th { font-size: .7rem; color: #5e6e88; background: #f6f8fc; font-weight: 600; }
.rep-calor td { font-size: .8rem; font-weight: 700; min-width: 2rem; border: 2px solid #fff; font-variant-numeric: tabular-nums; }
.rep-ayuda summary { cursor: pointer; list-style: none; }

/* --- Reportes: análisis general --------------------------------------- */
.rep-hallazgos li { display: flex; gap: .35rem; padding: .25rem 0; font-size: .95rem; }
.rep-hallazgos li i { color: var(--cti-blue); font-size: 1.2rem; line-height: 1.1; }
.rep-delta { font-weight: 700; font-size: .82rem; }
.rep-delta small { font-weight: 500; color: #6b7a93; }
.rep-delta.is-bien { color: #006300; }
.rep-delta.is-mal { color: #b91c1c; }
.rep-delta.is-neutro { color: #52514e; font-weight: 600; }
.rep-ahora { color: #33415c; padding: 0 .2rem; }
.rep-serie-doble .rep-par { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.rep-serie-doble .rep-par .rep-col-barra { flex: 1; }
.rep-col-barra.is-b { background: #eb6834; }
.rep-col:hover .rep-col-barra.is-b { background: #c4521f; }
.rep-hbar { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr 5.5rem; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.rep-hbar-nombre { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-hbar-pista { height: .75rem; background: #edf1f7; border-radius: 0 4px 4px 0; }
.rep-hbar-pista span { display: block; height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; }
.rep-hbar-pista.is-gris span { background: #898781; }
.rep-hbar-valor { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .88rem; }
.rep-link-cliente { color: inherit; text-decoration: none; }
.rep-link-cliente:hover { color: var(--cti-blue); text-decoration: underline; }
.rep-link-cliente .bi { opacity: .45; }

/* --- Usuarios y permisos ------------------------------------------------ */
.usr-tabla .usr-inactivo td { opacity: .6; }
.usr-grupo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #5e6e88; margin: .9rem 0 .3rem; }
.usr-grupo:first-of-type { margin-top: .3rem; }
.usr-permiso { display: flex; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid #edf1f7; }
.usr-permiso:last-child { border-bottom: 0; }
.usr-permiso-nombre { flex: 1; min-width: 0; line-height: 1.25; }
.usr-niveles { flex: none; }
.usr-niveles .btn { min-width: 4.6rem; }
@media (max-width: 575.98px) {
    .usr-permiso { flex-direction: column; align-items: stretch; }
    .usr-niveles { width: 100%; }
}

/* --- Reporte por cliente (radiografía) --------------------------------- */
.cli-avatar { width: 3.4rem; height: 3.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
              background: #e8f0ff; color: var(--cti-navy-2); flex: none; }
.cli-nombre { font-size: 1.45rem; font-weight: 800; color: var(--cti-navy-2); }
.cli-resumen { background: #f6f8fc; font-size: .95rem; line-height: 1.5; }
.cli-resumen .bi { color: var(--cti-blue); }
.cli-detalle td { font-size: .86rem; }
.cli-texto { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; word-break: break-word; }
.cli-texto:hover { -webkit-line-clamp: unset; }
.cli-fuera-periodo { background: #fffaf0; }
.cli-detalle .sla-pill { margin-top: .25rem; font-size: .72rem; }

@media print {
    @page { size: letter landscape; margin: 12mm; }
    body.admin { background: #fff !important; }
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .admin-main { margin: 0 !important; padding: 0 !important; }
    .admin-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #d9dee8 !important; break-inside: avoid; }
    .cli-detalle tr { break-inside: avoid; }
    .cli-texto { -webkit-line-clamp: unset; display: block; }
    .rep-serie { height: 7rem; }
    a { color: inherit !important; text-decoration: none !important; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Errores / varios -------------------------------------------------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.error-card { max-width: 32rem; text-align: center; background: #fff; border-radius: 1.1rem; padding: 2.5rem; box-shadow: 0 10px 40px rgba(15, 28, 51, .08); }
.error-code { font-size: 4.5rem; font-weight: 800; color: var(--cti-blue); line-height: 1; }
.error-detail { text-align: left; font-size: .78rem; background: #f6f8fc; padding: .8rem; border-radius: .5rem; white-space: pre-wrap; }
.filter-card .form-label { font-size: .8rem; color: #5e6e88; }
