/* ==========================================================================
   COOPINFA SIS — Sistema de diseño (Fase 5)
   --------------------------------------------------------------------------
   Capa de tema que moderniza la plantilla SB Admin 2 sin cambiar el marcado.
   Se carga DESPUÉS de sb-admin-2.min.css y redefine color, tipografía,
   espaciado, sombras y componentes mediante variables CSS (design tokens).
   Incluye modo claro y oscuro. La migración a Bootstrap 5 y la limpieza de
   marcado llegan en fases posteriores; esto es la base visual.
   ========================================================================== */

/* Indica al navegador el esquema activo: sin esto, los controles nativos
   (inputs sin fondo explícito, date pickers, scrollbars) se pintan en blanco
   en modo oscuro. Es la causa de los "campos blancos" en oscuro. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* ---------- Tokens: modo claro ---------- */
:root {
    /* Marca — verde cooperativa, refinado desde el #008000 original */
    --brand-50:  #e9f6ee;
    --brand-100: #c9e9d5;
    --brand-200: #97d3ac;
    --brand-300: #63bd82;
    --brand-400: #34a75e;
    --brand-500: #1e8e4a;   /* primario */
    --brand-600: #16773c;   /* hover */
    --brand-700: #105e2f;   /* activo */
    --brand-800: #0c4a26;
    --brand-900: #08361b;

    /* Neutros */
    --gray-50:  #f7f8fa;
    --gray-100: #eef1f5;
    --gray-200: #e2e6ec;
    --gray-300: #cbd2db;
    --gray-400: #9aa4b2;
    --gray-500: #6b7684;
    --gray-600: #4d5866;
    --gray-700: #363f4a;
    --gray-800: #232a33;
    --gray-900: #151a20;

    /* Semánticos */
    --primary:   var(--brand-500);
    --primary-h: var(--brand-600);
    --success:   #1e8e4a;
    --info:      #2b7fb8;
    --warning:   #d99a06;
    --danger:    #d1483a;

    /* Superficies */
    --bg:        var(--gray-50);
    --surface:   #ffffff;
    --surface-2: var(--gray-100);
    --border:    var(--gray-200);
    --text:      var(--gray-800);
    --text-muted:var(--gray-500);
    --text-invert:#ffffff;

    /* Sidebar / topbar */
    --sidebar-bg-1: #1c7a41;
    --sidebar-bg-2: #145e31;
    --sidebar-text: rgba(255,255,255,.88);
    --sidebar-text-muted: rgba(255,255,255,.6);
    --sidebar-active: rgba(255,255,255,.16);
    --topbar-bg: #ffffff;

    /* Forma */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --shadow:    0 2px 8px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
    --shadow-lg: 0 12px 28px rgba(16,24,40,.14);

    /* Tipografía */
    --font-sans: "Inter", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Tokens: modo oscuro ---------- */
:root[data-theme="dark"] {
    --bg:        #0f141a;
    --surface:   #171e26;
    --surface-2: #1e2731;
    --border:    #2a333f;
    --text:      #e4e8ee;
    --text-muted:#9aa6b3;

    --sidebar-bg-1: #123018;
    --sidebar-bg-2: #0c220f;
    --topbar-bg: #171e26;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow:    0 2px 10px rgba(0,0,0,.45);
    --shadow-lg: 0 14px 34px rgba(0,0,0,.55);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:        #0f141a;
        --surface:   #171e26;
        --surface-2: #1e2731;
        --border:    #2a333f;
        --text:      #e4e8ee;
        --text-muted:#9aa6b3;
        --sidebar-bg-1: #123018;
        --sidebar-bg-2: #0c220f;
        --topbar-bg: #171e26;
    }
}

/* ---------- Base ---------- */
body {
    font-family: var(--font-sans);
    background-color: var(--bg) !important;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
#wrapper { background-color: var(--bg); }
#content-wrapper { background-color: var(--bg) !important; }
a { color: var(--primary); }
a:hover { color: var(--primary-h); }
.text-gray-800 { color: var(--text) !important; }
.text-gray-500, .text-gray-600 { color: var(--text-muted) !important; }
h1,h2,h3,h4,h5,h6 { color: var(--text); letter-spacing: -.01em; }

/* ---------- Sidebar ---------- */
.sidebar,
.navbar-nav.sidebar,
ul.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg-1), var(--sidebar-bg-2)) !important;
    box-shadow: var(--shadow);
}
.sidebar .nav-item .nav-link,
.sidebar a.nav-link { color: var(--sidebar-text) !important; border-radius: var(--radius-sm); margin: 2px 10px; transition: background-color .15s ease; }
.sidebar .nav-item .nav-link i { color: var(--sidebar-text-muted) !important; }
.sidebar .nav-item .nav-link:hover { background: var(--sidebar-active) !important; }
.sidebar .nav-item .nav-link:hover i { color: #fff !important; }
.sidebar .nav-item.active .nav-link,
.sidebar .nav-item .nav-link.active { background: var(--sidebar-active) !important; font-weight: 600; }
.sidebar .sidebar-heading { color: rgba(255,255,255,.45) !important; letter-spacing: .08em; font-size: .66rem; }
.sidebar-brand { background: rgba(0,0,0,.12); }
.sidebar hr.sidebar-divider { border-top-color: rgba(255,255,255,.12); }
.sidebar .nav-item .collapse .collapse-inner,
.sidebar .nav-item .collapsing .collapse-inner {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Topbar ---------- */
.topbar {
    background: var(--topbar-bg) !important;
    box-shadow: none !important;
    border-bottom: 1px solid var(--border);
    height: 4rem;
}
.topbar .nav-link { color: var(--text-muted) !important; }
.topbar .nav-link:hover { color: var(--text) !important; }
.topbar .topbar-divider { border-right-color: var(--border); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card .card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text) !important;
}
.card .card-header .m-0.font-weight-bold,
.card .card-header .font-weight-bold { color: var(--text) !important; }

/* ---------- Botones ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; transition: all .15s ease; }
.btn:focus, .btn.focus { box-shadow: 0 0 0 .2rem rgba(30,142,74,.25); }
.btn-primary, .btn-success {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}
.btn-primary:hover, .btn-success:hover {
    background-color: var(--primary-h) !important;
    border-color: var(--primary-h) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-danger  { background-color: var(--danger) !important;  border-color: var(--danger) !important; }
.btn-warning { background-color: var(--warning) !important; border-color: var(--warning) !important; color:#fff !important; }
.btn-info    { background-color: var(--info) !important;    border-color: var(--info) !important; color:#fff !important; }
.btn-outline-primary { color: var(--primary) !important; border-color: var(--primary) !important; }
.btn-outline-primary:hover { background: var(--primary) !important; color:#fff !important; }
.btn-link { color: var(--primary) !important; }

/* ---------- Formularios ---------- */
.form-control, .custom-select {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .custom-select:focus {
    background-color: var(--surface);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 .2rem rgba(30,142,74,.18);
    color: var(--text);
}
label { color: var(--text); font-weight: 600; font-size: .85rem; }

/* ---------- Tablas ---------- */
.table { color: var(--text); }
.table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    border-top: none;
    padding: .75rem 1rem;
}
.table td { border-top: 1px solid var(--border); padding: .75rem 1rem; vertical-align: middle; }
.table-hover tbody tr { transition: background-color .12s ease; }
.table-hover tbody tr:hover { background-color: var(--surface-2); }
.table-bordered, .table-bordered td, .table-bordered th { border-color: var(--border); }

/* ---------- Paginación ---------- */
.pagination .page-link {
    color: var(--primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 0 2px;
}
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color:#fff; }
.pagination .page-link:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { border-radius: 999px; font-weight: 600; padding: .35em .7em; }
.badge-primary, .badge-success { background: var(--brand-100); color: var(--brand-700); }
.badge-danger { background: #fbe3df; color: #a3271c; }
.badge-warning { background: #fbeecb; color: #8a6100; }

/* ---------- Dropdowns ---------- */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.dropdown-item { color: var(--text); }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-header { color: var(--text-muted); }

/* ---------- Footer ---------- */
.sticky-footer { background: var(--surface); border-top: 1px solid var(--border); }
.sticky-footer .copyright { color: var(--text-muted) !important; }

/* ---------- Scrollbar (webkit) ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #33404e; background-clip: content-box; }

/* ---------- Botón de tema ---------- */
#themeToggle { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: .5rem .75rem; border-radius: var(--radius-sm); }
#themeToggle:hover { color: var(--text); background: var(--surface-2); }
:root[data-theme="dark"] #themeToggle .fa-moon { display: none; }
:root:not([data-theme="dark"]) #themeToggle .fa-sun { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #themeToggle .fa-moon { display: none; }
    :root:not([data-theme="light"]) #themeToggle .fa-sun { display: inline; }
}

/* ---------- Login / páginas sin sesión ---------- */
.bg-login-image, .bg-register-image, .bg-password-image { background-color: var(--brand-600); }
.card.o-hidden { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }

/* ==========================================================================
   Endurecimiento de contraste — utilidades que referencian los tokens.
   Al mapear las utilidades de Bootstrap a variables, funcionan igual en claro
   y oscuro sin overrides duplicados.
   ========================================================================== */

/* Todo input de texto, aunque no lleve .form-control, toma la superficie */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=range]):not([type=color]):not([type=file]),
textarea,
select {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input:disabled, textarea:disabled, select:disabled,
.form-control:disabled, .form-control[readonly] { background-color: var(--surface-2); color: var(--text-muted); }

/* Autocompletado de Chrome: forzar colores del tema */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    caret-color: var(--text);
}

/* Superficies utilitarias -> tokens (blanco en claro, oscuro en oscuro) */
.bg-white { background-color: var(--surface) !important; }
.bg-light, .bg-gray-100, .bg-gray-200 { background-color: var(--surface-2) !important; }

/* Texto utilitario -> tokens */
.text-dark, .text-black, .text-gray-900, .text-gray-800, .text-gray-700 { color: var(--text) !important; }
.text-gray-600, .text-gray-500, .text-gray-400, .text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

/* Bordes y separadores utilitarios */
.border, .border-top, .border-bottom, .border-left, .border-right { border-color: var(--border) !important; }
hr, .dropdown-divider { border-top-color: var(--border); }

/* Modales */
.modal-content { background-color: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.modal-header, .modal-footer { border-color: var(--border); }
.close { color: var(--text); text-shadow: none; opacity: .7; }
.close:hover { color: var(--text); opacity: 1; }

/* Pestañas */
.nav-tabs { border-bottom-color: var(--border); }
.nav-tabs .nav-link { color: var(--text-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.nav-tabs .nav-link:hover { border-color: transparent; color: var(--text); }
.nav-tabs .nav-link.active { color: var(--primary); background: var(--surface); border-color: var(--border) var(--border) var(--surface); }

/* Listas y grupos */
.list-group-item { background-color: var(--surface); color: var(--text); border-color: var(--border); }
.input-group-text { background-color: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

/* Filas alternas de tabla */
.table-striped tbody tr:nth-of-type(odd) { background-color: var(--surface-2); }

/* Alerts (mantener legibles en oscuro) */
:root[data-theme="dark"] .alert-success { background:#123524; color:#7fe0a6; border-color:#1c5637; }
:root[data-theme="dark"] .alert-danger  { background:#3a1a17; color:#f2a89f; border-color:#5e2a24; }
:root[data-theme="dark"] .alert-warning { background:#3a2f12; color:#f0d190; border-color:#5c4a1e; }
:root[data-theme="dark"] .alert-info    { background:#12303a; color:#8fd0ef; border-color:#1e4c5c; }

/* SweetAlert v1: modal claro que en oscuro se ve como bloque blanco */
:root[data-theme="dark"] .sweet-alert { background-color: var(--surface); color: var(--text); }
:root[data-theme="dark"] .sweet-alert h2,
:root[data-theme="dark"] .sweet-alert p { color: var(--text); }

/* DataTables */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text) !important; }

/* Iconos en círculo del centro de notificaciones */
.icon-circle.bg-primary { background: var(--primary) !important; }

/* input date/native: icono del calendario visible en oscuro */
:root[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type=time]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.7); }

/* ==========================================================================
   Modernización del shell (2ª iteración) — tipografía Inter, sidebar con
   acento activo, inputs y cards más pulidos, mejor jerarquía.
   ========================================================================== */

body { font-size: .9rem; line-height: 1.55; letter-spacing: -.005em; }

/* Encabezado de página */
.container-fluid > .d-sm-flex.mb-4 { margin-bottom: 1.75rem !important; padding-bottom: .25rem; }
h1.h3, .h3.mb-0 { font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; }

/* Sidebar: ancho, marca y estados */
.sidebar { width: 15rem; }
@media (min-width: 768px){ .sidebar.toggled { width: 15rem; } }
.sidebar-brand { padding: 1.1rem 1rem; margin-bottom: .5rem; }
.sidebar .nav-item { margin: 0; }
.sidebar .nav-item .nav-link {
    padding: .62rem .9rem; font-size: .86rem; font-weight: 500;
    display: flex; align-items: center; gap: .1rem; position: relative;
}
.sidebar .nav-item .nav-link span { letter-spacing: -.01em; }
.sidebar .nav-item .nav-link i { width: 1.5rem; font-size: .95rem; }
/* Barra de acento en el activo */
.sidebar .nav-item.active .nav-link::before,
.sidebar .nav-item .nav-link.active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 3px; background: #fff;
}
.sidebar .sidebar-heading { margin-top: 1rem; padding: 0 1.4rem .3rem; font-weight: 700; }

/* Topbar más limpia y alta */
.topbar { height: 4.25rem; padding: 0 1.25rem; }
.topbar .navbar-nav .nav-item .nav-link { padding: .5rem .75rem; }
.topbar .dropdown .dropdown-toggle::after { display: none; }
.topbar .mr-2.d-none.d-lg-inline.text-gray-600.small,
.topbar .text-gray-600.small { color: var(--text) !important; font-weight: 600; }

/* Cards con más aire y título más marcado */
.card { transition: box-shadow .2s ease, transform .2s ease; }
.card .card-header { font-size: .95rem; letter-spacing: -.01em; }
.card .card-body { padding: 1.25rem 1.4rem; }

/* Inputs más altos y cómodos */
.form-control, .custom-select,
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=range]):not([type=color]):not([type=file]),
select, textarea {
    min-height: 2.6rem; padding: .5rem .8rem; font-size: .9rem;
}
textarea { min-height: 5rem; }
.form-control:focus, .custom-select:focus,
input:focus, select:focus, textarea:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(30,142,74,.16);
    outline: none;
}
label { margin-bottom: .35rem; font-size: .8rem; letter-spacing: .01em; text-transform: none; }

/* Botones con proporción moderna */
.btn { padding: .5rem 1.05rem; font-size: .875rem; letter-spacing: -.01em; }
.btn-sm { padding: .3rem .7rem; }
.btn i { margin-right: .35rem; }

/* Tabla: cabecera y filas más elegantes */
.table thead th { font-weight: 700; }
.table td, .table th { border-color: var(--border); }
.card > .table-responsive:last-child .table, .card .table:last-child { margin-bottom: 0; }

/* Badges de estado más suaves */
.badge { font-size: .72rem; letter-spacing: .01em; }

/* Enlaces de acción en tablas */
.table a { font-weight: 600; }

/* Barra de búsqueda: agrupar input + botones con estilo tarjeta */
.card-body .form-control + .input-group-append .btn,
.input-group .btn { border-radius: var(--radius-sm); }

/* Divisor de sección tipográfico usado en formularios (h4/h5 sueltos) */
.container-fluid h4, .container-fluid h5 { font-weight: 700; margin-top: 1.25rem; letter-spacing: -.01em; }

/* Focus visible accesible en toda la app */
a:focus-visible, button:focus-visible, .btn:focus-visible, .page-link:focus-visible {
    outline: 2px solid var(--brand-400); outline-offset: 2px;
}

/* Botones planos: elimina degradados heredados de SB Admin 2 para respetar el
   color del token (p.ej. .btn-success no debe verse lima). */
.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info,
.btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-warning:hover, .btn-info:hover {
    background-image: none !important;
}

/* Cabecera de tabla "oscura" heredada -> superficie del tema */
.thead-dark th, .table .thead-dark th {
    background-color: var(--surface-2) !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
}
/* Filas de color contextual: texto legible en ambos temas */
.table-primary, .table-warning, .table-success, .table-info, .table-danger, .table-secondary { color: var(--text) !important; }

/* ==========================================================================
   Stat tiles (KPI) — componente reutilizable del sistema de diseño.
   ========================================================================== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 992px){ .stat-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px){ .stat-row { grid-template-columns: 1fr; } }
.stat-tile {
    display: flex; align-items: center; gap: 1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-ico {
    flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; color: var(--tone, var(--primary));
    background: color-mix(in srgb, var(--tone, var(--primary)) 14%, transparent);
}
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; color: var(--text); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }

/* ==========================================================================
   Encabezado de perfil (ficha de detalle) — componente reutilizable.
   ========================================================================== */
.profile-hero {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.5rem 1.6rem;
    box-shadow: var(--shadow-sm); margin-bottom: 1.5rem;
    position: relative; overflow: hidden;
}
.profile-hero::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-300));
}
.profile-avatar {
    flex: 0 0 auto; width: 72px; height: 72px; border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 800; color: #fff; letter-spacing: -.02em;
    background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
    box-shadow: var(--shadow);
}
.profile-id { flex: 1 1 260px; min-width: 220px; }
.profile-id h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); margin: 0; }
.profile-id .sub { color: var(--text-muted); font-size: .88rem; margin-top: .15rem; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.profile-meta .item { display: flex; flex-direction: column; }
.profile-meta .item .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
.profile-meta .item .v { font-size: .9rem; color: var(--text); font-weight: 600; margin-top: .1rem; }
.status-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.status-pill.on { background: var(--brand-100); color: var(--brand-700); }
.status-pill.off { background: #eceff3; color: var(--gray-600); }
.status-pill.pend { background: #fbeecb; color: #8a6100; }
/* Informativa: no es un estado del flujo, es un rasgo de la operación. */
.status-pill.info { background: #e4edf6; color: #2f5b84; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
:root[data-theme="dark"] .status-pill.off { background: #26303b; color: #9aa6b3; }
:root[data-theme="dark"] .status-pill.info { background: #1d2f42; color: #8fb6d8; }
:root[data-theme="dark"] .status-pill.pend { background: #3a3115; color: #e6c168; }

/* ==========================================================================
   Home: saludo y accesos rápidos (Fase 7 — index).
   ========================================================================== */
.home-greeting { margin-bottom: 1.5rem; }
.home-greeting h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.home-greeting p { color: var(--text-muted); margin: .25rem 0 0; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 992px){ .quick-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px){ .quick-grid { grid-template-columns: 1fr; } }
.quick-card {
    display: flex; align-items: center; gap: .9rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.1rem 1.2rem;
    color: var(--text); text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand-300); color: var(--text); text-decoration: none; }
.quick-card .q-ico {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
    color: var(--tone, var(--primary)); background: color-mix(in srgb, var(--tone, var(--primary)) 14%, transparent);
}
.quick-card .q-txt strong { display: block; font-weight: 700; font-size: .95rem; }
.quick-card .q-txt span { color: var(--text-muted); font-size: .8rem; }
.section-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; margin: 1.75rem 0 .85rem; }

/* ---------- Listados (Fase 7) ---------- */
/* Barra de acciones del encabezado: búsqueda + botón "Agregar" en línea. */
.list-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.list-toolbar form { display: flex; align-items: center; gap: .5rem; margin: 0; }
.list-search { position: relative; }
.list-search > i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .85rem; pointer-events: none;
}
.list-search input {
    padding-left: 2.2rem !important; min-height: 2.5rem; min-width: 240px;
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.btn-add {
    display: inline-flex; align-items: center; gap: .45rem;
    background: var(--primary); color: #fff; border: none; border-radius: var(--radius);
    padding: .55rem 1rem; font-weight: 600; font-size: .9rem; text-decoration: none;
    transition: background .15s ease, transform .15s ease;
}
.btn-add:hover { background: var(--primary-h); color: #fff; text-decoration: none; transform: translateY(-1px); }

/* Tarjeta de listado */
.list-card { padding: 0; overflow: hidden; }
.list-card .list-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.list-card .list-head .count { color: var(--text-muted); font-size: .85rem; }
.list-card table { margin: 0; }
.list-card .table thead th {
    background: var(--surface-2); border-bottom: 1px solid var(--border);
    font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
    padding: .7rem 1.1rem;
}
.list-card .table td { padding: .8rem 1.1rem; }
.list-card .table tbody tr:last-child td { border-bottom: none; }

/* Botón "Ver"/acción de fila */
.btn-row {
    display: inline-flex; align-items: center; gap: .35rem;
    color: var(--primary); font-weight: 600; font-size: .85rem; text-decoration: none;
    padding: .3rem .6rem; border-radius: var(--radius-sm); transition: background .12s ease;
    /* Se usa tanto en <a> como en <button>: sin este reseteo, el botón arrastra
       el borde y el fondo por defecto del navegador y desentona con el resto. */
    background: none; border: 0; font-family: inherit; line-height: 1.4;
    cursor: pointer; -webkit-appearance: none; appearance: none;
}
.btn-row:hover { background: var(--brand-50); color: var(--primary-h); text-decoration: none; }
:root[data-theme="dark"] .btn-row:hover { background: rgba(255,255,255,.06); }
.btn-row.danger { color: var(--danger); }
.btn-row.danger:hover { background: #fbe3df; color: #a3271c; }
:root[data-theme="dark"] .btn-row.danger:hover { background: rgba(209,72,58,.14); color: #f2a89f; }
.list-toolbar select.form-control { min-height: 2.5rem; border-radius: var(--radius); min-width: 150px; }

/* Estado vacío */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .ico {
    width: 56px; height: 56px; margin: 0 auto .8rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
    background: var(--surface-2); color: var(--text-muted);
}
.empty-state p { margin: 0; font-size: .92rem; }
.list-footer { padding: .9rem 1.1rem; border-top: 1px solid var(--border); }

/* Barra de filtros (débitos/créditos) */
.filter-card { padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.filter-grid { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filter-grid .f { display: flex; flex-direction: column; gap: .3rem; }
.filter-grid .f label { font-size: .78rem; color: var(--text-muted); font-weight: 600; margin: 0; }
.filter-grid .f input, .filter-grid .f select { min-height: 2.5rem; border-radius: var(--radius); min-width: 170px; }
.filter-grid .f-actions { display: flex; gap: .5rem; margin-left: auto; }
.btn-export {
    display: inline-flex; align-items: center; gap: .45rem;
    background: var(--surface); color: var(--success); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .55rem 1rem; font-weight: 600; font-size: .9rem;
    cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.btn-export:hover { background: var(--brand-50); border-color: var(--brand-300); }
:root[data-theme="dark"] .btn-export:hover { background: rgba(255,255,255,.05); }

/* ---------- Formularios (Fase 7) ---------- */
.card-body > .row { row-gap: 1rem; }
.card-body label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: .3rem; }
/* Botón "icon-split": ícono integrado, sin caja pesada */
.btn-icon-split { display: inline-flex; align-items: center; border-radius: var(--radius) !important; overflow: hidden; }
.btn-icon-split .icon { background: transparent !important; padding: .5rem .2rem .5rem .8rem; display: inline-flex; align-items: center; }
.btn-icon-split .icon i { color: currentColor !important; opacity: .9; }
.btn-icon-split .text { padding: .5rem .9rem .5rem .5rem; font-weight: 600; }
/* "Volver atrás": estilo sutil de contorno en vez de gris sólido */
.btn-secondary {
    background: var(--surface) !important; color: var(--text-muted) !important;
    border: 1px solid var(--border) !important;
}
.btn-secondary:hover { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--gray-300) !important; }
.btn-secondary .icon i { color: var(--text-muted) !important; }
/* Barra de acciones del formulario */
.form-actions { display: flex; gap: .6rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ==========================================================================
   Acceso rápido de creación en desplegables de catálogo (js/quick-add.js).
   ========================================================================== */
.qa-row { display: flex; gap: .4rem; align-items: center; }
.qa-row > select.form-control { flex: 1 1 auto; width: auto; min-width: 0; }
.qa-toggle {
    flex: 0 0 auto; width: 38px; height: calc(1.5em + .75rem + 2px);
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.qa-toggle:hover { background: var(--brand-100); color: var(--brand-700); border-color: var(--brand-500); }

/* Panel plegable: se despliega bajo el desplegable, en una sola fila. */
.qa-form {
    display: none; gap: .4rem; margin-top: .5rem; padding: .6rem;
    align-items: center; flex-wrap: wrap;
    background: var(--surface-2); border: 1px dashed var(--border-strong, var(--border));
    border-radius: var(--radius-sm);
}
.qa-form.open { display: flex; }
.qa-form .form-control { flex: 1 1 140px; min-width: 110px; width: auto; }
/* Los catálogos se guardan en mayúsculas: se escribe viéndolas, como en el
   resto de los formularios. Es sólo presentación; quien mayusculiza de verdad
   es el endpoint. */
.qa-form input[type="text"] { text-transform: uppercase; }
.qa-form .btn { flex: 0 0 auto; }
.qa-error:not(:empty) { margin-top: .35rem; }

/* ==========================================================================
   Vistas rápidas del listado de operaciones.
   ========================================================================== */
.quick-views { display: flex; flex-wrap: wrap; gap: .5rem; }
.quick-view {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .45rem .85rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-size: .85rem; font-weight: 600;
    text-decoration: none; transition: all .15s ease;
}
.quick-view:hover { border-color: var(--brand-500); color: var(--brand-700); text-decoration: none; }
.quick-view .qv-count {
    background: var(--surface-2); color: var(--text-muted);
    border-radius: 999px; padding: .05rem .5rem; font-size: .78rem;
    font-variant-numeric: tabular-nums;
}
.quick-view.active { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.quick-view.active .qv-count { background: rgba(255,255,255,.22); color: #fff; }
.quick-view.warn:not(.active) .qv-count { background: #fbeecb; color: #8a6100; }
.quick-view.crit:not(.active) .qv-count { background: #fbe3df; color: #a3271c; }
:root[data-theme="dark"] .quick-view.warn:not(.active) .qv-count { background: #3a3115; color: #e6c168; }
:root[data-theme="dark"] .quick-view.crit:not(.active) .qv-count { background: rgba(209,72,58,.16); color: #f2a89f; }

/* ==========================================================================
   Buscador por sugerencia sobre <select> (js/searchable-select.js).
   El <select> nativo sigue en el DOM, oculto: es la fuente de verdad.
   ========================================================================== */
.ss-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.ss-native { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.ss-input { cursor: text; }
.ss-panel {
    display: none; position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    max-height: 260px; overflow-y: auto;
}
.ss-panel.open { display: block; }
.ss-list { list-style: none; margin: 0; padding: .25rem; }
.ss-opt {
    padding: .45rem .6rem; border-radius: var(--radius-sm);
    font-size: .88rem; color: var(--text); cursor: pointer;
}
.ss-opt:hover, .ss-opt.act { background: var(--surface-2); }
.ss-opt.sel { color: var(--primary); font-weight: 600; }
.ss-empty { display: none; padding: .7rem .6rem; font-size: .85rem; color: var(--text-muted); }

/* ==========================================================================
   Operación sin costo económico.
   La casilla no es un ajuste más: cambia cómo se juzga la operación, así que
   se le da su propio recuadro en vez de perderla entre los campos.
   ========================================================================== */
.no-cost-box {
    border: 1px dashed var(--border); border-radius: var(--radius-sm);
    padding: .85rem 1rem; background: var(--surface-2);
}
.no-cost-check { display: flex; align-items: center; gap: .55rem; margin: 0 0 .35rem; cursor: pointer; }
.no-cost-check input { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--primary); }
.no-cost-check span { font-weight: 600; color: var(--text); }
.no-cost-box small { display: block; color: var(--text-muted); font-size: .8rem; line-height: 1.5; }
