/* PRESTAMOS-V1 · UI */
:root {
  --brand: #0f766e;
  --brand-rgb: 15, 118, 110;
  --brand-ink: #ffffff;
  --sidebar-w: 248px;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #18212b;
  --muted: #6b7785;
  --line: #e4e8ec;
  --radius: 14px;
}
html, body { background: var(--bg); color: var(--ink); }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .94rem; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: var(--brand-ink) !important; }
.btn-brand { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: #fff; --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-hover-color: #fff; --bs-btn-active-bg: color-mix(in srgb, var(--brand) 75%, #000); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-brand { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); --bs-btn-active-color: #fff; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--brand-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .82rem; color: #3b4652; margin-bottom: .3rem; }

/* ---------- Layout ---------- */
.app-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #0f1720; color: #c9d3dd; z-index: 1030; display: flex; flex-direction: column; }
.app-sidebar .brand { display: flex; gap: .65rem; align-items: center; padding: 1.1rem 1.1rem .9rem; color: #fff; text-decoration: none; }
.app-sidebar .brand .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; font-weight: 800; color: #fff; flex: 0 0 auto; overflow: hidden; }
.app-sidebar .brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.app-sidebar .brand small { display: block; color: #8b98a6; font-size: .72rem; }
.app-sidebar nav { flex: 1; overflow-y: auto; padding: .4rem .6rem 1rem; }
.app-sidebar .nav-section { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #6c7a89; padding: .9rem .7rem .35rem; }
.app-sidebar .nav-link { color: #c9d3dd; border-radius: 10px; padding: .55rem .75rem; display: flex; gap: .7rem; align-items: center; font-weight: 500; }
.app-sidebar .nav-link i { font-size: 1.05rem; opacity: .9; }
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-sidebar .nav-link.active { background: var(--brand); color: #fff; }
.app-sidebar .sidebar-foot { padding: .8rem 1rem; border-top: 1px solid rgba(255,255,255,.07); font-size: .78rem; color: #7f8c99; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: .6rem 1.4rem; display: flex; align-items: center; gap: .8rem; }
.app-topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.4rem; flex: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(var(--brand-rgb), .12); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; flex: 0 0 auto; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.impersonation-bar { background: #b45309; color: #fff; text-align: center; font-size: .82rem; padding: .35rem; }
.bottom-nav { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1025; }
  .app-main { margin-left: 0; }
  .app-content { padding: 1rem .9rem 5.5rem; }
  .app-topbar { padding: .55rem .9rem; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1020; background: #fff; border-top: 1px solid var(--line); padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; text-align: center; font-size: .68rem; color: var(--muted); text-decoration: none; padding: .25rem 0; }
  .bottom-nav a i { display: block; font-size: 1.25rem; line-height: 1.2; }
  .bottom-nav a.active { color: var(--brand); font-weight: 600; }
  .bottom-nav a.fab i { background: var(--brand); color: #fff; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; margin: -18px auto 0; box-shadow: 0 6px 16px rgba(var(--brand-rgb), .35); }
}

/* ---------- Componentes ---------- */
.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: 700; padding: .85rem 1.1rem; }
.card-body { padding: 1.1rem; }
.kpi { padding: 1rem 1.1rem; display: flex; flex-direction: row; gap: .9rem; align-items: center; height: 100%; }
.kpi .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex: 0 0 auto; }
.kpi .lbl { color: var(--muted); font-size: .78rem; font-weight: 600; }
.kpi .val { font-size: 1.32rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.kpi .sub { font-size: .74rem; color: var(--muted); }
.ico-brand { background: rgba(var(--brand-rgb), .12); color: var(--brand); }
.ico-green { background: #dcfce7; color: #15803d; }
.ico-red { background: #fee2e2; color: #b91c1c; }
.ico-amber { background: #fef3c7; color: #b45309; }
.ico-blue { background: #dbeafe; color: #1d4ed8; }
.ico-violet { background: #ede9fe; color: #6d28d9; }
.table { --bs-table-hover-bg: rgba(var(--brand-rgb), .04); margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #f8fafb; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-sm td, .table-sm th { padding: .45rem .6rem; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { font-weight: 600; letter-spacing: .01em; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty i { font-size: 2.4rem; display: block; margin-bottom: .5rem; opacity: .5; }
.stepper { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; }
.stepper .step { flex: 1 0 auto; display: flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 999px; background: #eef1f4; color: var(--muted); font-weight: 600; font-size: .8rem; cursor: pointer; border: 0; }
.stepper .step .n { width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: .72rem; }
.stepper .step.active { background: var(--brand); color: #fff; }
.stepper .step.active .n { color: var(--brand); }
.stepper .step.done { background: rgba(var(--brand-rgb), .14); color: var(--brand); }

.capture-box { border: 2px dashed #cdd5dd; border-radius: 12px; background: #fafbfc; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: .8rem; cursor: pointer; position: relative; overflow: hidden; transition: border-color .15s; }
.capture-box:hover { border-color: var(--brand); }
.capture-box img { max-width: 100%; max-height: 220px; border-radius: 8px; object-fit: contain; }
.capture-box .hint { color: var(--muted); font-size: .8rem; }
.capture-box i.big { font-size: 2rem; color: var(--brand); }
.capture-box .badge-ok { position: absolute; top: .5rem; right: .5rem; }
.thumb { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.thumb-sm { width: 56px; height: 56px; }
.map { height: 280px; border-radius: 12px; border: 1px solid var(--line); z-index: 1; }
.map-lg { height: 460px; }
.sig-wrap { border: 2px dashed #cdd5dd; border-radius: 12px; background: #fff; position: relative; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 220px; display: block; cursor: crosshair; }
.sig-wrap .sig-line { position: absolute; left: 8%; right: 8%; bottom: 46px; border-bottom: 1px solid #aab4be; pointer-events: none; }
.sig-wrap .sig-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #9aa5b1; font-size: .75rem; pointer-events: none; }
.camera-modal video { width: 100%; max-height: 70vh; background: #000; border-radius: 10px; }
.camera-modal .guide { position: absolute; inset: 12% 8%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,.25); }
.camera-modal .guide.round { inset: 10% 22%; border-radius: 50%; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline li:last-child { border-left-color: transparent; }
.list-cobro .item { display: flex; gap: .8rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); align-items: center; }
.list-cobro .item:last-child { border-bottom: 0; }
.progress-thin { height: 6px; border-radius: 99px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: .8rem 0 .2rem; z-index: 5; }
.filters .form-control, .filters .form-select { min-width: 140px; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: #fff; }
.var-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .74rem; background: #eef2f5; border-radius: 6px; padding: .12rem .4rem; cursor: pointer; display: inline-block; margin: 0 .2rem .3rem 0; }
.var-chip:hover { background: rgba(var(--brand-rgb), .15); }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; line-height: 1.5; }

/* ---------- Documento (contrato en pantalla) ---------- */
.doc { background: #fff; padding: 2.2rem 2.4rem; border-radius: var(--radius); border: 1px solid var(--line); font-family: Georgia, "Times New Roman", serif; font-size: .95rem; line-height: 1.6; color: #1f2933; }
.doc .doc-h1 { font-size: 1.15rem; text-align: center; font-weight: 800; font-family: system-ui, sans-serif; margin-bottom: 1.2rem; }
.doc .doc-h2 { font-size: 1rem; text-align: center; font-weight: 700; color: var(--brand); font-family: system-ui, sans-serif; margin: 1.4rem 0 .8rem; }
.doc p { text-align: justify; margin-bottom: .75rem; }
.doc .doc-note { font-style: italic; color: #6b7785; }
.doc-table { width: 100%; border-collapse: collapse; font-family: system-ui, sans-serif; font-size: .78rem; margin: .5rem 0 1rem; }
.doc-table th { background: var(--brand); color: #fff; padding: .35rem .45rem; text-align: left; white-space: nowrap; }
.doc-table td { border-bottom: 1px solid var(--line); padding: .3rem .45rem; white-space: nowrap; }
.doc-table tr:nth-child(even) td { background: #f6f8f9; }
.doc .firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2.2rem; font-family: system-ui, sans-serif; text-align: center; font-size: .8rem; }
.doc .firmas .linea { border-top: 1px solid #333; padding-top: .35rem; margin-top: 4.2rem; font-weight: 700; }
.doc .firmas .linea.con-firma { margin-top: .2rem; }
.doc .firmas img { max-height: 90px; max-width: 100%; }
@media (max-width: 575.98px) { .doc { padding: 1.2rem 1rem; font-size: .9rem; } .doc .firmas { grid-template-columns: 1fr; } }

/* ---------- Auth / páginas públicas ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at -10% -10%, rgba(255,255,255,.12), transparent), linear-gradient(140deg, #0f1720 0%, #12313a 55%, var(--brand) 130%); color: #e5edf3; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-weight: 800; font-size: 2.2rem; letter-spacing: -.02em; color: #fff; }
.auth-hero .feat { display: flex; gap: .7rem; margin-bottom: .9rem; align-items: flex-start; }
.auth-hero .feat i { color: #5eead4; font-size: 1.2rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.2rem; background: #fff; }
.auth-form .box { width: 100%; max-width: 380px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }
.public-shell { max-width: 860px; margin: 0 auto; padding: 1rem .9rem 3rem; }
.public-head { display: flex; align-items: center; gap: .8rem; padding: 1rem 0; }
.public-head .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; overflow: hidden; }
.public-head .logo img { width: 100%; height: 100%; object-fit: cover; }
.loan-card { border-left: 4px solid var(--brand); }
.loan-card.atraso { border-left-color: #dc2626; }

/* ---------- Ticket térmico ---------- */
.ticket { font-family: "Courier New", ui-monospace, monospace; color: #000; background: #fff; margin: 0 auto; padding: 4mm 3mm; font-size: 11.5px; line-height: 1.35; }
.ticket.w58 { width: 58mm; font-size: 10px; }
.ticket.w80 { width: 80mm; }
.ticket .c { text-align: center; }
.ticket .b { font-weight: 700; }
.ticket .big { font-size: 1.25em; }
.ticket .row2 { display: flex; justify-content: space-between; gap: 6px; }
.ticket .row2 span:last-child { text-align: right; white-space: nowrap; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; }
.ticket .qr { display: flex; justify-content: center; margin: 6px 0; }
.ticket .cancelado { border: 2px solid #000; padding: 2px; text-align: center; font-weight: 800; letter-spacing: .2em; }
@media print {
  @page { margin: 0; size: auto; }
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .app-sidebar, .app-topbar, .bottom-nav { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; }
  .card { border: 0 !important; box-shadow: none !important; }
}

/* ---------- Copyright ---------- */
.copyright { text-align: center; font-size: .74rem; line-height: 1.5; color: var(--muted); padding: 1.2rem 1rem 1.4rem; border-top: 1px solid var(--line); margin-top: 1.5rem; }
.copyright a { color: inherit; text-decoration: none; font-weight: 600; }
.copyright .copyright-sub { font-size: .66rem; letter-spacing: .12em; }
.copyright.on-dark { color: rgba(255,255,255,.65); border-top-color: rgba(255,255,255,.15); text-align: left; padding: 0; margin: 0; border: 0; }
.copyright.on-dark .fw-bold { color: #fff; }
.app-sidebar .copyright { text-align: left; font-size: .68rem; color: #8b98a6; padding: .8rem 1rem; margin: 0; border-top: 1px solid rgba(255,255,255,.07); }
.app-sidebar .copyright .fw-bold { color: #c9d3dd; }
@media (max-width: 991.98px) { .app-main > .copyright { margin-bottom: 4.5rem; } }
@media print { .copyright { display: none; } }

.copyright .copyright-ver { margin-top: .35rem; opacity: .9; }
.copyright .copyright-ver a { font-weight: 500; text-decoration: underline; }
