/* ============================================
   SalesChampion - PWA Mobile-First Styles
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   App Container
   ============================================ */

.app-container {
    max-width: 480px;
    margin: 0 auto;
    background: var(--white);
    min-height: 100vh;
    position: relative;
    padding-bottom: 70px;
}

/* ============================================
   Header
   ============================================ */

.app-header {
    background: var(--primary);
    color: var(--white);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header .logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.header-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.header-actions {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 12px;
}

.header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--white);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ============================================
   Tab Bar (Bottom Navigation)
   ============================================ */

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray-200);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 8px;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
    gap: 4px;
}

.tab-item svg {
    width: 24px;
    height: 24px;
}

.tab-item.active {
    color: var(--primary);
}

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

/* ============================================
   Main Content
   ============================================ */

.main-content {
    padding: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 20px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ============================================
   Stats Grid
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Lists
   ============================================ */

.list {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover, .list-item:active {
    background: var(--gray-50);
}

.list-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.list-item-icon svg {
    width: 22px;
    height: 22px;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

.list-item-action {
    color: var(--gray-400);
    margin-left: 8px;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 17px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Forms
   ============================================ */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ============================================
   Alerts / Flash Messages
   ============================================ */

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ============================================
   Badges
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--white);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-gray {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* ============================================
   Tables (Mobile Friendly)
   ============================================ */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 14px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* ============================================
   Search Box
   ============================================ */

.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px;
    background: var(--white);
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gray-400);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--gray-50);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    display: none;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ============================================
   Visita / Check-in Styles
   ============================================ */

.visita-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.visita-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.visita-card p {
    font-size: 14px;
    opacity: 0.9;
}

.visita-timer {
    font-size: 32px;
    font-weight: 700;
    margin-top: 12px;
}

.camera-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 16px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-900);
    aspect-ratio: 4/3;
}

.camera-container video, .camera-container canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.capture-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--danger);
    border: 4px solid var(--white);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    margin: 0 auto;
    display: block;
}

/* ============================================
   Pedido / Cart Item
   ============================================ */

.pedido-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.pedido-item-info {
    flex: 1;
}

.pedido-item-title {
    font-weight: 600;
    font-size: 14px;
}

.pedido-item-meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.pedido-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pedido-item-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 8px;
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   Invitacion Link
   ============================================ */

.invite-link {
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    margin: 8px 0;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   Login Page
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo-img {
    width: 120px;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    margin-bottom: 8px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--gray-900);
    margin-top: 12px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 14px;
}

/* ============================================
   Utilities
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.hidden { display: none !important; }

/* ============================================
   Loading Spinner
   ============================================ */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* ============================================
   Responsive / Desktop
   ============================================ */

@media (min-width: 768px) {
    .app-container {
        box-shadow: var(--shadow-lg);
        margin: 20px auto;
        border-radius: var(--radius);
        min-height: calc(100vh - 40px);
    }

    .tab-bar {
        border-radius: 0 0 var(--radius) var(--radius);
    }
}

/* ============================================
   PWA - Standalone Mode
   ============================================ */

@media (display-mode: standalone) {
    .app-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}

/* ============================================
   Product Table
   ============================================ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-products {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-products thead {
    background: var(--primary);
    color: var(--white);
}

.table-products th {
    padding: 10px 6px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.table-products td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

.table-products tbody tr:hover {
    background: var(--gray-50);
}

.input-mini {
    width: 60px;
    padding: 6px 4px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
}

.input-mini:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.btn-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--success);
    color: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add:hover {
    background: #059669;
}

.btn-add:active {
    transform: scale(0.95);
}

.btn-add:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

/* Producto ya agregado a la lista */
.producto-agregado {
    background: #d1fae5 !important;
}

.producto-agregado input:disabled {
    background: #a7f3d0;
    color: var(--gray-700);
}

.badge-agregado {
    display: inline-block;
    background: var(--success);
    color: var(--white);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Producto info en tabla */
.producto-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.producto-codigo {
    font-size: 14px;
    color: var(--gray-800);
}

.producto-precio {
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
}

.producto-nombre {
    font-size: 11px;
    color: var(--gray-500);
    line-height: 1.3;
}

.producto-stock {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}

.stock-badge {
    font-size: 10px;
    font-weight: 600;
    font-family: monospace;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
}

.stock-badge.ctx {
    background: #dbeafe;
    color: #1e40af;
}

.stock-badge.gye {
    background: #d1fae5;
    color: #065f46;
}

.stock-badge.uio {
    background: #fef3c7;
    color: #92400e;
}

.stock-badge.cmp {
    background: #ede9fe;
    color: #5b21b6;
}

.stock-badge.sin-stock {
    background: #fee2e2;
    color: #991b1b;
}

/* Visita info en Lista */
.visita-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.visita-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.visita-info-item svg {
    color: var(--primary);
    flex-shrink: 0;
}

.visita-info-item > div {
    display: flex;
    flex-direction: column;
}

.visita-info-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.visita-info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.visita-notas {
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.visita-notas-text {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 4px;
    font-style: italic;
}

/* Visita History Items */
.visita-history-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.visita-history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.visita-history-cliente {
    display: flex;
    flex-direction: column;
}

.visita-history-cliente strong {
    font-size: 14px;
    color: var(--gray-800);
}

.visita-history-times {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.visita-history-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray-600);
}

.visita-history-time svg {
    color: var(--primary);
}

.visita-history-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   Visit Tabbar & Panels
   ============================================ */

.visit-tabbar .tab-item {
    position: relative;
}

.tabbar-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(18px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-item.active .tabbar-badge {
    background: var(--danger);
}

.tab-panel {
    display: none;
    padding-bottom: 80px; /* Espacio para el tabbar */
}

.tab-panel.active {
    display: block;
}

.empty-state-mini {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.empty-state-mini svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-mini p {
    font-size: 14px;
}

.flex-1 {
    flex: 1;
}

/* ============================================
   Galería de Fotos de Visita
   ============================================ */

.camera-container-mini {
    width: 100%;
    max-width: 200px;
    margin: 0 auto 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-900);
    aspect-ratio: 4/3;
}

.camera-container-mini video,
.camera-container-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.capture-btn-sm {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    background: white;
    cursor: pointer;
    position: relative;
}

.capture-btn-sm::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
}

.capture-btn-sm:active::after {
    background: var(--primary-dark);
}

.galeria-fotos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.foto-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
}

.foto-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.foto-item-info {
    padding: 8px;
}

.foto-tipo {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
    background: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
}

.foto-fecha {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: 6px;
}

.foto-desc {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 4px;
    line-height: 1.3;
}

.foto-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.foto-delete svg {
    stroke: white;
}

.foto-delete:active {
    background: var(--danger);
}

/* ============================================
   Modal de Info / Versión
   ============================================ */
/* Nota: .modal-overlay base ya definido arriba, solo extendemos .modal-content */

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-sm {
    max-width: 300px;
    text-align: center;
}

.version-info {
    background: var(--gray-100);
    padding: 12px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.version-label {
    color: var(--gray-500);
    font-size: 14px;
}

.version-number {
    font-weight: 600;
    color: var(--primary);
    font-size: 18px;
}

.update-status {
    margin-top: 12px;
    font-size: 13px;
    min-height: 20px;
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

/* ============================================
   Promo Access Card (Admin Dashboard)
   ============================================ */

.promo-access-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: var(--radius);
    margin: 16px 0;
    text-decoration: none;
    box-shadow: var(--shadow-md);
}

.promo-access-card:active {
    transform: scale(0.98);
}

.promo-access-icon {
    background: rgba(255,255,255,0.2);
    padding: 10px;
    border-radius: 10px;
}

.promo-access-icon svg {
    stroke: white;
}

.promo-access-text {
    flex: 1;
}

.promo-access-text strong {
    display: block;
    font-size: 16px;
}

.promo-access-text span {
    font-size: 12px;
    opacity: 0.9;
}

/* ============================================
   Badge Info (for promos)
   ============================================ */

.badge-info {
    background: #3b82f6;
    color: white;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

/* ============================================
   Dashboard Ventas - Stats Grid 4 cols
   ============================================ */

.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stats-grid-4 .stat-card {
    overflow: hidden;
}

.stats-grid-4 .stat-value {
    font-size: 22px;
    word-break: break-word;
}

@media (min-width: 420px) {
    .stats-grid-4 .stat-value {
        font-size: 26px;
    }
}

@media (min-width: 500px) {
    .stats-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .stats-grid-4 .stat-value {
        font-size: 20px;
    }
}

@media (min-width: 600px) {
    .stats-grid-4 .stat-value {
        font-size: 24px;
    }
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.stat-icon-blue { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.stat-icon-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.stat-icon-green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon-gold { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.stat-card-highlight {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    overflow: hidden;
}

.stat-card-highlight .stat-value {
    color: #92400e;
    font-size: 16px;
    white-space: nowrap;
}

@media (min-width: 420px) {
    .stat-card-highlight .stat-value {
        font-size: 18px;
    }
}

@media (min-width: 500px) {
    .stat-card-highlight .stat-value {
        font-size: 16px;
    }
}

@media (min-width: 600px) {
    .stat-card-highlight .stat-value {
        font-size: 20px;
    }
}

/* ============================================
   Ranking List
   ============================================ */

.ranking-list {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    gap: 12px;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-position {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.ranking-position.top-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.ranking-position.top-2 {
    background: linear-gradient(135deg, #d1d5db, #9ca3af);
    color: white;
}

.ranking-position.top-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.ranking-bar {
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.ranking-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ranking-bar-team .ranking-bar-fill {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.ranking-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--success);
    white-space: nowrap;
}

/* Table rank badges */
.table-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 12px;
    font-weight: 600;
}

.table-rank.rank-1 {
    background: #fef3c7;
    color: #92400e;
}

.table-rank.rank-2 {
    background: #e5e7eb;
    color: #374151;
}

.table-rank.rank-3 {
    background: #fed7aa;
    color: #9a3412;
}

/* ============================================
   Inner Tabs (tabs internos arriba de página)
   ============================================ */

.inner-tabs {
    display: flex;
    background: var(--white);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.inner-tabs .inner-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    text-decoration: none !important;
    transition: all 0.2s;
    background: transparent;
}

a.inner-tab {
    text-decoration: none !important;
}

.inner-tabs .inner-tab:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.inner-tabs .inner-tab.active {
    background: var(--primary);
    color: var(--white);
}

.inner-tabs .inner-tab svg {
    flex-shrink: 0;
}

/* ============================================
   Barcode Scanner Modal
   ============================================ */

#scanner-container {
    width: 100%;
    min-height: 300px;
}

#scanner-container video {
    width: 100% !important;
    border-radius: 0;
}

#modalEscaner .modal-content {
    overflow: hidden;
    border-radius: var(--radius);
}

#modalEscaner .modal-header {
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ============================================
   Inputs Stack (Inv/Rep/PVP en columna)
   ============================================ */

.inputs-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inputs-stack .input-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.inputs-stack .input-row label {
    font-size: 10px;
    color: var(--gray-500);
    width: 28px;
    text-align: right;
}

.inputs-stack .input-mini {
    width: 55px;
    padding: 4px 6px;
    font-size: 13px;
}

/* ============================================
   Form Row (inputs lado a lado)
   ============================================ */

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

/* ============================================
   Matrices de Presencia de Marcas
   ============================================ */

.matriz-card {
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.matriz-card.matriz-completa {
    border-color: var(--success);
}

.matriz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    background: var(--gray-50);
    transition: background 0.2s;
}

.matriz-header:hover {
    background: var(--gray-100);
}

.matriz-completa .matriz-header {
    background: #d1fae5;
}

.matriz-titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-800);
}

.matriz-chevron {
    transition: transform 0.2s;
    color: var(--gray-500);
}

.matriz-progreso {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

.matriz-progreso svg {
    color: var(--success);
}

.matriz-contenido {
    border-top: 1px solid var(--gray-200);
}

.matriz-tabla-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matriz-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: max-content;
}

.matriz-tabla thead th {
    background: var(--primary);
    color: var(--white);
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.matriz-tabla thead th.marca-propia {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.matriz-tabla thead th:first-child {
    background: var(--gray-700);
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 3;
}

.matriz-th-fija {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-700);
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 1;
}

.matriz-tabla td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--gray-100);
    border-right: 1px solid var(--gray-100);
}

.matriz-tabla td.celda-propia {
    background: rgba(16, 185, 129, 0.08);
}

/* Input de cantidad para matriz */
.matriz-cantidad {
    width: 50px;
    height: 36px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--white);
    color: var(--gray-800);
    transition: all 0.15s;
    -moz-appearance: textfield;
}

.matriz-cantidad::-webkit-outer-spin-button,
.matriz-cantidad::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.matriz-cantidad:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.matriz-cantidad:not(:placeholder-shown) {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.08);
}

.matriz-cantidad.guardado {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
}

.matriz-cantidad::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

/* Badge mini para marca propia */
.badge-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 9px;
    font-weight: 700;
    background: rgba(255,255,255,0.3);
    color: white;
    border-radius: 4px;
    margin-left: 4px;
}

/* Badge warning para el tabbar */
.tabbar-badge-warning {
    background: var(--warning);
}

/* Matrix Preview en Admin */
.matriz-preview-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matriz-preview {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.matriz-preview th,
.matriz-preview td {
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    text-align: center;
}

.matriz-preview thead th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.matriz-preview thead th.marca-propia {
    background: #d1fae5;
    color: #065f46;
}

.matriz-preview tbody th {
    background: var(--gray-50);
    text-align: left;
    font-weight: 600;
}

.matriz-preview td.celda-propia {
    background: rgba(16, 185, 129, 0.08);
}

.checkbox-preview {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 4px;
    margin: 0 auto;
}
