:root {
  --bg-primary: #F5F6FA;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F0F1F5;
  --bg-input: #F8F9FC;
  --border: #E2E4EB;
  --border-focus: #4A6CF7;
  --text-primary: #1A1D2E;
  --text-secondary: #5C6078;
  --text-muted: #8B8FA3;
  --accent: #4A6CF7;
  --accent-light: #4A6CF7;
  --accent-bg: rgba(74, 108, 247, 0.08);
  --success: #16A34A;
  --success-bg: rgba(22, 163, 74, 0.08);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.06);
  --orange: #EA580C;
  --orange-bg: rgba(234, 88, 12, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 100; }
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--orange), #FF8A50); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; color: white; }
.logo-text span:first-child { font-size: 16px; font-weight: 700; display: block; }
.logo-text span:last-child { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.2px; padding: 0 12px; margin-bottom: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); font-size: 14px; font-weight: 500; position: relative; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-bg); color: var(--accent-light); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-badge { margin-left: auto; background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.user-profile { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #8B5CF6); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: white; }
.user-info span:first-child { font-size: 13px; font-weight: 600; display: block; }
.user-info span:last-child { font-size: 11px; color: var(--text-muted); }

/* Main */
.main { margin-left: 260px; min-height: 100vh; }
.topbar { position: sticky; top: 0; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; z-index: 50; }
.topbar-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-subtitle { font-size: 13px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px; width: 280px; }
.search-box:focus-within { border-color: var(--border-focus); }
.search-box input { background: none; border: none; outline: none; color: var(--text-primary); font-family: inherit; font-size: 13px; width: 100%; }
.search-box input::placeholder { color: var(--text-muted); }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; position: relative; }
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--bg-primary); }

/* Content */
.content { padding: 28px 32px; }
.page-section { display: none; }
.page-section.active { display: block; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: all var(--transition); }
.stat-card:hover { border-color: var(--border-focus); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.stat-icon.blue { background: var(--accent-bg); color: var(--accent-light); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; }
.stat-change { font-size: 12px; font-weight: 600; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Panels & Tables */
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.panel-title { font-size: 16px; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 24px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; background: var(--bg-input); border-bottom: 1px solid var(--border); }
td { padding: 14px 24px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(74, 108, 247, 0.04); }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.text-right { text-align: right; }
.customer-name { color: var(--text-primary); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition); border: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text-primary); }
.btn-orange { background: var(--orange); color: white; }
.btn-orange:hover { background: #E05A1B; }

/* Status Badges */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-badge.paid { background: var(--success-bg); color: var(--success); }
.status-badge.paid::before { background: var(--success); }
.status-badge.pending { background: var(--warning-bg); color: var(--warning); }
.status-badge.pending::before { background: var(--warning); }
.status-badge.overdue { background: var(--danger-bg); color: var(--danger); }
.status-badge.overdue::before { background: var(--danger); }
.status-badge.ok { background: var(--success-bg); color: var(--success); }
.status-badge.ok::before { background: var(--success); }
.status-badge.low { background: var(--danger-bg); color: var(--danger); }
.status-badge.low::before { background: var(--danger); }
.status-badge.sent { background: var(--accent-bg); color: var(--accent-light); }
.status-badge.sent::before { background: var(--accent); }
.status-badge.accepted { background: var(--success-bg); color: var(--success); }
.status-badge.accepted::before { background: var(--success); }
.status-badge.expired { background: rgba(100,100,120,0.15); color: #888; }
.status-badge.expired::before { background: #888; }
.status-badge.confirmed { background: var(--accent-bg); color: var(--accent-light); }
.status-badge.confirmed::before { background: var(--accent); }
.status-badge.processing { background: var(--warning-bg); color: var(--warning); }
.status-badge.processing::before { background: var(--warning); }
.status-badge.fulfilled { background: var(--success-bg); color: var(--success); }
.status-badge.fulfilled::before { background: var(--success); }
.status-badge.picking { background: var(--warning-bg); color: var(--warning); }
.status-badge.picking::before { background: var(--warning); }
.status-badge.packed { background: var(--orange-bg); color: var(--orange); }
.status-badge.packed::before { background: var(--orange); }
.status-badge.shipped { background: var(--accent-bg); color: var(--accent-light); }
.status-badge.shipped::before { background: var(--accent); }
.status-badge.delivered { background: var(--success-bg); color: var(--success); }
.status-badge.delivered::before { background: var(--success); }

/* Quick Actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.quick-action { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.quick-action:hover { border-color: var(--accent); background: var(--accent-bg); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-action-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.quick-action-label { font-size: 13px; font-weight: 600; }
.quick-action-desc { font-size: 11px; color: var(--text-muted); }

/* Grid layouts */
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* Chart */
.chart-area { height: 200px; display: flex; align-items: flex-end; gap: 8px; padding: 20px 24px; }
.chart-bar { flex: 1; background: linear-gradient(to top, var(--accent), var(--accent-light)); border-radius: 4px 4px 0 0; min-height: 20px; position: relative; }
.chart-bar::after { content: attr(data-label); position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-muted); }

/* Product Grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding: 16px 24px; }
.product-item { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; cursor: pointer; transition: all var(--transition); }
.product-item:hover { border-color: var(--accent); background: var(--accent-bg); }
.product-barcode { margin-bottom: 8px; overflow: hidden; }
.product-barcode svg { width: 100%; height: 28px; }
.product-sku { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.product-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }
.product-price { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; color: var(--success); }
.product-stock { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: inherit; font-size: 14px; }
.form-input:focus { outline: none; border-color: var(--border-focus); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
textarea.form-input { font-family: inherit; }

/* Quantity Input */
.qty-input { width: 50px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 4px; color: var(--text-primary); text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Tab Filters */
.tab-filters { display: flex; gap: 4px; padding: 4px; background: var(--bg-input); border-radius: var(--radius-sm); width: fit-content; }
.tab-filter { padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 6px; border: none; background: none; font-family: inherit; }
.tab-filter.active { background: var(--accent); color: white; }
.tab-filter:hover:not(.active) { color: var(--text-primary); }

/* Invoice Preview (print-friendly) */
.invoice-preview { background: white; color: #1a1a1a; border-radius: var(--radius); padding: 40px; max-width: 800px; margin: 0 auto; box-shadow: var(--shadow); }
.invoice-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 3px solid var(--orange); }
.invoice-company h1 { font-size: 24px; font-weight: 800; color: #0B1D35; margin-bottom: 4px; }
.invoice-company p { font-size: 12px; color: #666; line-height: 1.6; }
.invoice-title-block { text-align: right; }
.invoice-title-block h2 { font-size: 28px; font-weight: 800; color: var(--orange); }
.invoice-title-block p { font-size: 12px; color: #666; margin-top: 4px; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.invoice-meta-block h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #999; margin-bottom: 8px; font-weight: 600; }
.invoice-meta-block p { font-size: 13px; color: #333; line-height: 1.7; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-table th { background: #0B1D35; color: white; padding: 10px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; border: none; }
.invoice-table th:first-child { border-radius: 6px 0 0 0; }
.invoice-table th:last-child { border-radius: 0 6px 0 0; }
.invoice-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #eee; color: #333; background: white; }
.invoice-table tr:nth-child(even) td { background: #FAFAFA; }
.invoice-totals { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.invoice-totals table { width: 280px; }
.invoice-totals td { padding: 8px 0; font-size: 13px; border: none; color: #333; }
.invoice-totals td:last-child { text-align: right; font-family: 'JetBrains Mono', monospace; }
.invoice-totals tr.total { border-top: 2px solid #0B1D35; }
.invoice-totals tr.total td { font-size: 16px; font-weight: 800; padding-top: 12px; color: #0B1D35; }
.invoice-footer { border-top: 1px solid #eee; padding-top: 16px; font-size: 11px; color: #999; text-align: center; line-height: 1.8; }

/* ============ NEW STYLES ============ */

/* Sales Pipeline (Dashboard) */
.pipeline-bar { display: flex; align-items: center; padding: 20px 24px; gap: 4px; }
.pipeline-stage { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 12px; border-radius: var(--radius-sm); border: 1px solid; cursor: pointer; transition: all var(--transition); }
.pipeline-stage:hover { transform: translateY(-2px); }
.pipeline-count { font-size: 20px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.pipeline-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.pipeline-amount { font-size: 11px; font-family: 'JetBrains Mono', monospace; opacity: 0.7; }
.pipeline-arrow { font-size: 18px; color: var(--text-muted); padding: 0 4px; }

/* Flow Steps (Order/Delivery/Invoice pages) */
.flow-steps { display: flex; align-items: center; padding: 16px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.flow-step { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.flow-step.completed { color: var(--success); }
.flow-step.active-step { background: var(--accent-bg); color: var(--accent-light); }
.flow-icon { font-size: 16px; }
.flow-connector { flex: 1; height: 2px; background: var(--border); margin: 0 4px; }
.flow-connector.completed { background: var(--success); }
.flow-connector.active { background: linear-gradient(to right, var(--success), var(--accent)); }

/* Document Tags (Dashboard) */
.doc-tag { padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.tag-quote { background: var(--accent-bg); color: var(--accent-light); }
.tag-order { background: var(--warning-bg); color: var(--warning); }
.tag-delivery { background: var(--orange-bg); color: var(--orange); }
.tag-invoice { background: rgba(139,92,246,0.12); color: #A78BFA; }

/* Source Tags (Invoices/Orders) */
.source-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.source-quote { background: var(--accent-bg); color: var(--accent-light); }
.source-direct { background: rgba(100,100,120,0.15); color: var(--text-secondary); }
.source-web { background: var(--success-bg); color: var(--success); }
.source-delivery { background: var(--orange-bg); color: var(--orange); }

/* Delivery Type */
.delivery-type { font-size: 12px; font-weight: 600; }

/* Barcode in tables */
svg.barcode-sm { width: 100px; height: 24px; }

/* Scanner Indicator */
.scanner-indicator { display: flex; align-items: center; gap: 6px; }
.scanner-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse-dot 2s ease-in-out infinite; }
.scanner-indicator.scanned .scanner-dot { background: var(--accent); animation: none; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Quotation Approval Section (customer-facing) */
.quote-approval-section { margin: 32px 0 24px; padding: 28px; background: linear-gradient(135deg, #F0F7FF, #E8F4E8); border: 2px solid #4A6CF7; border-radius: 16px; }
.quote-approval-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.quote-approval-actions { display: flex; gap: 12px; }
.quote-approve-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 24px; background: #22C55E; color: white; border: none; border-radius: 12px; font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.quote-approve-btn:hover { background: #16A34A; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(34,197,94,0.3); }
.quote-negotiate-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 24px; background: white; color: #4A6CF7; border: 2px solid #4A6CF7; border-radius: 12px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.quote-negotiate-btn:hover { background: #F0F4FF; }
.quote-decline-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 20px; background: white; color: #999; border: 1px solid #ddd; border-radius: 12px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.quote-decline-btn:hover { color: #EF4444; border-color: #EF4444; background: #FEF2F2; }

/* Approval demo banner */
.approval-demo-banner { margin-top: 20px; padding: 20px 24px; background: var(--bg-card); border: 1px dashed var(--accent); border-radius: var(--radius); display: flex; align-items: flex-start; gap: 12px; }

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeInUp 0.4s ease both; }
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }

/* ============ CUSTOMER CARDS ============ */
.customer-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.customer-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: all var(--transition); }
.customer-card:hover { border-color: var(--border-focus); box-shadow: var(--shadow); }
.customer-card-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.customer-avatar { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: white; flex-shrink: 0; }
.customer-card-name { font-size: 16px; font-weight: 700; }
.customer-card-body { padding: 20px 24px; }
.customer-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.customer-info-item { display: flex; flex-direction: column; gap: 2px; }
.customer-info-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.customer-info-value { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.customer-card-footer { display: flex; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg-input); }
.pin-badge { background: rgba(139, 92, 246, 0.15); color: #A78BFA; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: help; }

/* Authorised Buyers */
.authorised-buyers { padding-top: 16px; border-top: 1px solid var(--border); }
.authorised-buyers-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.buyer-list { display: flex; flex-direction: column; gap: 8px; }
.buyer-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-input); border-radius: var(--radius-sm); }
.buyer-avatar { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; }
.buyer-info { display: flex; flex-direction: column; }
.buyer-name { font-size: 13px; font-weight: 600; }
.buyer-detail { font-size: 11px; color: var(--text-muted); }

/* PIN Verification Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); display: flex; flex-direction: column; }
.modal-body { overflow-y: auto; flex: 1; }
.modal-header { padding: 28px 28px 16px; text-align: center; }
.modal-header h3 { font-size: 20px; font-weight: 700; margin-top: 8px; }
.modal-body { padding: 0 28px 20px; }
.modal-footer { padding: 16px 28px 28px; display: flex; gap: 8px; }

/* PIN Input */
.pin-input-row { display: flex; gap: 8px; justify-content: center; }
.pin-digit { width: 48px; height: 56px; background: var(--bg-primary); border: 2px solid var(--border); border-radius: 10px; text-align: center; font-size: 24px; font-family: 'JetBrains Mono', monospace; color: var(--text-primary); outline: none; }
.pin-digit:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,108,247,0.2); }

/* Photo Capture */
.photo-capture-area { border: 2px dashed var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: all var(--transition); }
.photo-capture-area:hover { border-color: var(--accent); background: var(--accent-bg); }
.photo-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 4px; }

/* Product View Toggle */
.view-toggle { padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-card); font-family: inherit; transition: all var(--transition); }
.view-toggle.active { background: var(--accent); color: white; border-color: var(--accent); }
.view-toggle:hover:not(.active) { color: var(--text-primary); border-color: var(--text-muted); }

/* Supplier Tags */
.supplier-tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.supplier-tag.yele { background: var(--orange-bg); color: var(--orange); }
.supplier-tag.tradezone { background: var(--accent-bg); color: var(--accent-light); }
.supplier-tag.icool { background: var(--success-bg); color: var(--success); }

/* Supplier Name (purchase side) */
.supplier-name { color: var(--text-primary); font-weight: 500; }
.lang-tag { display: inline-flex; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 700; background: rgba(139,92,246,0.15); color: #A78BFA; margin-left: 4px; vertical-align: middle; }

/* Margin Indicators */
.margin-good { color: var(--success) !important; }
.margin-ok { color: var(--warning) !important; }
.margin-low { color: var(--danger) !important; }

/* Supplier Detail (collapsible) */
.supplier-detail { transition: all 0.3s ease; }
.supplier-detail.collapsed { display: none; }

/* Status badge additions */
.status-badge.draft { background: rgba(100,100,120,0.15); color: #999; }
.status-badge.draft::before { background: #999; }

/* ============ SMART IMPORT ============ */
.import-type-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; gap: 12px; }
.import-type-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.import-type-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.import-type-title { font-size: 16px; font-weight: 700; }
.import-type-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.import-type-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.import-tag { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; background: var(--accent-bg); color: var(--accent-light); }

/* File Drop Zone */
.file-drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); transition: all var(--transition); cursor: pointer; }
.file-drop-zone:hover { border-color: var(--accent); background: var(--accent-bg); }
.drop-zone-content { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; gap: 4px; }

/* PDF Preview */
.pdf-preview-area { background: var(--bg-input); }
.pdf-page-sim { margin: 16px; padding: 20px; background: white; border-radius: 4px; color: #333; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.pdf-product-row { display: flex; align-items: center; gap: 12px; padding: 10px; margin: 8px 0; border: 1px solid #e5e5e5; border-radius: 6px; background: #FAFAFA; position: relative; }
.pdf-product-img { width: 48px; height: 48px; background: #eee; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.pdf-product-info { flex: 1; }
.pdf-highlight-box { position: absolute; right: 8px; top: 8px; font-size: 9px; font-weight: 700; color: #22C55E; background: rgba(34,197,94,0.1); padding: 2px 6px; border-radius: 4px; }

/* Extraction Stats */
.extraction-stat { display: flex; flex-direction: column; align-items: center; padding: 8px 16px; }
.extraction-stat-value { font-size: 18px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.extraction-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Extracted Products */
.extracted-product-list { padding: 12px 24px; display: flex; flex-direction: column; gap: 12px; max-height: 500px; overflow-y: auto; }
.extracted-product { display: flex; gap: 12px; padding: 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.extracted-product-img { width: 56px; height: 56px; background: var(--bg-card-hover); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.extracted-product-body { flex: 1; }
.extracted-product-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.extracted-field-row { display: flex; gap: 8px; margin-bottom: 4px; }
.extracted-field { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.extracted-field-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.extracted-field-input { padding: 4px 8px !important; font-size: 12px !important; }
.extracted-product-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* Column Mapping (Excel) */
.column-map-grid { display: flex; flex-direction: column; gap: 10px; }
.column-map-item { display: flex; align-items: center; gap: 10px; }
.column-map-from { font-size: 12px; font-family: 'JetBrains Mono', monospace; color: var(--text-secondary); min-width: 180px; }
.column-map-arrow { color: var(--success); font-weight: 700; }

/* Radio Labels */
.radio-label { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.radio-label input { margin-top: 2px; }

/* ============ EMAIL MODAL ============ */
.email-to-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 42px; }
.email-to-field:focus-within { border-color: var(--border-focus); }
.email-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--accent-bg); color: var(--accent-light); border-radius: 16px; font-size: 12px; font-weight: 500; }
.email-chip-x { cursor: pointer; font-size: 14px; opacity: 0.6; margin-left: 2px; }
.email-chip-x:hover { opacity: 1; }
.email-to-input { background: none; border: none; outline: none; color: var(--text-primary); font-family: inherit; font-size: 13px; flex: 1; min-width: 150px; }
.email-contact-suggestions { margin-top: 6px; padding: 4px 0; }
.email-suggestion { padding: 4px 8px; font-size: 12px; cursor: pointer; border-radius: 4px; transition: background 0.15s; }
.email-suggestion:hover { background: var(--accent-bg); }

/* Email Body Editor */
.email-body-editor { min-height: 180px; max-height: 250px; overflow-y: auto; padding: 16px; background: white; color: #333; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.7; border: 1px solid var(--border); }
.email-body-editor:focus { outline: none; border-color: var(--border-focus); }
.email-body-editor p { margin-bottom: 8px; }
.email-body-editor a { color: #4A6CF7; }

/* Email Attachments */
.email-attachments { display: flex; flex-direction: column; gap: 6px; }
.email-attachment { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.email-attachment-name { font-size: 13px; font-weight: 600; }
.email-attachment-size { font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* Email Options */
.email-option { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

/* Email Template Buttons */
.email-template-btn { padding: 4px 10px; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 4px; border: 1px solid var(--border); background: none; font-family: inherit; transition: all 0.15s; }
.email-template-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.email-template-btn:hover:not(.active) { color: var(--text-primary); }

/* Email Toast */
.email-toast { position: fixed; bottom: 32px; right: 32px; display: flex; align-items: center; gap: 12px; padding: 16px 24px; background: var(--bg-card); border: 1px solid var(--success); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,0.3); z-index: 2000; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ============ SUPPLIER CARDS ============ */
.supplier-card-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; cursor: pointer; transition: background 0.15s; }
.supplier-card-header:hover { background: var(--bg-card-hover); }
.supplier-expand { transition: all 0.3s; }
.supplier-expand.collapsed { display: none; }
.supplier-info-section { padding: 20px 24px; border-top: 1px solid var(--border); }
.supplier-info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 16px; }
.supplier-section-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.supplier-info-col { display: flex; flex-direction: column; gap: 6px; }
.supplier-info-row { display: flex; gap: 8px; font-size: 13px; }
.supplier-info-label { color: var(--text-muted); min-width: 90px; flex-shrink: 0; font-size: 11px; font-weight: 600; padding-top: 1px; }
.supplier-contact-card { padding: 10px 12px; background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 8px; }
.supplier-contact-role { font-size: 10px; font-weight: 700; color: var(--accent-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.supplier-contact-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.supplier-contact-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.supplier-info-actions { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Price Level Tags */
.price-level-tag { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.price-level-tag.vip { background: var(--orange-bg); color: var(--orange); }
.price-level-tag.trade { background: var(--accent-bg); color: var(--accent-light); }
.price-level-tag.standard { background: rgba(100,100,120,0.15); color: var(--text-secondary); }

/* Supplier Type Selector (in form) */
.supplier-type-option { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; flex: 1; transition: all 0.15s; font-size: 13px; font-weight: 600; }
.supplier-type-option:hover { border-color: var(--accent); }
.supplier-type-option.selected, .supplier-type-option:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.supplier-type-option input { display: none; }

/* Supplier Contact Form Card */
.supplier-contact-form-card { padding: 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; }

/* ============ PROCUREMENT PLANNING ============ */
.procurement-alert { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--danger-bg); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius); }
.procurement-alert-icon { font-size: 32px; }
.procurement-alert-body { flex: 1; }
.procurement-alert-body strong { color: var(--danger); font-size: 14px; }
.procurement-alert-body p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Planning table rows */
.procurement-row.urgent td { background: rgba(239,68,68,0.06); }
.procurement-row.warning td { background: rgba(245,158,11,0.04); }

/* Stockout date badges */
.stockout-date { font-size: 12px; font-weight: 600; }
.stockout-date.critical { color: var(--danger); }
.stockout-date.danger { color: var(--danger); }
.stockout-date.warning { color: var(--warning); }
.stockout-label { display: block; font-size: 10px; font-weight: 700; margin-top: 2px; }
.procurement-row.urgent .stockout-label { color: var(--danger); }
.procurement-row.warning .stockout-label { color: var(--warning); }

/* Reorder badges */
.reorder-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.reorder-badge.critical { background: var(--danger-bg); color: var(--danger); }
.reorder-badge.urgent { background: var(--danger-bg); color: var(--danger); }
.reorder-badge.warning { background: var(--warning-bg); color: var(--warning); }
.reorder-badge.ok { background: var(--success-bg); color: var(--success); }

/* Transit info */
.transit-info { display: flex; flex-direction: column; gap: 1px; }

/* Velocity Chart */
.velocity-chart { padding: 16px 24px; }
.velocity-chart-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.velocity-chart-row.highlight { background: var(--accent-bg); margin: 0 -24px; padding: 6px 24px; border-radius: 0; }
.velocity-week { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--text-muted); min-width: 32px; }
.velocity-bar-track { flex: 1; height: 22px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.velocity-bar { height: 100%; background: linear-gradient(to right, var(--accent), var(--accent-light)); border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; }
.velocity-bar span { font-size: 10px; font-weight: 700; color: white; }
.velocity-bar.current { background: linear-gradient(to right, var(--orange), #FF8A50); }
.velocity-avg { font-size: 11px; font-weight: 600; color: var(--accent-light); white-space: nowrap; }

/* ============ ROLE SWITCHER ============ */
.role-switcher { position: absolute; bottom: 68px; left: 8px; right: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 0; display: none; z-index: 100; box-shadow: 0 -8px 24px rgba(0,0,0,0.4); }
.role-switcher.open { display: block; }
.role-switcher-title { padding: 8px 16px 10px; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.role-option { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; transition: background 0.1s; }
.role-option:hover { background: var(--bg-card-hover); }
.role-option-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; }
.role-option-info { display: flex; flex-direction: column; gap: 1px; }
.role-option-name { font-size: 13px; font-weight: 600; }
.role-option-role { font-size: 11px; color: var(--text-muted); }
.role-option-check { margin-left: auto; font-size: 14px; color: var(--accent); opacity: 0; }
.role-option.active .role-option-check { opacity: 1; }
.role-option.active { background: var(--accent-bg); }

/* ============ ROLE-BASED DATA MASKING ============ */
/* Blur helper */
[data-sensitive] { transition: filter 0.2s; }
.hide-cost [data-sensitive="cost"],
.hide-margin [data-sensitive="margin"],
.hide-supplier-price [data-sensitive="supplier-price"] { filter: blur(8px); pointer-events: none; user-select: none; position: relative; }
.hide-cost [data-sensitive="cost"]::after,
.hide-margin [data-sensitive="margin"]::after,
.hide-supplier-price [data-sensitive="supplier-price"]::after { content: '🔒'; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 10px; filter: none; }

/* Hide purchase view toggle for sales/warehouse */
.hide-supplier-price #viewPurchase,
.hide-supplier-price #viewFull { display: none !important; }

/* Hide supplier catalog section for sales */
.hide-supplier-price .supplier-name { filter: blur(8px); pointer-events: none; user-select: none; }

/* PIN Verify Bar (in invoice builder) */
.pin-verify-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.3); border-radius: var(--radius-sm); margin-bottom: 12px; }

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; position: relative; white-space: nowrap; }
th.sortable:hover { background: rgba(0,0,0,0.04); }
th.sortable .sort-icon { font-size: 10px; opacity: 0.4; margin-left: 4px; }
th.sortable:hover .sort-icon { opacity: 0.7; }
th.sortable.sort-asc .sort-icon, th.sortable.sort-desc .sort-icon { opacity: 1; color: var(--accent); }

/* Customer search combo in Invoice Builder */
#invoiceCustomerDropdown .customer-combo-item:hover,
#invoiceCustomerDropdown .customer-combo-item:focus {
  background: var(--bg-hover) !important;
}
#invoiceCustomerSearch:focus + .customer-combo-hidden + #invoiceCustomerDropdown {
  display: block;
}

/* Mobile responsive modal */
@media (max-width: 768px) {
  .modal-overlay { align-items: flex-start !important; padding: 8px; }
  .modal-box, #editProductModal .modal-box, #editProductModal > div:first-child { max-width: 100% !important; width: 100% !important; max-height: calc(100vh - 16px) !important; overflow-y: auto !important; border-radius: 12px; }
  #editProductModal > div:first-child { max-width: 100% !important; width: 100% !important; max-height: calc(100vh - 16px) !important; overflow-y: auto !important; }
  .modal-body, #editProductModal div[style*="grid-template-columns: 1fr 1fr"], #editProductModal div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
}
