/* ============================================================
   PIXELHUB · Estilos del panel y del login
   ------------------------------------------------------------
   1. Tokens, modo oscuro y base   8. Comparativas
   2. Componentes Bootstrap        9. Administración
   3. Estructura (app shell)      10. Avisos (toasts) y SweetAlert
   4. Dashboard                   11. Login
   5. Gráficos                    12. Tema, sincronización y tiendas bloqueadas
   6. Tablas                      13. Utilidades y movimiento
   7. Modales                     14. (Control: ver css/control.css)
   Móvil primero en el layout; breakpoints de Bootstrap
   (md ≥ 768, lg ≥ 992, xl ≥ 1200).
   ============================================================ */

/* ============================================================
   1. TOKENS Y BASE
   ============================================================ */
:root {
    color-scheme: light;

    /* Marca */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-dark: #3730a3;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --grad-primary: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    --grad-sunset: linear-gradient(135deg, #f43f5e 0%, #f97316 100%);
    --grad-ocean: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    --grad-forest: linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Estados */
    --success: #059669;
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --warning: #d97706;
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --danger: #dc2626;
    --danger-50: #fef2f2;
    --danger-100: #fee2e2;
    --info: #0284c7;
    --info-50: #f0f9ff;
    --info-100: #e0f2fe;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;

    /* Superficies y texto */
    --bg-body: #f5f6fa;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-input: #f8fafc;
    --bg-input-hover: #f1f5f9;
    --text-primary: #101828;
    --text-secondary: #475467;
    --text-muted: #667085;
    --text-subtle: #98a2b3;
    --border-color: #e4e7ec;
    --border-light: #eef0f4;
    --border-strong: #d0d5dd;
    --row-hover: #fafbfd;
    --segmented-bg: #e9ecf2;
    --topbar-bg: rgba(255, 255, 255, 0.92);
    --scrollbar: #cfd4dc;
    --overlay: rgba(16, 24, 40, 0.55);

    /* Botones rellenos (en oscuro el primario de texto es más claro que el de fondo) */
    --primary-solid: #4f46e5;
    --primary-solid-hover: #4338ca;

    /* Forma */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 999px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.10), 0 2px 6px -2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.22);
    --focus-ring: 0 0 0 4px rgba(79, 70, 229, 0.16);
    --transition: 160ms ease;

    /* Estructura */
    --sidebar-width: 228px;   /* David, 2-11: 236 dejaba mucho blanco; 212 cortaba «Configuración» */
    --topbar-height: 64px;
    --bottomnav-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* --- Modo oscuro (data-theme lo pone el script del <head> y el selector de tema) --- */
:root[data-theme="dark"] {
    color-scheme: dark;

    --primary: #a5b4fc;
    --primary-hover: #c7d2fe;
    --primary-dark: #c7d2fe;
    --primary-50: rgba(129, 140, 248, 0.12);
    --primary-100: rgba(129, 140, 248, 0.20);
    --primary-200: rgba(129, 140, 248, 0.38);
    --primary-solid: #6366f1;
    --primary-solid-hover: #818cf8;

    --success: #34d399;
    --success-50: rgba(52, 211, 153, 0.12);
    --success-100: rgba(52, 211, 153, 0.24);
    --warning: #fbbf24;
    --warning-50: rgba(251, 191, 36, 0.12);
    --warning-100: rgba(251, 191, 36, 0.24);
    --danger: #f87171;
    --danger-50: rgba(248, 113, 113, 0.12);
    --danger-100: rgba(248, 113, 113, 0.24);
    --info: #38bdf8;
    --info-50: rgba(56, 189, 248, 0.12);
    --info-100: rgba(56, 189, 248, 0.24);
    --neutral-50: #1a2234;
    --neutral-100: #222c42;

    --bg-body: #0c111d;
    --bg-card: #131a2a;
    --bg-elevated: #182134;
    --bg-input: #1a2234;
    --bg-input-hover: #222c42;
    --text-primary: #eef1f7;
    --text-secondary: #c1c8d6;
    --text-muted: #94a0b8;
    --text-subtle: #6c7891;
    --border-color: #263046;
    --border-light: #1f283b;
    --border-strong: #35405a;
    --row-hover: rgba(255, 255, 255, 0.025);
    --segmented-bg: #0f1523;
    --topbar-bg: rgba(19, 26, 42, 0.92);
    --scrollbar: #35405a;
    --overlay: rgba(0, 0, 0, 0.65);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.50);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.70);
    --focus-ring: 0 0 0 4px rgba(129, 140, 248, 0.28);
}
:root[data-theme="dark"] .table > tbody > tr:hover > td { background: rgba(255, 255, 255, 0.025); }
:root[data-theme="dark"] .detalle-header-venta { background: linear-gradient(135deg, #047857 0%, #065f46 100%); }
:root[data-theme="dark"] .detalle-header-mov { background: linear-gradient(135deg, #0369a1 0%, #1e40af 100%); }
:root[data-theme="dark"] .top-product-rank.rank-3 { color: #fb923c; }
:root[data-theme="dark"] .login-page {
    background:
        radial-gradient(1200px 600px at -10% -20%, rgba(99, 102, 241, 0.18), transparent 60%),
        radial-gradient(900px 500px at 110% 120%, rgba(124, 58, 237, 0.14), transparent 60%),
        var(--bg-body);
}
/* Iconos de calendario de <input type="date"> visibles sobre fondo oscuro */
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; letter-spacing: -0.01em; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

code {
    color: var(--primary-dark);
    background: var(--primary-50);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.9em;
}

::selection { background: var(--primary-100); }

/* Scroll fino */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-gradient { color: var(--primary); }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ============================================================
   2. COMPONENTES BOOTSTRAP
   ============================================================ */

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    padding: 9px 16px;
    min-height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}
.btn i { font-size: 1em; line-height: 1; }
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn:disabled, .btn.disabled { opacity: 0.6; }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 15px; }

.btn-primary {
    background: var(--primary-solid);
    border-color: var(--primary-solid);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover, .btn-primary:focus { background: var(--primary-solid-hover); border-color: var(--primary-solid-hover); color: #fff; }
.btn-primary:active { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }

.btn-light {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
    box-shadow: var(--shadow-xs);
}
.btn-light:hover, .btn-light:focus { background: var(--neutral-50); border-color: var(--border-strong); color: var(--text-primary); }

.btn-success-soft { background: var(--success-50); border-color: var(--success-100); color: var(--success); }
.btn-success-soft:hover { background: var(--success-100); color: var(--success); }

.btn-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    box-shadow: none;
}
.btn-link:hover { color: var(--text-primary); background: var(--neutral-100); }

/* Contornos: suaves, con color solo en el texto */
.btn-outline-primary, .btn-outline-success, .btn-outline-danger,
.btn-outline-warning, .btn-outline-info, .btn-outline-secondary {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-xs);
}
.btn-outline-primary { color: var(--primary); }
.btn-outline-success { color: var(--success); }
.btn-outline-danger { color: var(--danger); }
.btn-outline-warning { color: var(--warning); }
.btn-outline-info { color: var(--info); }
.btn-outline-secondary { color: var(--text-secondary); }
.btn-outline-primary:hover { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-hover); }
.btn-outline-success:hover { background: var(--success-50); border-color: var(--success-100); color: var(--success); }
.btn-outline-danger:hover { background: var(--danger-50); border-color: var(--danger-100); color: var(--danger); }
.btn-outline-warning:hover { background: var(--warning-50); border-color: var(--warning-100); color: var(--warning); }
.btn-outline-info:hover { background: var(--info-50); border-color: var(--info-100); color: var(--info); }
.btn-outline-secondary:hover { background: var(--neutral-50); color: var(--text-primary); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Botón cuadrado solo con icono */
.btn-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
}
.btn-icon:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-200); }

/* --- Formularios --- */
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-label i { margin-right: 6px; color: var(--text-muted); }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.form-control,
.form-select,
.table-selector {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    min-height: 40px;
    padding: 8px 12px;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control:focus,
.form-select:focus,
.table-selector:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    outline: none;
}
textarea.form-control { min-height: 88px; }
.form-select, select.form-control, .table-selector { padding-right: 34px; cursor: pointer; }
select.form-control, .table-selector {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px 10px;
}
.form-select-sm { min-height: 34px; font-size: 13px; padding: 5px 30px 5px 10px; border-radius: var(--radius-sm); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--primary); }

/* --- Tarjetas --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
}
.card-header:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card-header h5 { font-size: 15px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-header h5 i { color: var(--primary); }
.card-header small { display: block; width: 100%; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card-header > h5 + small { margin-top: -8px; }
.card-body { padding: 20px; }

/* Cabecera de sección (título + subtítulo + acciones) */
.section-card { margin-bottom: 20px; }
.section-title h2 { font-size: 15px; font-weight: 600; margin: 0; }
.section-title p { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-actions .form-select { width: auto; }

/* --- Badges --- */
.badge {
    font-family: var(--font);
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
}

/* --- Menú desplegable --- */
.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 230px;
    font-size: 14px;
}
.dropdown-header { font-size: 12px; color: var(--text-muted); padding: 8px 10px; white-space: normal; word-break: break-all; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 500;
}
.dropdown-item i { color: var(--text-muted); width: 16px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--neutral-100); color: var(--text-primary); }
.dropdown-item.text-danger i, .dropdown-item.text-danger { color: var(--danger) !important; }
.dropdown-item.text-danger:hover { background: var(--danger-50); }
.dropdown-divider { margin: 6px 0; border-color: var(--border-light); }

/* --- Pestañas tipo control segmentado (subpestañas de Admin) --- */
.segmented {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 4px;
    background: var(--segmented-bg);
    border-radius: var(--radius-md);
    border: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
}
.segmented .nav-link:hover { color: var(--text-primary); }
.segmented .nav-link.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.segmented .nav-link i { color: inherit; }

/* Spinner */
.spinner-border { --bs-spinner-border-width: 0.18em; }
.text-primary.spinner-border, .spinner-border.text-primary { color: var(--primary) !important; }

/* ============================================================
   3. ESTRUCTURA (APP SHELL)
   ============================================================ */
.dashboard-page.hidden { display: none; }
.dashboard-page { min-height: 100vh; min-height: 100dvh; }

/* Marca */
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
}
.app-brand:hover { color: var(--text-primary); }
.app-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--grad-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    box-shadow: 0 6px 14px -6px rgba(79, 70, 229, 0.6);
    flex-shrink: 0;
}

/* --- Barra lateral (PC) / barra inferior (móvil) --- */
.app-sidebar {
    position: fixed;
    z-index: 1030;
    background: var(--bg-card);
}
.app-sidebar .app-brand { display: none; }

.app-nav {
    display: flex;
    flex-wrap: nowrap;
    list-style: none;
    margin: 0;
    padding: 0;
}
.app-nav .nav-link {
    display: flex;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    transition: color var(--transition), background-color var(--transition);
}
.app-nav .nav-link i { line-height: 1; }

/* Móvil y tablet: barra inferior fija */
@media (max-width: 991.98px) {
    .app-sidebar {
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(var(--bottomnav-height) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 16px -8px rgba(16, 24, 40, 0.12);
        background: var(--topbar-bg);
        backdrop-filter: saturate(180%) blur(12px);
    }
    .app-nav { height: 100%; justify-content: space-around; }
    .app-nav .nav-item { flex: 1 1 0; max-width: 120px; }
    .app-nav .nav-link {
        height: 100%;
        width: 100%;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        font-size: 11px;
        padding: 6px 4px;
        position: relative;
    }
    .app-nav .nav-link i { font-size: 20px; }
    .app-nav .nav-link.active { color: var(--primary); }
    .app-nav .nav-link.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 28%;
        right: 28%;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--primary);
    }
    .app-main { padding-bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 16px); }
}

/* PC: barra lateral */
@media (min-width: 992px) {
    .app-sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        border-right: 1px solid var(--border-color);
        padding: 18px 14px;
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    .app-sidebar .app-brand { display: inline-flex; padding: 4px 8px; }
    .app-nav { flex-direction: column; gap: 2px; }
    .app-nav .nav-link {
        width: 100%;
        gap: 12px;
        padding: 10px 12px;
        border-radius: var(--radius-md);
        font-size: 14px;
        color: var(--text-secondary);
    }
    .app-nav .nav-link i { font-size: 18px; color: var(--text-muted); }
    .app-nav .nav-link:hover { background: var(--neutral-100); color: var(--text-primary); }
    .app-nav .nav-link.active { background: var(--primary-50); color: var(--primary); }
    .app-nav .nav-link.active i { color: var(--primary); }
    .app-main { margin-left: var(--sidebar-width); }
}

/* --- Barra superior --- */
.app-topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}
.app-brand-mobile { order: 0; }
.app-topbar-end { order: 1; margin-left: auto; display: flex; align-items: center; gap: 14px; }
.app-context { order: 2; width: 100%; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.context-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 140px;
    min-width: 0;
}
/* Varios TPV: el selector «Todos / TPV n» solo con más de un TPV (common.js cargarTpvsDash) */
.context-field[hidden] { display: none; }
.context-field > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 15px;
    z-index: 1;
}
.context-select {
    appearance: none;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 32px 8px 36px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--neutral-50) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat right 12px center / 12px 9px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}
.context-select:hover { background-color: var(--neutral-100); }
.context-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); background-color: var(--bg-card); }

.context-custom {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.context-custom .form-control { flex: 1 1 130px; width: auto; }

/* Usuario */
.user-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
    padding: 3px;
    border-radius: var(--radius-full);
}
.user-toggle:hover { color: var(--text-primary); background: var(--neutral-100); }
.user-toggle::after { display: none; }
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--primary-200);
}
.user-toggle-name { display: none; font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Móvil estrecho: tienda y fecha en filas propias para que el nombre no se corte */
@media (max-width: 575.98px) {
    .context-store, .context-date { flex: 1 1 100%; }
}
@media (min-width: 576px) and (max-width: 767.98px) {
    .context-store { flex: 1 1 58%; }
    .context-date { flex: 1 1 36%; }
}

@media (min-width: 768px) {
    .app-topbar { padding: 12px 24px; }
    .app-context { width: auto; flex: 1 1 auto; order: 1; flex-wrap: nowrap; }
    .app-topbar-end { order: 2; }
    .context-field { flex: 0 1 240px; }
    .context-store { flex: 0 1 320px; }
    .context-date { flex: 0 1 220px; }
    .context-custom { flex: 0 1 auto; flex-wrap: nowrap; }
    .context-custom .form-control { width: 150px; flex: 0 0 auto; }
    .user-toggle-name { display: inline; }
    .user-toggle { padding: 3px 10px 3px 3px; }
}

@media (min-width: 992px) {
    .app-topbar {
        position: sticky;
        top: 0;
        z-index: 1020;
        min-height: var(--topbar-height);
        padding: 12px 32px;
        background: var(--topbar-bg);
        backdrop-filter: saturate(180%) blur(12px);
    }
    .app-brand-mobile { display: none; }
}

/* --- Contenido --- */
.app-content {
    padding: 16px;
    max-width: 1440px;
    margin: 0 auto;
}
@media (min-width: 768px) { .app-content { padding: 24px; } }
@media (min-width: 992px) { .app-content { padding: 28px 32px 40px; } }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-eyebrow { margin: 0 0 2px; font-size: 13px; color: var(--text-muted); }
.page-eyebrow span:first-child { color: var(--text-secondary); font-weight: 600; }
#currentDate::first-letter { text-transform: uppercase; }
.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    word-break: break-word;
}
.page-range {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius-full);
}
@media (min-width: 992px) { .page-title { font-size: 26px; } }

/* Las pestañas no animan el alto (evita saltos) */
.tab-content > .tab-pane.fade { transition: opacity 150ms linear; }

.loading-block { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.loading-block p { margin: 12px 0 0; font-size: 13.5px; }

/* ============================================================
   4. DASHBOARD
   ============================================================ */

/* --- KPIs --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
/* 4 columnas en tablet y PC; 2 entre 992 y 1199 px, donde la barra lateral resta ancho */
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 992px) and (max-width: 1199.98px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* --- Tarjetas de registros (tiles) --- */
.data-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.data-tile:hover { border-color: var(--primary-200); box-shadow: var(--shadow-md); }
.data-tile:active { transform: scale(0.98); }
.tile-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    margin-bottom: 10px;
}
.tile-count {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.tile-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.3;
}
.tile-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color var(--transition), background-color var(--transition);
}
.tile-badge::after {
    content: '\F285';   /* bi-chevron-right */
    font-family: 'bootstrap-icons';
    font-size: 13px;
}
.data-tile:hover .tile-badge { background: var(--primary-50); color: var(--primary); }

/* Colores por tipo de tabla (icono de tile y de configuración) */
.tile-primary .tile-icon, .tile-config-icon.tile-primary { background: var(--primary-50); color: var(--primary); }
.tile-success .tile-icon, .tile-config-icon.tile-success { background: var(--success-50); color: var(--success); }
.tile-info .tile-icon, .tile-config-icon.tile-info { background: var(--info-50); color: var(--info); }
.tile-warning .tile-icon, .tile-config-icon.tile-warning { background: var(--warning-50); color: var(--warning); }
.tile-danger .tile-icon, .tile-config-icon.tile-danger { background: var(--danger-50); color: var(--danger); }
.tile-secondary .tile-icon, .tile-config-icon.tile-secondary { background: var(--neutral-100); color: var(--text-secondary); }

/* --- Productos más vendidos --- */
.top-products-list { display: flex; flex-direction: column; gap: 4px; }
.top-product-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-light);
}
.top-product-item:last-child { border-bottom: 0; }
.top-product-rank {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: var(--neutral-100);
    color: var(--text-secondary);
    flex-shrink: 0;
}
.top-product-rank.rank-1 { background: var(--warning-50); color: var(--warning); }
.top-product-rank.rank-2 { background: var(--neutral-100); color: var(--text-secondary); }
.top-product-rank.rank-3 { background: rgba(234, 88, 12, 0.12); color: #c2410c; }
.top-product-info { flex: 1; min-width: 0; }
.top-product-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
    text-transform: capitalize;
}
.top-product-bar { height: 6px; background: var(--neutral-100); border-radius: 6px; overflow: hidden; }
.top-product-bar-fill { height: 100%; background: var(--primary); border-radius: 6px; }
.top-product-stats { text-align: right; flex-shrink: 0; min-width: 72px; }
.top-product-qty { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.top-product-total { font-size: 12px; color: var(--success); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================
   5. GRÁFICOS
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.charts-grid .card { margin: 0; }
@media (min-width: 768px) {
    .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .charts-grid .chart-card:first-child { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
    .charts-grid { grid-template-columns: 2fr 1fr 1fr; }
    .charts-grid .chart-card:first-child { grid-column: auto; }
}
.chart-card .card-body { display: flex; flex-direction: column; gap: 12px; }

.chart-compact-canvas { position: relative; height: 190px; }
.chart-compact-canvas.chart-lg { height: 240px; }
@media (min-width: 1200px) { .chart-compact-canvas.chart-lg { height: 270px; } }
.chart-bars-container { position: relative; height: 300px; }
.chart-compare { margin-top: 20px; }
.chart-compact-canvas canvas, .chart-bars-container canvas { max-width: 100%; }

/* Leyendas de los donuts */
.donut-legend { display: flex; flex-direction: column; gap: 2px; max-height: 150px; overflow-y: auto; }
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: var(--radius-xs);
    font-size: 12.5px;
}
.legend-item:hover { background: var(--neutral-50); }
.legend-color { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; min-width: 0; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.legend-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.legend-subvalue { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* ============================================================
   6. TABLAS
   ============================================================ */
.table {
    --bs-table-bg: transparent;
    margin: 0;
    font-size: 13.5px;
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}
.table > thead > tr > th {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--neutral-50);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    white-space: nowrap;
}
.table > tbody > tr > td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tbody > tr:hover > td { background: var(--row-hover); }
.table > tbody > tr.fila-clicable { cursor: pointer; }
.table > tbody > tr.fila-clicable:hover > td { background: var(--primary-50); }

/* Celdas especiales (formatearCelda) */
.cell-date { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-money { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-null { color: var(--text-subtle); }
.cell-text { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.col-acciones { text-align: right; white-space: nowrap; }
.acciones-fila { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.acciones-fila .btn { min-height: 32px; padding: 5px 10px; }
.acciones-fila .btn:not(:has(span)) { width: 32px; padding: 0; }
@media (min-width: 768px) { .table-data .acciones-fila { flex-wrap: nowrap; } }

/* Tabla → tarjetas en móvil (cada <td> lleva data-label) */
@media (max-width: 767.98px) {
    .table-cards,
    .table-cards tbody,
    .table-cards tr,
    .table-cards td { display: block; width: 100%; }
    .table-cards thead { display: none; }
    .table-cards > tbody > tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-xs);
        padding: 6px 14px;
        margin-bottom: 10px;
    }
    .table-cards > tbody > tr:hover > td { background: transparent; }
    .table-cards > tbody > tr > td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px dashed var(--border-light);
        text-align: right;
        min-height: 38px;
    }
    .table-cards > tbody > tr > td:last-child { border-bottom: 0; }
    .table-cards > tbody > tr > td::before {
        content: attr(data-label);
        flex-shrink: 0;
        max-width: 45%;
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
    }
    .table-cards > tbody > tr > td:not([data-label])::before,
    .table-cards > tbody > tr > td[data-label=""]::before { display: none; }
    .table-cards > tbody > tr > td[colspan] { display: block; text-align: center; border: 0; }
    .table-cards > tbody > tr:has(> td[colspan]) { border: 0; box-shadow: none; background: transparent; padding: 0; }
    .table-cards .cell-text { max-width: 100%; white-space: normal; text-align: right; }
    .table-cards .cell-date, .table-cards .cell-money { white-space: normal; }
    .table-cards td > .d-flex { justify-content: flex-end; flex-wrap: wrap; }
    /* Primera celda como título de la tarjeta */
    .table-cards > tbody > tr > td.td-titulo {
        justify-content: flex-start;
        text-align: left;
        font-weight: 600;
        font-size: 14.5px;
        border-bottom: 1px solid var(--border-light);
        padding: 10px 0;
    }
    .table-cards > tbody > tr > td.td-titulo::before { display: none; }
    .table-cards .col-acciones { justify-content: flex-end; }
    .table-cards .col-acciones::before { display: none; }
    .table-cards .table-responsive, .card-body.p-0 .table-cards { padding: 12px; }
}

/* ============================================================
   7. MODALES
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--overlay);
    backdrop-filter: blur(3px);
}
.modal-overlay.show { display: flex; animation: overlay-in 160ms ease-out; }
.modal-overlay > .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    background: var(--bg-card);
    border: 0;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-overlay.modal-md > .modal-content { max-width: 640px; }
.modal-overlay.modal-lg > .modal-content { max-width: 760px; }
.modal-overlay.modal-xl > .modal-content { max-width: 1240px; height: calc(100vh - 48px); height: calc(100dvh - 48px); }
/* Ancha, con el alto que pida (David, 4-11): documentos con sus líneas, una plantilla con su vista previa al lado, roles… */
.modal-overlay.modal-ancho > .modal-content { max-width: 1120px; }

/* Modal de edición por encima del de datos */
#editModal { z-index: 1070; }
#ventaDetalleModal, #movimientoDetalleModal { z-index: 1075; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.modal-header h5 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }
.modal-header small { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.modal-title-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-title-group > div { min-width: 0; }
.modal-title-group h5 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--primary-50);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}

/* Cabecera centrada (2FA, crear tienda, crear usuario: HTML con <i> + h5 + p) */
.modal-header-centered,
#createUserModal .modal-header {
    flex-direction: column;
    text-align: center;
    gap: 6px;
    padding: 28px 24px 8px;
    border-bottom: 0;
}
.modal-header-centered .modal-icon { width: 48px; height: 48px; font-size: 22px; margin-bottom: 6px; }
.modal-header-centered p,
#createUserModal .modal-header p { margin: 0; font-size: 13.5px; color: var(--text-muted); }
#createUserModal .modal-header > i {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--primary-50);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 6px;
}

.modal-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-header-centered + .modal-body,
#createUserModal .modal-header + .modal-body { padding: 16px 24px 24px; }
.modal-body-scroll { overflow-y: auto; }
/* Botón principal a lo ancho en los modales simples (HTML generado sin w-100) */
#createUserModal .modal-body > .btn-primary { width: 100%; }
.modal-body > .btn-link { color: var(--text-muted); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--neutral-50);
    flex-shrink: 0;
}

.btn-close-modal {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}
.btn-close-modal:hover { background: var(--neutral-100); color: var(--text-primary); }
.btn-close-modal-light { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.btn-close-modal-light:hover { background: rgba(255, 255, 255, 0.3); color: #fff; }

/* Campo de 2FA */
.otp-input {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.4em;
    text-align: center;
    min-height: 56px;
    font-variant-numeric: tabular-nums;
}
.qr-container { text-align: center; margin-bottom: 16px; }
.qr-container img { width: 180px; height: 180px; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 8px; background: var(--bg-card); }

/* --- Modal de datos --- */
.modal-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--neutral-50);
    flex-shrink: 0;
}
.modal-info-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.record-count { font-size: 13px; color: var(--text-muted); }
.record-count strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.search-field { position: relative; flex: 0 1 300px; min-width: 200px; }
.search-field > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.modal-search {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px 8px 36px;
    font-family: var(--font);
    font-size: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-xs);
}
.modal-search:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

.modal-body-table { padding: 0; display: flex; flex-direction: column; min-height: 0; }
.table-container { overflow: auto; flex: 1 1 auto; min-height: 0; }
.table-data > thead > tr > th { position: sticky; top: 0; z-index: 2; }
.modal-empty { text-align: center; padding: 56px 16px; color: var(--text-muted); }
.modal-empty i { font-size: 40px; color: var(--text-subtle); display: block; margin-bottom: 10px; }
.modal-empty h5 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.modal-empty p { margin: 0; font-size: 13.5px; }

/* Filtro de fecha del modal */
.filtro-fecha-wrap { position: relative; }
.btn-filtro-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
}
.btn-filtro-toggle:hover { border-color: var(--border-strong); background: var(--neutral-50); }
.btn-filtro-toggle .bi-chevron-down { font-size: 11px; color: var(--text-muted); }
.popover-fecha {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    display: none;
    width: 320px;
    max-width: calc(100vw - 32px);
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.popover-fecha-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }
.popover-fecha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.popover-fecha-grid .span-2 { grid-column: 1 / -1; }
.btn-filtro-fecha {
    min-height: 36px;
    padding: 6px 10px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--neutral-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.btn-filtro-fecha:hover { background: var(--neutral-100); color: var(--text-primary); }
.btn-filtro-fecha.activo { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary); }
.popover-fecha-fechas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popover-fecha-fechas .form-label { font-size: 12px; margin-bottom: 4px; }
.popover-fecha-fechas .form-control { min-height: 36px; font-size: 13px; padding: 6px 8px; }
.popover-fecha-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* --- Configuración de tiles --- */
.tile-config-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--bg-card);
    transition: border-color var(--transition), background-color var(--transition);
    margin: 0;
    height: 100%;
}
.tile-config-item:hover { border-color: var(--border-strong); background: var(--neutral-50); }
.tile-config-item.active { border-color: var(--primary-200); background: var(--primary-50); }
.tile-config-check { position: absolute; opacity: 0; pointer-events: none; }
.tile-config-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.tile-config-info { flex: 1; min-width: 0; }
.tile-config-name { font-size: 13.5px; font-weight: 600; }
.tile-config-count { font-size: 12px; color: var(--text-muted); }
.tile-config-check-icon { font-size: 18px; color: var(--border-strong); transition: color var(--transition); }
.tile-config-item.active .tile-config-check-icon { color: var(--primary); }

/* --- Detalle de venta / movimiento (cuerpo generado por JS) --- */
.detalle-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px;
    color: #fff;
    flex-shrink: 0;
}
.detalle-header-venta { background: linear-gradient(135deg, #059669 0%, #047857 100%); }
.detalle-header-mov { background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%); }
.detalle-header h5 { color: #fff; margin: 0; font-size: 20px; font-weight: 700; }
.detalle-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
}
.detalle-eyebrow { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.detalle-subtitulo { font-size: 13px; opacity: 0.92; margin-top: 2px; }
/* En la cabecera de color, en blanco: el .detalle-subtitulo de los paneles (css/ventas.css, gris) dejaba la fecha del
   ticket en verde oscuro sobre verde (David, 4-11) */
.detalle-header .detalle-subtitulo { color: #fff; font-size: 13.5px; }
.detalle-titulos { min-width: 0; }
.detalle-body { padding: 20px 22px; overflow-y: auto; background: var(--neutral-50); flex: 1 1 auto; }

/* --- Móvil: los modales ocupan la pantalla o salen desde abajo --- */
@media (max-width: 767.98px) {
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-overlay > .modal-content,
    .modal-overlay.modal-md > .modal-content,
    .modal-overlay.modal-lg > .modal-content,
    .modal-overlay.modal-ancho > .modal-content {
        max-width: 100%;
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        padding-bottom: var(--safe-bottom);
        animation: sheet-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    /* Datos, edición y detalles: pantalla completa */
    .modal-overlay.modal-xl > .modal-content,
    .modal-overlay.modal-lg > .modal-content,
    .modal-overlay.modal-ancho > .modal-content {
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
    .modal-header { padding: 12px 14px; }
    .modal-body { padding: 16px; }
    .modal-info-bar { padding: 10px 14px; }
    .search-field { flex: 1 1 100%; min-width: 0; }
    .modal-footer { padding: 12px 14px calc(12px + var(--safe-bottom)); }
    .modal-footer .btn { flex: 1; }
    .modal-body-table .table-container { padding: 12px; background: var(--neutral-50); }
    .detalle-header { padding: 16px; }
    .detalle-body { padding: 16px; }
    /* El popover de fechas se ancla abajo, a lo ancho (la posición la pone el JS: se fuerza) */
    .popover-fecha {
        position: fixed;
        left: 12px !important;
        right: 12px !important;
        top: auto;
        bottom: calc(12px + var(--safe-bottom));
        width: auto;
        max-width: none;
    }
}

/* ============================================================
   8. COMPARATIVAS Y 9. ADMINISTRACIÓN
   Las pinta public/js/comparar.js y admin.js; su CSS está en css/comparar.css y css/admin.css.
   ============================================================ */
.badge-soft { background: var(--neutral-100); color: var(--text-secondary); }

/* ============================================================
   10. AVISOS (TOASTS) Y SWEETALERT
   ============================================================ */
.toast-container {
    position: fixed;
    z-index: 2000;
    display: flex;
    gap: 8px;
    pointer-events: none;
    left: 12px;
    right: 12px;
    /* En el móvil, abajo y encima de la barra de áreas: arriba tapaban la cabecera (logo, buscador y tienda) */
    bottom: calc(var(--bottomnav-height, 64px) + var(--safe-bottom, 0px) + 12px);
    flex-direction: column-reverse;
}
@media (min-width: 768px) {
    .toast-container { left: auto; right: 24px; top: auto; bottom: 24px; width: 360px; flex-direction: column-reverse; }
}
.toast-custom {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success) !important; }
.toast-danger .toast-icon { color: var(--danger) !important; }
.toast-warning .toast-icon { color: var(--warning) !important; }
.toast-info .toast-icon { color: var(--primary) !important; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: 13px; color: var(--text-secondary); word-break: break-word; }
.toast-message:empty { display: none; }
.toast-close {
    background: none;
    border: 0;
    color: var(--text-muted);
    padding: 2px;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
}
.toast-close:hover { background: var(--neutral-100); color: var(--text-primary); }

/* SweetAlert2 con el mismo estilo */
.swal2-container { z-index: 2100 !important; }
.swal2-popup {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    font-family: var(--font) !important;
    border-radius: var(--radius-xl) !important;
    padding: 24px 22px 22px !important;
    width: min(440px, calc(100vw - 32px)) !important;
}
.swal2-title { font-size: 18px !important; font-weight: 600 !important; color: var(--text-primary) !important; padding: 8px 0 0 !important; }
.swal2-html-container { font-size: 14px !important; color: var(--text-secondary) !important; margin: 10px 0 0 !important; }
.swal2-icon { transform: scale(0.75); margin: 0 auto -4px !important; }
.swal2-actions { gap: 8px; margin-top: 20px !important; width: 100%; }
.swal2-styled { margin: 0 !important; border-radius: var(--radius-md) !important; font-weight: 600 !important; font-size: 14px !important; min-height: 40px; padding: 9px 18px !important; box-shadow: none !important; }
.swal2-styled.swal2-confirm:not([style*="background"]) { background: var(--primary-solid) !important; }
.swal2-styled.swal2-cancel { background: var(--bg-card) !important; color: var(--text-secondary) !important; border: 1px solid var(--border-color) !important; }
.swal2-input, .swal2-select, .swal2-textarea { font-family: var(--font) !important; font-size: 15px !important; border-radius: var(--radius-md) !important; border: 1px solid var(--border-strong) !important; box-shadow: var(--shadow-xs) !important; }
.swal2-input:focus, .swal2-select:focus { border-color: var(--primary) !important; box-shadow: var(--focus-ring) !important; }
.swal2-validation-message { font-size: 13px !important; }
@media (max-width: 575.98px) {
    .swal2-actions { flex-direction: column-reverse; }
    .swal2-actions .swal2-styled { width: 100%; }
}

/* ============================================================
   11. LOGIN
   ============================================================ */
.login-body-page { background: var(--bg-card); }
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(1200px 600px at -10% -20%, rgba(99, 102, 241, 0.12), transparent 60%),
        radial-gradient(900px 500px at 110% 120%, rgba(124, 58, 237, 0.10), transparent 60%),
        var(--bg-body);
}
.login-container {
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.login-aside {
    display: none;
    position: relative;
    padding: 44px 40px;
    color: #fff;
    background: var(--grad-primary);
    overflow: hidden;
}
.login-aside::after {
    content: '';
    position: absolute;
    right: -120px;
    bottom: -120px;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}
.login-aside .app-brand { color: #fff; }
.login-aside .app-brand-mark { background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: none; }
.login-aside h2 { color: #fff; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 48px 0 12px; }
.login-aside p { color: rgba(255, 255, 255, 0.85); font-size: 15px; margin: 0 0 28px; max-width: 360px; }
.login-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--topbar-bg); }
.login-features i { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, 0.16); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }

.login-card { padding: 36px 28px 32px; }
.login-header { text-align: center; margin-bottom: 28px; }
.logo-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--grad-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 10px 22px -10px rgba(79, 70, 229, 0.7);
}
.login-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-header p { margin: 0; color: var(--text-muted); font-size: 14px; }
.login-card .form-control { min-height: 44px; }
/* El ojo de la contraseña: de la altura del campo y con su mismo borde */
.login-card .input-group-password .btn { min-height: 44px; min-width: 46px; border-color: var(--bs-border-color); color: var(--bs-secondary-color); background: var(--bs-body-bg); }
.login-card .input-group-password .btn:hover, .login-card .input-group-password .btn:focus-visible { color: var(--bs-body-color); background: var(--bs-tertiary-bg); }
.login-card .btn-primary { width: 100%; min-height: 44px; margin-top: 8px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12.5px; color: var(--text-muted); }

@media (min-width: 992px) {
    .login-page { padding: 40px; }
    .login-container { grid-template-columns: 1.05fr 1fr; min-height: 560px; }
    .login-aside { display: flex; flex-direction: column; }
    .login-card { padding: 56px 52px; display: flex; flex-direction: column; justify-content: center; }
    .login-header { text-align: left; }
    .login-header .logo-icon { display: none; }
}
@media (max-width: 991.98px) {
    .login-container { max-width: 420px; }
}

/* ============================================================
   12. TEMA, ESTADO DE SINCRONIZACIÓN Y TIENDAS BLOQUEADAS
   ============================================================ */

/* --- Tema --- */
.btn-icon-sm { width: 32px; min-width: 32px; height: 32px; min-height: 32px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-tema i { font-size: 16px; }
.btn-tema-login { position: fixed; top: 16px; right: 16px; z-index: 10; }
.dropdown-tema { padding: 6px 10px 8px; }
.dropdown-tema-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.tema-selector { display: flex; gap: 2px; padding: 3px; background: var(--segmented-bg); border-radius: var(--radius-sm); }
.tema-selector button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 30px;
    padding: 4px 6px;
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}
.tema-selector button:hover { color: var(--text-primary); }
.tema-selector button.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* --- Píldora de sincronización --- */
.page-header-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter var(--transition);
}
.sync-pill:hover { filter: brightness(0.97); }
.sync-ok { background: var(--success-50); color: var(--success); border-color: var(--success-100); }
.sync-aviso { background: var(--warning-50); color: var(--warning); border-color: var(--warning-100); }
.sync-error { background: var(--danger-50); color: var(--danger); border-color: var(--danger-100); }
.sync-bloqueada { background: var(--danger-50); color: var(--danger); border-color: var(--danger-100); }
.sync-neutro { background: var(--neutral-100); color: var(--text-secondary); border-color: var(--border-color); }

/* --- Avisos en página --- */
.aviso {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid;
    font-size: 13.5px;
}
.aviso > i { font-size: 18px; line-height: 1.3; }
.aviso > div { flex: 1; min-width: 0; }
.aviso .btn { flex-shrink: 0; }
.aviso-bloqueada { background: var(--danger-50); border-color: var(--danger-100); color: var(--text-primary); }
.aviso-bloqueada > i { color: var(--danger); }
@media (max-width: 575.98px) {
    .aviso { flex-wrap: wrap; }
    .aviso .btn { width: 100%; }
}

/* --- Tiendas bloqueadas --- */

.bloqueadas-lista { list-style: none; margin: 0; padding: 0; }
.bloqueada-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
}
.bloqueada-item:last-child { border-bottom: 0; }
.bloqueada-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--neutral-100);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bloqueada-nombre { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.bloqueada-meta { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 575.98px) {
    .bloqueada-item { flex-wrap: wrap; padding: 12px 16px; }
    .bloqueada-item .btn { width: 100%; }
}

/* --- Contenido de diálogos (SweetAlert) --- */
.swal-texto { text-align: left; font-size: 14px; color: var(--text-secondary); }
.swal-texto p { margin: 0 0 6px; }
.swal-texto .form-control { font-size: 15px; }
.swal-lista { margin: 6px 0 0; padding-left: 18px; }
.swal-lista li { margin-bottom: 4px; }
.swal-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    background: var(--neutral-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
}
.swal-check .form-check-input { margin-top: 2px; flex-shrink: 0; }
.swal2-popup.swal-ancho { width: min(620px, calc(100vw - 32px)) !important; }

/* --- Configuración de tarjetas agrupada --- */
.tiles-grupo-titulo { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 4px 0 8px; }
.tiles-grupo-otras { margin-top: 16px; }
.tiles-grupo-otras > summary {
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
    list-style-position: inside;
}
.tiles-grupo-otras > summary:hover { color: var(--text-primary); }
.tiles-grupo-otras > .row { margin-top: 4px; }

/* Ningún valor largo (stock enorme, códigos…) desborda su celda */
.table > tbody > tr > td { overflow-wrap: break-word; }
.badge .bi-infinity { font-size: 1.1em; }

/* ============================================================
   13. UTILIDADES Y MOVIMIENTO
   ============================================================ */
.fade-in-up { animation: fade-in-up 280ms ease-out both; }
.hidden { display: none; }
.min-w-0 { min-width: 0; }

@keyframes fade-in-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Móvil: campos a 16 px para que iOS no haga zoom al tocarlos */
@media (max-width: 767.98px) {
    .form-control, .form-select, .table-selector, .context-select, .modal-search,
    .swal2-input, .swal2-select, .swal2-textarea, .popover-fecha-fechas .form-control { font-size: 16px !important; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    .section-card { margin-bottom: 16px; }
    .page-header { margin-bottom: 16px; }
    .page-title { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* Entradas → Planos: en el móvil las butacas no encogen por debajo de un tamaño que se pueda pulsar con el dedo;
   el plano se desplaza a lo ancho (js/entradas.js, --ancho-plano) */
.en-plano-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) { .en-plano-scroll .en-plano { min-width: calc(var(--ancho-plano) * 1.25); } }
