/* =====================================================================
   Sistema de Préstamos · Tema visual
   Bootstrap 5.3 + tokens propios (tipografía, colores, radios, sombras)
   ===================================================================== */

:root {
    /* Marca */
    --brand: #4f46e5;
    --brand-600: #4338ca;
    --brand-700: #3730a3;
    --brand-50: #eef2ff;
    --brand-100: #e0e7ff;
    --brand-rgb: 79, 70, 229;

    /* Neutros */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e5e7eb;
    --line-2: #eef0f4;
    --surface: #ffffff;
    --app-bg: #f4f6fb;

    /* Estados */
    --ok: #059669;
    --ok-rgb: 5, 150, 105;
    --bad: #e11d48;
    --bad-rgb: 225, 29, 72;
    --warn: #d97706;
    --info: #0284c7;

    /* Forma */
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-2: 0 4px 6px -1px rgba(15, 23, 42, .05), 0 12px 24px -6px rgba(15, 23, 42, .08);
    --sidebar-w: 264px;

    /* Bootstrap */
    --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: .935rem;
    --bs-body-color: var(--ink-2);
    --bs-body-bg: var(--app-bg);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: 12px;
    --bs-primary: var(--brand);
    --bs-primary-rgb: var(--brand-rgb);
    --bs-success-rgb: var(--ok-rgb);
    --bs-danger-rgb: var(--bad-rgb);
    --bs-warning-rgb: 245, 158, 11;
    --bs-info-rgb: 14, 165, 233;
    --bs-link-color-rgb: var(--brand-rgb);
    --bs-link-hover-color-rgb: 67, 56, 202;
    --bs-primary-bg-subtle: var(--brand-50);
    --bs-primary-text-emphasis: var(--brand-700);
    --bs-focus-ring-color: rgba(var(--brand-rgb), .25);
}

body { background: var(--app-bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
.fw-semibold { font-weight: 600 !important; }
.text-muted { color: var(--muted) !important; }
a { text-decoration: none; }
::selection { background: var(--brand-100); }

/* ---------- Botones ---------- */
.btn { --bs-btn-font-weight: 600; --bs-btn-border-radius: var(--radius-sm); --bs-btn-padding-x: 1rem; letter-spacing: -.005em; }
.btn-sm { --bs-btn-border-radius: 8px; --bs-btn-padding-x: .7rem; }
.btn-lg { --bs-btn-border-radius: 12px; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 1px 2px rgba(var(--brand-rgb), .25), 0 4px 12px -4px rgba(var(--brand-rgb), .45);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: rgba(var(--brand-rgb), .35);
    --bs-btn-hover-bg: var(--brand-50); --bs-btn-hover-color: var(--brand-700); --bs-btn-hover-border-color: rgba(var(--brand-rgb), .5);
    --bs-btn-active-bg: var(--brand); --bs-btn-active-color: #fff; --bs-btn-active-border-color: var(--brand);
}
.btn-success {
    --bs-btn-bg: var(--ok); --bs-btn-border-color: var(--ok);
    --bs-btn-hover-bg: #047857; --bs-btn-hover-border-color: #047857;
    --bs-btn-active-bg: #065f46; --bs-btn-active-border-color: #065f46;
    --bs-btn-disabled-bg: var(--ok); --bs-btn-disabled-border-color: var(--ok);
    box-shadow: 0 1px 2px rgba(var(--ok-rgb), .25), 0 4px 12px -4px rgba(var(--ok-rgb), .45);
}
.btn-outline-success {
    --bs-btn-color: var(--ok); --bs-btn-border-color: rgba(var(--ok-rgb), .4);
    --bs-btn-hover-bg: #ecfdf5; --bs-btn-hover-color: #047857; --bs-btn-hover-border-color: rgba(var(--ok-rgb), .6);
    --bs-btn-active-bg: var(--ok); --bs-btn-active-border-color: var(--ok);
}
.btn-outline-danger {
    --bs-btn-color: var(--bad); --bs-btn-border-color: rgba(var(--bad-rgb), .35);
    --bs-btn-hover-bg: #fff1f2; --bs-btn-hover-color: #be123c; --bs-btn-hover-border-color: rgba(var(--bad-rgb), .55);
    --bs-btn-active-bg: var(--bad); --bs-btn-active-border-color: var(--bad);
}
.btn-danger { --bs-btn-bg: var(--bad); --bs-btn-border-color: var(--bad); --bs-btn-hover-bg: #be123c; --bs-btn-hover-border-color: #be123c; }
.btn-outline-secondary {
    --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: #f8fafc; --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #cbd5e1;
    --bs-btn-active-bg: #f1f5f9; --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: #cbd5e1;
    background: var(--surface);
}
.btn-outline-dark { --bs-btn-color: var(--ink); --bs-btn-border-color: #cbd5e1; --bs-btn-hover-bg: var(--ink); --bs-btn-hover-border-color: var(--ink); }

/* ---------- Formularios ---------- */
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select {
    border-color: var(--line); border-radius: var(--radius-sm); padding: .55rem .85rem;
    background-color: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control-lg { border-radius: 12px; }
.form-control:hover, .form-select:hover { border-color: #cbd5e1; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--brand-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .12); }
.input-group-text { background: #f8fafc; border-color: var(--line); color: var(--muted); font-weight: 600; font-size: .85rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: rgba(var(--brand-rgb), .5); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .12); }
.form-text { color: var(--muted); }
.btn-check:checked + .btn-outline-primary { box-shadow: 0 4px 12px -4px rgba(var(--brand-rgb), .5); }

/* ---------- Tarjetas ---------- */
.card {
    --bs-card-border-color: var(--line-2);
    --bs-card-border-radius: var(--radius);
    --bs-card-inner-border-radius: calc(var(--radius) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-spacer-x: 1.25rem;
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-1);
}
.card.border-0 { border: 1px solid var(--line-2) !important; }
.shadow-sm { box-shadow: var(--shadow-1) !important; }
.card-header { padding: .95rem 1.25rem; border-bottom-color: var(--line-2); color: var(--ink); font-size: .95rem; }
.card-header.bg-white { background: transparent !important; }
.card-header .bi { color: var(--brand); margin-right: .15rem; }
.card-header.bg-success { background: linear-gradient(135deg, #059669, #10b981) !important; }
.card-header.bg-success .bi { color: #fff; }
.card-footer { background: transparent; border-top-color: var(--line-2); padding: .9rem 1.25rem; }
.card.border-success { border-color: rgba(var(--ok-rgb), .35) !important; }
.card.border-primary { border-color: rgba(var(--brand-rgb), .3) !important; }
.card.border-danger { border-color: rgba(var(--bad-rgb), .35) !important; }

/* ---------- Tablas ---------- */
.table { --bs-table-hover-bg: #f8fafc; --bs-table-striped-bg: #fafbfd; --bs-table-border-color: var(--line-2); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table-sm > :not(caption) > * > * { padding: .5rem .7rem; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
    color: var(--muted); background: #f8fafc !important; border-bottom: 1px solid var(--line);
}
.table-primary { --bs-table-bg: var(--brand-50); --bs-table-color: var(--brand-700); }
.table thead.table-primary th { background: var(--brand-50) !important; color: var(--brand-700); }
.table-success { --bs-table-bg: #f0fdf4; }
.table-danger { --bs-table-bg: #fff1f2; }
.table-light { --bs-table-bg: #f8fafc; }
.table td, .table th { white-space: nowrap; }
tfoot td { font-weight: 700; color: var(--ink); }

/* ---------- Insignias ---------- */
.badge { font-weight: 600; letter-spacing: .01em; padding: .38em .65em; border-radius: 999px; }
.badge-soft { border: 1px solid transparent; }
.badge-soft-primary   { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge-soft-success   { background: #ecfdf5; color: #047857; border-color: #d1fae5; }
.badge-soft-danger    { background: #fff1f2; color: #be123c; border-color: #ffe4e6; }
.badge-soft-warning   { background: #fffbeb; color: #b45309; border-color: #fef3c7; }
.badge-soft-info      { background: #f0f9ff; color: #0369a1; border-color: #e0f2fe; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge-soft-dark      { background: #1e293b; color: #f8fafc; }
.badge-soft-light     { background: #fff; color: #64748b; border-color: #e2e8f0; }

/* ---------- Alertas ---------- */
.alert { border-radius: 12px; border-width: 1px; }
.alert-success { --bs-alert-bg: #ecfdf5; --bs-alert-border-color: #d1fae5; --bs-alert-color: #065f46; }
.alert-danger  { --bs-alert-bg: #fff1f2; --bs-alert-border-color: #ffe4e6; --bs-alert-color: #9f1239; }
.alert-warning { --bs-alert-bg: #fffbeb; --bs-alert-border-color: #fef3c7; --bs-alert-color: #92400e; }
.alert-info    { --bs-alert-bg: #f0f9ff; --bs-alert-border-color: #e0f2fe; --bs-alert-color: #075985; }
.alert-light   { --bs-alert-bg: #f8fafc; --bs-alert-border-color: var(--line-2); }

/* ---------- Menús, ventanas ---------- */
.dropdown-menu {
    --bs-dropdown-border-color: var(--line-2); --bs-dropdown-border-radius: 12px;
    --bs-dropdown-link-active-bg: var(--brand); --bs-dropdown-link-hover-bg: #f8fafc;
    --bs-dropdown-item-padding-y: .5rem; box-shadow: var(--shadow-2); padding: .4rem;
}
.dropdown-item { border-radius: 8px; font-weight: 500; }
.dropdown-item .bi { color: var(--muted); margin-right: .35rem; }
.modal-content { border: 0; border-radius: 20px; box-shadow: 0 25px 50px -12px rgba(15, 23, 42, .25); }
.modal-header { border-bottom-color: var(--line-2); padding: 1.1rem 1.4rem; }
.modal-footer { border-top-color: var(--line-2); }
.list-group-item { border-color: var(--line-2); }

/* =====================================================================
   Estructura: barra lateral + barra superior
   ===================================================================== */
.app-shell { min-height: 100vh; }

.sidebar { --bs-offcanvas-width: 280px; }
.sidebar-inner {
    display: flex; flex-direction: column; width: 100%; height: 100%;
    background: linear-gradient(180deg, #111827 0%, #1e1b4b 100%);
    color: #cbd5e1; padding: 1.1rem .85rem;
}
@media (min-width: 992px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1035; }
    .app-main { margin-left: var(--sidebar-w); }
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.2rem; }
.brand-logo {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.25rem; color: #fff;
    background: linear-gradient(135deg, #818cf8, #4f46e5); box-shadow: 0 6px 16px -4px rgba(99, 102, 241, .6);
}
.brand-name { color: #fff; font-weight: 800; font-size: .95rem; line-height: 1.15; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: #94a3b8; }
.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #64748b; font-weight: 700; padding: 1rem .75rem .4rem; }
.sidebar-link {
    display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; margin-bottom: 2px;
    border-radius: 10px; color: #cbd5e1; font-weight: 500; font-size: .9rem; transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; color: #94a3b8; transition: color .15s; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link:hover i { color: #c7d2fe; }
.sidebar-link.active { background: rgba(129, 140, 248, .16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #818cf8; }
.sidebar-link.active i { color: #a5b4fc; }
.sidebar-user {
    display: flex; align-items: center; gap: .65rem; margin-top: .75rem; padding: .75rem;
    border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-user .nombre { color: #fff; font-weight: 600; font-size: .85rem; line-height: 1.2; }
.sidebar-user .rol { font-size: .72rem; color: #94a3b8; }
.sidebar-user .btn-icon { color: #94a3b8; }
.sidebar-user .btn-icon:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
    font-weight: 700; font-size: .8rem; color: #fff; background: linear-gradient(135deg, #818cf8, #4f46e5);
}
.btn-icon { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; border: 0; background: transparent; padding: 0; }

.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.5rem; padding-top: calc(.7rem + env(safe-area-inset-top));
    background: rgba(244, 246, 251, .82); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, .7);
}
.topbar-toggle { font-size: 1.5rem; color: var(--ink); padding: 0; width: 40px; height: 40px; }
.topbar-brand { font-weight: 800; color: var(--ink); font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.topbar-brand .brand-logo { width: 32px; height: 32px; font-size: 1rem; border-radius: 10px; }
.topbar-date { color: var(--muted); font-size: .85rem; font-weight: 500; }
.topbar-date strong { color: var(--ink); font-weight: 700; }
.topbar .user-btn { display: flex; align-items: center; gap: .5rem; padding: .2rem .35rem .2rem .2rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.topbar .user-btn:hover { border-color: #cbd5e1; }
.badge-rol-superadmin { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; }

.content { padding: 1.5rem; max-width: 1480px; }
@media (max-width: 575.98px) { .content { padding: 1rem .85rem; } .topbar { padding-left: .85rem; padding-right: .85rem; } }

/* Encabezado de cada página */
.page-header h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.page-header h1 .bi { display: none; }
.page-header .subtitulo { color: var(--muted); font-size: .9rem; margin-top: .2rem; }
@media (max-width: 575.98px) { .page-header h1 { font-size: 1.25rem; } }

/* =====================================================================
   Componentes
   ===================================================================== */
.stat-card { position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.stat-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.35rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }

.hero {
    border-radius: 20px; padding: 1.75rem; color: #fff; position: relative; overflow: hidden;
    background: radial-gradient(1200px 300px at 100% 0%, rgba(167, 139, 250, .45), transparent 60%),
                linear-gradient(135deg, #4338ca 0%, #4f46e5 45%, #6366f1 100%);
    box-shadow: 0 20px 40px -18px rgba(79, 70, 229, .6);
}
.hero::after {
    content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.hero h2 { color: #fff; font-weight: 800; font-size: 1.6rem; margin: 0; }
.hero p { color: rgba(255, 255, 255, .8); margin: .3rem 0 0; }
.hero .hero-kpi { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.hero .btn-light { --bs-btn-color: var(--brand-700); font-weight: 700; }
.hero .btn-glass { color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); }
.hero .btn-glass:hover { background: rgba(255, 255, 255, .22); color: #fff; }

.quick-link {
    display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-radius: 12px; color: var(--ink-2);
    font-weight: 600; transition: background .15s;
}
.quick-link:hover { background: #f8fafc; color: var(--ink); }
.quick-link .ql-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 2.5rem; color: #cbd5e1; display: block; margin-bottom: .5rem; }

.resumen-card .valor { font-size: 1.15rem; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.condiciones-lista { max-height: 180px; overflow-y: auto; }
.tabla-cuotas { max-height: 520px; overflow-y: auto; }
.tabla-cuotas thead.sticky-top th { z-index: 1; }

/* Tarjetas de la ruta de cobro */
.cobro-card { transition: transform .15s, box-shadow .15s; }
.cobro-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }

/* Fotos de la cédula */
.foto-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
    min-height: 170px; border: 2px dashed #cbd5e1; border-radius: 14px; background: #f8fafc; color: var(--muted);
    cursor: pointer; overflow: hidden; text-align: center; transition: border-color .15s, background .15s;
}
.foto-drop:hover { border-color: rgba(var(--brand-rgb), .6); background: var(--brand-50); color: var(--brand-700); }
.foto-drop .bi { font-size: 1.8rem; }
.foto-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-drop.con-foto { border-style: solid; border-color: var(--line); }
.foto-drop.con-foto .foto-hint { display: none; }
.foto-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.foto-cedula { border-radius: 12px; border: 1px solid var(--line); width: 100%; aspect-ratio: 1.58; object-fit: cover; background: #f8fafc; cursor: zoom-in; }
.foto-vacia { border-radius: 12px; border: 2px dashed var(--line); aspect-ratio: 1.58; display: grid; place-items: center; color: #94a3b8; font-size: .85rem; }

/* ---------- Inicio de sesión ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-aside {
    position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
    background: radial-gradient(900px 400px at 0% 100%, rgba(129, 140, 248, .35), transparent 60%),
                linear-gradient(160deg, #111827 0%, #1e1b4b 55%, #3730a3 100%);
}
.auth-aside::before {
    content: ""; position: absolute; width: 420px; height: 420px; right: -120px; top: -120px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .45), transparent 70%);
}
.auth-aside h1 { color: #fff; font-size: 2.3rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.auth-aside p { color: #c7d2fe; max-width: 420px; }
.auth-feature { display: flex; gap: .75rem; align-items: center; color: #e0e7ff; font-weight: 500; margin-bottom: .75rem; }
.auth-feature .bi { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: #fff; }
.auth-form .form-box { width: 100%; max-width: 380px; }
@media (max-width: 991.98px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-form { background: var(--app-bg); }
    .auth-form .form-box { background: #fff; padding: 2rem 1.5rem; border-radius: 20px; box-shadow: var(--shadow-2); }
}

/* ---------- Ticket ---------- */
.ticket-preview {
    background: #fff;
    font-family: "Courier New", Consolas, monospace;
    font-size: 13px;
    line-height: 1.35;
    padding: 18px 12px 28px;
    box-shadow: var(--shadow-2);
    border-radius: 6px 6px 0 0;
    width: fit-content;
    min-width: 260px;
    white-space: pre;
    color: #000;
    position: relative;
}
.ticket-preview .t-line { min-height: 1.35em; }
.ticket-preview .t-bold { font-weight: 700; }
.ticket-preview .t-big { font-size: 2em; font-weight: 700; line-height: 1.2; }
.ticket-preview.anulado::after {
    content: "ANULADO"; position: absolute; top: 40%; left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    font-size: 42px; color: rgba(225, 29, 72, .35); font-weight: 800; border: 4px solid rgba(225, 29, 72, .35); padding: 0 10px;
}

.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(var(--ok-rgb), .2); }
.status-dot.busy { background: #f59e0b; }

/* ---------- Impresión ---------- */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .bottom-nav, .d-print-none, .btn { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 0 !important; }
}
/* Impresión del ticket desde el navegador (papel de 58/80 mm) */
@media print {
    body.pagina-ticket .content > *:not(.row),
    body.pagina-ticket .row > :not(:first-child) { display: none !important; }
    body.pagina-ticket .ticket-preview { box-shadow: none; padding: 0; margin: 0 !important; font-size: 11px; }
    @page { margin: 2mm; }
}

/* =====================================================================
   Celulares y tablets
   ===================================================================== */

/* Evita el zoom automático de iOS al tocar un campo */
@media (max-width: 991.98px) {
    .form-control, .form-select, .input-group-text { font-size: 16px; }
}

/* Áreas táctiles más cómodas */
@media (pointer: coarse) {
    .btn-sm { min-height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; }
    .form-check-input { width: 1.3em; height: 1.3em; }
    .form-check-label { padding-top: .1em; }
    .dropdown-item { padding-top: .6rem; padding-bottom: .6rem; }
}

/* Barra de navegación inferior (estilo app) */
.bottom-nav {
    position: fixed; left: .6rem; right: .6rem; bottom: calc(.6rem + env(safe-area-inset-bottom)); z-index: 1030;
    display: flex; background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 30px -10px rgba(15, 23, 42, .25);
    padding: .25rem;
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    padding: .4rem 0; font-size: .68rem; font-weight: 600; color: var(--muted); min-height: 54px; border-radius: 16px;
}
.bottom-nav a i { font-size: 1.3rem; line-height: 1.1; }
.bottom-nav a.active { color: var(--brand); background: var(--brand-50); }
@media (max-width: 991.98px) {
    body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    .toast-app { bottom: calc(90px + env(safe-area-inset-bottom)) !important; }
}

/* Encabezado de página: botones a lo ancho en celular */
@media (max-width: 575.98px) {
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > a.btn { flex: 1 1 auto; }
    .card-header { padding: .75rem 1rem; }
    .stat-value { font-size: 1.1rem; }
    .hero { padding: 1.25rem; }
    .hero h2 { font-size: 1.3rem; }
}

/* Tablas de listado -> tarjetas en pantallas pequeñas */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr {
        background: #fff; border: 1px solid var(--line-2); border-radius: 14px;
        margin-bottom: .75rem; padding: .6rem .95rem; box-shadow: var(--shadow-1);
    }
    .table-stack > tbody > tr > td {
        border: 0; padding: .32rem 0; background: transparent !important; box-shadow: none !important;
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        text-align: right !important; white-space: normal;
    }
    .table-stack td[data-label]::before {
        content: attr(data-label); font-weight: 600; font-size: .78rem; color: var(--muted);
        text-align: left; flex-shrink: 0;
    }
    .table-stack > tbody > tr > td:first-child { font-size: 1.02rem; font-weight: 700; color: var(--ink); justify-content: flex-start; text-align: left !important; border-bottom: 1px dashed var(--line); padding-bottom: .5rem; margin-bottom: .2rem; }
    .table-stack > tbody > tr > td:first-child::before { display: none; }
    .table-stack > tbody > tr > td.td-acciones { justify-content: flex-end; border-top: 1px dashed var(--line); margin-top: .3rem; padding-top: .55rem; }
    .table-stack > tbody > tr > td[colspan] { justify-content: center; border: 0; }
    .card:has(> .table-responsive > .table-stack) { background: transparent; box-shadow: none !important; border: 0 !important; }
    .card:has(> .table-responsive > .table-stack) > .card-header { background: transparent !important; border: 0; padding-left: 0; }
    .table-responsive:has(> .table-stack) { overflow: visible; }
}

/* Tablas de cuotas: en celular se ocultan columnas de desglose (botón "Desglose") */
@media (max-width: 575.98px) {
    .tabla-cuotas:not(.ver-detalle) .col-detalle { display: none; }
    .tabla-cuotas { max-height: none; font-size: .88rem; }
    .tabla-cuotas thead.sticky-top { position: static; }
    .tabla-cuotas td, .tabla-cuotas th { padding-left: .45rem !important; padding-right: .45rem !important; }
}

/* Ticket en pantallas pequeñas */
@media (max-width: 400px) {
    .ticket-preview { font-size: 11px; min-width: 0; }
}
.min-w-0 { min-width: 0; }
