/* =====================================================================
   apge · Estilos del panel (Bootstrap 5.3 + identidad del logo)
   Verde institucional #13503e · menta #88ceac · gris #8a8a8a
   ===================================================================== */
:root {
    --apge-verde: #13503e;
    --apge-verde-2: #1b6b52;
    --apge-menta: #88ceac;
    --apge-menta-suave: #e8f5ee;
    --apge-gris: #8a8a8a;
    --apge-fondo: #f4f7f5;
    --apge-sidebar-w: 264px;

    --bs-primary: #13503e;
    --bs-primary-rgb: 19, 80, 62;
    --bs-link-color: #13503e;
    --bs-link-color-rgb: 19, 80, 62;
    --bs-link-hover-color: #0d3a2d;
    --bs-body-font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-border-radius: .6rem;
}

body { background: var(--apge-fondo); font-size: .925rem; }

.btn-primary {
    --bs-btn-bg: var(--apge-verde); --bs-btn-border-color: var(--apge-verde);
    --bs-btn-hover-bg: #0f4233; --bs-btn-hover-border-color: #0f4233;
    --bs-btn-active-bg: #0d3a2d; --bs-btn-active-border-color: #0d3a2d;
    --bs-btn-disabled-bg: var(--apge-verde); --bs-btn-disabled-border-color: var(--apge-verde);
}
.btn-outline-primary {
    --bs-btn-color: var(--apge-verde); --bs-btn-border-color: var(--apge-verde);
    --bs-btn-hover-bg: var(--apge-verde); --bs-btn-hover-border-color: var(--apge-verde);
    --bs-btn-active-bg: var(--apge-verde); --bs-btn-active-border-color: var(--apge-verde);
}
.text-bg-primary { background-color: var(--apge-verde) !important; }
.form-control:focus, .form-select:focus { border-color: var(--apge-menta); box-shadow: 0 0 0 .2rem rgba(136, 206, 172, .35); }
.form-check-input:checked { background-color: var(--apge-verde); border-color: var(--apge-verde); }
.nav-tabs .nav-link.active { color: var(--apge-verde); font-weight: 600; }
.nav-tabs .nav-link { color: #555; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--apge-sidebar-w);
    background: linear-gradient(180deg, #13503e 0%, #0e3f31 100%);
    color: #fff;
}
.sidebar .marca { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; }
.sidebar .marca img { height: 34px; background: #fff; border-radius: .5rem; padding: 3px 5px; }
.sidebar .marca span { font-weight: 700; letter-spacing: .3px; font-size: 1.15rem; }
.sidebar .marca small { display: block; font-size: .7rem; font-weight: 400; color: var(--apge-menta); letter-spacing: .5px; }
.sidebar .grupo { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.5); padding: 1rem 1.25rem .35rem; }
.sidebar .nav-link {
    color: rgba(255,255,255,.85); padding: .5rem 1.25rem; margin: 1px .6rem; border-radius: .5rem;
    display: flex; align-items: center; gap: .65rem; font-size: .9rem;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: var(--apge-menta); color: var(--apge-verde); font-weight: 600; }
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

@media (min-width: 992px) {
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 1030; }
    .contenido { margin-left: var(--apge-sidebar-w); }
}

/* ---------- Topbar ---------- */
.topbar {
    background: #fff; border-bottom: 1px solid #e6ebe8; position: sticky; top: 0; z-index: 1020;
    padding: .7rem 1.25rem; min-height: 60px;
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; margin: 0; color: #1d2a25; }
.topbar .migas { font-size: .75rem; color: var(--apge-gris); }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--apge-menta-suave); color: var(--apge-verde);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; object-fit: cover;
}

/* ---------- Tarjetas y KPIs ---------- */
.card { border: 1px solid #e6ebe8; box-shadow: 0 1px 2px rgba(16, 40, 30, .04); }
.card-header { background: #fff; font-weight: 600; border-bottom-color: #eef2f0; }
.kpi { border-left: 4px solid var(--apge-menta); }
.kpi .valor { font-size: 1.45rem; font-weight: 700; color: #1d2a25; line-height: 1.2; }
.kpi .etiqueta { font-size: .78rem; color: var(--apge-gris); text-transform: uppercase; letter-spacing: .04em; }
.kpi .icono { font-size: 1.6rem; color: var(--apge-verde); opacity: .8; }
.kpi.alerta { border-left-color: #dc3545; }
.kpi.aviso { border-left-color: #ffc107; }

.dato-label { font-size: .75rem; color: var(--apge-gris); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .1rem; }
.dato-valor { font-weight: 500; margin-bottom: .8rem; word-break: break-word; }

/* ---------- Tablas / DataTables ---------- */
.table > :not(caption) > * > * { padding: .6rem .7rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #5d6b65; background: #f8faf9; white-space: nowrap; }
div.dt-container .dt-buttons .btn { font-size: .8rem; }
div.dt-container .dt-search input { min-width: 220px; }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--apge-verde); border-color: var(--apge-verde); }
.dt-container .row:first-child { row-gap: .5rem; }
td.acciones { white-space: nowrap; text-align: right; }

/* ---------- Módulos (tarjetas conmutables) ---------- */
.modulo-card { border: 1px solid #e6ebe8; border-radius: .75rem; padding: .9rem 1rem; display: flex; gap: .8rem; align-items: flex-start; background: #fff; }
.modulo-card.activo { border-color: var(--apge-menta); background: var(--apge-menta-suave); }
.modulo-card .icono { font-size: 1.5rem; color: var(--apge-verde); }

/* ---------- Login ---------- */
.login-fondo { min-height: 100vh; background: radial-gradient(circle at 20% 10%, #e8f5ee 0, #f4f7f5 40%, #eef3f0 100%); }
.login-card { max-width: 410px; width: 100%; border-radius: 1rem; }
.login-card .logo { max-width: 240px; }

/* ---------- Cuenta de cobro imprimible ---------- */
.hoja { background: #fff; max-width: 820px; margin: 1.5rem auto; padding: 2.5rem; border: 1px solid #e6ebe8; }
@media print {
    .no-print, .sidebar, .topbar { display: none !important; }
    .contenido { margin: 0 !important; }
    body { background: #fff; }
    .hoja { border: 0; margin: 0; padding: 0; max-width: none; }
}

/* ---------- Móvil ---------- */
@media (max-width: 991.98px) {
    .topbar h1 { font-size: 1rem; }
    .kpi .valor { font-size: 1.2rem; }
    div.dt-container .dt-search input { min-width: 0; width: 100%; }
}
.btn-instalar { display: none; }

/* Pills y paginación con el verde institucional */
.nav-pills { --bs-nav-pills-link-active-bg: var(--apge-verde); --bs-nav-link-color: var(--apge-verde); --bs-nav-link-hover-color: #0d3a2d; }
.pagination { --bs-pagination-color: var(--apge-verde); --bs-pagination-hover-color: #0d3a2d; --bs-pagination-active-bg: var(--apge-verde); --bs-pagination-active-border-color: var(--apge-verde); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(136, 206, 172, .35); }
div.dt-container .dt-buttons { flex-wrap: wrap; }
.min-w-0 { min-width: 0; }

.contenido { min-width: 0; }
.dt-container .dt-layout-table, .dt-container .dt-layout-cell.dt-layout-full { max-width: 100%; overflow-x: auto; }
.card, .card-body { min-width: 0; }

/* ---------- Ayuda (modal y página de manuales) ---------- */
.btn-ayuda { white-space: nowrap; }
#modalAyuda .modal-body { position: relative; }
.ayuda-texto { font-size: .93rem; line-height: 1.55; }
.ayuda-texto h4, .ayuda-texto .ayuda-h { scroll-margin-top: .5rem; }
.ayuda-texto h4 { font-size: 1.05rem; font-weight: 600; margin: 1.4rem 0 .6rem; padding-bottom: .3rem; border-bottom: 1px solid #e7ece9; color: #1d2a25; }
.ayuda-texto h5 { font-size: .97rem; font-weight: 600; margin: 1.1rem 0 .5rem; }
.ayuda-texto h6 { font-size: .9rem; font-weight: 600; margin: 1rem 0 .4rem; }
.ayuda-texto ol, .ayuda-texto ul { padding-left: 1.3rem; }
.ayuda-texto li { margin-bottom: .3rem; }
.ayuda-texto code { color: #0b5d4b; background: #eef5f2; padding: .05rem .3rem; border-radius: .25rem; }
.ayuda-tabla { font-size: .85rem; }
.ayuda-tabla th { background: #f3f6f4; white-space: nowrap; }
.ayuda-nota { border-left: 4px solid #adb5bd; background: #f8f9fa; padding: .6rem .8rem; border-radius: .35rem; margin: .8rem 0; font-size: .9rem; }
.ayuda-nota-warning { border-color: #f0ad4e; background: #fff8ec; }
.ayuda-nota-success { border-color: #2e9e6e; background: #eefaf4; }
.ayuda-nota-info { border-color: #3d8bfd; background: #eef4ff; }
.ayuda-resumen { font-size: 1rem; color: #4a5a53; }
.ayuda-grupo { text-transform: uppercase; font-size: .72rem; letter-spacing: .05em; color: #6c7a73; margin: .8rem 0 .3rem; }
.ayuda-resaltado { background: #fff3c4; transition: background .4s; border-radius: .25rem; }
.ayuda-indice-lateral .list-group-item.active { background: #e7f3ee; color: #0b5d4b; border-color: #cfe5db; }
@media print {
    .ayuda-indice-lateral, .ayuda-no-print { display: none !important; }
    .ayuda-texto h4 { break-after: avoid; }
    .ayuda-manual + .ayuda-manual { break-before: page; }
}
