/* Style definitions for WhatsApp Price Comparator web app */
:root {
    /* Color Palette */
    --bg-app: #06060a;
    --bg-sidebar: #0d0d15;
    --bg-card: rgba(18, 18, 29, 0.65);
    --bg-card-hover: rgba(25, 25, 40, 0.8);
    --bg-input: #10101c;
    --bg-active-tab: rgba(99, 102, 241, 0.15);
    
    /* Missing variables required by admin panel / widgets */
    --bg-primary: #06060a;
    --bg-secondary: #10101c;
    --bg-tag: rgba(99, 102, 241, 0.15);
    --radius-sm: 6px;
    --surface-card: rgba(18, 18, 29, 0.65);
    --border: rgba(255, 255, 255, 0.07);
    
    --border-color: rgba(255, 255, 255, 0.07);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Brand & Accents */
    --primary: #6366f1; /* Indigo */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --primary-glow: rgba(99, 102, 241, 0.3);
    
    --success: #10b981; /* Emerald */
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-border: rgba(16, 185, 129, 0.3);
    
    --warning: #f59e0b; /* Amber */
    --warning-bg: rgba(245, 158, 11, 0.12);
    
    --danger: #f43f5e; /* Rose */
    --danger-bg: rgba(244, 63, 94, 0.15);
    
    --wa-green: #22c55e;
    --wa-green-bg: rgba(34, 197, 94, 0.12);
    
    /* Layout Constants */
    --sidebar-width: 260px;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Base Reset & Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Typography styles */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 32px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.brand h2 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: var(--transition-fast);
    width: 100%;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    background-color: var(--bg-active-tab);
    border-left: 3px solid var(--primary);
    padding-left: 13px; /* Keep total padding aligned */
    font-weight: 600;
}

.nav-item svg {
    transition: var(--transition-fast);
}

.nav-item.active svg {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.badge {
    background: var(--primary-gradient);
    border-radius: 20px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    margin-left: auto;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 4px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--warning); /* default */
}

.status-indicator.active {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* User Session Info Box (Sidebar) */
.user-session-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
}

.user-session-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    font-weight: 500;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow */
    height: 100vh;
}

.content-header {
    background-color: rgba(8, 8, 12, 0.6);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
}

.header-title h1 {
    font-size: 26px;
    font-weight: 700;
}

.header-title p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.content-body {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
    background-image: radial-gradient(circle at 80% 10%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
                      radial-gradient(circle at 10% 90%, rgba(168, 85, 247, 0.03) 0%, transparent 45%);
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Styling */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

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

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.card-body {
    padding: 24px;
}

.full-width-card {
    grid-column: 1 / -1;
}

/* Buttons */
.btn {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    box-shadow: 0 4px 14px var(--primary-glow);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--text-primary);
}

.btn-outline-primary:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.btn-outline-white {
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.btn-outline-white:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-outline-success {
    border-color: var(--success);
    color: var(--success);
}

.btn-outline-success:hover {
    background-color: var(--success-bg);
}

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

.btn-success:hover {
    background-color: #0d9668;
    transform: translateY(-1px);
}

.btn-sm {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
}

.btn-xs {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
}

.full-width {
    width: 100%;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    box-shadow: var(--shadow-premium);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.purple {
    background-color: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.stat-icon.blue {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-icon.green {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 4px;
    font-family: var(--font-heading);
}

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

/* Dashboard Hero */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.main-hero {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.05) 100%), var(--bg-card);
    position: relative;
    display: flex;
    align-items: center;
    padding: 40px;
}

.hero-content {
    max-width: 60%;
    z-index: 2;
}

.main-hero h2 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
}

.main-hero p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-top: 12px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.hero-illustration {
    position: absolute;
    right: 40px;
    width: 35%;
    height: 80%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    z-index: 1;
}

.floating-chat {
    background: rgba(22, 22, 35, 0.95);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-size: 11px;
    animation: floating 4s ease-in-out infinite;
}

.floating-chat.wa-bubble {
    border-left: 3px solid var(--wa-green);
    align-self: flex-start;
    animation-delay: 0.5s;
}

.floating-chat.ai-bubble {
    border-left: 3px solid var(--primary);
    align-self: flex-end;
    animation-delay: 2s;
    width: 90%;
}

.bubble-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.bubble-body {
    color: var(--text-secondary);
    line-height: 1.4;
}

@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Supplier List Dashboard */
.supplier-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.supplier-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-fast);
}

.supplier-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.supplier-meta h4 {
    font-size: 14px;
    font-weight: 600;
}

.supplier-meta span {
    font-size: 11px;
    color: var(--text-muted);
}

.supplier-stats {
    text-align: right;
}

.supplier-stats .count {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.supplier-stats .lbl {
    font-size: 10px;
    color: var(--text-secondary);
    display: block;
}

/* Savings Visualizer */
.savings-visualizer {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    align-items: center;
}

.comparison-bar-container {
    margin-bottom: 16px;
}

.comparison-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.bar-bg {
    background-color: rgba(255, 255, 255, 0.04);
    border-radius: 20px;
    height: 28px;
    overflow: hidden;
    width: 100%;
}

.bar-fill {
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 16px;
    font-size: 12px;
    font-weight: 700;
    color: white;
    border-radius: 20px;
    transition: width 1s ease-out;
}

.bar-fill.red {
    background: linear-gradient(90deg, #ef4444 0%, #b91c1c 100%);
}

.bar-fill.amber {
    background: linear-gradient(90deg, #f59e0b 0%, #b45309 100%);
}

.bar-fill.green {
    background: linear-gradient(90deg, #10b981 0%, #047857 100%);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.savings-badge-large {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%);
    border: 1px solid var(--success-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.savings-badge-large .savings-title {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.savings-badge-large .savings-amount {
    font-size: 28px;
    font-weight: 800;
    color: var(--success);
    margin-top: 4px;
}

.savings-badge-large p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Animations */
.animate-pulse {
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.1); box-shadow: 0 0 16px rgba(16, 185, 129, 0.5); }
}

/* Split Layouts for Input & Planner */
.layout-split {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    align-items: start;
}

.layout-split .flex-grow-2 {
    grid-column: span 1;
}

.layout-split:has(.flex-grow-2) {
    grid-template-columns: 1.8fr 1.2fr;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.form-control {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-size: 14px;
    padding: 12px 16px;
    width: 100%;
    transition: var(--transition-fast);
}

.form-control:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.text-area {
    min-height: 220px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

.input-inline {
    display: flex;
    gap: 8px;
}

.input-inline select {
    flex-grow: 1;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

/* Extraction Loading & Empty State */
.preview-container {
    height: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    flex-grow: 1;
}

.empty-state svg {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.empty-state h4 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    max-width: 280px;
    line-height: 1.4;
}

/* AI Scanner Visualizer */
.extraction-loading {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.01);
    border-radius: var(--border-radius-md);
    min-height: 300px;
}

.ai-scanner {
    text-align: center;
    z-index: 2;
    padding: 24px;
    max-width: 320px;
}

.scanner-text h4 {
    font-size: 16px;
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.scanner-text p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.scanner-beam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    box-shadow: 0 0 15px var(--primary);
    animation: scan 2s infinite ease-in-out;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

.spin-icon {
    animation: spin 1s linear infinite;
}

@keyframes scan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.supplier-info-header {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
}

.small-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.supplier-info-header h4 {
    font-size: 15px;
    font-weight: 700;
}

/* Tables Styles */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: rgba(255, 255, 255, 0.01);
}

.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.small-table th, .small-table td {
    padding: 10px 14px;
    font-size: 13px;
}

/* Comparison Matrix Styling */
.comparison-table th {
    background-color: rgba(255,255,255,0.02);
}

.matrix-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-input-wrapper {
    position: relative;
    min-width: 220px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper .form-control {
    padding-left: 36px;
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 13px;
}

/* Dynamic Price Highlighting in Matrix */
.price-cell {
    position: relative;
}

.price-cell.cheapest {
    background-color: rgba(16, 185, 129, 0.06);
    color: var(--success);
    font-weight: 700;
}

.cheapest-badge {
    background-color: var(--success);
    color: white;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 700;
    display: inline-block;
    vertical-align: middle;
}

.price-cell.highest {
    color: var(--danger);
    font-weight: 500;
}

.price-diff-indicator {
    font-size: 11px;
    color: var(--text-secondary);
}

.price-diff-indicator.percent {
    color: var(--danger);
}

/* Smart Planner Styling */
.savings-callout {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
    border: 1px solid var(--success-border);
    border-radius: var(--border-radius-md);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.savings-visual-gauge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 4px solid var(--success);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.gauge-value {
    font-size: 14px;
    font-weight: 800;
    color: var(--success);
}

.gauge-label {
    font-size: 7px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.order-summary-box {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
}

.summary-line:last-child {
    margin-bottom: 0;
}

.summary-line strong {
    font-size: 16px;
    color: var(--primary);
}

/* Planner Optimization Split orders */
.orders-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.supplier-order-card {
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.supplier-order-header {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
}

.supplier-order-header .order-total {
    color: var(--success);
}

.supplier-order-body {
    padding: 10px 14px;
}

.order-product-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
}

.order-product-item .savings-badge {
    color: var(--success);
    font-weight: 600;
    margin-left: 6px;
}

/* Custom Checkbox for Planner */
.checkbox-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: var(--transition-fast);
}

.custom-checkbox.checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.custom-checkbox.checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Integration Guide Cards */
.grid-three-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.method-card {
    padding: 24px;
    position: relative;
    background-color: rgba(255, 255, 255, 0.015);
    height: 100%;
}

.method-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.highlight-method {
    border-color: rgba(16, 185, 129, 0.3);
    background-color: rgba(16, 185, 129, 0.02);
}

.highlight-method:hover {
    border-color: var(--success);
}

.method-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.method-icon.green {
    background-color: var(--wa-green-bg);
    color: var(--wa-green);
}

.method-icon.purple {
    background-color: rgba(168, 85, 247, 0.08);
    color: #a855f7;
}

.method-icon.blue {
    background-color: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
}

.method-card h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.method-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    min-height: 80px;
}

.method-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.method-features li {
    font-size: 12px;
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.method-features li::before {
    position: absolute;
    left: 0;
    top: 2px;
    font-weight: 700;
}

.method-features li.plus::before {
    content: '+';
    color: var(--success);
}

.method-features li.minus::before {
    content: '-';
    color: var(--danger);
}

.bg-accent-glow {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.02) 100%);
    border: 1px solid var(--border-color);
}

/* Modals */
.modal-overlay {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeInFast 0.2s ease-out;
}

.modal-card {
    background-color: #0f0f18;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-fast);
}

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

.modal-body {
    padding: 20px;
}

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

.hide {
    display: none !important;
}

@keyframes fadeInFast {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.link-primary {
    color: var(--primary);
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
}

.small-text {
    font-size: 12px;
}

.section-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.p-0 { padding: 0 !important; }
.p-3 { padding: 16px !important; }
.p-5 { padding: 48px !important; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

/* ----------------------------------------------------
   AUTHENTICATION OVERLAY SPECIFIC STYLES
   ---------------------------------------------------- */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(10, 10, 18, 0.93) 0%, rgba(4, 4, 6, 0.99) 100%);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Ultimate top depth */
    transition: opacity 0.4s ease;
}

.auth-card {
    background-color: rgba(20, 20, 32, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.auth-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.auth-brand h2 {
    font-size: 26px;
    font-weight: 800;
}

.auth-brand h2 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.4;
}

.auth-toggle-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 20px;
}

.auth-toggle-text span {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.auth-toggle-text span:hover {
    text-decoration: underline;
}

.auth-alert {
    background-color: var(--danger-bg);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    margin-top: 20px;
    padding: 12px 16px;
    line-height: 1.4;
    animation: fadeInFast 0.2s ease-out;
}

.auth-alert.success {
    background-color: var(--success-bg);
    border-color: var(--success-border);
    color: #a7f3d0;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .layout-split,
    .layout-split:has(.flex-grow-2) {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .brand {
        padding-bottom: 16px;
    }
    .nav-item.active {
        border-left: none;
        border-bottom: 3px solid var(--primary);
        padding-left: 12px;
        padding-bottom: 9px;
    }
    .sidebar-btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }
    .form-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        align-items: stretch;
    }
    .form-actions button {
        width: 100%;
    }
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .nav-item {
        width: auto;
        padding: 8px 12px;
        font-size: 12px;
    }
    .sidebar-footer {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-top: none;
        font-size: 11px;
    }
    .sidebar-footer .btn-logout,
    .sidebar-footer .api-status {
        font-size: 11px;
    }
    .main-content {
        height: auto;
    }
    .content-header {
        padding: 16px 20px;
    }
    .content-body {
        padding: 20px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .main-hero {
        padding: 24px;
        flex-direction: column;
        align-items: flex-start;
    }
    .hero-content {
        max-width: 100%;
    }
    .hero-illustration {
        position: static;
        width: 100%;
        margin-top: 24px;
    }
    .savings-visualizer {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .flex-column-mobile {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ======================================================
   EXTRACTION MATCHING TABLE (3-column editable)
   ====================================================== */

.extraction-match-table {
    table-layout: fixed;
    width: 100%;
}

.extraction-match-table th:nth-child(1) { width: 35%; }
.extraction-match-table th:nth-child(2) { width: 45%; }
.extraction-match-table th:nth-child(3) { width: 20%; }

/* Original text column */
.original-text-cell {
    vertical-align: middle;
}

.original-text-content {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    display: block;
    word-break: break-word;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Matched name editable input */
.matched-name-cell {
    vertical-align: middle;
}

.matched-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.matched-name-input {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 10px;
    width: 100%;
    transition: var(--transition-fast);
    font-family: var(--font-sans);
}

.matched-name-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.matched-name-input:hover:not(:focus) {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Status badges */
.mapping-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    width: fit-content;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.mapping-badge.learned {
    background-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.mapping-badge.learned::before {
    content: '✓ ';
}

.mapping-badge.suggested {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.mapping-badge.suggested::before {
    content: '⚡ ';
}

.mapping-badge.no-match {
    background-color: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.mapping-badge.no-match::before {
    content: '? ';
}

/* Price cell compact */
.price-cell-compact {
    vertical-align: middle;
    white-space: nowrap;
    font-size: 14px;
}


/* ======================================================
   PRODUCT CATALOG MODAL
   ====================================================== */

.header-actions-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-wide {
    max-width: 640px;
    width: 90%;
}

.catalog-add-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.catalog-add-form .form-control {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
}

.catalog-cat-select {
    flex: 0 0 130px !important;
    min-width: 130px;
}

.catalog-list-container {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.catalog-list {
    display: flex;
    flex-direction: column;
}

.catalog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

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

.catalog-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.catalog-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.catalog-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-item-cat {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.catalog-item-global {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success);
    white-space: nowrap;
    flex-shrink: 0;
}

.catalog-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.catalog-item-delete:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

.catalog-empty {
    padding: 32px;
    text-align: center;
}


/* ======================================================
   ANALYTICS TAB
   ====================================================== */

.analytics-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.analytics-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.analytics-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.analytics-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
}

.analytics-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.analytics-card-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.analytics-card-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
    line-height: 1.1;
}

/* Sparkline in product table */
.sparkline-cell {
    padding: 4px 8px !important;
}

.sparkline-canvas {
    display: block;
    width: 100%;
    height: 32px;
}

/* Product row clickable */
.analytics-product-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.analytics-product-row:hover {
    background-color: rgba(99, 102, 241, 0.08) !important;
}

.analytics-product-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.analytics-product-category {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trend-up { color: #ef4444; }
.trend-down { color: #10b981; }
.trend-flat { color: var(--text-muted); }

/* Responsive */
@media (max-width: 900px) {
    .analytics-summary-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .analytics-summary-row {
        grid-template-columns: 1fr;
    }
}

/* ======================================================
   SUPPLIER INTELLIGENCE
   ====================================================== */

.intelligence-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 16px;
}

.intelligence-chart-card {
    background: rgba(18, 18, 29, 0.65);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
}

.intelligence-chart-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.intelligence-table-container {
    overflow-x: auto;
}

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

.competitiveness-badge.green {
    background-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.competitiveness-badge.yellow {
    background-color: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.competitiveness-badge.red {
    background-color: rgba(244, 63, 94, 0.12);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.25);
}

/* ======================================================
   PRICE ALERTS
   ====================================================== */

.alert-form-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px 16px;
    transition: var(--transition-smooth);
}

.alert-card:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.alert-card.triggered {
    border-color: rgba(16, 185, 129, 0.4);
    background-color: rgba(16, 185, 129, 0.06);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.15);
}

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

.alert-card-product {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.alert-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.alert-card-delete {
    flex-shrink: 0;
    margin-left: 12px;
}

/* ======================================================
   ANOMALY DETECTOR
   ====================================================== */

.anomaly-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.anomaly-card {
    background: rgba(18, 18, 29, 0.65);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--border-radius-md);
    padding: 16px;
    transition: var(--transition-smooth);
}

.anomaly-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.anomaly-card.opportunity {
    border-left-color: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.08);
}

.anomaly-card.opportunity:hover {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.anomaly-card.high {
    border-left-color: #ef4444;
}

.anomaly-card-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.anomaly-card-supplier {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.anomaly-card-prices {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.anomaly-price-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.anomaly-price-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.anomaly-price-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.anomaly-card-deviation {
    font-size: 12px;
    font-weight: 700;
}

/* ======================================================
   PRICE CHANGES PANEL
   ====================================================== */

.price-changes-panel {
    margin-top: 16px;
    padding: 16px;
    background: rgba(18, 18, 29, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.changes-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.change-badge.down {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    color: #10b981;
}

.change-badge.up {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.change-badge.new {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
    color: #3b82f6;
}

.change-badge.same {
    background-color: rgba(100, 116, 139, 0.08);
    border-color: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
}

/* Price change table row tints */
.change-row-down {
    background-color: rgba(16, 185, 129, 0.05) !important;
}

.change-row-down:hover {
    background-color: rgba(16, 185, 129, 0.1) !important;
}

.change-row-up {
    background-color: rgba(239, 68, 68, 0.05) !important;
}

.change-row-up:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.change-row-new {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

.change-row-new:hover {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

/* ======================================================
   MODAL CLOSE BUTTON (for new modals)
   ====================================================== */

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-fast);
}

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

/* ======================================================
   RESPONSIVE: NEW FEATURES
   ====================================================== */

@media (max-width: 1024px) {
    .intelligence-grid {
        grid-template-columns: 1fr;
    }

    .alert-form-row {
        flex-wrap: wrap;
    }

    .alert-form-row select,
    .alert-form-row input {
        flex: 1 1 100% !important;
    }

    .anomaly-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .intelligence-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .intelligence-chart-card {
        padding: 14px;
    }

    .alert-form-row {
        flex-direction: column;
    }

    .alert-form-row .btn {
        width: 100%;
    }

    .anomaly-cards-grid {
        grid-template-columns: 1fr;
    }

    .changes-summary-bar {
        flex-direction: column;
        gap: 6px;
    }

    .change-badge {
        width: 100%;
        justify-content: center;
    }
}

/* ======================================================
   BACKUP BUTTON
   ====================================================== */
.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, var(--border-radius-sm));
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 6px;
}
.sidebar-btn:hover {
    background: var(--bg-active-tab);
    color: var(--text-primary);
    border-color: var(--primary);
}
.sidebar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

/* ======================================================
   KPI DASHBOARD CARDS
   ====================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px !important;
}
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.kpi-content {
    flex: 1;
    min-width: 0;
}
.kpi-value {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kpi-secondary-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}
.kpi-secondary-divider {
    color: var(--text-muted);
}
.kpi-secondary-stat strong {
    color: var(--text-primary);
    font-family: var(--font-heading);
}

@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card { padding: 14px !important; }
    .kpi-icon { width: 40px; height: 40px; font-size: 18px; }
    .kpi-value { font-size: 18px; }
}

/* Admin Header Button */
.btn-admin-users {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-sm);
    color: #a5b4fc;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.btn-admin-users:hover {
    background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.25));
    border-color: #6366f1;
    color: #c7d2fe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.admin-user-count {
    background: #6366f1;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* Admin Drawer Backdrop */
.admin-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.admin-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* Admin Drawer Panel */
.admin-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 100vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
.admin-drawer.open {
    transform: translateX(0);
}
.admin-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.05));
}
.admin-drawer-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}
.admin-drawer-subtitle {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.admin-drawer-close {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.admin-drawer-close:hover {
    background: rgba(239,68,68,0.15);
    border-color: #ef4444;
    color: #ef4444;
}
.admin-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Admin Sections */
.admin-section {
    margin-bottom: 24px;
}
.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.admin-section-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Admin Create Form */
.admin-create-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
}
.admin-form-group {
    margin-bottom: 12px;
}
.admin-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-block {
    width: 100%;
    justify-content: center;
}
.admin-form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 8px 0 0;
    text-align: center;
}

/* Admin User Card */
.admin-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-bottom: 8px;
    transition: all 0.2s ease;
}
.admin-user-card:hover {
    border-color: rgba(99,102,241,0.4);
    background: rgba(99,102,241,0.04);
}
.admin-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    color: white;
    text-transform: uppercase;
}
.admin-user-avatar.role-admin {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.admin-user-avatar.role-user {
    background: linear-gradient(135deg, #10b981, #059669);
}
.admin-user-info {
    flex: 1;
    min-width: 0;
}
.admin-user-email {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-user-meta {
    display: flex;
    gap: 12px;
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
}
.admin-user-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}
.admin-user-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-user-badge.badge-admin {
    background: rgba(99,102,241,0.15);
    color: #818cf8;
    border: 1px solid rgba(99,102,241,0.3);
}
.admin-user-badge.badge-user {
    background: rgba(16,185,129,0.15);
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.3);
}
.admin-user-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.admin-action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
    color: var(--text-secondary);
}
.admin-action-btn:hover {
    transform: translateY(-1px);
}
.admin-action-btn.action-view:hover {
    background: rgba(139,92,246,0.15);
    border-color: #8b5cf6;
    color: #a78bfa;
    box-shadow: 0 2px 8px rgba(139,92,246,0.2);
}
.admin-action-btn.action-push:hover {
    background: rgba(99,102,241,0.15);
    border-color: #6366f1;
    color: #818cf8;
    box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}
.admin-action-btn.action-delete:hover {
    background: rgba(239,68,68,0.15);
    border-color: #ef4444;
    color: #f87171;
    box-shadow: 0 2px 8px rgba(239,68,68,0.2);
}

/* Admin Empty State */
.admin-empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Old admin panel styles (kept for backwards compat) */
.admin-create-user-form { margin-bottom: 16px; }
.admin-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
@media (max-width: 768px) {
    .admin-form-row { flex-direction: column; }
    .admin-form-row .form-control,
    .admin-form-row .btn { width: 100%; }
}
@media (max-width: 500px) {
    .admin-drawer { width: 100vw; }
    .btn-admin-users span { display: none; }
}

/* Catalog checkboxes */
.catalog-item-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

/* Impersonation Banner */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    font-size: 13px;
    font-family: var(--font-sans);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.4);
    animation: bannerSlideIn 0.3s ease-out;
}
@keyframes bannerSlideIn {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}
.impersonation-banner strong {
    color: #e0e7ff;
}

/* Upload History */
.history-day-group {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-bottom: 10px;
    overflow: hidden;
}
.history-day-group.collapsed .history-day-sessions {
    display: none;
}
.history-day-group.collapsed .history-chevron {
    transform: rotate(-90deg);
}
.history-day-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.history-day-header:hover {
    background: var(--bg-active-tab);
}
.history-day-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}
.history-day-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tag);
    padding: 2px 8px;
    border-radius: 10px;
}
.history-chevron {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.history-day-sessions {
    border-top: 1px solid var(--border-color);
}
.history-session-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
    transition: background var(--transition-fast);
}
.history-session-row:last-child {
    border-bottom: none;
}
.history-session-row:hover {
    background: var(--bg-active-tab);
}
.history-session-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-session-supplier {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.history-session-meta {
    font-size: 11px;
    color: var(--text-muted);
}
.history-session-actions {
    display: flex;
    gap: 6px;
}

/* Supplier Detection Badge */
.supplier-detect-badge {
    display: none;
    margin-top: 6px;
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    color: #818cf8;
    animation: fadeIn 0.3s ease;
}

/* Comparison Mode Toggle */
.comparison-mode-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}
.mode-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-sans);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.mode-btn.active {
    background: var(--primary);
    color: white;
}
.mode-btn:hover:not(.active) {
    background: var(--bg-active-tab);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile optimizations for catalog form & modales scroll */
@media (max-width: 600px) {
    .catalog-add-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .catalog-cat-select {
        flex: none !important;
        width: 100% !important;
    }
}

@media (max-height: 600px) or (max-width: 600px) {
    .modal-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: 20px;
    }
    .modal-card {
        margin: auto;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
    }
    .modal-body {
        overflow-y: auto;
    }
}

/* ====================================================
   FILE UPLOAD ZONE
   ==================================================== */
.file-upload-zone {
    margin-top: 12px;
}

.upload-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.upload-divider-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.upload-divider-text {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.btn-attach {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 16px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md, 10px);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-attach:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary);
}

.btn-attach:hover svg {
    stroke: var(--primary);
}

.btn-attach svg {
    transition: stroke var(--transition-fast);
}

.btn-attach-hint {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
}

/* File Preview Badge */
.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm, 6px);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    animation: filePreviewIn 0.3s ease-out;
}

.file-preview--excel {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}

.file-preview--image {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
}

.file-preview-icon {
    font-size: 20px;
    line-height: 1;
}

.file-preview-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-size {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.file-preview-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    line-height: 1;
}

.file-preview-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

@keyframes filePreviewIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .btn-attach {
        padding: 14px;
    }
    .file-preview {
        flex-wrap: wrap;
    }
    .file-preview-name {
        flex: 1 1 60%;
    }
}

/* ----------------------------------------------------
   AI CHAT
---------------------------------------------------- */
.badge-ai {
    background: var(--primary-gradient) !important;
    color: #fff !important;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-premium);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    max-width: 85%;
}
.chat-msg-user {
    align-self: flex-end;
    justify-content: flex-end;
}
.chat-msg-assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.93rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chat-msg-user .chat-bubble {
    background: var(--primary-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-bubble {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-bubble strong { color: inherit; font-weight: 700; }
.chat-bubble code {
    background: rgba(255,255,255,0.08);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chat-bubble ul {
    margin: 6px 0 6px 2px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.chat-bubble li { list-style: disc; }

/* Indicador "escribiendo…" */
.chat-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 2px 0;
}
.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chatTyping 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 12px;
}
.chat-suggestions.hide { display: none; }
.chat-chip {
    background: var(--bg-tag);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: var(--font-sans);
}
.chat-chip:hover {
    background: var(--bg-active-tab);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
}
.chat-input {
    flex: 1;
    resize: none;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 11px 14px;
    font-size: 0.93rem;
    font-family: var(--font-sans);
    line-height: 1.4;
    max-height: 140px;
    outline: none;
    transition: var(--transition-fast);
}
.chat-input:focus { border-color: var(--border-focus); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}
.chat-send-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ----------------------------------------------------
   TOAST (notificaciones no bloqueantes)
---------------------------------------------------- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    min-width: 240px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    color: #fff;
    background: #1f2937;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.6);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #065f46; border-color: rgba(16,185,129,0.5); }
.toast-error { background: #7f1d1d; border-color: rgba(244,63,94,0.5); }
.toast-info { background: #1e3a5f; border-color: rgba(99,102,241,0.5); }

/* ============================================================
   WhatsApp Web embebido (modo oscuro, integrado al tema)
   ============================================================ */
.wa-chat-card { padding: 0 !important; overflow: hidden; }
.wa-layout { display: flex; height: 74vh; min-height: 520px; }

/* ---- Lista de chats ---- */
.wa-list-pane { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--bg-sidebar); }
.wa-search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.wa-search { width: 100%; padding: 9px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); color: var(--text-primary); outline: none; font-size: 14px; transition: border-color .15s; }
.wa-search:focus { border-color: var(--border-focus); }
.wa-list { flex: 1; overflow-y: auto; }
.wa-row { display: flex; gap: 12px; align-items: center; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.035); transition: background .12s; }
.wa-row:hover { background: var(--bg-card-hover); }
.wa-row.active { background: var(--bg-active-tab); }
.wa-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, #2a2a3d, #16161f); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; color: #8b8ba7; }
.wa-row-main { flex: 1; min-width: 0; }
.wa-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.wa-row-name { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-row-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.wa-row-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 3px; }
.wa-row-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-badge { background: var(--wa-green); color: #06060a; border-radius: 11px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; flex-shrink: 0; line-height: 1.5; }
.wa-list-empty { padding: 24px 16px; color: var(--text-muted); text-align: center; font-size: 14px; }

/* ---- Conversación ---- */
.wa-conv-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background-color: #0a0a12; background-image: radial-gradient(rgba(255,255,255,0.022) 1px, transparent 1px); background-size: 22px 22px; }
.wa-conv-header { padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.wa-conv-header .wa-avatar { width: 40px; height: 40px; font-size: 16px; }
.wa-conv-title { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.wa-conv-sub { font-size: 12px; color: var(--text-muted); }
.wa-conv-msgs { flex: 1; overflow-y: auto; padding: 18px 7%; display: flex; flex-direction: column; gap: 3px; }
.wa-conv-empty { margin: auto; text-align: center; color: var(--text-muted); }
.wa-conv-empty svg { width: 64px; height: 64px; opacity: .25; margin-bottom: 12px; }

/* Burbujas */
.wa-bubble { max-width: 65%; padding: 6px 9px 7px; border-radius: 9px; font-size: 14px; line-height: 1.4; color: #e9edef; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.28); position: relative; }
/* La meta (hora/tilde) y la media no deben heredar el pre-wrap del texto. */
.wa-bubble .wa-meta, .wa-bubble img, .wa-bubble video, .wa-bubble audio { white-space: normal; }
.wa-bubble.in { align-self: flex-start; background: #202c33; border-top-left-radius: 3px; }
.wa-bubble.out { align-self: flex-end; background: #144d37; border-top-right-radius: 3px; }
.wa-sender { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; white-space: normal; }
.wa-bubble + .wa-bubble { margin-top: 1px; }
.wa-bubble img, .wa-bubble video { max-width: 300px; max-height: 340px; border-radius: 6px; display: block; cursor: pointer; }
.wa-bubble audio { max-width: 260px; }
.wa-bubble a { color: #53bdeb; text-decoration: none; }
.wa-cap { margin-top: 4px; }
.wa-meta { font-size: 10.5px; color: rgba(233,237,239,.45); text-align: right; margin-top: 2px; user-select: none; }
.wa-meta .tick-read { color: #53bdeb; }
.wa-media-missing { color: var(--text-muted); font-style: italic; }

/* Composer */
.wa-composer { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-sidebar); flex-shrink: 0; }
.wa-attach { border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 20px; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.wa-attach:hover { background: var(--bg-card-hover); }
.wa-msg-input { flex: 1; padding: 11px 18px; border: 1px solid var(--border); border-radius: 22px; background: var(--bg-input); color: var(--text-primary); outline: none; font-size: 14px; }
.wa-msg-input:focus { border-color: var(--border-focus); }
.wa-file-chip { font-size: 12px; color: var(--wa-green); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scrollbars finos */
.wa-list::-webkit-scrollbar, .wa-conv-msgs::-webkit-scrollbar { width: 7px; }
.wa-list::-webkit-scrollbar-thumb, .wa-conv-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.wa-list::-webkit-scrollbar-thumb:hover, .wa-conv-msgs::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

@media (max-width: 768px) {
    .wa-list-pane { width: 120px; }
    .wa-conv-msgs { padding: 14px 4%; }
    .wa-bubble { max-width: 85%; }
}

/* ---- Vincular chat ↔ proveedor ---- */
.wa-link-btn { margin-left: auto; flex-shrink: 0; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); border-radius: 18px; padding: 6px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.wa-link-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.wa-link-btn.linked { color: var(--wa-green); border-color: rgba(34,197,94,.4); }
.wa-link-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; z-index: 9999; backdrop-filter: blur(2px); }
.wa-link-modal { background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; width: min(440px, 92vw); max-height: 82vh; overflow-y: auto; box-shadow: var(--shadow-premium); color: var(--text-primary); }
.wa-link-hint { font-size: 13px; color: var(--text-secondary); margin: 4px 0 14px; line-height: 1.4; }
.wa-link-list { max-height: 260px; overflow-y: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; }
.wa-link-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 14px; }
.wa-link-item:last-child { border-bottom: none; }
.wa-link-item:hover { background: var(--bg-card-hover); }
.wa-link-phone { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.wa-link-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 13px; }
.wa-link-new { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.wa-link-new .wa-msg-input { flex: 1; }

.wa-admin-tag { font-size: 10px; background: var(--bg-active-tab); color: var(--primary); border-radius: 8px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
