/* ============================================================
   La Malquerida — Gestión de Albaranes · Stitch Pro Design v3
   ============================================================
   Midnight Navy dark mode, #ec5b13 primary, Public Sans font
   Inspired by Stitch Pro designs
   ============================================================ */

/* Mobile-only: hidden on desktop, visible on phones */
.mobile-only { display: none !important; }
/* === Design Tokens === */
:root {
    --primary: #ec5b13;
    --primary-soft: rgba(236, 91, 19, 0.1);
    --primary-glow: rgba(236, 91, 19, 0.2);
    --bg-base: #0a0d12;
    --bg-card: #131924;
    --bg-border: #2a3549;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(30, 41, 59, 0.6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-soft: rgba(59, 130, 246, 0.1);
    --purple: #8b5cf6;
    --purple-soft: rgba(139, 92, 246, 0.1);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.1);
    --sem-green: #22c55e;
    --sem-yellow: #f59e0b;
    --sem-red: #ef4444;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --font: 'Public Sans', 'Inter', -apple-system, sans-serif;
    --transition: 0.2s ease;
    --shadow-depth: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2), inset 0 1px 1px rgba(255,255,255,0.05);
}

/* === Light Theme === */
[data-theme="light"] {
    --primary: #ec5b13;
    --primary-soft: rgba(236, 91, 19, 0.08);
    --primary-glow: rgba(236, 91, 19, 0.15);
    --bg-base: #f8f6f4;
    --bg-card: #ffffff;
    --bg-border: #d1cdc8;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-input: #ebe8e4;
    --bg-secondary: #ebe8e4;
    --bg-tertiary: #f2f0ed;
    --text-primary: #1a1a1a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.1);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, 0.08);
    --purple: #7c3aed;
    --purple-soft: rgba(124, 58, 237, 0.08);
    --amber: #d97706;
    --amber-soft: rgba(217, 119, 6, 0.08);
    --sem-green: #16a34a;
    --sem-yellow: #d97706;
    --sem-red: #dc2626;
    --shadow-depth: 0 1px 3px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);

    color-scheme: light;
}

/* Light theme overrides for hardcoded colors */
[data-theme="light"] .sidebar {
    background: #f3f1ee;
    border-right: 1px solid #d1cdc8;
}
[data-theme="light"] .sidebar-link:hover {
    background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .sidebar-user {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .sidebar-user-avatar {
    background: var(--primary-soft);
}
[data-theme="light"] .sidebar-brand-text h1,
[data-theme="light"] .sidebar-user-name,
[data-theme="light"] .content-header-title,
[data-theme="light"] .extract-header-title,
[data-theme="light"] .card-title,
[data-theme="light"] .stat-value,
[data-theme="light"] .table-cell-bold,
[data-theme="light"] .cfg-header-left,
[data-theme="light"] .cfg-user-name,
[data-theme="light"] .cfg-role-item strong,
[data-theme="light"] .login-logo,
[data-theme="light"] .albaran-sep-title {
    color: var(--text-primary);
}
[data-theme="light"] .content-header {
    background: #fff;
    border-bottom-color: var(--bg-border);
}
[data-theme="light"] .mobile-header {
    background: rgba(248, 246, 244, 0.92);
    backdrop-filter: blur(16px);
}
[data-theme="light"] .actions-bar {
    background: rgba(248, 246, 244, 0.95);
    backdrop-filter: blur(16px);
}
[data-theme="light"] .accordion-header:hover,
[data-theme="light"] .cfg-header:hover,
[data-theme="light"] .cfg-prov-header:hover,
[data-theme="light"] .cfg-user-card:hover {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .accordion-count,
[data-theme="light"] .filter-tab-count {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .data-table thead tr {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .data-table td {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .data-table tbody tr:hover {
    background: rgba(236, 91, 19, 0.03);
}
[data-theme="light"] .card-header {
    background: rgba(0, 0, 0, 0.04);
}
/* cfg items → override moved below with border */
[data-theme="light"] .badge-neutral {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .product-nota {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .bottom-nav {
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .date-input {
    color-scheme: light;
}
[data-theme="light"] .login-container {
    background: radial-gradient(ellipse at top, rgba(236, 91, 19, 0.06), transparent 60%);
}
[data-theme="light"] .form-group input:focus,
[data-theme="light"] .cfg-input:focus {
    background: rgba(236, 91, 19, 0.03);
}
[data-theme="light"] .ficha-lookup-found {
    background: rgba(22, 163, 74, 0.04);
    border-color: rgba(22, 163, 74, 0.15);
}
[data-theme="light"] .ficha-lookup-empty {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .ficha-img-placeholder {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .row-new {
    background: rgba(236, 91, 19, 0.03);
}
[data-theme="light"] .filter-toggle:has(input:checked) {
    background: rgba(217, 119, 6, 0.08);
}
[data-theme="light"] .filter-tab.active .filter-tab-count {
    background: var(--primary-soft);
}
[data-theme="light"] .config-toast {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .btn-ghost {
    border-color: #c4c0bb;
    color: #475569;
}
[data-theme="light"] .btn-ghost:hover {
    border-color: #9ca3af;
    background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .product-detail-label {
    color: #6b7280;
}
[data-theme="light"] .product-detail-value {
    color: #1e293b;
}
[data-theme="light"] .albaran-separator {
    background: rgba(0, 0, 0, 0.04);
    border-color: #d1cdc8;
}
[data-theme="light"] .cfg-prov-item,
[data-theme="light"] .cfg-user-card,
[data-theme="light"] .cfg-new-user,
[data-theme="light"] .cfg-role-legend {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .stat-card {
    border: 1px solid #d1cdc8;
}
[data-theme="light"] .card {
    border: 1px solid rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .product-card {
    border-color: #d1cdc8;
}
[data-theme="light"] .sidebar-link.active {
    background: rgba(236, 91, 19, 0.08);
}
[data-theme="light"] .sidebar-section-label {
    color: #6b7280;
}

/* Confirm Modal */
#confirm-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px);
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: confirmFadeIn 0.15s ease;
}
#confirm-modal[style*="display: none"],
#confirm-modal[style*="display:none"] {
    display: none !important;
}
@keyframes confirmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.confirm-box {
    background: var(--bg-card) !important;
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
}
.confirm-msg {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
    white-space: pre-line;
}
.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle-btn .material-symbols-outlined {
    font-size: 20px;
    transition: transform 0.3s ease;
}

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* === Custom Scrollbar === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* === Views === */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   LOGIN
   ========================================================= */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at top, var(--primary-soft), transparent 60%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 36px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-depth);
}
.login-logo {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}
.login-logo-sub {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 4px;
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 32px;
}
.form-group {
    margin-bottom: 16px;
    text-align: left;
}
.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color var(--transition), background var(--transition);
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(236, 91, 19, 0.05);
}
.form-group input::placeholder { color: var(--text-muted); }
.error-msg {
    margin-top: 12px;
    padding: 10px;
    background: var(--danger-soft);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.85rem;
}

/* =========================================================
   APP LAYOUT (Sidebar + Content)
   ========================================================= */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar (Desktop) === */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--bg-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-depth);
    z-index: 20;
}
.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
}
.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.sidebar-brand-text h1 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}
.sidebar-brand-text span {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}
.sidebar-section-label {
    padding: 0 12px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    margin-top: 16px;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}
.sidebar-link:hover {
    background: rgba(30, 41, 59, 0.5);
    color: var(--text-primary);
}
.sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(236, 91, 19, 0.2);
    font-weight: 600;
}
.sidebar-link .material-symbols-outlined {
    font-size: 22px;
}
.sidebar-link-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    min-width: 22px;
    text-align: center;
}
.sidebar-bottom {
    padding: 16px;
    border-top: 1px solid var(--bg-border);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: rgba(30, 41, 59, 0.3);
}
.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--primary-soft);
    border: 2px solid rgba(236, 91, 19, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
}
.sidebar-user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 10px;
    color: var(--primary);
    font-weight: 500;
}

/* Selector de empresa */
.sidebar-empresa-selector {
    position: relative;
    padding: 0 16px;
    margin-bottom: 8px;
}
.empresa-select {
    width: 100%;
    padding: 8px 32px 8px 12px;
    background: rgba(255, 120, 50, 0.08);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ff7832' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}
.empresa-select:hover {
    background: rgba(255, 120, 50, 0.15);
    box-shadow: 0 0 0 3px rgba(255, 120, 50, 0.1);
}
.empresa-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 120, 50, 0.2);
}
.empresa-select option {
    background: var(--bg-card, #1a1d21);
    color: var(--text, #e0e0e0);
    padding: 8px;
}
.sidebar-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}
.sidebar-logout:hover { color: var(--danger); }

/* === Main Content Area === */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* === Content Header === */
.content-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-border);
    flex-shrink: 0;
    z-index: 10;
}
.content-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}
.content-header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}
.content-header-search {
    position: relative;
    max-width: 400px;
    width: 100%;
}
.content-header-search .material-symbols-outlined {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
}
.content-header-search input {
    width: 100%;
    padding: 8px 16px 8px 40px;
    background: var(--bg-input);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: all var(--transition);
}
.content-header-search input:focus {
    outline: none;
    border-color: var(--primary);
}
.content-header-search input::placeholder { color: var(--text-muted); }
.content-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.content-header-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--bg-border);
    background: var(--bg-input);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.header-icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* === Content Body (Scrollable) === */
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--bg-base);
}
.content-body-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* =========================================================
   BOTTOM SHEET NAVIGATION (Mobile)
   ========================================================= */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--bg-card);
    border-top: 1px solid var(--bg-border);
    border-radius: 20px 20px 0 0;
    padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.3);
}
.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 12px;
    border: none;
    background: none;
    font-family: var(--font);
    transition: all var(--transition);
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item .material-symbols-outlined { font-size: 24px; }
.bottom-nav-item span:last-child {
    font-size: 10px;
    font-weight: 600;
}
.bottom-nav-center {
    margin-top: -24px;
}
.bottom-nav-fab {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--primary-glow);
    transition: all var(--transition);
}
.bottom-nav-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--primary-glow); }
.bottom-nav-fab .material-symbols-outlined { font-size: 28px; }

/* === Mobile Header === */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(10, 13, 18, 0.85);
    backdrop-filter: blur(16px);
    padding: 16px;
}
.mobile-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mobile-header-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.mobile-header-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}
.mobile-header-brand p {
    font-size: 11px;
    color: var(--text-muted);
}
.mobile-header-actions {
    display: flex;
    gap: 8px;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--bg-border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-hover); }
.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 20px var(--primary-glow); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239,68,68,0.4); }
.btn-danger:hover { background: var(--danger-soft); }

/* =========================================================
   KPI / STAT CARDS
   ========================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-depth);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stat-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card-icon.primary { background: var(--primary-soft); color: var(--primary); }
.stat-card-icon.blue { background: var(--info-soft); color: var(--info); }
.stat-card-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-card-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-card-trend {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 2px;
}
.stat-card-trend.up { background: var(--success-soft); color: var(--success); }
.stat-card-trend.down { background: var(--danger-soft); color: var(--danger); }
.stat-card-trend.stable { background: rgba(71, 85, 105, 0.2); color: var(--text-secondary); }
.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    line-height: 1;
}

/* Dashboard open card sections */
.dash-section { margin-bottom: 0; }
.dash-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .dash-charts-grid { grid-template-columns: 1fr; }
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-border);
    background: rgba(30, 41, 59, 0.15);
}
.card-title {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
}
.card-body {
    padding: 16px 20px;
}
.section-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 20px 0 12px;
}
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* =========================================================
   CARDS (Universal)
   ========================================================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-depth);
    overflow: hidden;
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--bg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}
.card-body { padding: 24px; }

/* =========================================================
   EMAIL LIST
   ========================================================= */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.email-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-depth);
}
.email-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}
.email-card.processed { opacity: 0.5; }
.email-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.email-icon.pending { background: var(--warning-soft); }
.email-icon.processed { background: var(--success-soft); }
.email-icon.rejected { background: var(--danger-soft); }
.email-icon.new, .email-icon.listo, .email-icon.nuevo { background: var(--primary-soft); }
.email-icon.aceptado { background: var(--success-soft); color: var(--success); }
.email-icon.anulado { background: var(--danger-soft); color: var(--danger); opacity: 0.6; }
.email-icon.pendiente { background: var(--warning-soft); color: var(--warning); }
.email-info { flex: 1; min-width: 0; }
.email-from {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-subject {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-meta { text-align: right; flex-shrink: 0; }
.email-date { font-size: 0.7rem; color: var(--text-muted); }
.email-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.email-badge.pending { background: var(--warning-soft); color: var(--warning); }
.email-badge.processed, .email-badge.procesado { background: var(--success-soft); color: var(--success); }
.email-badge.new, .email-badge.listo, .email-badge.nuevo { background: var(--primary-soft); color: var(--primary); }
.email-badge.rechazado { background: var(--danger-soft); color: var(--danger); }

/* =========================================================
   PROVEEDOR BAR
   ========================================================= */
.proveedor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin: 8px 0;
    background: var(--primary-soft);
    border: 1px solid rgba(236, 91, 19, 0.15);
    border-radius: var(--radius-lg);
    gap: 10px;
}
.proveedor-bar-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proveedor-bar-label { font-size: 0.8rem; color: var(--text-muted); }
.proveedor-bar-name { font-size: 0.9rem; color: var(--primary); font-weight: 600; }
.proveedor-bar-source { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.proveedor-bar-actions { display: flex; align-items: center; gap: 8px; }
.proveedor-select { min-width: 180px; }

/* =========================================================
   ACCORDION
   ========================================================= */
.accordion { margin-bottom: 6px; border-radius: var(--radius-lg); overflow: hidden; }
.accordion-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; cursor: pointer; user-select: none;
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg); transition: background 0.2s;
}
.accordion-header:hover { background: rgba(30, 41, 59, 0.8); }
.accordion-chevron { transition: transform 0.25s; font-size: 0.7rem; color: var(--text-muted); }
.accordion.open .accordion-chevron { transform: rotate(90deg); }
.accordion-title { font-weight: 600; font-size: 0.85rem; flex: 1; }
.accordion-count { font-size: 0.75rem; color: var(--text-muted); background: rgba(30, 41, 59, 0.5); padding: 2px 8px; border-radius: 10px; }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.accordion.open .accordion-body { max-height: 5000px; transition: max-height 0.5s ease-in; }
.accordion-body-inner { padding: 4px 0; }

/* Accordion accent colors */
.accordion-header.accent-green { border-left: 3px solid var(--success); }
.accordion-header.accent-red { border-left: 3px solid var(--danger); }
.accordion-header.accent-blue { border-left: 3px solid var(--primary); }
.accordion-header.accent-yellow { border-left: 3px solid var(--warning); }

/* =========================================================
   DATE FILTER BAR
   ========================================================= */
.date-filter-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; margin-bottom: 12px;
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg); flex-wrap: wrap;
}
.date-btn {
    padding: 4px 12px; border: 1px solid var(--bg-border);
    border-radius: 16px; background: transparent; color: var(--text-secondary);
    font-size: 0.78rem; cursor: pointer; transition: all 0.2s; font-weight: 500;
    font-family: var(--font);
}
.date-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.date-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.date-filter-sep { color: var(--text-muted); font-size: 0.8rem; margin: 0 2px; }
.date-input {
    padding: 3px 8px; border: 1px solid var(--bg-border); border-radius: 8px;
    background: var(--bg-input); color: var(--text-primary); font-size: 0.78rem;
    font-family: var(--font); color-scheme: dark;
}

/* =========================================================
   EXTRACT HEADER + STATUS
   ========================================================= */
.extract-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bg-border);
}
.extract-header .btn {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.extract-header-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    margin: 0;
}
.proveedor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.proveedor-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.proveedor-bar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.proveedor-bar-name {
    font-size: 0.9rem;
    color: var(--primary);
}
.proveedor-bar-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}
.proveedor-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.proveedor-select {
    max-width: 200px;
}
.albaran-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--primary-soft);
    border: 1px solid rgba(236, 91, 19, 0.2);
    border-radius: var(--radius-lg);
    margin: 16px 0 8px;
    font-size: 0.85rem;
}
.albaran-sep-icon { font-size: 1.1rem; }
.albaran-sep-title { font-weight: 700; color: white; }
.albaran-sep-date { color: var(--text-secondary); font-size: 0.8rem; }
.albaran-sep-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}
.extract-status {
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-depth);
}
.extract-status.loading {
    display: flex;
    align-items: center;
    gap: 10px;
}
.extract-status.loading::before {
    content: '';
    width: 16px; height: 16px;
    border: 1.5px solid var(--bg-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    flex-shrink: 0;
    opacity: 0.7;
}
@keyframes spin { to { transform: rotate(360deg); } }
.extract-timer { color: var(--text-muted); font-size: 0.8em; margin-left: 4px; }

/* Progress bar animado de extracción */
.extract-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85em;
}
.extract-progress-label { font-weight: 500; }
.extract-emoji {
    display: inline-block;
    animation: emojiBounce 0.6s ease infinite alternate;
}
@keyframes emojiBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-3px); }
}
.extract-progress-time { color: var(--text-muted); font-size: 0.85em; }
.extract-progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-secondary);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}
.extract-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--primary), #f59e0b, #10b981);
    transition: width 0.3s ease;
    position: relative;
}
.extract-progress-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}
.extract-progress-msg {
    font-size: 0.78em;
    color: var(--primary);
    font-style: italic;
    transition: opacity 0.3s;
}

/* Botones de la card de producto */
.product-card-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.product-instrucciones-btn {
    color: var(--text-muted) !important;
    font-size: 0.75em !important;
}
.product-instrucciones-btn:hover {
    color: var(--primary) !important;
}

/* Panel inline de instrucciones / chat */
.instrucciones-inline {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}
.instrucciones-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.06);
    border-bottom: 1px solid var(--bg-border);
    font-size: 0.85em;
    flex-shrink: 0;
}
.instrucciones-context {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 14px;
    font-size: 0.8em;
    background: rgba(139, 92, 246, 0.03);
    border-bottom: 1px solid var(--bg-border);
    flex-shrink: 0;
}
.instrucciones-context-label { color: var(--text-muted); }
.instrucciones-context-data { color: var(--text-secondary); font-size: 0.9em; }
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 80px;
}
.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.82em;
    line-height: 1.5;
    max-width: 95%;
    min-width: 0;
    word-wrap: break-word;
    overflow-x: auto;
    flex-shrink: 0;
}
.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    margin: 8px 0;
    white-space: nowrap;
}
.chat-table th, .chat-table td {
    padding: 3px 8px;
    border: 1px solid var(--border);
    text-align: left;
}
.chat-table th {
    background: var(--bg-tertiary, rgba(255,255,255,0.05));
    font-weight: 600;
}
.chat-table tr:nth-child(even) td {
    background: rgba(255,255,255,0.02);
}
.chat-assistant {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 8px 14px;
    border-top: 1px solid var(--bg-border);
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--bg-border);
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85em;
    font-family: 'Inter', sans-serif;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-send-btn {
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-save-bar {
    padding: 8px 14px;
    border-top: 1px solid rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
    text-align: center;
    flex-shrink: 0;
}

/* Leyenda de columnas del PDF del proveedor */
.pdf-columns-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(245, 158, 11, 0.08);
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    font-size: 0.7em;
}
.pdf-col-tag {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.pdf-col-sep {
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 0.8em;
}
.pdf-not-found {
    padding: 8px 14px;
    background: rgba(245, 158, 11, 0.1);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    font-size: 0.8em;
    font-weight: 500;
}

/* =========================================================
   PRE-EXTRACTION PREVIEW
   ========================================================= */
.preview-email-info {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.preview-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.preview-info-row .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
}
.preview-section {
    margin-bottom: 20px;
}
.preview-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding: 0 4px;
}
.preview-section-header .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-muted);
}
.preview-pdfs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.preview-pdf-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}
.preview-pdf-item:hover {
    border-color: rgba(236, 91, 19, 0.3);
}
.preview-pdf-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: rgba(236, 91, 19, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.preview-pdf-icon .material-symbols-outlined {
    color: var(--primary);
    font-size: 22px;
}
.preview-pdf-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}
.preview-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px dashed var(--bg-border);
    border-radius: var(--radius-lg);
    color: var(--warning);
    font-size: 0.88rem;
}
.preview-proveedor {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}
.preview-prov-detected, .preview-prov-unknown {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.preview-prov-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}
.preview-actions {
    display: flex;
    gap: 12px;
    padding: 20px 0;
    align-items: center;
}
.preview-actions .btn { display: flex; align-items: center; gap: 6px; }

/* Row state classes */
.row-new td:first-child { font-weight: 700; }
.row-new { background: rgba(236, 91, 19, 0.04); }
.row-muted { opacity: 0.5; }
.email-card.row-new .email-from { font-weight: 700; }
.email-card.row-muted { opacity: 0.5; }

/* =========================================================
   PRODUCTS
   ========================================================= */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 80px;
}
.product-card {
    display: grid;
    grid-template-columns: 6px auto 1fr auto;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-depth);
}
.product-card:not(.selectable) {
    grid-template-columns: 6px 1fr auto;
}
.product-card:hover { border-color: rgba(236, 91, 19, 0.3); }
.product-bar { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.product-bar.green { background: var(--sem-green); }
.product-bar.yellow { background: var(--sem-yellow); }
.product-bar.red { background: var(--sem-red); }
.product-bar.new { background: var(--primary); }
.product-body { padding: 12px 14px; }
.product-check {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px 0 8px;
}
.product-check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.product-sel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    font-size: 0.82rem;
}
.product-sel-all {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
}
.product-sel-all input { accent-color: var(--primary); width: 16px; height: 16px; }
.product-sel-count { color: var(--text-muted); font-size: 0.78rem; }
/* Filter bar */
.product-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--bg-border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--text-primary); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-count {
    font-size: 0.72rem;
    background: rgba(255,255,255,0.15);
    padding: 1px 7px;
    border-radius: 10px;
}
.filter-btn.active .filter-count { background: rgba(255,255,255,0.25); }
/* Badge NUEVO */
.product-badge-nuevo {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 2;
}
.product-badge-updated {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success, #22c55e);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 2;
    animation: fadeInBadge 0.5s ease;
}
@keyframes fadeInBadge {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Preview de instrucciones antes de guardar */
.instrucciones-preview {
    background: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: 12px;
    margin: 8px 12px 12px;
    padding: 0;
    animation: fadeInBadge 0.3s ease;
}
.instrucciones-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(var(--primary-rgb, 232, 126, 4), 0.08);
    border-radius: 10px 10px 0 0;
}
.instrucciones-preview-body {
    padding: 12px 14px;
    font-size: 0.82rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-secondary);
}
.instrucciones-preview-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}
.product-card { position: relative; }
.product-view-pdf {
    margin-top: 8px;
    font-size: 0.75rem !important;
    color: var(--primary) !important;
    padding: 4px 10px !important;
    border: 1px solid rgba(236,91,19,0.3) !important;
}
/* Inline PDF preview */
.pdf-inline-preview {
    margin-top: 10px;
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
}
.pdf-inline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--bg-border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.pdf-inline-loading { padding: 20px; text-align: center; }
.pdf-inline-body {
    position: relative;
    max-height: 400px;
    overflow-y: auto;
}
.pdf-inline-img {
    width: 100%;
    display: block;
}
.pdf-inline-marker {
    position: absolute;
    left: 0;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
}
.pdf-marker-arrow {
    display: inline-flex;
    align-items: center;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    animation: pdfMarkerPulse 2.5s ease-in-out 3;
}
@keyframes pdfMarkerPulse {
    0%, 100% { opacity: 1; transform: translateX(0); }
    50% { opacity: 0.5; transform: translateX(2px); }
}
@media (max-width: 640px) {
    .pdf-inline-body { max-height: 300px; }
}
.product-contenido-pendiente {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px dashed rgba(245, 158, 11, 0.3);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.contenido-input {
    width: 70px;
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8rem;
    text-align: center;
}
.contenido-input:focus {
    outline: none;
    border-color: var(--primary);
}
.product-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.product-details {
    display: flex;
    gap: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.product-detail { display: flex; flex-direction: column; }
.product-detail-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.product-detail-value { font-weight: 600; color: var(--text-primary); }
.product-nota {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 8px;
    background: var(--bg-hover);
    border-radius: var(--radius);
}
.product-variation {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 90px;
}
.variation-value { font-size: 1.1rem; font-weight: 700; }
.variation-value.green { color: var(--sem-green); }
.variation-value.yellow { color: var(--sem-yellow); }
.variation-value.red { color: var(--sem-red); }
.variation-value.new { color: var(--primary); }
.variation-label { font-size: 0.65rem; color: var(--text-muted); }

/* =========================================================
   ACTIONS BAR
   ========================================================= */
.actions-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 14px 20px;
    background: rgba(10, 13, 18, 0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--bg-border);
    display: flex;
    justify-content: center;
    gap: 12px;
    z-index: 90;
}

/* =========================================================
   DATA CARDS (Proveedores, Productos, Albaranes)
   ========================================================= */
.data-list { display: flex; flex-direction: column; gap: 6px; }
.data-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-depth);
}
.data-card:hover {
    border-color: rgba(236, 91, 19, 0.3);
    transform: translateX(4px);
}
.data-card-compact { padding: 10px 16px; }
.data-card-muted { opacity: 0.5; }
.data-card-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.data-card-icon.aceptado { background: var(--success-soft); color: var(--success); }
.data-card-icon.rechazado { background: var(--danger-soft); color: var(--danger); }
.data-card-main { flex: 1; min-width: 0; }
.data-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-card-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-card-badges { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* =========================================================
   BADGES
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: rgba(30, 41, 59, 0.5); color: var(--text-secondary); }
.badge-subtle { background: transparent; color: var(--text-muted); }
.badge-price {
    background: linear-gradient(135deg, var(--primary-soft), var(--info-soft));
    color: #fb923c;
    font-weight: 700;
}

/* =========================================================
   FILTER BAR (Productos)
   ========================================================= */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.filter-select, .filter-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: border-color var(--transition);
}
.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-select { max-width: 50%; }
.filter-select option { background: var(--bg-card); color: var(--text-primary); }

/* =========================================================
   CHART CONTAINER
   ========================================================= */
.dash-section { margin-bottom: 28px; }
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-depth);
}
.chart-small { max-width: 300px; margin: 0 auto; }

/* =========================================================
   ALBARAN SEPARATOR
   ========================================================= */
.albaran-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 16px 0 8px;
    background: var(--primary-soft);
    border: 1px solid rgba(236, 91, 19, 0.2);
    border-radius: var(--radius-lg);
}
.albaran-sep-icon { font-size: 1.1rem; }
.albaran-sep-title { font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.albaran-sep-date { font-size: 0.8rem; color: var(--text-secondary); }
.albaran-sep-count { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

/* =========================================================
   LOADING / EMPTY
   ========================================================= */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .mobile-header { display: block; }
    .bottom-nav { display: block; }
    .content-header { display: none; }
    .content-body { padding: 16px; padding-bottom: 100px; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .data-table-wrap { display: none; }
    .email-cards-mobile { display: flex; }
}
@media (max-width: 600px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    /* Product card: compact single-column layout */
    .product-card { grid-template-columns: 4px 1fr; }
    .product-card:not(.selectable) { grid-template-columns: 4px 1fr; }
    .product-card.selectable { grid-template-columns: 4px auto 1fr; }
    .product-body { padding: 8px 10px; }
    /* Name: max 2 lines, truncated */
    .product-name {
        font-size: 0.8rem;
        margin-bottom: 4px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        line-height: 1.3;
    }
    /* Details: compact 3-col grid */
    .product-details {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 2px 8px;
        font-size: 0.72rem;
    }
    .product-detail { gap: 0; }
    .product-detail-label { font-size: 0.55rem; letter-spacing: 0.3px; }
    .product-detail-value { font-size: 0.78rem; }
    /* Variation: inline, compact */
    .product-variation {
        grid-column: 2 / -1;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        padding: 0 10px 6px;
        min-width: unset;
    }
    .variation-value { font-size: 0.85rem; }
    .variation-label { font-size: 0.6rem; }
    /* Buttons: smaller */
    .product-card-btns { gap: 4px; margin-top: 6px; flex-wrap: wrap; }
    .product-card-btns .btn { font-size: 0.68rem; padding: 3px 8px; }
    .product-card-btns .btn .material-symbols-outlined { font-size: 14px; }
    /* Badges */
    .product-badge-nuevo, .product-badge-updated { font-size: 0.6rem; padding: 1px 6px; top: 6px; right: 6px; }
    /* Check */
    .product-check { padding: 0 2px 0 4px; }
    .product-check input[type="checkbox"] { width: 16px; height: 16px; }
    /* Misc */
    .product-nota { font-size: 0.7rem; padding: 3px 6px; margin-top: 4px; }
    .product-contenido-pendiente { padding: 6px 8px; font-size: 0.7rem; margin-top: 6px; }
    .filter-bar { flex-direction: column; }
    .content-body { padding: 12px; padding-bottom: 100px; }
    .filter-tabs { gap: 4px; }
    .filter-tab { font-size: 0.7rem; padding: 6px 10px; }
    .products-grid { gap: 8px; }
    .albaran-separator { padding: 8px 12px; font-size: 0.8rem; }
}

/* =========================================================
   FILTER TABS
   ========================================================= */
.filter-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--bg-border);
    margin-bottom: 20px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 0;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-tab:hover { color: var(--text-secondary); }
.filter-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
}
.filter-tab-count {
    background: rgba(30, 41, 59, 0.5);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
}
.filter-tab.active .filter-tab-count {
    background: var(--primary-soft);
    color: var(--primary);
}

/* =========================================================
   DATA TABLE
   ========================================================= */
.data-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-depth);
}
.data-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}
.data-table thead tr {
    background: rgba(30, 41, 59, 0.3);
}
.data-table th {
    padding: 12px 16px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 1px solid var(--bg-border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.3);
    transition: color var(--transition);
}
.data-table tbody tr {
    transition: all var(--transition);
}
.data-table tbody tr:hover {
    background: rgba(236, 91, 19, 0.04);
}
.data-table tbody tr:hover .row-chevron {
    color: var(--primary);
}
.data-table tbody tr.row-muted {
    opacity: 0.45;
}
.data-table tbody tr.row-muted:hover {
    opacity: 0.7;
}
.table-cell-bold {
    font-weight: 600;
    color: white;
}
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.row-chevron {
    color: var(--text-muted);
    width: 40px;
    text-align: center;
}
.row-chevron .material-symbols-outlined { font-size: 20px; }

/* Desktop: show table, hide cards */
@media (min-width: 1025px) {
    .email-cards-mobile { display: none; }
    .data-table-wrap { display: block; }
}
/* Mobile: show cards, hide table */
.email-cards-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================================================
   STATUS BADGES (with dot indicator)
   ========================================================= */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-nuevo { background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(236, 91, 19, 0.15); }
.status-pendiente { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.15); }
.status-aceptado, .status-procesado { background: var(--success-soft); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.15); }
.status-rechazado, .status-anulado { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.15); }
.status-listo { background: var(--info-soft); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.15); }

/* =========================================================
   FILTER TOGGLES
   ========================================================= */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--bg-border);
    background: transparent;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    user-select: none;
}
.filter-toggle input[type="checkbox"] { display: none; }
.filter-toggle:has(input:checked) {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}
.filtros-leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 14px;
    margin: 0 0 8px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: 10px;
    font-size: 0.75em;
}
.leyenda-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    line-height: 1.3;
}
.leyenda-item strong {
    color: var(--text-primary);
    white-space: nowrap;
}

/* =========================================================
   PRODUCT TAGS & WARNINGS
   ========================================================= */
.prod-card { cursor: pointer; transition: all var(--transition); }
.prod-card:hover { border-color: var(--primary); }
.prod-warn { border-left: 3px solid var(--warning) !important; }
.prod-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.prod-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.prod-tag.warn { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.prod-tag.ok { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.prod-tag.neutral { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }

/* =========================================================
   FICHA DE PRODUCTO
   ========================================================= */
.ficha-section {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
}
/* Collapsible sections */
.ficha-section-collapsible .ficha-section-header {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
    border-bottom: none;
}
.ficha-section-collapsible .ficha-section-header:hover {
    background: rgba(30, 41, 59, 0.3);
}
.ficha-section-collapsible .ficha-section-header .ficha-chevron {
    margin-left: auto;
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.25s;
}
.ficha-section-collapsible.open .ficha-section-header {
    border-bottom: 1px solid var(--bg-border);
}
.ficha-section-collapsible.open .ficha-section-header .ficha-chevron {
    transform: rotate(90deg);
}
.ficha-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.ficha-section-collapsible.open .ficha-section-body {
    max-height: 800px;
}
/* Delete link */
.ficha-delete-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: color var(--transition);
}
.ficha-delete-link:hover {
    color: var(--danger);
}
.ficha-section-warn {
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.05);
}
.ficha-section-danger {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.05);
}
.ficha-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--bg-border);
    color: var(--text-primary);
}
.ficha-section-header .material-symbols-outlined {
    font-size: 20px;
    color: var(--primary);
}
.ficha-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 14px 16px;
}
.ficha-grid .ficha-field {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-border);
    border-right: 1px solid var(--bg-border);
}
.ficha-grid .ficha-field:nth-child(3n) {
    border-right: none;
}
.ficha-grid .ficha-field:nth-last-child(-n+3) {
    border-bottom: none;
}
@media (max-width: 640px) {
    /* Ficha: grid 3 columnas compactas en móvil */
    .ficha-grid { margin: 10px 12px; }
    .ficha-grid .ficha-field { padding: 8px 10px; }
    .ficha-label { font-size: 0.6rem; }
    .ficha-value { font-size: 0.82rem; }
    
    /* Ficha: secciones más compactas */
    .ficha-section { margin-bottom: 8px; }
    .ficha-section-header { padding: 12px 14px; font-size: 0.82rem; }
    .ficha-contenido-editor { padding: 12px 14px; }
    
    /* Ocultar inputs manuales innecesarios en móvil */
    .mobile-hide { display: none !important; }
    .mobile-only { display: inline-flex !important; }
    
    /* Botones full-width y touch-friendly */
    .ficha-section .btn { min-height: 44px; font-size: 0.85rem; }
    .ficha-section .btn-sm { padding: 10px 16px; }
    
    /* Allergen grid compacto: 4 por fila */
    .ficha-allergen-grid { gap: 4px; }
    .ficha-allergen-tag { padding: 6px 8px; min-width: 50px; }
    .ficha-allergen-tag span { font-size: 0.72rem; }
    .ficha-allergen-tag small { font-size: 0.58rem; }
    
    /* Product cards: badges debajo */
    .data-card-compact { flex-direction: column; align-items: stretch; }
    .data-card-compact .data-card-badges { justify-content: flex-start; margin-top: 4px; }
    .data-card-compact > .material-symbols-outlined { display: none; }
    
    /* Ficha image más grande en móvil */
    .ficha-product-img { max-width: 140px; max-height: 140px; }
    
    /* Lookup result compacto */
    .ficha-lookup-found { flex-direction: column; }
    .ficha-lookup-img { width: 50px; height: 50px; }
    
    /* Filter toggles wrap */
    .filter-bar { flex-wrap: wrap; }
    .filter-toggle { flex: 1; min-width: 120px; justify-content: center; }

    /* Panel header back button */
    .panel-header { padding: 8px 0; }
    .panel-header h2 { font-size: 1rem; }
}
.ficha-field { display: flex; flex-direction: column; gap: 4px; }
.ficha-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ficha-value { font-size: 0.9rem; color: var(--text-primary); }
.ficha-value.highlight { color: var(--primary); font-weight: 700; }

.ficha-warn-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    font-weight: 700;
    margin-left: auto;
}
.ficha-sku-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    font-family: monospace;
    margin-left: auto;
}
.ficha-contenido-editor {
    padding: 14px 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.ficha-field-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ficha-field-inline label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ficha-lookup-found {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(34, 197, 94, 0.05);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius);
}
.ficha-lookup-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: var(--radius);
    background: white;
}
.ficha-lookup-info { font-size: 0.85rem; }
.ficha-lookup-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(148, 163, 184, 0.08);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.85rem;
}
.ficha-product-img {
    max-width: 180px;
    max-height: 180px;
    border-radius: var(--radius-lg);
    object-fit: contain;
    background: transparent;
    padding: 4px;
}
.ficha-img-placeholder {
    padding: 24px;
    background: rgba(148, 163, 184, 0.05);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--bg-border);
}
.ficha-allergen-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.ficha-allergen-tag {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--bg-border);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 60px;
    text-align: center;
}
.ficha-allergen-tag span {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.ficha-allergen-tag small {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.ficha-allergen-tag:hover {
    border-color: var(--primary);
    background: rgba(236, 91, 19, 0.05);
}
.ficha-allergen-tag.active {
    background: rgba(245, 158, 11, 0.12);
    border-color: var(--warning);
}
.ficha-allergen-tag.active span {
    color: var(--warning);
}
.ficha-allergen-tag.active small {
    color: var(--warning);
}

/* =========================================================
   CONFIGURATION PANEL
   ========================================================= */
.config-container {
    max-width: 800px;
}
.cfg-section {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow-depth);
    overflow: hidden;
}
.cfg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}
.cfg-header:hover {
    background: rgba(30, 41, 59, 0.4);
}
.cfg-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}
.cfg-header-left .material-symbols-outlined {
    font-size: 22px;
    color: var(--primary);
}
.cfg-arrow {
    color: var(--text-muted);
    font-size: 22px;
    transition: transform 0.25s;
}
.cfg-body {
    padding: 20px 24px;
    border-top: 1px solid var(--bg-border);
}
.cfg-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 640px) {
    .cfg-row { grid-template-columns: 1fr; }
}
.cfg-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.cfg-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color var(--transition);
}
.cfg-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(236, 91, 19, 0.05);
}
select.cfg-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.cfg-textarea {
    min-height: 80px;
    resize: vertical;
    margin-bottom: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
}
.cfg-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}
.cfg-divider {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 0 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--bg-border);
}

/* Range slider */
.cfg-range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cfg-range-wrap input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: var(--bg-border);
    border-radius: 3px;
    outline: none;
}
.cfg-range-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px var(--primary-glow);
}
.cfg-range-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 42px;
    text-align: right;
}

/* Toggle switch */
.cfg-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}
.cfg-toggle input[type="checkbox"] {
    display: none;
}
.cfg-toggle-slider {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--bg-border);
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}
.cfg-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.25s;
}
.cfg-toggle input:checked + .cfg-toggle-slider {
    background: var(--primary-soft);
}
.cfg-toggle input:checked + .cfg-toggle-slider::after {
    left: 23px;
    background: var(--primary);
}
.cfg-toggle-label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Provider instructions */
.cfg-prov-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cfg-prov-item {
    background: rgba(30, 41, 59, 0.2);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cfg-prov-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    gap: 8px;
}
.cfg-prov-header:hover {
    background: rgba(30, 41, 59, 0.4);
}
.cfg-prov-name {
    font-weight: 600;
    font-size: 0.85rem;
    flex: 1;
}
.cfg-prov-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.cfg-prov-body {
    padding: 12px 16px;
    border-top: 1px solid var(--bg-border);
}

/* Config toast notification */
.config-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.config-toast .material-symbols-outlined {
    font-size: 20px;
}
.config-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Password visibility toggle */
.cfg-pass-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.cfg-pass-wrapper .cfg-input {
    padding-right: 40px;
    flex: 1;
}
.cfg-pass-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.cfg-pass-toggle:hover {
    opacity: 1;
    color: var(--primary);
}
.cfg-pass-toggle .material-symbols-outlined {
    font-size: 20px;
}

/* User management */
.cfg-users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cfg-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(30, 41, 59, 0.2);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    transition: all var(--transition);
    gap: 12px;
    flex-wrap: wrap;
}
.cfg-user-card:hover {
    background: rgba(30, 41, 59, 0.4);
}
.cfg-user-inactive {
    opacity: 0.45;
    border-style: dashed;
}
.cfg-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 180px;
}
.cfg-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(30, 41, 59, 0.3);
}
.cfg-user-avatar .material-symbols-outlined {
    font-size: 20px;
}
.cfg-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
}
.cfg-user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.cfg-user-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cfg-user-rol-select {
    font-size: 0.8rem !important;
}
.cfg-new-user {
    background: rgba(30, 41, 59, 0.15);
    border: 1px dashed var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}
.cfg-role-legend {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: rgba(30, 41, 59, 0.15);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
}
.cfg-role-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.cfg-role-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
}
.cfg-role-item .material-symbols-outlined {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}
.cfg-role-item strong {
    display: block;
    font-size: 0.85rem;
    color: white;
    margin-bottom: 2px;
}
.cfg-role-item span:last-child {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}
@media (max-width: 640px) {
    .cfg-role-grid { grid-template-columns: 1fr; }
    .cfg-user-card { flex-direction: column; align-items: flex-start; }
    .cfg-user-actions { width: 100%; justify-content: flex-end; }
}

/* Contacto cards (ficha proveedor) */
.contacto-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}
.contacto-card:hover {
    border-color: var(--accent);
}
.contacto-info { flex: 1; }
.contacto-info strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.contacto-cargo {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-badge);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}
.contacto-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.contacto-comments {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}
.contacto-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

/* =========================================================
   ONBOARDING TOUR
   ========================================================= */
.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 100000;
    transition: opacity 0.3s ease;
    animation: tourFadeIn 0.4s ease;
}
@keyframes tourFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.tour-spotlight {
    position: absolute;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65),
                0 0 0 4px var(--primary),
                0 0 24px rgba(236, 91, 19, 0.3);
    z-index: 100001;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.tour-tooltip {
    position: fixed;
    z-index: 100002;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 380px;
    width: calc(100vw - 32px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(236, 91, 19, 0.12);
    animation: tourTooltipIn 0.35s ease;
}
@keyframes tourTooltipIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.tour-tooltip-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.tour-tooltip-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.tour-tooltip-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}
.tour-tooltip-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.tour-step-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}
.tour-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-border);
    transition: all 0.3s ease;
}
.tour-dot.active {
    background: var(--primary);
    width: 20px;
    border-radius: 4px;
}
.tour-dot.done {
    background: var(--primary);
    opacity: 0.4;
}
.tour-btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}
.tour-btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}
.tour-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--primary-glow);
}
.tour-btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--bg-border);
}
.tour-btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.tour-btn-skip {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 0.8rem;
    padding: 8px 12px;
}
.tour-btn-skip:hover {
    color: var(--text-primary);
}

/* Tour welcome/finish full-screen card */
.tour-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.tour-welcome-card {
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 80px rgba(236, 91, 19, 0.1);
    animation: tourWelcomeIn 0.5s ease;
}
@keyframes tourWelcomeIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.tour-welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 36px;
    margin: 0 auto 24px;
    box-shadow: 0 8px 24px var(--primary-glow);
}
.tour-welcome-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.tour-welcome-name {
    color: var(--primary);
}
.tour-welcome-role {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.tour-welcome-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 32px;
}
.tour-welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

@media (max-width: 768px) {
    .tour-tooltip {
        max-width: calc(100vw - 24px);
        padding: 20px;
    }
    .tour-welcome-card {
        padding: 32px 24px;
    }
    .tour-welcome-title {
        font-size: 1.3rem;
    }
    .tour-step-dots {
        display: none;
    }
}
