/**
 * SHOYO — Sistema de Diseño v5.1
 * Dark-first · Sidebar layout · Inter · Lucide Icons
 * Minimalista, profesional — Inspirado en Holded
 */

/* =====================================================
   FUENTE
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
/* DM Sans and Fraunces removed — using Inter only */

/* =====================================================
   VARIABLES — DARK MODE (default)
   ===================================================== */
:root {
    /* Backgrounds — Negro/Gris neutro puro (sin tinte azul) */
    --bg-app:       #0e0e0e;
    --bg-primary:   #0e0e0e;
    --bg-secondary: #161616;
    --bg-tertiary:  #1e1e1e;
    --bg-sidebar:   #111111;
    --bg-card:      #171717;
    --bg-hover:     rgba(255, 255, 255, 0.04);
    --bg-active:    rgba(255, 255, 255, 0.07);
    --bg-input:     #141414;

    /* Text — Blancos neutros */
    --text-primary:   #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-tertiary:  #666666;
    --text-muted:     #555555;

    /* Borders — Grises neutros */
    --border-primary:   #2a2a2a;
    --border-secondary: #1f1f1f;
    --border-focus:     #3a3a3a;

    /* Color de acento principal — Gradiente SHOYO */
    --accent-primary: #6236ff;
    --accent-hover:   #7c5aff;
    --accent-blue:    #09a5ff;
    --accent-green:   #22c55e;
    --accent-red:     #ef4444;
    --accent-orange:  #f59e0b;
    --accent-yellow:  #eab308;
    --accent-purple:  #a855f7;
    --accent-indigo:  #6236ff;
    --accent-cyan:    #09a5ff;
    --accent-gradient: linear-gradient(135deg, #09a5ff, #6236ff, #a855f7);

    /* Semantic KPI — Tonos claros profesionales */
    --kpi-positive:   #22c55e;
    --kpi-negative:   #ef4444;
    --kpi-info:       #3b82f6;
    --kpi-alert:      #f59e0b;

    /* Overlays */
    --bg-overlay: rgba(0, 0, 0, 0.6);

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-xl:  0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.12);

    /* Radii */
    --radius-xs:   6px;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-xl:   20px;
    --radius-2xl:  24px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out:          cubic-bezier(0.25, 1, 0.5, 1);
    --ease-spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast:   0.15s var(--ease-out);
    --transition-normal: 0.2s var(--ease-out);
    --transition-slow:   0.35s var(--ease-out);

    /* Spacing scale */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Layout */
    --sidebar-width:     240px;
    --sidebar-collapsed: 68px;
    --header-height:     56px;
}

/* =====================================================
   VARIABLES — LIGHT MODE
   ===================================================== */
[data-theme="light"] {
    --bg-app:       #f3f4f6;
    --bg-primary:   #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary:  #f0f1f3;
    --bg-sidebar:   #1a1e27;
    --bg-card:      #ffffff;
    --bg-hover:     rgba(100, 116, 139, 0.04);
    --bg-active:    rgba(100, 116, 139, 0.08);
    --bg-input:     #ffffff;

    --text-primary:   rgba(17, 24, 39, 0.92);
    --text-secondary: rgba(17, 24, 39, 0.55);
    --text-tertiary:  rgba(17, 24, 39, 0.38);
    --text-muted:     rgba(17, 24, 39, 0.22);

    --border-primary:   rgba(17, 24, 39, 0.10);
    --border-secondary: rgba(17, 24, 39, 0.05);
    --border-focus:     rgba(100, 116, 139, 0.35);

    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-xl:  0 20px 60px rgba(0, 0, 0, 0.10);
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.05);
}

/* Light mode sidebar stays dark */
[data-theme="light"] .sidebar {
    --text-primary:   rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-tertiary:  rgba(255, 255, 255, 0.40);
    --text-muted:     rgba(255, 255, 255, 0.24);
    --border-primary:   rgba(255, 255, 255, 0.08);
    --border-secondary: rgba(255, 255, 255, 0.04);
    --bg-hover:     rgba(148, 163, 184, 0.08);
    --bg-active:    rgba(148, 163, 184, 0.15);
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    font-size: 14px;
}

::selection {
    background: var(--accent-primary);
    color: #fff;
}

/* Lucide icons inline alignment */
[data-lucide], svg.lucide {
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.5rem; }

a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); text-decoration: none; }

/* =====================================================
   UTILITIES
   ===================================================== */
.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.8125rem; }
.text-base { font-size: 0.875rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-muted   { color: var(--text-tertiary); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.ml-2 { margin-left: var(--space-2); }

.hidden { display: none !important; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    outline: none;
}

.btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
    transition-duration: 0.05s;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px var(--border-focus);
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-success {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #fff;
    font-weight: 600;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-warning {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: #fff;
    font-weight: 600;
}
.btn-warning:hover { filter: brightness(1.1); }

.btn-active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-primary);
    opacity: 0.75;
}
.btn-ghost:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    opacity: 1;
}

/* Action icon buttons — visible in both light and dark modes */
.btn-icon-edit {
    background: transparent;
    border-color: transparent;
    color: var(--accent-orange);
    opacity: 0.85;
}
.btn-icon-edit:hover {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange);
    opacity: 1;
}
.btn-icon-delete {
    background: transparent;
    border-color: transparent;
    color: var(--accent-red);
    opacity: 0.85;
}
.btn-icon-delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    opacity: 1;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-primary);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
    border-radius: var(--radius-xs);
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

/* form-control: estilo global para inputs, selects y textareas */
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
    cursor: pointer;
}

select.form-control option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.5;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

.input::placeholder { color: var(--text-muted); }

.input-lg {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
}

textarea.input {
    min-height: 100px;
    resize: vertical;
}

select.input {
    cursor: pointer;
    appearance: none;
    /* Arrow color: #a0a0a0 = --text-secondary (SVG data-URI can't use var()) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a0a0a0' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.625rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    /* subtle lift on hover - can be overridden */
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3, .card-header h4 { margin: 0; }

.card-body { padding: var(--space-5); }

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-secondary);
    background: var(--bg-secondary);
}

/* =====================================================
   KPI / STAT CARDS
   ===================================================== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Icon circle backgrounds — sutiles, neutros */
.stat-card-icon.icon-green  { background: rgba(34, 197, 94, 0.10); color: var(--accent-green); }
.stat-card-icon.icon-red    { background: rgba(239, 68, 68, 0.10); color: var(--accent-red); }
.stat-card-icon.icon-blue   { background: rgba(37, 99, 235, 0.10); color: var(--accent-blue); }
.stat-card-icon.icon-orange { background: rgba(245, 158, 11, 0.10); color: var(--accent-orange); }
.stat-card-icon.icon-purple { background: rgba(139, 92, 246, 0.10); color: var(--accent-purple); }
.stat-card-icon.icon-cyan   { background: rgba(6, 182, 212, 0.10); color: var(--accent-cyan); }

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.stat-card-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: var(--space-1);
}
.stat-card-change.positive { color: var(--kpi-positive); }
.stat-card-change.negative { color: var(--kpi-negative); }

/* Variation badge */
.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
}
.kpi-badge.up {
    background: rgba(34, 197, 94, 0.10);
    color: #22c55e;
}
.kpi-badge.down {
    background: rgba(239, 68, 68, 0.10);
    color: #ef4444;
}

/* Sparkline container */
.kpi-sparkline {
    margin-top: 12px;
    height: 48px;
    width: 100%;
}
.kpi-sparkline canvas {
    width: 100% !important;
    height: 48px !important;
}

/* Solid-color KPI variant (CoreUI-style) */
.stat-card.kpi-solid {
    border: none;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.stat-card.kpi-solid .stat-card-value {
    color: #fff;
}
.stat-card.kpi-solid .stat-card-label {
    color: rgba(255,255,255,0.75);
}
.stat-card.kpi-solid:hover {
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* ── Top Vendedores cards ── */
.vendedor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-normal);
}
.vendedor-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.vendedor-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.vendedor-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--border-primary);
    overflow: hidden;
    margin-top: 8px;
}
.vendedor-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s;
}
.vendedor-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.vendedor-cat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
}
.vendedor-cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* =====================================================
   BADGES / PILLS
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    white-space: nowrap;
}

.badge-primary { background: rgba(37, 99, 235, 0.12); color: #60a5fa; }
.badge-success { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.badge-danger  { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.badge-warning { background: rgba(234, 179, 8, 0.12); color: #facc15; }
.badge-info    { background: rgba(37, 99, 235, 0.12); color: #60a5fa; }

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto;
    margin-top: 4px;
}
.autocomplete-dropdown .autocomplete-item:hover {
    background: var(--bg-tertiary);
}

/* Status pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 20px;
    letter-spacing: 0.02em;
}
.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-pill.active { background: rgba(34, 197, 94, 0.10); color: #4ade80; }
.status-pill.active::before { background: #22c55e; }
.status-pill.inactive { background: rgba(239, 68, 68, 0.10); color: #f87171; }
.status-pill.inactive::before { background: #ef4444; }
.status-pill.pending { background: rgba(245, 158, 11, 0.10); color: #fbbf24; }
.status-pill.pending::before { background: #f59e0b; }

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.625rem 1rem;
    text-align: left;
}

th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

td {
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-secondary);
    color: var(--text-primary);
}

td strong { color: var(--text-primary); }

tr:last-child td { border-bottom: none; }

/* Alternating rows */
tbody tr:nth-child(even) td {
    background: var(--bg-hover);
}

/* Hover */
tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover td {
    background: var(--bg-active);
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(16px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent-red);
    color: #fff;
}

.modal-body {
    padding: var(--space-5) var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-secondary);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    background: var(--bg-secondary);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

/* =====================================================
   TOAST
   ===================================================== */
.toast-container {
    position: fixed;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
}

.toast {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition: all var(--transition-normal);
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* =====================================================
   EMPTY STATES
   ===================================================== */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-8);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-4);
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

/* =====================================================
   SPINNER
   ===================================================== */
.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-secondary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRow {
    from { opacity: 0; background: var(--accent-bg, rgba(99,102,241,0.08)); }
    to   { opacity: 1; background: transparent; }
}

/* =====================================================
   BREADCRUMBS
   ===================================================== */
.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.875rem;
    font-weight: 500;
}

.breadcrumb-item { color: var(--text-primary); }

.breadcrumb-item:first-child {
    color: var(--text-tertiary);
    font-weight: 400;
    transition: color var(--transition-fast);
    cursor: pointer;
}

.breadcrumb-item:first-child:hover {
    color: var(--accent-primary);
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-weight: 300;
    margin: 0 2px;
}

/* =====================================================
   TABS
   ===================================================== */
.tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--border-secondary);
    padding-bottom: 0;
}

.tab {
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background: transparent;
}

/* =====================================================
   LAYOUT — LOGIN
   ===================================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-app);
    padding: var(--space-6);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 44px 36px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.login-logo-img {
    width: 180px;
    height: auto;
    margin-bottom: var(--space-4);
    filter: drop-shadow(0 4px 24px rgba(98, 54, 255, 0.25));
}

.login-subtitle {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-top: var(--space-1);
}

.login-error {
    padding: var(--space-3) var(--space-4);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent-red);
    font-size: 0.8125rem;
    margin-bottom: var(--space-4);
    display: none;
}

.login-error.show { display: block; }

.passkey-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    gap: 12px;
}
.passkey-divider::before,
.passkey-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}
.passkey-divider span {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* =====================================================
   LAYOUT — HOLDING VIEW
   ===================================================== */
.holding-wrapper {
    min-height: 100vh;
    background: var(--bg-app);
    padding: var(--space-6);
}

.holding-header {
    max-width: 1200px;
    margin: 0 auto var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.holding-title {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.holding-title h1 {
    font-size: 1.375rem;
    letter-spacing: -0.02em;
}

/* =====================================================
   LAYOUT — EMPRESAS GRID
   ===================================================== */
.empresas-grid {
    max-width: 1200px;
    margin: 0 auto var(--space-6);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.empresa-card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-card);
    position: relative;
}

.empresa-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.empresa-card.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.empresa-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.empresa-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 116, 139, 0.10);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.empresa-icon-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.empresa-info h3 {
    font-size: 0.9375rem;
    margin-bottom: 2px;
}

.empresa-info p {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.empresa-stats {
    display: flex;
    gap: var(--space-4);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.empresa-add {
    background: transparent;
    border: 1.5px dashed var(--border-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--text-muted);
    box-shadow: none;
}

.empresa-add:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-hover);
    box-shadow: none;
    transform: none;
}

.empresa-add-icon {
    font-size: 1.75rem;
    margin-bottom: var(--space-2);
}

/* =====================================================
   LAYOUT — APP (sidebar + main)
   ===================================================== */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-normal);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
    height: var(--header-height);
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid var(--border-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.sidebar-header:hover {
    background: var(--bg-hover);
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(98, 54, 255, 0.3));
}

.sidebar-brand {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.sidebar-empresa-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: auto;
    border: 1px solid var(--border);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-empresa-logo,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item-label { display: none; }

.sidebar-nav {
    flex: 1;
    padding: var(--space-3);
    overflow-y: auto;
}

.nav-section { margin-bottom: var(--space-4); }

.nav-section-title {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 1px;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-item-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.625rem;
}

.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--border-secondary);
    flex-shrink: 0;
}

/* =====================================================
   LAYOUT — MAIN AREA
   ===================================================== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.header-title {
    font-size: 0.9375rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.header-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Notification bell */
.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}
.notification-bell:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.notif-badge.hidden { display: none; }

/* Notification panel */
.notif-panel {
    position: fixed;
    top: 56px;
    right: 16px;
    width: 380px;
    max-height: calc(100vh - 80px);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notif-panel.hidden { display: none; }
.notif-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.notif-panel-header h4 { margin: 0; font-size: 14px; }
.notif-panel-body {
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.notif-item:hover { background: var(--bg-secondary); }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 5%, var(--bg-primary)); }
.notif-item .notif-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.notif-item .notif-icon.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.notif-item .notif-icon.success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.notif-item .notif-icon.warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.notif-item .notif-icon.error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.notif-item .notif-icon.tpv { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.notif-item .notif-content { flex: 1; min-width: 0; }
.notif-item .notif-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.notif-item .notif-msg { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 3px var(--space-3) 3px 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
}

.user-avatar {
    width: 26px;
    height: 26px;
    background: var(--accent-primary);
    color: #fff;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 500;
}

.content {
    flex: 1;
    overflow: auto;
    padding: var(--space-6);
    background: var(--bg-app);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s var(--ease-out); }

/* =====================================================
   DASHBOARD
   ===================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

/* =====================================================
   MODULE HEADER
   ===================================================== */
.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.module-title {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.module-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* =====================================================
   FILE UPLOAD
   ===================================================== */
.file-upload {
    border: 1.5px dashed var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.file-upload:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.file-upload-icon {
    font-size: 1.75rem;
    margin-bottom: var(--space-3);
    color: var(--text-tertiary);
}

.file-upload-text { color: var(--text-secondary); font-size: 0.8125rem; }
.file-upload input { display: none; }

/* =====================================================
   CHECKBOX GROUP (módulos activos)
   ===================================================== */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1.5px solid var(--border-primary);
    font-size: 0.875rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-item:hover {
    background: var(--bg-active);
    border-color: var(--text-tertiary);
    color: var(--text-primary);
}

.checkbox-item.checked {
    border-color: var(--accent-primary);
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-primary);
}

.checkbox-item input { display: none; }
.checkbox-icon { font-size: 1rem; }

/* =====================================================
   GRID UTILITY
   ===================================================== */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

/* =====================================================
   SIDEBAR OVERLAY (for mobile)
   ===================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 499;
}

/* =====================================================
   MOBILE MODULE TABS — Horizontal scrollable navigation
   ===================================================== */
.mobile-module-tabs {
    display: none;
}

/* =====================================================
   RESPONSIVE — DESKTOP (>1024px)
   Dashboard grid 4 columns is the default
   ===================================================== */

/* =====================================================
   RESPONSIVE — TABLET (≤1024px)
   ===================================================== */
@media (max-width: 1024px) {
    .mobile-module-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 0;
        scrollbar-width: none;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-secondary);
        padding: 0 var(--space-2);
        position: sticky;
        top: 0;
        z-index: 90;
    }
    .mobile-module-tabs::-webkit-scrollbar { display: none; }

    .mobile-tab {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 10px 14px;
        font-size: 0.8125rem;
        font-weight: 500;
        color: var(--text-secondary);
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        flex-shrink: 0;
        transition: color var(--transition-fast), border-color var(--transition-fast);
        font-family: inherit;
    }
    .mobile-tab:hover {
        color: var(--text-primary);
    }
    .mobile-tab.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }
    .mobile-tab i {
        flex-shrink: 0;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        width: var(--sidebar-width);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { transform: translateX(-100%); }

    .sidebar-overlay.active { display: block; }

    .main { margin-left: 0 !important; }

    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .empresas-grid  { grid-template-columns: repeat(2, 1fr); }

    /* Top vendedores: 2 cols on tablet */
    #tpvVendedoresGrid { grid-template-columns: repeat(2, 1fr) !important; }

    /* Holding dashboard charts: stack vertically on tablet */
    .holding-charts-grid { grid-template-columns: 1fr !important; }

    .module-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }

    .module-actions { width: 100%; }

    .modal { max-width: 90vw; }

    th, td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .card-body { padding: var(--space-4); }
    .card-header { padding: var(--space-3) var(--space-4); }
    .content { padding: var(--space-4); }
}

/* =====================================================
   RESPONSIVE — SMARTPHONE (≤640px)
   ===================================================== */
@media (max-width: 640px) {
    html { font-size: 15px; }

    .sidebar { width: 85vw; max-width: 300px; }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    .empresas-grid { grid-template-columns: 1fr; }

    .stat-card { padding: 16px; }
    .stat-card-value { font-size: 22px; }
    .kpi-sparkline { height: 36px; }
    .kpi-sparkline canvas { height: 36px !important; }

    /* Top vendedores: 1 col on mobile */
    #tpvVendedoresGrid { grid-template-columns: 1fr !important; }

    .module-header { padding: 0; margin-bottom: var(--space-4); }

    .module-actions .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 0;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        flex-shrink: 0;
        font-size: 0.75rem;
        padding: var(--space-2) var(--space-3);
    }

    th, td {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .form-row { grid-template-columns: 1fr; }

    .modal {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: var(--radius-lg);
        margin: var(--space-2);
    }

    .modal-body { padding: var(--space-4); }
    .modal-header { padding: var(--space-4); }
    .modal-footer { padding: var(--space-3) var(--space-4); }

    .breadcrumb { font-size: 0.8125rem; }

    .header { padding: 0 var(--space-3); }
    .header-title { font-size: 0.8125rem; }

    .content { padding: var(--space-3); }

    .card { border-radius: var(--radius-md); }
    .card-body { padding: var(--space-3); }

    .table-container { font-size: 0.75rem; }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.6875rem;
    }

    #holdingTabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .holding-wrapper { padding: var(--space-3); }
    .holding-header { margin-bottom: var(--space-4); }

    .login-card {
        padding: 32px 24px;
        border-radius: var(--radius-xl);
    }

    .empresa-card { padding: var(--space-4); }
}

/* =====================================================
   RESPONSIVE — SMALL PHONE / SUNMI P3 (≤380px)
   ===================================================== */
@media (max-width: 380px) {
    html { font-size: 14px; }

    .dashboard-grid { grid-template-columns: 1fr; }
    .stat-card-value { font-size: 1.125rem; }

    .login-card { padding: 24px 16px; }

    .holding-title h1 { font-size: 1.125rem; }

    .stat-card {
        padding: var(--space-3);
    }

    .stat-card-icon { width: 32px; height: 32px; font-size: 0.875rem; }
    .stat-card-label { font-size: 0.6875rem; }

    .empresa-card { padding: var(--space-3); }
    .empresa-icon { width: 32px; height: 32px; font-size: 1rem; }

    .modal { margin: var(--space-1); border-radius: var(--radius-md); }
    .modal-body { padding: var(--space-3); }

    .tabs { gap: 0; }
    .tab { padding: var(--space-2); font-size: 0.6875rem; }
}

/* =====================================================
   TPV — Estética minimalista tipo Apple
   ===================================================== */
/* =====================================================
   TPV — PANTALLA DE VENTA COMPLETA
   Migrado desde JS <style> block → theme.css
   ===================================================== */
.tpv-venta-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.tpv-venta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    gap: var(--space-3);
    min-height: 56px;
}

.tpv-search-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.tpv-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    max-height: 400px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.tpv-search-item {
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-primary);
}
.tpv-search-item:hover { background: var(--bg-tertiary); }

/* Tarifa product search dropdown */
.tarifa-prod-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    margin-top: 2px;
}
.tarifa-prod-item {
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--border-primary);
}
.tarifa-prod-item:last-child { border-bottom: none; }
.tarifa-prod-item:hover { background: var(--bg-tertiary); }

.tpv-venta-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.tpv-venta-left {
    flex: 1 1 0%;
    overflow-y: auto;
    padding: var(--space-3);
    min-width: 0;
}

.tpv-venta-right {
    flex: 0 0 320px;
    max-width: 360px;
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

/* Categorías grid */
.tpv-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-2);
}

.tpv-cat-btn {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    background: var(--bg-secondary);
}
.tpv-cat-btn:hover { transform: scale(1.03); border-color: var(--accent-primary); }
.tpv-cat-btn.active { border-color: var(--accent-primary); background: var(--bg-active); }
.tpv-cat-btn .cat-name { font-weight: 600; font-size: 0.85rem; }
.tpv-cat-btn .cat-count { font-size: 0.75rem; opacity: 0.7; }

/* Productos grid */
.tpv-prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.tpv-prod-btn {
    position: relative;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--bg-primary);
    user-select: none;
    -webkit-user-select: none;
}
.tpv-prod-btn:hover { border-color: var(--accent-primary); transform: scale(1.02); }
.tpv-prod-btn:active { transform: scale(0.97); }
.tpv-prod-btn .prod-name {
    font-size: 0.82rem; font-weight: 600; line-height: 1.2;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    margin-top: 4px;
}
.tpv-prod-btn .prod-price { font-size: 0.95rem; font-weight: 700; color: var(--accent-primary); margin-top: 2px; }

/* Category filter bar (horizontal chips) */
.tpv-cat-bar {
    display: flex;
    gap: 6px;
    padding: 0 0 var(--space-2) 0;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tpv-cat-bar::-webkit-scrollbar { display: none; }
.tpv-cat-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid var(--border-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s;
    color: var(--text-primary);
}
.tpv-cat-chip:hover { border-color: var(--accent-primary); background: var(--bg-active); }
.tpv-cat-chip.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    font-weight: 600;
}
.tpv-prod-btn img { width: 80px; height: 80px; object-fit: contain; border-radius: var(--radius-sm); }
.tpv-prod-btn.grande { grid-column: span 2; }
.tpv-prod-btn.tpv-drag-over { border: 2px dashed var(--accent-primary); background: var(--bg-active); }

.tpv-prod-btn .prod-delete-btn {
    position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-red); color: white; border: none; cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center; z-index: 1;
}

/* Wobble (layout edit mode — tipo iOS) */
.tpv-prod-btn.tpv-wobble {
    animation: tpvWobble 0.25s ease-in-out infinite;
    cursor: grab;
}
.tpv-prod-btn.tpv-wobble:nth-child(even) { animation-delay: 0.12s; }
.tpv-prod-btn.tpv-wobble:nth-child(3n) { animation-duration: 0.28s; }
@keyframes tpvWobble {
    0%, 100% { transform: rotate(-1.8deg); }
    50% { transform: rotate(1.8deg); }
}

/* Drag clone (floating element while dragging) */
.tpv-drag-clone {
    border-radius: var(--radius-md) !important;
    background: var(--bg-primary) !important;
    overflow: hidden;
}

/* Drop target highlight */
.tpv-prod-btn.tpv-drag-over {
    border: 2px dashed var(--accent-primary) !important;
    background: var(--bg-active) !important;
    transform: scale(1.05);
}

/* Context menu (long-press en producto) */
.tpv-ctx-menu {
    position: fixed;
    z-index: 10000;
    min-width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: tpvCtxIn 0.15s ease-out;
}
@keyframes tpvCtxIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.tpv-ctx-header {
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.tpv-ctx-item {
    padding: 10px 14px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.1s;
}
.tpv-ctx-item:hover { background: var(--bg-active); }
.tpv-ctx-item:active { background: var(--accent-primary); color: white; }

/* Back button */
.tpv-back-btn {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
    border: 1px solid var(--border-primary); cursor: pointer;
    background: var(--bg-secondary); margin-bottom: var(--space-2); font-size: 0.85rem;
}
.tpv-back-btn:hover { background: var(--bg-tertiary); }

/* Ticket panel */
.tpv-ticket-header {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-primary);
    display: flex; align-items: center; justify-content: space-between;
}

/* Contenedor del ticket (header + líneas + totales + acciones) — flex column para scroll */
#tpvTicketContent {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;       /* Crítico: sin esto, flex children no respetan overflow */
    overflow: hidden;
}

.tpv-ticket-lines { flex: 1; overflow-y: auto; padding: 0; min-height: 0; }

.tpv-ticket-line {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-primary);
    display: flex; align-items: center; gap: var(--space-2); font-size: 0.85rem;
}
.tpv-ticket-line:hover { background: var(--bg-tertiary); }
.tpv-ticket-line .line-desc { flex: 1; min-width: 0; }
.tpv-ticket-line .line-desc .desc-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpv-ticket-line .line-desc .desc-detail { font-size: 0.75rem; opacity: 0.6; }

.tpv-ticket-line .line-qty { display: flex; align-items: center; gap: 2px; }
.tpv-ticket-line .line-qty button {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary); background: var(--bg-primary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-primary); font-size: 1rem;
}
.tpv-ticket-line .line-qty button:hover { background: var(--bg-tertiary); }
.tpv-ticket-line .line-qty span { min-width: 28px; text-align: center; font-weight: 600; }
.tpv-ticket-line .line-total { font-weight: 600; min-width: 65px; text-align: right; }
.tpv-ticket-line .line-actions { display: flex; gap: 2px; }
.tpv-ticket-line .line-actions button {
    width: 24px; height: 24px; border: none; background: none; cursor: pointer;
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.tpv-ticket-line .line-actions button:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Totals */
.tpv-ticket-totals { padding: var(--space-3); border-top: 2px solid var(--border-primary); }
.tpv-ticket-totals .total-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 2px 0; }
.tpv-ticket-totals .total-row.total-final { font-size: 1.3rem; font-weight: 700; padding: var(--space-2) 0; color: var(--accent-primary); }

/* Actions */
.tpv-ticket-actions {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border-primary);
    display: flex; gap: var(--space-2);
}
.tpv-ticket-actions .btn { flex: 1; height: 52px; font-size: 1rem; font-weight: 600; }

/* Empty ticket */
.tpv-ticket-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; opacity: 0.4; gap: var(--space-2);
}

/* TPV Modals */
.tpv-modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: var(--bg-overlay);
    display: flex; align-items: center; justify-content: center;
}

.tpv-modal {
    background: var(--bg-secondary); border-radius: var(--radius-lg);
    padding: var(--space-4); min-width: 400px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
}
.tpv-modal h3 { margin: 0 0 var(--space-3) 0; }

/* Payment buttons */
.tpv-pago-btn {
    display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3);
    border-radius: var(--radius-md); border: 2px solid var(--border-primary); cursor: pointer;
    background: var(--bg-primary); transition: all 0.15s; margin-bottom: var(--space-2);
}
.tpv-pago-btn:hover { border-color: var(--accent-primary); }
.tpv-pago-btn.selected { border-color: var(--accent-primary); background: var(--bg-active); }
.tpv-pago-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; color: white;
}
.tpv-pago-btn .pago-name { font-weight: 600; font-size: 0.95rem; }

/* Change display */
.tpv-cambio-display {
    text-align: center; padding: var(--space-3); margin: var(--space-3) 0;
    border-radius: var(--radius-md); background: var(--bg-tertiary);
}
.tpv-cambio-display .cambio-label { font-size: 0.85rem; opacity: 0.7; }
.tpv-cambio-display .cambio-value { font-size: 2rem; font-weight: 700; }
.tpv-cambio-display .cambio-value.positive { color: var(--accent-green); }
.tpv-cambio-display .cambio-value.negative { color: var(--accent-red); }

/* Numpad */
.tpv-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-1); margin-top: var(--space-2); }
.tpv-numpad button {
    height: 48px; border-radius: var(--radius-sm); border: 1px solid var(--border-primary);
    background: var(--bg-primary); cursor: pointer; font-size: 1.1rem; font-weight: 600;
    color: var(--text-primary);
}
.tpv-numpad button:hover { background: var(--bg-tertiary); }
.tpv-numpad button:active { transform: scale(0.95); }

/* Delivery button */
.tpv-entrega-btn {
    display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3);
    border-radius: var(--radius-md); border: 2px solid var(--border-primary); cursor: pointer;
    background: var(--bg-primary); transition: all 0.15s; width: 100%; margin-bottom: var(--space-2);
}
.tpv-entrega-btn:hover { border-color: var(--accent-primary); }

/* Legacy classes (kept for backward compat) */
.tpv-productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
    padding: var(--space-4);
}

.tpv-producto-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-secondary);
    transition: all 0.15s;
    cursor: pointer;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-2);
}
.tpv-producto-card:hover { border-color: var(--border-focus); background: var(--bg-tertiary); }

.tpv-ticket-resumen {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tpv-btn-cobrar {
    background: var(--accent-primary) !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 1.1rem;
    height: 56px;
    border-radius: var(--radius-sm);
    width: 100%;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.tpv-btn-cobrar:hover { background: var(--accent-hover) !important; transform: translateY(-1px); }

.tpv-metodo-pago-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.tpv-metodo-pago-btn:hover { border-color: var(--border-focus); background: var(--bg-active); }
.tpv-metodo-pago-btn.selected { border-color: var(--accent-primary); background: var(--bg-active); }

/* TPV Responsive — Sunmi Zepat 14" (1920x1080) */
@media (max-width: 1400px) {
    .tpv-venta-right { flex: 0 0 300px; max-width: 320px; }
    .tpv-prod-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .tpv-prod-btn { min-height: 120px; }
    .tpv-prod-btn img { width: 64px; height: 64px; }
}

/* TPV Responsive — Sunmi L3 tablet (~10") */
@media (max-width: 1100px) {
    .tpv-venta-right { flex: 0 0 270px; max-width: 280px; }
    .tpv-venta-left { padding: var(--space-2); }
    .tpv-prod-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
    .tpv-prod-btn { min-height: 100px; padding: 6px; }
    .tpv-prod-btn .prod-name { font-size: 0.75rem; }
    .tpv-prod-btn .prod-price { font-size: 0.85rem; }
    .tpv-prod-btn img { width: 56px; height: 56px; }
    .tpv-venta-header { padding: var(--space-2) var(--space-3); }
    .tpv-cat-chip { padding: 5px 12px; font-size: 0.78rem; }
}

/* Expand button — hidden on desktop, visible on mobile */
.tpv-cart-expand-btn {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 40px;
    height: 24px;
    border-radius: 12px 12px 0 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-bottom: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.tpv-cart-expand-btn:hover { background: var(--bg-tertiary); }

/* TPV Responsive — Sunmi P3R smartphone (~6") */
@media (max-width: 768px) {
    .tpv-venta-body { flex-direction: column; position: relative; }
    .tpv-venta-left { flex: none; height: 55vh; transition: height 0.3s ease; }
    .tpv-venta-right { flex: none; height: 45vh; max-width: 100%; border-left: none; border-top: 1px solid var(--border-primary); transition: height 0.3s ease; }
    .tpv-venta-left { padding: var(--space-2); }
    .tpv-prod-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 4px; }
    .tpv-prod-btn { min-height: 80px; }
    .tpv-prod-btn .prod-name { font-size: 0.7rem; -webkit-line-clamp: 1; }
    .tpv-prod-btn .prod-price { font-size: 0.78rem; }
    .tpv-prod-btn img { width: 44px; height: 44px; }
    .tpv-venta-header { padding: var(--space-1) var(--space-2); }
    .tpv-search-container { display: none; }
    .tpv-cat-chip { padding: 4px 10px; font-size: 0.75rem; }

    /* Show expand button */
    .tpv-cart-expand-btn { display: flex; top: 54.5vh; margin-top: -24px; }

    /* Expanded cart states */
    .tpv-venta-right.tpv-cart-expanded { height: 85vh; }
    .tpv-venta-left.tpv-left-collapsed { height: 15vh; }
    .tpv-left-collapsed + .tpv-cart-expand-btn { top: 14.5vh; }
}

/* Icon selector for payment methods */
.icon-selector-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-2);
    padding: var(--space-2);
}

.icon-selector-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-primary);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.icon-selector-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.icon-selector-btn.selected {
    border-color: var(--accent-primary);
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-primary);
}

/* =====================================================
   STAT CARD ACCENT BORDERS (Fabricación)
   ===================================================== */
.stat-accent-green  { border-left: 3px solid var(--accent-green); }
.stat-accent-red    { border-left: 3px solid var(--accent-red); }
.stat-accent-orange { border-left: 3px solid var(--accent-orange); }
.stat-accent-purple { border-left: 3px solid var(--accent-purple); }

/* =====================================================
   STATUS PILL EXTRA VARIANTS
   ===================================================== */
.status-pill.warning  { background: rgba(245, 158, 11, 0.10); color: #fbbf24; }
.status-pill.warning::before  { background: #f59e0b; }
.status-pill.danger   { background: rgba(239, 68, 68, 0.10); color: #f87171; }
.status-pill.danger::before   { background: #ef4444; }
.status-pill.info     { background: rgba(59, 130, 246, 0.10); color: #60a5fa; }
.status-pill.info::before     { background: #3b82f6; }
.status-pill.completed { background: rgba(34, 197, 94, 0.10); color: #4ade80; }
.status-pill.completed::before { background: #22c55e; }
.status-pill.neutral  { background: rgba(107, 114, 128, 0.10); color: #9ca3af; }
.status-pill.neutral::before  { background: #6b7280; }

/* =====================================================
   MÓDULO INFORMES — Estilos específicos
   ===================================================== */

/* B1: Píldoras de filtros en Informes */
#infContent .btn-ghost,
#infContent .btn.btn-ghost {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
    min-height: 36px;
    transition: all 0.2s;
}
#infContent .btn-ghost:hover,
#infContent .btn.btn-ghost:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}
#infContent .btn-primary,
#infContent .btn.btn-primary {
    background: var(--accent-orange);
    color: #000;
    border: 1px solid var(--accent-orange);
    border-radius: 20px;
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
    min-height: 36px;
    font-weight: 500;
}
#infContent .btn-primary:hover,
#infContent .btn.btn-primary:hover {
    background: #d4820f;
    border-color: #d4820f;
}

/* B1: Selectores y date inputs en filtros de Informes */
#infContent .form-control,
#infContent select.form-control,
#infContent input[type="date"].form-control {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    min-height: 36px;
    transition: border-color 0.2s;
}
#infContent .form-control:hover,
#infContent .form-control:focus {
    border-color: var(--accent-orange);
    outline: none;
}
#infContent .form-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
}

/* B2: Títulos de sección en Informes */
#infContent .inf-section-title {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* B2: KPI cards en Informes — consistentes */
#infContent .card.kpi-card,
#infContent .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px 24px;
}
#infContent .kpi-label,
#infContent .stat-card-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
}
#infContent .kpi-value,
#infContent .stat-card-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

/* B2: Tablas en Informes — estilo consistente */
#infContent .table thead tr,
#infContent table thead tr {
    background: var(--bg-tertiary);
}
#infContent .table thead th,
#infContent table thead th {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    letter-spacing: 0.03em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
}
#infContent .table tbody tr,
#infContent table tbody tr {
    border-bottom: 1px solid var(--border-primary);
    transition: background 0.15s;
}
#infContent .table tbody tr:hover,
#infContent table tbody tr:hover {
    background: var(--bg-tertiary);
}
#infContent .table td,
#infContent table td {
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

/* B2: Cards generales en Informes */
#infContent .card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
}

/* B3: Pestañas de navegación principal del módulo Informes */
#infTabs {
    gap: 0;
    border-bottom: 1px solid var(--border-primary);
}
#infTabs .tab {
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
    background: transparent;
}
#infTabs .tab:hover {
    color: var(--text-primary);
}
#infTabs .tab.active {
    color: var(--accent-orange);
    border-bottom-color: var(--accent-orange);
    font-weight: 500;
}

/* =====================================================
   AYUDA — Botón ? y Drawer lateral
   ===================================================== */

/* Botón ? en header */
.btn-ayuda {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border-primary);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-ayuda:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.08);
}

/* Overlay detrás del drawer */
.ayuda-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
}
.ayuda-overlay.open {
    display: block;
}

/* Drawer lateral */
.ayuda-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 30%;
    min-width: 340px;
    max-width: 480px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ayuda-drawer.open {
    transform: translateX(0);
}

/* Header del drawer */
.ayuda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}
.ayuda-titulo {
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
    margin: 0;
}
.ayuda-cerrar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.ayuda-cerrar:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Body scrollable */
.ayuda-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 32px;
}

/* Secciones */
.ayuda-seccion-titulo {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-primary);
}
.ayuda-seccion-titulo:first-child {
    margin-top: 0;
}

/* Items de la lista */
.ayuda-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 48px;
}
.ayuda-item:hover {
    background: var(--bg-tertiary);
}
.ayuda-item-titulo {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
}
.ayuda-item-arrow {
    color: var(--text-muted);
    font-size: 14px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Vista detalle */
.ayuda-detalle-volver {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    color: var(--accent-orange);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    min-height: 48px;
    transition: opacity 0.15s;
}
.ayuda-detalle-volver:hover {
    opacity: 0.8;
}
.ayuda-detalle-titulo {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: var(--text-primary);
    margin: 8px 0 4px;
}
.ayuda-detalle-modulo {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.ayuda-detalle-separador {
    height: 1px;
    background: var(--border-primary);
    margin-bottom: 20px;
}
.ayuda-paso {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    min-height: 48px;
    align-items: flex-start;
}
.ayuda-paso-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--accent-orange);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.ayuda-paso-texto {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    padding-top: 3px;
}
.ayuda-btn-video {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    padding: 12px 20px;
    min-height: 48px;
    border-radius: 8px;
    border: 1px solid var(--accent-orange);
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-orange);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.ayuda-btn-video:hover {
    background: rgba(245, 158, 11, 0.15);
}

/* Responsive: móvil y tablet → 100% ancho */
@media (max-width: 1024px) {
    .ayuda-drawer {
        width: 100%;
        min-width: unset;
        max-width: unset;
    }
}

/* =====================================================
   RESPONSIVE — MOBILE ERP (≤768px)
   Override inline styles for Sunmi L3 / smartphones
   ===================================================== */
@media (max-width: 768px) {

    /* ── Viewport meta ── */
    html { font-size: 15px; }

    /* ── Filter toolbars: stack vertically ── */
    .filter-toolbar,
    [style*="display: flex"][style*="flex-wrap: wrap"],
    [style*="display:flex"][style*="flex-wrap:wrap"] {
        flex-wrap: wrap !important;
    }

    /* ── Search inputs: remove min-width constraint ── */
    .input[style*="min-width: 200px"],
    .input[style*="min-width:200px"],
    input[style*="min-width: 200px"],
    input[style*="min-width:200px"] {
        min-width: 100% !important;
        width: 100% !important;
    }

    /* ── Select filters: full width on mobile ── */
    select.input[style*="width: 140px"],
    select.input[style*="width:140px"],
    select.input[style*="width: 150px"],
    select.input[style*="width:150px"],
    select.input[style*="width: 160px"],
    select.input[style*="width:160px"],
    select.input[style*="width: 180px"],
    select.input[style*="width:180px"],
    select.input[style*="width: 200px"],
    select.input[style*="width:200px"],
    select.input[style*="width: 120px"],
    select.input[style*="width:120px"],
    select.input[style*="width: 100px"],
    select.input[style*="width:100px"],
    input.input[style*="width: 160px"],
    input.input[style*="width:160px"],
    select.form-control[style*="min-width"],
    .input[style*="max-width:240px"],
    .input[style*="max-width: 240px"],
    .input[style*="max-width:160px"],
    .input[style*="max-width: 160px"],
    .input[style*="max-width:180px"],
    .input[style*="max-width: 180px"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* ── 4-column grids → 2 columns ── */
    .dashboard-grid[style*="repeat(4"],
    [style*="grid-template-columns:repeat(4"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ── 2-column detail grids → 1 column (fichas) ── */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── 3-column grids → 1 column ── */
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Fabricación: 7-column escandallo grid → responsive ── */
    .fab-escandallo-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    .fab-escandallo-grid .form-group { margin: 0 !important; }

    /* ── max-width containers: full width ── */
    [style*="max-width:1200px"],
    [style*="max-width: 1200px"],
    [style*="max-width:1400px"],
    [style*="max-width: 1400px"] {
        max-width: 100% !important;
        padding-left: var(--space-2) !important;
        padding-right: var(--space-2) !important;
    }

    /* ── Images in product fichas ── */
    img[style*="max-width:200px"],
    img[style*="max-width: 200px"] {
        max-width: 100% !important;
        height: auto !important;
    }

    /* ── File upload areas ── */
    .file-upload[style*="max-width:300px"],
    .file-upload[style*="max-width: 300px"] {
        max-width: 100% !important;
    }

    /* ── Modals: full width ── */
    .modal[style*="max-width:640px"],
    .modal[style*="max-width: 640px"] {
        max-width: 95vw !important;
    }

    /* ── Holding dashboard KPI grids ── */
    .holding-charts-grid,
    [style*="grid-template-columns:1fr 1fr;gap:20px"] {
        grid-template-columns: 1fr !important;
    }

    /* ── TPV venta: panel derecho stackable ── */
    .tpv-venta-body {
        flex-direction: column !important;
        position: relative;
    }
    .tpv-venta-right {
        flex: none !important;
        max-width: 100% !important;
        border-left: none !important;
        border-top: 1px solid var(--border-primary);
        max-height: none;
        height: 45vh;
        transition: height 0.3s ease;
    }
    .tpv-venta-left {
        flex: none !important;
        height: 55vh;
        min-height: auto;
        transition: height 0.3s ease;
    }
    .tpv-cart-expand-btn { display: flex; }
    .tpv-venta-right.tpv-cart-expanded { height: 85vh !important; }
    .tpv-venta-left.tpv-left-collapsed { height: 15vh !important; }

    /* ── TPV categorías: smaller cards ── */
    .tpv-cat-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    }
    .tpv-cat-btn {
        min-height: 60px !important;
        padding: var(--space-2) !important;
    }

    /* ── TPV productos: smaller buttons ── */
    .tpv-prod-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    }
    .tpv-prod-btn {
        min-height: 70px !important;
    }

    /* ── KDS grid ── */
    [style*="minmax(300px"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Audit log detail grid ── */
    [style*="grid-template-columns:repeat(auto-fit,minmax(180px,1fr))"] {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    }

    /* ── Pagination: compact ── */
    .card-footer[style*="display:flex"] {
        flex-wrap: wrap !important;
        gap: var(--space-2) !important;
    }

    /* ── Header: hide time, compact user menu ── */
    .header-time { display: none; }
    .user-name { display: none; }
    .user-menu { padding: 3px; }

    /* ── Holding header: stack on mobile ── */
    .holding-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: var(--space-3) !important;
    }

    /* ── Config logo ── */
    img[style*="max-width:180px"],
    img[style*="max-width: 180px"],
    img[style*="max-height:80px"],
    img[style*="max-height: 80px"] {
        max-width: 120px !important;
        max-height: 60px !important;
    }

    /* ── RRHH employee grid ── */
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Informes KPI grid ── */
    [style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ── Flex rows with many children: wrap ── */
    [style*="display:flex"][style*="gap:var(--space-3)"],
    [style*="display: flex"][style*="gap: var(--space-3)"] {
        flex-wrap: wrap !important;
    }

    /* ── Action buttons in fichas: stack ── */
    [style*="display:flex"][style*="gap:var(--space-3)"][style*="margin-top"] {
        flex-direction: column !important;
    }
    [style*="display:flex"][style*="gap:var(--space-3)"][style*="margin-top"] .btn {
        width: 100% !important;
    }

    /* ── Tables: smaller text ── */
    .table-container {
        font-size: 0.7rem;
    }
    .table-container th,
    .table-container td {
        padding: 0.35rem 0.4rem;
        font-size: 0.7rem;
    }

    /* ── Label checkboxes compact ── */
    label[style*="display:flex"][style*="gap:6px"],
    label[style*="display: flex"][style*="gap: 6px"],
    label[style*="display:flex"][style*="gap:4px"],
    label[style*="display: flex"][style*="gap: 4px"] {
        font-size: 0.75rem !important;
    }

    /* ── TPV modals: force responsive width ── */
    .tpv-modal[style*="min-width:480px"],
    .tpv-modal[style*="min-width: 480px"],
    .tpv-modal[style*="min-width:450px"],
    .tpv-modal[style*="min-width: 450px"],
    .tpv-modal[style*="min-width:400px"],
    .tpv-modal[style*="min-width: 400px"],
    .tpv-modal[style*="min-width:380px"],
    .tpv-modal[style*="min-width: 380px"] {
        min-width: unset !important;
        max-width: 95vw !important;
        width: 95vw !important;
    }

    /* ── Grids with minmax(340px+): force single column ── */
    [style*="minmax(340px"],
    [style*="minmax(380px"],
    [style*="minmax(400px"],
    [style*="minmax(350px"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Tables: remove large min-width constraints ── */
    table[style*="min-width:900px"],
    table[style*="min-width: 900px"],
    table[style*="min-width:800px"],
    table[style*="min-width: 800px"],
    table[style*="min-width:700px"],
    table[style*="min-width: 700px"],
    .table[style*="min-width:900px"],
    .table[style*="min-width: 900px"],
    .table[style*="min-width:800px"],
    .table[style*="min-width: 800px"] {
        min-width: unset !important;
    }
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Modals 700-800px: safe width ── */
    .modal[style*="max-width:700px"],
    .modal[style*="max-width: 700px"],
    .modal[style*="max-width:800px"],
    .modal[style*="max-width: 800px"],
    .modal[style*="max-width:900px"],
    .modal[style*="max-width: 900px"] {
        max-width: calc(100vw - 16px) !important;
    }

    /* ── Fabricación: fixed-width column grids ── */
    [style*="grid-template-columns:100px 1fr 60px"],
    [style*="grid-template-columns: 100px 1fr 60px"] {
        grid-template-columns: 1fr !important;
    }
}

/* =====================================================
   RESPONSIVE — SMALL DEVICES (≤480px) — Sunmi L3 portrait
   ===================================================== */
@media (max-width: 480px) {

    /* ── Dashboard: 1 column for very small screens ── */
    .dashboard-grid,
    .dashboard-grid[style*="repeat(4"],
    .dashboard-grid[style*="repeat(2"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Empresas grid: 1 col ── */
    .empresas-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── TPV: even smaller ── */
    .tpv-cat-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    }
    .tpv-prod-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    }

    /* ── Holding tabs: horizontal scroll ── */
    #holdingTabs {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }
    #holdingTabs .tab {
        flex-shrink: 0 !important;
        font-size: 0.7rem !important;
    }

    /* ── Stat cards: even more compact ── */
    .stat-card {
        padding: var(--space-2) !important;
    }
    .stat-card-value {
        font-size: 1.25rem !important;
    }

    /* ── Content area: less padding ── */
    .content {
        padding: var(--space-2) !important;
    }

    /* ── Module header: compact ── */
    .module-header {
        gap: var(--space-2) !important;
    }
    .module-title {
        font-size: 0.95rem !important;
    }
    .module-actions .btn {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* ── Form rows → single column ── */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* ── Fabricación grid → single column ── */
    [style*="grid-template-columns:120px 1fr 80px"] {
        grid-template-columns: 1fr !important;
    }
}

/* =====================================================
   PRINT
   ===================================================== */
@media print {
    .sidebar, .header, .toast-container, .modal-overlay, .ayuda-drawer, .ayuda-overlay { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0; overflow: visible; }
    body { background: white; color: black; }
}
