/* Préstamos · estilos propios sobre Bootstrap 5 */
:root {
  --ink: #16181d;
  --ink-2: #52514e;
  --muted: #898781;
  --plane: #f4f5f2;
  --surface: #ffffff;
  --line: #e6e5df;
  --brand: #13795b;
  --brand-dark: #0d5a43;
  --brand-soft: #e3f3ec;
  --good: #0ca30c;
  --good-ink: #0a7a0a;
  --warn: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #2a78d6;
  --radius: 14px;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-primary: var(--brand);
  --bs-primary-rgb: 19, 121, 91;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 19, 121, 91;
  --bs-link-hover-color: var(--brand-dark);
}
body.app { background: var(--plane); color: var(--ink); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-dark); }
.form-control:focus, .form-select:focus { border-color: #7cc3a9; box-shadow: 0 0 0 .2rem rgba(19,121,91,.15); }
.btn-wa { --bs-btn-bg: #1faa53; --bs-btn-border-color: #1faa53; --bs-btn-color: #fff; --bs-btn-hover-bg: #178a43; --bs-btn-hover-border-color: #178a43; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #178a43; }
.btn-outline-wa { --bs-btn-color: #178a43; --bs-btn-border-color: #8fd3a9; --bs-btn-hover-bg: #1faa53; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #1faa53; }
.btn-icon { border: 0; font-size: 1.5rem; line-height: 1; padding: .25rem .4rem; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { --bs-offcanvas-width: 250px; background: #0f2a22 !important; color: #fff; display: flex; flex-direction: column; }
@media (min-width: 992px) { .app-sidebar { width: 240px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; } }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.25rem 1rem; font-weight: 700; font-size: 1.1rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: #2fbf8a; color: #0f2a22; display: grid; place-items: center; font-size: 1.1rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem .75rem; flex: 1; }
.sidebar-nav a, .sidebar-foot a { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 10px; color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; }
.sidebar-nav a:hover, .sidebar-foot a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: #2fbf8a; color: #0f2a22; }
.sidebar-nav i, .sidebar-foot i { font-size: 1.1rem; width: 1.2rem; }
.nav-count { margin-left: auto; background: var(--warn); color: #0b0b0b; border-radius: 999px; font-size: .75rem; padding: 0 .5rem; font-weight: 700; }
.sidebar-foot { padding: 1rem .75rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot > div { padding: 0 .8rem; }
.app-main { flex: 1; min-width: 0; }
.app-topbar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.5rem; background: var(--plane); position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.app-content { padding: 0 1.5rem 2rem; }
@media (max-width: 575.98px) { .app-topbar { padding: .75rem 1rem; } .app-content { padding: 0 1rem 1.5rem; } .page-title { font-size: 1.15rem; } }

/* Tarjetas */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: .9rem 1.1rem; }
.card-title-sm { font-size: .95rem; font-weight: 600; margin: 0; }
.card-sub { font-size: .8rem; color: var(--muted); }

/* KPIs */
.kpi { padding: 1rem 1.1rem; height: 100%; display: flex; flex-direction: column; gap: .2rem; }
.kpi-label { font-size: .8rem; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.kpi-icon { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; font-size: .95rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.kpi-foot { font-size: .78rem; color: var(--muted); }
@media (max-width: 575.98px) { .kpi-value { font-size: 1.25rem; } }
.tone-green { background: #e3f3ec; color: #13795b; }
.tone-blue { background: #e3eefb; color: #1c5cab; }
.tone-orange { background: #fdeee6; color: #b4471b; }
.tone-red { background: #fbe7e7; color: #a32626; }
.tone-violet { background: #ecebfb; color: #4a3aa7; }

/* Donas */
.donut-wrap { position: relative; width: 100%; max-width: 230px; margin: 0 auto; aspect-ratio: 1; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-center .big { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.donut-center .small { font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.legend-list { list-style: none; padding: 0; margin: 1rem 0 0; font-size: .85rem; }
.legend-list li { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-list .lbl { color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-list .pct { color: var(--muted); font-variant-numeric: tabular-nums; width: 3.2rem; text-align: right; }

/* Pills de estado (icono + texto, nunca solo color) */
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: #e5f5e5; color: #0a6e0a; }
.pill-alerta { background: #fbe7e7; color: #a32626; }
.pill-aviso { background: #fff3d6; color: #8a5a00; }
.pill-info { background: #e3eefb; color: #1c5cab; }
.pill-neutro { background: #efeeea; color: #52514e; }

/* Tablas */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem 1rem; border-bottom-color: var(--line); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.fila-link { cursor: pointer; }
tr.fila-link:hover { background: #fafaf8; }

/* Listas de pendientes */
.lista-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); }
.lista-item:last-child { border-bottom: 0; }
.lista-item .avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.lista-item .info { flex: 1; min-width: 0; }
.lista-item .nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-item .det { font-size: .8rem; color: var(--muted); }
.lista-item .monto { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; }

/* Barra de avance */
.avance { height: 8px; background: #efeeea; border-radius: 99px; overflow: hidden; }
.avance > span { display: block; height: 100%; background: var(--good); border-radius: 99px; }

/* Previsualización de préstamo */
.preview-box { background: #f7faf8; border: 1px dashed #b9dccc; border-radius: var(--radius); padding: 1rem; }
.preview-big { font-size: 1.5rem; font-weight: 700; }

/* Visor de comprobante */
.comprobante-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #0f2a22 0%, #13795b 100%); }
.auth-card { width: 100%; max-width: 400px; border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.pin-input { font-size: 2rem; letter-spacing: 1rem; text-align: center; font-weight: 700; padding-left: 1.5rem; }
.table-sm > :not(caption) > * > * { padding: .55rem .7rem; }
