/* DICRIM — estilos de la plataforma. Los colores institucionales llegan como variables desde la configuración. */
:root {
    --pn-azul: #173A64;
    --pn-celeste: #1F86C6;
    --pn-oro: #B8935A;
    --pn-verde: #0B5A2C;
    --fondo: #F3F5F8;
    --borde: #DDE3EA;
    --texto: #1D2733;
    --tenue: #5D6B7A;
    --radio: 10px;
    --bs-primary: var(--pn-azul);
    --bs-link-color: var(--pn-celeste);
}

html, body { height: 100%; }
body { background: var(--fondo); color: var(--texto); font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { color: var(--pn-celeste); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100vh; }
.menu {
    width: 264px; flex-shrink: 0; background: var(--pn-azul); color: #fff;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-right: 4px solid var(--pn-oro);
}
.menu .marca { display: flex; gap: .75rem; align-items: center; padding: 1.1rem 1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.12); }
.menu .marca img { width: 46px; height: 50px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.menu .marca strong { display: block; font-size: .92rem; line-height: 1.2; }
.menu .marca small { display: block; font-size: .72rem; opacity: .75; line-height: 1.25; margin-top: 2px; }
.menu nav { padding: .75rem .5rem 2rem; display: flex; flex-direction: column; gap: 2px; }
.menu nav a {
    color: rgba(255,255,255,.86); text-decoration: none; padding: .55rem .75rem; border-radius: 8px;
    display: flex; gap: .65rem; align-items: center; transition: background-color .15s ease, color .15s ease;
}
.menu nav a i { font-size: 1.05rem; opacity: .9; }
.menu nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu nav a.activo { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--pn-oro); }
.menu .seccion { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; opacity: .55; padding: 1rem .75rem .35rem; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra { height: 56px; background: #fff; border-bottom: 1px solid var(--borde); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1020; }
.barra .usuario { border: 1px solid var(--borde); background: #fff; }
.barra .badge.rol { background: color-mix(in srgb, var(--pn-celeste) 14%, white); color: var(--pn-azul); font-weight: 600; }
.contenido { padding: 1.5rem; max-width: 1480px; width: 100%; }

@media (max-width: 991.98px) {
    .menu { position: fixed; left: 0; z-index: 1040; transform: translateX(-100%); transition: transform .2s ease; }
    .menu.abierto { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    .contenido { padding: 1rem; }
}

/* ---------- Componentes ---------- */
.titulo { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.titulo h1 { font-size: 1.45rem; font-weight: 700; margin: 0; color: var(--pn-azul); text-wrap: balance; }
.titulo .sub { color: var(--tenue); font-size: .875rem; margin-top: .15rem; }
.titulo .acciones { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.tarjeta > .cab { padding: .85rem 1.1rem; border-bottom: 1px solid var(--borde); display: flex; align-items: center; gap: .5rem; }
.tarjeta > .cab h2, .tarjeta > .cab h3 { font-size: .95rem; font-weight: 700; margin: 0; color: var(--pn-azul); }
.tarjeta > .cab .ms-auto { margin-left: auto; }
.tarjeta > .cuerpo { padding: 1.1rem; }
.tarjeta + .tarjeta { margin-top: 1rem; }

.kpi { padding: 1rem 1.1rem; }
.kpi .valor { font-size: 1.85rem; font-weight: 700; color: var(--pn-azul); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .etq { color: var(--tenue); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

.btn-primary { --bs-btn-bg: var(--pn-azul); --bs-btn-border-color: var(--pn-azul); --bs-btn-hover-bg: color-mix(in srgb, var(--pn-azul) 85%, black); --bs-btn-hover-border-color: color-mix(in srgb, var(--pn-azul) 85%, black); --bs-btn-active-bg: color-mix(in srgb, var(--pn-azul) 75%, black); }
.btn-oro { background: var(--pn-oro); color: #fff; border-color: var(--pn-oro); }
.btn-oro:hover { background: color-mix(in srgb, var(--pn-oro) 85%, black); color: #fff; }
.btn { transition: transform .1s ease, background-color .15s ease; }
.btn:active { transform: scale(.97); }

.etapa { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
    color: var(--c, var(--pn-azul)); background: color-mix(in srgb, var(--c, var(--pn-azul)) 12%, white); white-space: nowrap; }
.etapa::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--pn-azul)); }

.table { --bs-table-hover-bg: #F6F9FC; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tenue); font-weight: 600; background: #FAFBFC; white-space: nowrap; }
.table td { vertical-align: middle; }
.table a.fila { color: inherit; text-decoration: none; font-weight: 600; }

.form-label { font-size: .78rem; font-weight: 600; color: #3A4756; margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .02em; }
.form-control, .form-select { border-color: #CBD3DC; }
.form-control:focus, .form-select:focus { border-color: var(--pn-celeste); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--pn-celeste) 22%, transparent); }
.mayus { text-transform: uppercase; }
.mayus::placeholder { text-transform: none; }
.field-validation-error, .text-danger { font-size: .8rem; }

/* Secciones del formulario de caso */
.seccion-caso { scroll-margin-top: 70px; }
.seccion-caso > .cab .num { width: 26px; height: 26px; border-radius: 50%; background: var(--pn-azul); color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
.persona { border: 1px dashed #C9D2DC; border-radius: 8px; padding: .9rem; position: relative; background: #FBFCFD; }
.persona + .persona { margin-top: .75rem; }
.persona .quitar { position: absolute; top: .5rem; right: .5rem; }
.persona .etq-persona { font-size: .75rem; font-weight: 700; color: var(--pn-azul); text-transform: uppercase; margin-bottom: .5rem; }
#mapa, .mapa { height: 340px; border-radius: 8px; border: 1px solid var(--borde); z-index: 0; }
.barra-guardar { position: sticky; bottom: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(6px); border-top: 1px solid var(--borde);
    padding: .75rem 1.1rem; margin: 1rem -1.5rem -1.5rem; display: flex; gap: .5rem; justify-content: flex-end; z-index: 5; }
.indice-form { position: sticky; top: 72px; }
.indice-form a { display: block; padding: .3rem .6rem; color: var(--tenue); text-decoration: none; border-left: 2px solid var(--borde); font-size: .85rem; }
.indice-form a:hover { color: var(--pn-azul); border-color: var(--pn-celeste); }

/* Detalle del caso */
.dato { margin-bottom: .6rem; }
.dato .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tenue); font-weight: 600; }
.dato .v { font-weight: 500; }
.dato .v:empty::before { content: "—"; color: #A9B4C0; }
.linea-tiempo { list-style: none; padding: 0; margin: 0; position: relative; }
.linea-tiempo::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--borde); }
.linea-tiempo li { position: relative; padding: 0 0 1.1rem 2.5rem; }
.linea-tiempo li .punto { position: absolute; left: 4px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--c, var(--pn-celeste)); display: grid; place-items: center; font-size: .65rem; color: var(--c, var(--pn-celeste)); }
.linea-tiempo .meta { font-size: .78rem; color: var(--tenue); }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.galeria .item { border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.galeria .item img { width: 100%; height: 150px; object-fit: cover; background: #EEF1F4; outline: 1px solid rgba(0,0,0,.06); outline-offset: -1px; }
.galeria .item .doc { height: 150px; display: grid; place-items: center; font-size: 3rem; color: #B04040; background: #F7F0F0; }
.galeria .item .pie { padding: .55rem .65rem; font-size: .78rem; flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.galeria .item.retirado { opacity: .55; }
.hash { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .7rem; color: var(--tenue); word-break: break-all; }

/* Inicio de sesión */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .lado { background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--pn-celeste) 55%, var(--pn-azul)) 0%, var(--pn-azul) 60%); color: #fff;
    display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 3rem; text-align: center; border-right: 6px solid var(--pn-oro); }
.login .lado img { width: min(260px, 60%); filter: drop-shadow(0 12px 24px rgba(0,0,0,.35)); }
.login .lado h1 { font-size: 1.6rem; font-weight: 700; margin-top: 1.5rem; text-wrap: balance; }
.login .lado p { opacity: .8; max-width: 420px; }
.login .form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.login .form > div { width: 100%; max-width: 380px; }
.login .aviso { font-size: .78rem; color: var(--tenue); border-left: 3px solid var(--pn-oro); padding-left: .75rem; margin-top: 1.5rem; }
.btn-ms { background: #fff; border: 1px solid #8C8C8C; color: #3A3A3A; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: .6rem; }
.btn-ms:hover { background: #F3F3F3; }
.btn-ms .ms { width: 18px; height: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.btn-ms .ms span:nth-child(1) { background: #F25022; } .btn-ms .ms span:nth-child(2) { background: #7FBA00; }
.btn-ms .ms span:nth-child(3) { background: #00A4EF; } .btn-ms .ms span:nth-child(4) { background: #FFB900; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login .lado { padding: 2rem 1rem; border-right: 0; border-bottom: 6px solid var(--pn-oro); } .login .lado img { width: 120px; } }

/* Barras de estadísticas */
.barras { display: flex; flex-direction: column; gap: .45rem; }
.barras .fila { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 44px; gap: .6rem; align-items: center; font-size: .8rem; }
.barras .fila .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.barras .pista { height: 10px; background: #EEF2F6; border-radius: 99px; overflow: hidden; }
.barras .pista span { display: block; height: 100%; background: var(--pn-celeste); border-radius: 99px; }
.barras .etq { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.permisos .grupo { break-inside: avoid; margin-bottom: 1rem; }
.permisos { columns: 2 320px; column-gap: 1.5rem; }
.flujo { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.flujo .paso { flex: 1 1 180px; border-top: 4px solid var(--c); }
.flujo .flecha { align-self: center; color: var(--tenue); }

/* ---------- Reportes ---------- */
.kpi-rep .etq i { color: var(--pn-celeste); }
.kpi-rep .var { font-size: .75rem; color: var(--tenue); margin-top: .3rem; display: flex; gap: .3rem; align-items: center; }
.kpi-rep .var.bien { color: #0B7A3B; }
.kpi-rep .var.mal { color: #B42318; }
.grafico-linea { width: 100%; height: auto; display: block; }
.grafico-linea .rejilla { stroke: #E6EBF1; stroke-width: 1; }
.grafico-linea .eje { font-size: 11px; fill: var(--tenue); font-variant-numeric: tabular-nums; }
.grafico-linea .serie-a { fill: none; stroke: var(--pn-azul); stroke-width: 2.5; stroke-linejoin: round; }
.grafico-linea .serie-b { fill: none; stroke: var(--pn-oro); stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; }
.grafico-linea .punto-a { fill: #fff; stroke: var(--pn-azul); stroke-width: 2; }
.grafico-linea .punto-b { fill: var(--pn-oro); }
.leyenda { font-size: .78rem; color: var(--tenue); display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: .25rem; }
.leyenda span { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-left: .75rem; }
.leyenda .a { background: var(--pn-azul); } .leyenda .b { background: var(--pn-oro); }
.columnas-hora { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 340px; align-items: end; }
.columnas-hora .col-h { min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.columnas-hora .col-h span { width: 100%; min-height: 2px; background: var(--pn-celeste); border-radius: 3px 3px 0 0; }
.columnas-hora .col-h em { font-style: normal; font-size: .6rem; color: var(--tenue); writing-mode: vertical-rl; transform: rotate(180deg); }
.ver-tabla { position: absolute; top: .55rem; right: .75rem; color: var(--tenue); padding: .1rem .35rem; border-radius: 6px; }
.ver-tabla:hover { background: #EEF2F6; color: var(--pn-azul); }
.tabla-reporte table { font-size: .82rem; }
.tabla-reporte thead th { background: #F6F8FB; color: var(--pn-azul); white-space: nowrap; position: sticky; top: 0; }
.tabla-reporte tfoot th { background: #E8EEF5; }
.tabla-reporte tr.subtotal td { font-weight: 700; background: #F6F8FB; }
.tabla-reporte .table-responsive { max-height: 72vh; }
.lista-reportes .list-group-item { font-size: .85rem; }
.lista-reportes .list-group-item .small { color: var(--tenue); }
.lista-reportes .list-group-item.active { background: var(--pn-azul); border-color: var(--pn-azul); }
.lista-reportes .list-group-item.active .small { color: rgba(255,255,255,.75); }
.membrete { gap: 1rem; align-items: center; border-bottom: 3px solid var(--pn-oro); padding-bottom: .6rem; margin-bottom: 1rem; }
.membrete img { width: 64px; height: 70px; object-fit: contain; }
.membrete .m1 { font-weight: 700; color: var(--pn-azul); font-size: .95rem; }
.membrete .m2 { font-weight: 700; font-size: 1.15rem; }
.membrete .m3 { font-size: .8rem; color: var(--tenue); }
.membrete .m4 { margin-left: auto; text-align: right; font-size: .72rem; color: var(--tenue); }

@media print {
    @page { size: A4 landscape; margin: 12mm; }
    body { background: #fff; font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .menu, .barra { display: none !important; }
    .contenido { padding: 0; max-width: none; }
    .tarjeta { box-shadow: none; break-inside: avoid; }
    .evitar-corte { break-inside: avoid; }
    .tabla-reporte { break-inside: auto; }
    .tabla-reporte .table-responsive { max-height: none; overflow: visible; }
    .tabla-reporte thead th { position: static; }
    .tabla-reporte a { color: inherit; text-decoration: none; }
    .col-lg-6 { width: 50%; } .col-lg-4 { width: 33.33%; } .col-lg-8 { width: 66.66%; } .col-lg-3 { width: 25%; } .col-lg-9 { width: 100%; }
    .leaflet-control-container { display: none; }
}
