/* ============================================================
   QApps · Tema visual basado en POS Quiroti
   ============================================================ */
html { scroll-padding-top: 84px; }
:root {
    --bg: #f5f6fb;
    --bg-2: #eef0f8;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eff1f9;
    --text: #111827;
    --text-2: #4b5563;
    --text-3: #8b93a7;
    --border: #e7e9f2;
    --border-strong: #d7dae7;
    --primary: #4f46e5;
    --primary-2: #6366f1;
    --primary-soft: #eef0ff;
    --violet: #8b5cf6;
    --violet-soft: #f4efff;
    --emerald: #10b981;
    --emerald-soft: #e8fbf3;
    --amber: #f59e0b;
    --amber-soft: #fff6e5;
    --danger: #ef4444;
    --danger-soft: #feeeee;
    --slate-soft: #eef1f6;
    --sidebar: #111426;
    --sidebar-2: #171a31;
    --sidebar-text: #c6cade;
    --sidebar-muted: #7d84a3;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 14px 34px -18px rgba(16, 24, 40, .24);
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 24px;
    --sidebar-w: 272px;
    --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", "Cascadia Code", "Consolas", monospace;

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-primary: var(--primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-border-radius: 12px;
    --bs-border-radius-sm: 9px;
    --bs-border-radius-lg: 18px;
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--violet);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--violet); }
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.text-muted { color: var(--text-3) !important; }
.text-success { color: var(--emerald) !important; }
.text-danger { color: var(--danger) !important; }
.font-monospace, .mono { font-family: var(--mono) !important; font-size: 12.5px; }
::selection { background: var(--primary); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
#wrapper { min-height: 100dvh; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1640px; margin: 0 auto; padding: 24px 28px 56px; flex: 1; }
body.is-auth #wrapper { margin-left: var(--sidebar-w); }
.app-footer { margin-top: auto; border-top: 1px solid var(--border); background: var(--surface); }
.app-footer .page { padding-top: 14px; padding-bottom: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 20px;
    min-height: 78px; padding: 12px 28px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-heading { min-width: 0; }
.eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: var(--text-3);
}
.page-heading h1 { margin: 1px 0 0; font-size: 21px; font-weight: 750; line-height: 1.2; white-space: nowrap; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.global-search {
    display: flex; align-items: center; gap: 9px;
    width: 100%; max-width: 460px; height: 42px; padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow-sm);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.global-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.global-search-icon { color: var(--text-3); display: flex; }
.global-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-size: 13px; color: var(--text); }
.global-search-kbd, kbd {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px;
    background: var(--surface-3); border: 1px solid var(--border);
    color: var(--text-3); font-family: var(--font); font-size: 10.5px; font-weight: 700;
}
/* Buscador móvil: el campo del topbar se oculta y se abre este panel. */
.icon-btn.search-toggle { display: none; }
body.search-open { overflow: hidden; }
.search-panel {
    position: fixed; inset: 0; z-index: 80;
    padding: calc(12px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(17, 24, 39, .48);
    backdrop-filter: blur(3px);
}
.search-panel[hidden] { display: none; }
.search-panel-card {
    max-width: 640px; margin: 0 auto; padding: 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
.search-panel-form { display: flex; align-items: center; gap: 8px; }
.search-panel-form input {
    flex: 1; min-width: 0; height: 44px; padding: 0 4px;
    border: 0; background: transparent; outline: 0; font-size: 16px; color: var(--text);
}
.search-panel-hint { margin: 6px 6px 2px; font-size: 11.5px; color: var(--text-3); }
.search-panel-hint kbd { vertical-align: middle; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-user { display: flex; align-items: center; gap: 9px; padding-left: 6px; margin-left: 2px; border-left: 1px solid var(--border); }
.topbar-user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user-meta strong { font-size: 12.5px; white-space: nowrap; }
.topbar-user-meta small { font-size: 10.5px; color: var(--text-3); }
.icon-btn {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; border: 1px solid transparent; background: transparent;
    color: var(--text-2); transition: all .18s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 9px; }
.menu-btn { display: none; }
.avatar {
    width: 38px; height: 38px; border-radius: 12px; display: inline-flex;
    align-items: center; justify-content: center; flex: none;
    background: linear-gradient(135deg, var(--primary-2), var(--violet));
    color: #fff; font-size: 12.5px; font-weight: 800;
}
.avatar-sm { width: 34px; height: 34px; border-radius: 10px; font-size: 11.5px; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w) !important;
    background:
        radial-gradient(120% 45% at 0% 0%, rgba(99, 102, 241, .24), transparent 60%),
        linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%) !important;
    color: var(--sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, .04) !important;
}
.sidebar .offcanvas-body { padding: 6px 14px 18px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 18px 18px; }
.sidebar-brand .brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: #fff; }
.brand-mark {
    width: 42px; height: 42px; flex: none; display: inline-flex;
    align-items: center; justify-content: center; border-radius: 13px;
    background: linear-gradient(135deg, var(--primary-2), var(--violet));
    color: #fff; font-size: 19px;
    box-shadow: 0 8px 16px rgba(79, 70, 229, .35);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 700; color: #fff; }
.brand-text small { font-size: 11.5px; color: var(--sidebar-muted); }
.sidebar-close { display: none; color: var(--sidebar-muted); }
.sidebar-close:hover { background: rgba(255, 255, 255, .06); color: #fff; border-color: transparent; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
    padding: 18px 12px 7px; margin: 0;
    font-size: 10.5px; font-weight: 700; letter-spacing: .11em;
    text-transform: uppercase; color: var(--sidebar-muted);
}
.sidebar .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 11px;
    color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
    transition: background .18s ease, color .18s ease;
}
.sidebar .nav-item:hover { background: rgba(255, 255, 255, .055); color: #fff; }
.sidebar .nav-item.is-active {
    background: linear-gradient(120deg, rgba(99, 102, 241, .95), rgba(139, 92, 246, .85));
    color: #fff; box-shadow: 0 12px 24px -14px rgba(99, 102, 241, .9);
}
.nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; opacity: .9; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px 20px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .09); }
.nav-sub-item { padding: 6px 10px; border-radius: 8px; color: var(--sidebar-muted); font-size: 12.5px; }
.nav-sub-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-sub-item.is-active { color: #fff; background: rgba(255, 255, 255, .07); }
.sidebar-foot { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255, 255, 255, .06); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 6px 4px 10px; }
.user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.user-meta strong { font-size: 12.5px; color: #f0f1f8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 10.5px; color: var(--sidebar-muted); }
.sidebar-foot .icon-btn { color: var(--sidebar-muted); }
.sidebar-foot .icon-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; border-color: transparent; }

@media (min-width: 992px) {
    .sidebar { visibility: visible !important; transform: none !important; }
    .menu-btn { display: none; }
}
@media (max-width: 991.98px) {
    body.is-auth #wrapper { margin-left: 0; }
    .menu-btn { display: inline-flex; }
    .sidebar-close { display: inline-flex; }
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header { padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 700; }
.card-footer { padding: 12px 20px; background: var(--surface-2); border-top: 1px solid var(--border); }
.card-body { padding: 20px; }
/* Bootstrap .card es flex: un .float-end dentro de .card-body se estira a todo el ancho. */
.card-body > .float-end { align-self: flex-end; }
.card-body > .float-start { align-self: flex-start; }
.card-title { font-size: 15px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 16px; border-radius: 12px;
    font-size: 13.5px; font-weight: 650; line-height: 1;
    transition: all .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 12.5px; }
.btn-lg { height: 52px; padding: 0 20px; border-radius: 14px; font-size: 14.5px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--violet)); border-color: transparent; color: #fff; box-shadow: 0 10px 22px -14px rgba(79, 70, 229, .9); }
.btn-primary:hover, .btn-primary:focus { background: linear-gradient(135deg, var(--primary-2), var(--violet)); border-color: transparent; color: #fff; }
.btn-secondary { background: var(--surface-3); border-color: var(--border); color: var(--text-2); }
.btn-secondary:hover { background: var(--slate-soft); border-color: var(--border-strong); color: var(--text); }
.btn-success { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.btn-success:hover { background: #0ea472; border-color: #0ea472; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-warning { background: var(--amber); border-color: var(--amber); color: #241a02; }
.btn-outline-primary { border-color: var(--border-strong); color: var(--primary); background: var(--surface); }
.btn-outline-primary:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btn-outline-secondary { border-color: var(--border-strong); color: var(--text-2); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-outline-danger { border-color: #fecaca; color: var(--danger); background: var(--surface); }
.btn-outline-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-outline-success { border-color: #a7f3d0; color: #059669; background: var(--surface); }
.btn-outline-success:hover { background: var(--emerald-soft); border-color: var(--emerald); color: #059669; }
.btn-group-sm > .btn, .btn-group .btn { border-radius: 9px; }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 9px; border-radius: 8px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .01em;
    background: var(--surface-3); color: var(--text-2);
}
.text-bg-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.text-bg-success { background: var(--emerald-soft) !important; color: #059669 !important; }
.text-bg-warning { background: var(--amber-soft) !important; color: #b45309 !important; }
.text-bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.text-bg-secondary { background: var(--surface-3) !important; color: var(--text-3) !important; }
.text-bg-info { background: #e0f2fe !important; color: #0369a1 !important; }
.text-bg-light { background: var(--surface-3) !important; color: var(--text-2) !important; }

/* ---------- Forms ---------- */
.form-label, .field-label { margin-bottom: 6px; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.form-control, .form-select {
    min-height: 42px; padding: 9px 13px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 11px; color: var(--text); font-size: 13.5px;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.form-control:focus, .form-select:focus {
    background: var(--surface); border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft); color: var(--text);
}
.form-control::placeholder { color: var(--text-3); }
.form-control-sm, .form-select-sm { min-height: 34px; padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
textarea.form-control { min-height: 90px; }
.form-check-input { width: 1.05em; height: 1.05em; border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--text-2); border-radius: 11px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.form-text { color: var(--text-3); font-size: 11.5px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); font-size: 13px; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 12px 14px; border-bottom-color: var(--border); }
.table thead th {
    font-size: 10px; font-weight: 800; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-3);
    border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: var(--surface-2); background: var(--surface-2); }
.table-light { --bs-table-bg: var(--surface-2); }
.table td strong { font-weight: 650; }

/* ---------- Alerts ---------- */
.alert { border: 1px solid transparent; border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13px; }
.alert-success { background: var(--emerald-soft); border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--amber-soft); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--primary-soft); border-color: #c7d2fe; color: #3730a3; }

/* ---------- Dropdowns / nav ---------- */
.dropdown-menu { border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; font-size: 13px; }
.dropdown-item { border-radius: 8px; padding: 8px 11px; color: var(--text-2); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-divider { border-color: var(--border); }
.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--text-3); font-weight: 600; font-size: 13px; }
.nav-tabs .nav-link.active { background: transparent; border-bottom-color: var(--primary); color: var(--primary); }
.nav-pills .nav-link { border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.nav-pills .nav-link.active { background: var(--primary); color: #fff; }

/* ---------- List group ---------- */
.list-group { border-radius: var(--radius-sm); }
.list-group-item { border-color: var(--border); padding: 11px 14px; font-size: 13px; background: transparent; color: var(--text-2); }
.list-group-item-action:hover { background: var(--surface-2); color: var(--text); }
.list-group-item.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Pagination / DataTables ---------- */
.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-hover-color: var(--text); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-border-radius: 10px; }
.page-link { border-radius: 9px !important; margin: 0 2px; font-size: 12.5px; }
.dataTables_wrapper { padding: 4px 16px 14px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { padding: 6px 10px; font-size: 12.5px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { font-size: 12px; color: var(--text-3); }
.dataTables_wrapper .dataTables_filter { margin-bottom: 6px; }
.dataTables_wrapper .table { margin-top: 4px; }

/* ---------- Modals ---------- */
.modal-content { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-header { border-bottom-color: var(--border); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-footer { border-top-color: var(--border); padding: 12px 20px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100dvh; display: flex; align-items: center; justify-content: center;
    padding: calc(24px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    background:
        radial-gradient(90% 60% at 100% 0%, rgba(139, 92, 246, .16), transparent 60%),
        radial-gradient(70% 60% at 0% 100%, rgba(99, 102, 241, .14), transparent 60%),
        var(--bg);
}
.login-card {
    width: 100%; max-width: 400px; padding: 32px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.login-brand strong { display: block; font-size: 15px; }
.login-brand small { color: var(--text-3); font-size: 11.5px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .muted { color: var(--text-3); font-size: 13px; }
.login-form .btn { height: 46px; }

/* ---------- Utilities ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); }
.progress-bar { background: linear-gradient(90deg, var(--primary-2), var(--primary)); }
hr { border-color: var(--border); opacity: 1; }
code, pre { color: var(--violet); }

/* ---------- Dashboard POS ---------- */
.hero-card {
    position: relative; overflow: hidden;
    display: flex; align-items: stretch; justify-content: space-between;
    gap: 28px; padding: 30px 32px; margin-bottom: 18px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(90% 160% at 100% 0%, rgba(255, 255, 255, .16), transparent 60%),
        linear-gradient(115deg, #3730a3 0%, #4f46e5 45%, #7c3aed 100%);
    color: #fff;
    box-shadow: 0 30px 60px -32px rgba(79, 70, 229, .8);
}
.hero-card::before, .hero-card::after {
    content: ""; position: absolute; border-radius: 50%; pointer-events: none;
}
.hero-card::before { width: 280px; height: 280px; right: -80px; top: -120px; background: rgba(255, 255, 255, .09); }
.hero-card::after { width: 160px; height: 160px; right: 180px; bottom: -100px; background: rgba(255, 255, 255, .06); }
.hero-copy { position: relative; z-index: 1; max-width: 620px; }
.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: rgba(255, 255, 255, .78);
}
.hero-copy h2 {
    margin: 10px 0 0; font-size: clamp(1.6rem, 2.4vw, 2.15rem);
    line-height: 1.08; letter-spacing: -.03em; font-weight: 780; color: #fff;
}
.hero-copy p {
    margin: 8px 0 0; font-size: 13.5px; line-height: 1.55;
    color: rgba(255, 255, 255, .82); max-width: 470px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-card .btn-light { background: #fff; border-color: #fff; color: var(--primary); box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .5); }
.hero-card .btn-light:hover { background: #f4f4ff; border-color: #f4f4ff; color: var(--violet); }
.hero-card .btn-ghost-light { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .28); color: #fff; }
.hero-card .btn-ghost-light:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.hero-cash {
    position: relative; z-index: 1; min-width: 210px; align-self: center;
    display: flex; flex-direction: column; gap: 4px;
    padding: 18px 20px; border-radius: 16px;
    background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .18);
    backdrop-filter: blur(8px);
}
.hero-cash-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.hero-cash strong { font-size: 26px; font-weight: 780; letter-spacing: -.03em; margin-top: 2px; color: #fff; }
.hero-cash small { font-size: 11px; color: rgba(255, 255, 255, .72); }
.hero-cash .btn { margin-top: 10px; height: 36px; font-size: 12px; }
.cash-state { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, .85); }
.cash-state .dot { width: 6px; height: 6px; border-radius: 50%; background: #6ee7b7; }
.cash-state.is-closed .dot { background: #fbbf24; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid-auto { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi-card {
    display: flex; align-items: flex-start; gap: 13px; padding: 18px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.kpi-icon {
    width: 40px; height: 40px; flex: none; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary); font-size: 18px;
}
.kpi-icon.is-indigo { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.is-violet { background: var(--violet-soft); color: var(--violet); }
.kpi-icon.is-emerald { background: var(--emerald-soft); color: var(--emerald); }
.kpi-icon.is-amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.is-slate { background: var(--slate-soft); color: var(--text-2); }
.kpi-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.kpi-label { font-size: 11px; font-weight: 650; color: var(--text-3); }
.kpi-value { font-size: 23px; font-weight: 780; letter-spacing: -.03em; line-height: 1.15; }
.kpi-sub { font-size: 10.5px; color: var(--text-3); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--text-3); }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.link-arrow:hover { text-decoration: underline; }
.badge-soft { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--emerald-soft); color: #059669; }
.badge-warning { background: var(--amber-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.table-wrap { width: 100%; overflow-x: auto; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 54px 24px; color: var(--text-3); }
.empty-state-sm { padding: 30px 18px; }
.empty-icon {
    width: 54px; height: 54px; margin-bottom: 6px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-3); color: var(--text-3); font-size: 24px;
}
.empty-state-sm .empty-icon { width: 44px; height: 44px; font-size: 20px; }
.empty-state h2, .empty-state h3 { font-size: 16px; color: var(--text); font-weight: 700; }
.empty-state p { max-width: 340px; font-size: 12.5px; line-height: 1.55; margin: 0; }
.empty-state .btn { margin-top: 8px; }

/* ---------- Listados heredados ---------- */
.list-page-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 16px;
}
.list-page-head h1 { margin: 0; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.list-page-head h1 small { display: block; margin-bottom: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.list-page-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }
.list-page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: visible; }
.table-card > .table-responsive { border-radius: var(--radius); }
.table-card .table { margin-bottom: 0; }
.table-card .dataTables_wrapper { padding: 14px 16px 16px; }
.table-card .dataTables_wrapper .table { margin-top: 2px; }
.table-card .dataTables_filter { margin-bottom: 8px; }
.form-section {
    display: flex; align-items: center; gap: 9px;
    margin: 18px 0 10px; padding-bottom: 7px;
    border-bottom: 1px solid var(--border);
    font-size: 11px; font-weight: 800; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-3);
}
.form-section:first-child { margin-top: 0; }
.form-section i { color: var(--primary); font-size: 14px; }
.input-group-sm > .form-control, .input-group-sm > .form-select { min-height: 36px; font-size: 12.5px; }
.input-group-text { font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.legacy-note { font-size: 12px; color: var(--text-3); }
.state-icon { font-size: 3rem; line-height: 1; }
.doc-total { font-size: 18pt; font-weight: 700; white-space: nowrap; }

@media (max-width: 1100px) {
    .kpi-grid, .kpi-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .hero-card { flex-direction: column; padding: 24px; }
    .hero-cash { align-self: stretch; min-width: 0; }
}
@media (max-width: 575.98px) {
    .kpi-grid, .kpi-grid-3 { gap: 10px; }
    .kpi-card { padding: 14px; }
    .kpi-value { font-size: 20px; }
    .hero-card { padding: 20px; border-radius: var(--radius); }
    .list-page-head h1 { font-size: 18px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .page {
        padding: 18px max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }
    .app-footer .page { padding-top: 14px; padding-bottom: 14px; }
    .topbar {
        padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
        padding-top: calc(10px + env(safe-area-inset-top));
        min-height: 68px;
    }
    .topbar-center { display: none; }
    .icon-btn.search-toggle { display: inline-flex; }
    .topbar-left { flex: 1 1 auto; }
    .topbar-right { flex: none; }
    /* Inicio y salir ya están en la barra inferior y en el menú lateral. */
    .topbar-right > a[href="/logout"],
    .topbar-right > a[href="/"] { display: none; }
    .page-heading h1 { overflow: hidden; text-overflow: ellipsis; }
    .sidebar-brand { padding-top: calc(22px + env(safe-area-inset-top)); }
    /* iOS hace zoom automático al enfocar campos con tipografía menor a 16px. */
    input, select, textarea,
    .form-control, .form-select,
    .form-control-sm, .form-select-sm,
    .input-group-sm > .form-control, .input-group-sm > .form-select,
    .dataTables_wrapper .dataTables_filter input,
    .dataTables_wrapper .dataTables_length select { font-size: 16px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 38px; }
    /* Objetivos táctiles cómodos (mínimo recomendado 44px). */
    .icon-btn, .icon-btn-sm { min-width: 44px; min-height: 44px; }
    table .btn-group > .btn { min-width: 40px; min-height: 40px; }
    .table-responsive { -webkit-overflow-scrolling: touch; }
    /* Tablas heredadas sin wrapper: su contenedor directo permite desplazamiento. */
    .page :has(> table.table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Lista de productos del documento: compacta para que el total quede a la vista. */
    #tbl_product { font-size: 11.5px; }
    #tbl_product > :not(caption) > * > * { padding: 6px 5px; }
    #tbl_product th:first-child, #tbl_product td:first-child { width: 42px; }
    /* Editor heredado: la barra completa ocupa media pantalla en móvil. */
    .cke_top { max-height: 120px; overflow-y: auto; }
    .cke_bottom { padding: 4px 8px; }
    .cke_contents { max-height: 45vh; overflow-y: auto; }
}
@media (max-width: 575.98px) {
    .page {
        padding: 14px max(12px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }
    .topbar-user { display: none; }
    .page-heading h1 { font-size: 18px; }
    .card-body { padding: 16px; }
    .input-group-text { font-size: 10px; padding-left: 8px; padding-right: 8px; }
    .doc-total { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- PWA: estado de sincronización ---------- */
.qsync-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.qsync-chip:hover { color: var(--primary); border-color: var(--primary); }
.qsync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.qsync-dot.is-online { background: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-soft); }
.qsync-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.qsync-dot.is-syncing { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: qsync-pulse 1s infinite; }
.qsync-chip.has-pending { border-color: var(--amber); background: var(--amber-soft); color: #92400e; }
.qsync-chip.is-syncing .qsync-chip-text { color: var(--amber); }
@keyframes qsync-pulse { 50% { opacity: .35; } }
@media (max-width: 991.98px) {
    .qsync-chip { min-height: 34px; padding: 0 9px; font-size: 10.5px; }
}

/* ---------- PWA: navegación inferior móvil ---------- */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
    body.is-auth #wrapper { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    body.is-auth .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        gap: 2px;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .96);
        border-top: 1px solid var(--border);
        box-shadow: 0 -10px 30px -18px rgba(16, 24, 40, .35);
        backdrop-filter: blur(12px);
    }
    .bottom-nav-item {
        flex: 1 1 0;
        min-width: 0;
        min-height: 54px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 4px 2px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: var(--text-3);
        font-size: 10.5px;
        font-weight: 700;
        line-height: 1.1;
        text-decoration: none;
    }
    .bottom-nav-item i { font-size: 19px; line-height: 1; }
    .bottom-nav-item:hover,
    .bottom-nav-item.is-active { color: var(--primary); background: var(--primary-soft); }
    .bottom-nav-item:active { transform: scale(.97); }
}

/* ---------- PWA: panel de sincronización ---------- */
.sync-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 22px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #111426, #262a4d);
    color: #fff;
}
.sync-hero h2 { color: #fff; margin: 0 0 4px; font-size: 20px; }
.sync-hero p { color: #c6cade; margin: 0; font-size: 13px; }
.sync-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.sync-metric { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.sync-metric small { display: block; color: var(--text-3); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sync-metric strong { display: block; margin-top: 4px; font-size: 18px; }
@media (max-width: 575.98px) {
    .sync-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sync-hero { padding: 18px; }
}

