/* =====================================================================
   SAIGA TecnoCaribe — Estilos institucionales
   Paleta: Azul marino #003366 · Celeste #0099FF · Dorado #FFC000 · Gris #F8F9FA
   ===================================================================== */
:root {
    --inst-navy: #003366;
    --inst-navy-dark: #00264d;
    --inst-navy-light: #0b4a85;
    --inst-sky: #0099FF;
    --inst-gold: #FFC000;
    --inst-gray: #F8F9FA;
    --header-h: 60px;
    --footer-h: 36px;
    --sidebar-w: 262px;
    --bs-primary: #003366;
    --bs-primary-rgb: 0, 51, 102;
    --bs-link-color: #0077cc;
    --bs-link-hover-color: #0099FF;
    --bs-body-bg: #F8F9FA;
    --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { background: var(--inst-gray); }

/* ---------- Botones y componentes con la paleta ---------- */
.btn-primary { --bs-btn-bg: var(--inst-navy); --bs-btn-border-color: var(--inst-navy); --bs-btn-hover-bg: var(--inst-navy-light);
    --bs-btn-hover-border-color: var(--inst-navy-light); --bs-btn-active-bg: var(--inst-navy-dark); --bs-btn-active-border-color: var(--inst-navy-dark);
    --bs-btn-disabled-bg: #5d7a97; --bs-btn-disabled-border-color: #5d7a97; }
.btn-outline-primary { --bs-btn-color: var(--inst-navy); --bs-btn-border-color: var(--inst-navy); --bs-btn-hover-bg: var(--inst-navy);
    --bs-btn-hover-border-color: var(--inst-navy); --bs-btn-active-bg: var(--inst-navy-dark); }
.btn-sky { --bs-btn-color: #fff; --bs-btn-bg: var(--inst-sky); --bs-btn-border-color: var(--inst-sky); --bs-btn-hover-bg: #0084db;
    --bs-btn-hover-border-color: #0084db; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #0070bb; --bs-btn-active-color: #fff; }
.btn-gold, .btn-edit { --bs-btn-color: #2b2100; --bs-btn-bg: var(--inst-gold); --bs-btn-border-color: var(--inst-gold);
    --bs-btn-hover-bg: #e6ad00; --bs-btn-hover-border-color: #e6ad00; --bs-btn-hover-color: #2b2100; --bs-btn-active-bg: #cc9a00; }
.text-navy { color: var(--inst-navy) !important; }
.text-sky { color: var(--inst-sky) !important; }
.bg-navy { background: var(--inst-navy) !important; color: #fff; }
.bg-gold { background: var(--inst-gold) !important; color: #2b2100; }
.badge-gold { background: var(--inst-gold); color: #2b2100; }
a { color: #0077cc; }
a:hover { color: var(--inst-sky); }
.form-control:focus, .form-select:focus { border-color: var(--inst-sky); box-shadow: 0 0 0 .2rem rgba(0, 153, 255, .2); }
.form-check-input:checked { background-color: var(--inst-navy); border-color: var(--inst-navy); }
.nav-tabs .nav-link.active { color: var(--inst-navy); border-top: 3px solid var(--inst-sky); font-weight: 600; }
.nav-tabs .nav-link { color: #4b5d70; }
.page-link { color: var(--inst-navy); }
.page-item.active .page-link { background: var(--inst-navy); border-color: var(--inst-navy); }
.page-link:hover { color: var(--inst-sky); }
.alert-warning { border-left: 4px solid var(--inst-gold); }
.required::after { content: " *"; color: #d63384; }

/* ---------- Header fijo ---------- */
.app-header { height: var(--header-h); background: var(--inst-navy); border-bottom: 3px solid var(--inst-gold); z-index: 1040; }
.app-badge-sistema { background: rgba(255,255,255,.12); color: #e9f4ff; font-weight: 500; border: 1px solid rgba(255,255,255,.2); }
.app-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--inst-gold); color: var(--inst-navy); display: inline-flex;
    align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.app-rol { font-size: .72rem; color: #b8d4ef; }

/* ---------- Sidebar ---------- */
.app-sidebar, .offcanvas-lg.app-sidebar { background-color: var(--inst-navy-dark) !important; width: var(--sidebar-w); }
@media (min-width: 992px) {
    .app-sidebar { position: fixed; top: var(--header-h); bottom: var(--footer-h); left: 0; overflow-y: auto; }
    .app-main { margin-left: var(--sidebar-w); }
}
.app-sidebar .offcanvas-header { background: var(--inst-navy); }
.app-nav { padding: .75rem .5rem 1.5rem; }
.app-nav-top, .app-nav-group { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .6rem .8rem; border-radius: .5rem;
    color: #dbe8f5; text-decoration: none; background: transparent; border: 0; font-weight: 600; font-size: .92rem; text-align: left; }
.app-nav-top:hover, .app-nav-group:hover { background: rgba(255,255,255,.07); color: #fff; }
.app-nav-top.active { background: var(--inst-sky); color: #fff; }
.app-nav-group .app-chevron { transition: transform .2s; font-size: .75rem; }
.app-nav-group.collapsed .app-chevron { transform: rotate(-90deg); }
.app-nav-section { margin-bottom: .15rem; }
.app-nav-link { display: block; padding: .42rem .8rem .42rem 2.45rem; color: #b8cde2; text-decoration: none; font-size: .87rem;
    border-left: 3px solid transparent; border-radius: 0 .4rem .4rem 0; margin: 1px 0; }
.app-nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.app-nav-link.active { color: #fff; border-left-color: var(--inst-sky); background: rgba(0,153,255,.18); font-weight: 600; }
.app-nav-link.destacado { color: var(--inst-gold); font-weight: 600; }
.app-nav-sub { padding: .55rem .8rem .2rem 2.45rem; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #7f9bb8; }
.app-nav-link.destacado.active { color: #fff; }

/* ---------- Contenido y footer fijo ---------- */
.app-main { padding-top: var(--header-h); padding-bottom: calc(var(--footer-h) + 1rem); min-height: 100vh; }
.app-footer { position: fixed; bottom: 0; left: 0; right: 0; height: var(--footer-h); background: #fff; border-top: 1px solid #dee2e6;
    display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; font-size: .78rem; color: #6c757d; z-index: 1030; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.4rem; color: var(--inst-navy); margin: 0; font-weight: 700; }
.page-head .breadcrumb { margin: 0; font-size: .8rem; }
.card { border: 1px solid #e3e8ee; border-radius: .75rem; }
.card-header { background: #fff; border-bottom: 1px solid #e9eef3; font-weight: 600; color: var(--inst-navy); }
.card-accent { border-top: 3px solid var(--inst-sky); }

/* Tablas */
.table-inst thead th { background: var(--inst-navy); color: #fff; font-weight: 600; font-size: .8rem; white-space: nowrap; vertical-align: middle;
    border-color: var(--inst-navy-light); }
.table-inst tbody td { font-size: .86rem; vertical-align: middle; }
.table-inst tfoot td, .table-inst tfoot th { background: #fff8db; font-weight: 700; color: var(--inst-navy); }
.table-inst tbody tr:hover { background: #f1f8ff; }
.table-responsive { border-radius: .5rem; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* KPIs */
.kpi { border: 0; border-radius: .9rem; background: #fff; box-shadow: 0 1px 3px rgba(0,30,60,.08); padding: 1rem 1.1rem; height: 100%;
    border-left: 4px solid var(--inst-sky); }
.kpi.kpi-gold { border-left-color: var(--inst-gold); }
.kpi.kpi-navy { border-left-color: var(--inst-navy); }
.kpi.kpi-danger { border-left-color: #dc3545; }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6f84; font-weight: 600; }
.kpi-value { font-size: 1.45rem; font-weight: 700; color: var(--inst-navy); line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi-icon { font-size: 1.6rem; color: var(--inst-sky); opacity: .85; }
.total-hoy { background: linear-gradient(120deg, var(--inst-navy), var(--inst-navy-light)); color: #fff; border-radius: 1rem; padding: 1.1rem 1.4rem;
    border-bottom: 4px solid var(--inst-gold); }
.total-hoy .valor { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Barras simples */
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: .6rem; align-items: center; font-size: .82rem; margin-bottom: .45rem; }
.bar-track { background: #eaf2fa; border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { background: var(--inst-sky); height: 100%; border-radius: 999px; }

/* Autocompletar */
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #cfd8e3; border-radius: .5rem;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; display: none; }
.ac-list.show { display: block; }
.ac-item { padding: .5rem .75rem; cursor: pointer; border-bottom: 1px solid #f0f3f6; font-size: .88rem; }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: #e8f5ff; }
.ac-item small { color: #6c757d; }
.ac-empty { padding: .6rem .75rem; color: #6c757d; font-size: .85rem; }

/* Selección de estudiante */
.selected-card { border: 1px dashed var(--inst-sky); background: #f3faff; border-radius: .75rem; }

/* Wizard de matrícula */
.wizard-step { border-left: 3px solid #dbe5ef; padding-left: 1rem; margin-bottom: 1.25rem; }
.wizard-step.done { border-left-color: var(--inst-sky); }
.wizard-num { width: 28px; height: 28px; border-radius: 50%; background: var(--inst-navy); color: #fff; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: .85rem; margin-right: .5rem; }

/* Planilla de notas */
.grade-input { width: 4.6rem; text-align: center; font-weight: 600; }
.grade-input.changed { background: #fff6d6; border-color: var(--inst-gold); }
.grade-input.new-grade { background: #eaf7ff; border-color: var(--inst-sky); }
.grade-low { color: #c1121f; }
.badge-promedio { background: var(--inst-gold); color: #2b2100; font-weight: 700; }
.nota-audit { font-size: .7rem; color: #6c757d; display: block; line-height: 1.2; }

/* Login */
.auth-body { min-height: 100vh; background: radial-gradient(circle at top right, var(--inst-navy-light), var(--inst-navy) 45%, var(--inst-navy-dark)); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 480px; border-radius: 1.1rem; overflow: hidden; }
.auth-card.wide { max-width: 640px; }
.auth-brand { background: #fff; padding: 1.5rem 1.75rem .9rem; text-align: center; border-bottom: 4px solid var(--inst-gold); }
.auth-brand img { max-width: 340px; width: 100%; height: auto; }

/* Recibo */
.recibo { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid #dfe5ec; border-radius: .75rem; padding: 1.5rem; }
.recibo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 3px solid var(--inst-gold); padding-bottom: .75rem; }
.recibo-num { background: var(--inst-navy); color: #fff; border-radius: .5rem; padding: .5rem .9rem; text-align: right; }
.recibo-num .n { font-size: 1.15rem; font-weight: 700; letter-spacing: .03em; }
.recibo-anulado { position: relative; }
.recibo-anulado::after { content: "ANULADO"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 5rem;
    font-weight: 900; color: rgba(220, 53, 69, .18); pointer-events: none; }

/* Impresión */
.print-body { background: #fff; }
.print-toolbar { padding: .5rem 1rem; background: #f1f4f8; display: flex; gap: .5rem; }
.print-page { padding: 1rem 1.25rem; }
.print-header { display: flex; align-items: center; gap: 1rem; border-bottom: 3px solid var(--inst-gold); padding-bottom: .6rem; margin-bottom: .8rem; }
.print-header img { height: 54px; }
.print-inst { font-weight: 700; color: var(--inst-navy); font-size: 1.05rem; }
.print-footer { margin-top: 1rem; font-size: .72rem; color: #6c757d; border-top: 1px solid #dee2e6; padding-top: .4rem; }
.print-table { font-size: .72rem; }
.print-table th { background: var(--inst-navy) !important; color: #fff !important; }

@media print {
    @page { size: auto; margin: 12mm 10mm; }
    .no-print, .app-header, .app-sidebar, .app-footer, .page-head .btn, .btn, form.filters, .pagination, #app-alerts { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .card { border: 0 !important; box-shadow: none !important; }
    .table-inst thead th { background: var(--inst-navy) !important; color: #fff !important; }
    a { color: inherit; text-decoration: none; }
    .recibo { border: 0; }
}

@media (max-width: 575.98px) {
    .page-head h1 { font-size: 1.2rem; }
    .kpi-value { font-size: 1.2rem; }
    .total-hoy .valor { font-size: 1.5rem; }
}

/* ---- Columnas ordenables ---- */
th.th-sort a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
th.th-sort a:hover, th.th-sort a:focus-visible { text-decoration: underline; }
th.th-sort .sort-ind { font-size: .7em; opacity: .45; }
th.th-sort.sorted .sort-ind { opacity: 1; color: var(--inst-gold); }
.table-light th.th-sort.sorted .sort-ind, thead.table-light th.th-sort.sorted .sort-ind { color: var(--inst-sky); }
@media print { th.th-sort .sort-ind { display: none; } }

/* ---- Registros anulados / eliminados en vistas históricas ---- */
tr.row-anulado td { color: #6c757d; }
tr.row-eliminado td { color: #842029; background: #fff5f5; }
tr.row-eliminado td.tachado, tr.row-anulado td.tachado { text-decoration: line-through; }
.zona-peligro { border: 1px solid #f1aeb5; border-radius: .5rem; background: #fff8f8; }
.quick-actions .btn { display: flex; align-items: center; gap: .5rem; justify-content: flex-start; }
.report-card { transition: box-shadow .15s; }
.report-card:hover { box-shadow: 0 .25rem .75rem rgba(0, 51, 102, .15); }
.boletin-salto { page-break-before: always; break-before: page; height: 0; margin: 2rem 0; border-top: 2px dashed #ccd; }
@media print { .boletin-salto { border: 0; margin: 0; } }

/* ---------- Calendario de los campos de fecha (v1.5) ---------- */
.input-group-fecha { flex-wrap: nowrap; }
.cal-btn { display: inline-flex; align-items: center; color: var(--bs-secondary-color, #6c757d); }
.cal-btn:hover, .cal-btn[aria-expanded="true"] { color: #fff; background: #003366; border-color: #003366; }
.cal-pop { position: absolute; z-index: 1090; width: 272px; background: #fff; border: 1px solid #d0d7de; border-radius: .5rem; padding: .5rem; font-size: .875rem; }
.cal-head { display: flex; gap: .25rem; align-items: center; margin-bottom: .35rem; }
.cal-head select[data-mes] { flex: 1.4; }
.cal-head select[data-anio] { flex: 1; }
.cal-head .btn { padding: .1rem .55rem; font-size: 1.1rem; line-height: 1.2; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 600; color: #6c757d; padding: .15rem 0; }
.cal-day { border: 0; background: transparent; border-radius: .35rem; padding: .32rem 0; text-align: center; color: #212529; }
.cal-day:hover:not([disabled]), .cal-day:focus-visible { background: #e7f1fb; outline: none; }
.cal-day.hoy { box-shadow: inset 0 0 0 1px #0d6efd; font-weight: 600; }
.cal-day.sel { background: #003366; color: #fff; font-weight: 600; }
.cal-day[disabled] { color: #c3c8cd; cursor: not-allowed; }
.cal-foot { display: flex; justify-content: space-between; border-top: 1px solid #eef0f2; margin-top: .35rem; padding-top: .25rem; }
.cal-foot .btn { padding: .1rem .35rem; font-size: .8rem; text-decoration: none; }
@media print { .cal-btn, .cal-pop { display: none !important; } }
.total-hoy-compacto { padding: .7rem 1rem; border-radius: .75rem; }
.total-hoy-compacto .valor { font-size: 1.6rem; }

/* ---------- Membrete institucional en documentos HTML (v1.5) ---------- */
.membrete { display: flex; gap: 1rem; align-items: center; }
.membrete-logo { height: 58px; width: auto; max-width: 45%; object-fit: contain; }
.membrete-texto { line-height: 1.25; }
.recibo-membrete { display: flex; gap: .9rem; align-items: center; }
.recibo-membrete .print-inst { font-weight: 700; color: var(--inst-navy, #003366); }
.cert-head.membrete .membrete-logo { height: auto; width: 1.85in; max-width: none; }
.cert-head .print-inst { font-weight: 700; color: #003366; font-size: 12pt; line-height: 1.2; }
.documento-pie { text-align: center; font-weight: 600; color: #003366; border-top: 1px solid #dee2e6; margin-top: 1rem; padding-top: .3rem; font-size: .8rem; }
.diploma .escudo { width: auto; height: .95in; }

/* v1.6: roles */
.rol-badge { background: #eef3fa; color: #003366; border: 1px solid #c9d8ec; font-weight: 600; }
.permisos-modulo legend { font-size: .95rem; }
.matriz-permisos th, .matriz-permisos td { white-space: nowrap; }
.matriz-permisos td:first-child { white-space: normal; }
@media print { .matriz-permisos { font-size: 9px; } }

/* v1.7: libro de asistencia */
.libro-asistencia { max-height: 70vh; }
.libro-asistencia table { font-size: .85rem; }
.libro-asistencia thead th { position: sticky; top: 0; z-index: 2; background: #f1f4f8; }
.libro-asistencia .libro-fijo { position: sticky; left: 0; z-index: 1; background: #fff; min-width: 210px; box-shadow: 1px 0 0 #dee2e6; }
.libro-asistencia thead .libro-fijo { z-index: 3; background: #f1f4f8; }
.libro-asistencia .libro-sesion { min-width: 46px; white-space: nowrap; }
.libro-asistencia .libro-celda .badge { min-width: 1.6em; }
.libro-celda-vacia { color: #adb5bd; font-weight: 700; }

/* ===== Editor de plantillas de documentos (v1.8) ===== */
.editor-lienzo { display: flex; flex-direction: column; gap: 1rem; align-items: center; min-height: 200px; }
.editor-hoja { position: relative; width: 100%; max-width: 820px; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .14); user-select: none; }
.editor-hoja svg { display: block; width: 100%; height: auto; }
.editor-capa { position: absolute; inset: 0; }
.editor-caja { position: absolute; outline: 1px dashed rgba(0, 51, 102, .35); cursor: move; touch-action: none; min-height: 4px; }
.editor-caja.flujo { outline-color: rgba(13, 110, 253, .35); }
.editor-caja:hover { outline: 1px dashed rgba(0, 51, 102, .8); background: rgba(0, 51, 102, .04); }
.editor-caja.activa { outline: 2px solid #0d6efd; background: rgba(13, 110, 253, .06); z-index: 2; }
.editor-asa { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: #0d6efd; border: 1px solid #fff; cursor: nwse-resize; display: none; }
.editor-caja.activa .editor-asa { display: block; }
.editor-panel .tab-content { max-height: 70vh; overflow-y: auto; }
.editor-campos { max-height: 60vh; overflow-y: auto; }
.editor-campos code { white-space: normal; word-break: break-all; }
.archivo-miniatura { max-width: 80px; max-height: 60px; object-fit: contain; border: 1px solid #dee2e6; background: #fff; }

/* =====================================================================
   v1.11 — Presentación SAIGA: interfaz más limpia y adaptable a celular.
   Capa final: ajusta la apariencia sin cambiar la estructura de las vistas.
   ===================================================================== */
:root {
    --inst-ink: #14233a;
    --inst-muted: #5f6f82;
    --inst-line: #e4e9f0;
    --inst-surface: #ffffff;
    --inst-bg: #f3f6fa;
    --radius: .85rem;
    --radius-sm: .55rem;
    --shadow-sm: 0 1px 2px rgba(16, 38, 68, .06), 0 1px 3px rgba(16, 38, 68, .05);
    --shadow-md: 0 4px 14px rgba(16, 38, 68, .08);
    --header-h: 62px;
    --bs-body-bg: var(--inst-bg);
    --bs-body-color: var(--inst-ink);
    --bs-border-radius: .55rem;
    --bs-border-color: #d9e0e8;
}
body { background: var(--inst-bg); color: var(--inst-ink); -webkit-font-smoothing: antialiased; }
::selection { background: rgba(0, 153, 255, .2); }

/* Botones */
.btn { border-radius: var(--radius-sm); font-weight: 500; background-image: none; }
.btn-lg { border-radius: .7rem; }
.btn-primary { box-shadow: 0 1px 2px rgba(0, 51, 102, .25); }
.btn:focus-visible { box-shadow: 0 0 0 .2rem rgba(0, 153, 255, .3); }

/* Formularios */
.form-label { font-weight: 600; font-size: .86rem; color: #2c3e55; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #d3dbe5; background-color: #fff; }
.form-control:disabled, .form-select:disabled { background-color: #eef2f6; }
.form-control::placeholder { color: #98a5b4; }
.input-group-text { background: #f4f7fb; border-color: #d3dbe5; color: var(--inst-muted); }
.form-text { color: var(--inst-muted); }

/* Encabezado */
.app-header { background: linear-gradient(90deg, var(--inst-navy-dark), var(--inst-navy) 55%, #0a4278); border-bottom: 3px solid var(--inst-gold);
    box-shadow: 0 2px 10px rgba(0, 25, 55, .25); }
.app-brand { display: flex; align-items: center; gap: .6rem; color: #fff; }
.app-brand:hover { color: #fff; }
.app-brand-text { display: flex; flex-direction: column; line-height: 1; }
.app-brand-sigla { font-weight: 900; font-size: 1.5rem; letter-spacing: .02em; color: #fff; line-height: 1; }
.app-brand-sigla span { color: #4fb8ff; }
.app-brand-nombre { font-size: .68rem; color: #b9d3ec; font-weight: 500; letter-spacing: .03em; margin-top: .2rem; }
.app-brand-sep { width: 1px; height: 28px; background: rgba(255, 255, 255, .25); margin: 0 .35rem; }
.app-brand-inst { opacity: .92; }
.app-header .dropdown-toggle { border-radius: .7rem; padding: .25rem .5rem; }
.app-header .dropdown-toggle:hover { background: rgba(255, 255, 255, .08); }
.app-header .dropdown-menu { border: 1px solid var(--inst-line); border-radius: var(--radius); padding: .4rem; }
.app-header .dropdown-item { border-radius: .45rem; }
.app-avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }

/* Menú lateral */
.app-sidebar, .offcanvas-lg.app-sidebar { background: linear-gradient(180deg, #00284f, #001d3b) !important; }
.app-sidebar { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .2); border-radius: 3px; }
.app-sidebar .offcanvas-header { background: var(--inst-navy); border-bottom: 3px solid var(--inst-gold); }
.app-nav { padding: .9rem .65rem 1.5rem; }
.app-nav-top, .app-nav-group { border-radius: .6rem; font-size: .9rem; padding: .62rem .8rem; color: #d7e5f3; }
.app-nav-top i, .app-nav-group > i:first-child { width: 1.25rem; text-align: center; font-size: 1.05rem; color: #7fc6ff; }
.app-nav-top.active { background: linear-gradient(90deg, #0a84e0, var(--inst-sky)); box-shadow: 0 2px 8px rgba(0, 153, 255, .35); }
.app-nav-top.active i { color: #fff; }
.app-nav-group[aria-expanded="true"] { color: #fff; background: rgba(255, 255, 255, .05); }
.app-nav-section .collapse, .app-nav-section .collapsing { margin: .1rem 0 .35rem; }
.app-nav-link { margin-left: 1.05rem; padding-left: 1.2rem; border-left: 2px solid rgba(255, 255, 255, .1); border-radius: 0 .45rem .45rem 0; font-size: .855rem; }
.app-nav-link.active { border-left-color: var(--inst-sky); background: rgba(0, 153, 255, .16); }

/* Contenido */
.app-main > .container-fluid { max-width: 1680px; }
.page-head { margin-bottom: 1.15rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
.page-head .text-muted { color: var(--inst-muted) !important; }
.seccion-titulo { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--inst-muted); margin-bottom: .55rem; }

/* Tarjetas */
.card { --bs-card-bg: #fff; --bs-card-cap-bg: #fff; background-color: #fff; border: 1px solid var(--inst-line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.auth-card { --bs-card-bg: #fff; background: #fff; }
.card > .card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-header { padding: .8rem 1.1rem; font-size: .98rem; }
.card-footer { background: #fafbfd; border-top-color: var(--inst-line); }
.card-accent { border-top: 0; position: relative; overflow: hidden; }
.card-accent::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--inst-navy), var(--inst-sky)); }
.report-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.report-card { transition: box-shadow .15s, transform .15s; }

/* Indicadores */
.kpi { border: 1px solid var(--inst-line); border-left: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    padding: 1rem 1.1rem 1rem 1.3rem; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--inst-sky); }
.kpi.kpi-gold::before { background: var(--inst-gold); }
.kpi.kpi-navy::before { background: var(--inst-navy); }
.kpi.kpi-danger::before { background: #dc3545; }
a .kpi { transition: box-shadow .15s, transform .15s; }
a:hover .kpi { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-label { font-size: .72rem; letter-spacing: .05em; }
.kpi-value { font-size: 1.6rem; font-weight: 800; margin-top: .15rem; }
.total-hoy { border-radius: var(--radius); box-shadow: var(--shadow-md); }

/* Accesos rápidos en mosaico */
.quick-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; }
.quick-tiles .btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: .55rem; min-height: 92px;
    padding: .8rem .85rem; text-align: left; white-space: normal; line-height: 1.25; font-size: .88rem; font-weight: 600;
    background: var(--inst-surface); color: var(--inst-ink); border: 1px solid var(--inst-line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s, border-color .15s; }
.quick-tiles .btn:hover, .quick-tiles .btn:focus-visible { background: var(--inst-surface); color: var(--inst-navy); border-color: #b9d8f5; box-shadow: var(--shadow-md);
    transform: translateY(-1px); }
.quick-tiles .btn i { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border-radius: .65rem;
    font-size: 1.15rem; background: #e8f3ff; color: #0a6fc2; }
.quick-tiles .btn-gold i, .quick-tiles .btn-edit i { background: #fff3cc; color: #9a6b00; }
.quick-tiles .btn-primary i { background: var(--inst-navy); color: #fff; }
.quick-tiles .btn-sky i { background: var(--inst-sky); color: #fff; }
.quick-tiles .btn-outline-secondary i, .quick-tiles .btn-outline-dark i { background: #eef1f5; color: #44546a; }

/* Tablas */
.table { --bs-table-bg: transparent; }
.table-responsive { border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.table-inst { margin-bottom: 0; }
.table-inst thead th { background: #0b3a6b; border-color: #0b3a6b; padding-top: .65rem; padding-bottom: .65rem; letter-spacing: .01em; }
.table-inst thead tr:first-child th:first-child { border-top-left-radius: var(--radius-sm); }
.table-inst thead tr:first-child th:last-child { border-top-right-radius: var(--radius-sm); }
.table-inst tbody td { border-color: #edf1f5; padding-top: .6rem; padding-bottom: .6rem; }
.table-inst tbody tr:hover { background: #f3f9ff; }
.table > :not(caption) > * > * { border-bottom-color: #edf1f5; }
.badge { font-weight: 600; letter-spacing: .01em; }

/* Paginación, pestañas y alertas */
.pagination { --bs-pagination-border-radius: var(--radius-sm); gap: .2rem; flex-wrap: wrap; }
.page-link { border-radius: var(--radius-sm) !important; }
.nav-tabs { border-bottom-color: var(--inst-line); }
.alert { border-radius: var(--radius); border-width: 1px; }
.modal-content { border: 0; border-radius: 1rem; box-shadow: 0 1rem 2.5rem rgba(10, 30, 60, .2); }
.dropdown-menu { box-shadow: var(--shadow-md); }

/* Pie */
.app-footer { background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-top: 1px solid var(--inst-line); gap: 1rem; }

/* Acceso (login, recuperación, setup) */
.auth-body { background: radial-gradient(1200px 600px at 85% -10%, rgba(0, 153, 255, .35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 192, 0, .16), transparent 60%),
    linear-gradient(160deg, #002549, var(--inst-navy) 55%, #00203f); }
.auth-shell { display: flex; width: 100%; max-width: 480px; border-radius: 1.25rem; overflow: hidden; box-shadow: 0 1.5rem 3.5rem rgba(0, 10, 30, .45); }
.auth-shell.wide { max-width: 640px; }
.auth-card { max-width: none; border-radius: 0; flex: 1 1 auto; min-width: 0; }
.auth-card .card-body { padding: 1.75rem; }
.auth-brand { padding: 1.6rem 1.75rem 1rem; border-bottom: 0; position: relative; }
.auth-brand::after { content: ""; position: absolute; left: 1.75rem; right: 1.75rem; bottom: 0; height: 3px; border-radius: 3px;
    background: linear-gradient(90deg, var(--inst-gold), #ffd966); }
.auth-brand img { max-width: 320px; }
.auth-pie { color: rgba(255, 255, 255, .6); }
.auth-aside { flex: 0 0 46%; flex-direction: column; justify-content: space-between; gap: 2rem; padding: 2.5rem 2.25rem; color: #fff;
    background: linear-gradient(165deg, rgba(0, 153, 255, .22), rgba(0, 0, 0, 0) 55%), #00315f; border-right: 1px solid rgba(255, 255, 255, .08); }
.auth-aside-escudo { width: 64px; height: auto; margin-bottom: 1rem; }
.auth-aside-sigla { font-size: 3rem; font-weight: 900; letter-spacing: .02em; line-height: 1; }
.auth-aside-sigla span { color: #4fb8ff; }
.auth-aside-nombre { font-size: 1.05rem; font-weight: 600; margin: .6rem 0 .2rem; color: #e6f1fc; }
.auth-aside-lema { color: var(--inst-gold); font-style: italic; margin-bottom: 1.6rem; }
.auth-aside-lista { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; font-size: .9rem; color: #c7dbef; }
.auth-aside-lista li { display: flex; gap: .65rem; align-items: flex-start; }
.auth-aside-lista i { color: #4fb8ff; font-size: 1.05rem; line-height: 1.3; }
.auth-aside-inst { width: 190px; height: auto; opacity: .9; }
@media (min-width: 992px) {
    .auth-shell:not(.wide) { max-width: 940px; }
    .auth-card .card-body { padding: 2rem 2.5rem 2.25rem; }
    .auth-brand { padding: 2rem 2.5rem 1.1rem; }
    .auth-brand::after { left: 2.5rem; right: 2.5rem; }
}

/* ---------- Celulares y tabletas ---------- */
@media (max-width: 991.98px) {
    /* El pie deja de estar fijo: no tapa el contenido en pantallas pequeñas */
    .app-footer { position: static; height: auto; min-height: var(--footer-h); padding: .6rem 1rem; flex-wrap: wrap; }
    .app-main { padding-bottom: 1rem; min-height: calc(100vh - var(--footer-h)); }
    .app-sidebar.offcanvas-lg { width: min(86vw, 300px); }
}
@media (max-width: 767.98px) {
    .app-main > .container-fluid { padding-left: .85rem !important; padding-right: .85rem !important; }
    .page-head { align-items: stretch; }
    .page-head > div:first-child { flex: 1 1 100%; }
    .page-head h1 { font-size: 1.3rem; }
    .card-body { padding: .9rem; }
    .card-header { padding: .7rem .9rem; }
    .table-inst thead th, .table-inst tbody td { font-size: .8rem; }
    .table-responsive { background: linear-gradient(90deg, #fff 30%, rgba(255, 255, 255, 0)), linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 70%) 100% 0,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .12), transparent), radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .12), transparent) 100% 0;
        background-repeat: no-repeat; background-size: 30px 100%, 30px 100%, 10px 100%, 10px 100%; background-attachment: local, local, scroll, scroll; }
    .modal-dialog { margin: .6rem; }
}
@media (max-width: 575.98px) {
    .app-brand-sigla { font-size: 1.3rem; }
    .app-header .dropdown-toggle::after { display: none; }
    /* Botones de la cabecera de cada pantalla: a todo el ancho y fáciles de tocar */
    .page-head > .btn, .page-head > div:not(:first-child) { width: 100%; }
    .page-head > div:not(:first-child) { display: flex; flex-wrap: wrap; gap: .5rem; }
    .page-head > div:not(:first-child) > .btn { flex: 1 1 auto; }
    .quick-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
    .quick-tiles .btn { min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; font-size: .84rem; padding: .65rem .7rem; }
    .quick-tiles .btn i { flex: 0 0 auto; width: 2rem; height: 2rem; font-size: 1rem; }
    .kpi { padding: .85rem .9rem .85rem 1.1rem; }
    .kpi-value { font-size: 1.3rem; }
    .auth-wrap { padding: 1rem .75rem; justify-content: flex-start; padding-top: 6vh; }
    .auth-card .card-body { padding: 1.25rem; }
    .auth-brand { padding: 1.25rem 1.25rem .85rem; }
    .auth-brand::after { left: 1.25rem; right: 1.25rem; }
    .form-control:not(.form-control-sm), .form-select:not(.form-select-sm) { font-size: 16px; } /* evita el zoom automático en iPhone */
}
@media print {
    .app-footer { display: none !important; }
    .card, .kpi { box-shadow: none !important; }
}
