/* ═══════════════════════════════════════════════════════════
   JBP Trade Intelligence — Premium Theme (Dark + Light)
   ═══════════════════════════════════════════════════════════ */

/* ── Google Font ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
    color-scheme: dark;
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #252840;
    --bg-sidebar: #141620;
    --border-color: #2a2d3e;
    --border-hover: #3d4160;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --text-muted: #5c607a;
    --accent-teal: #00d4aa;
    --accent-teal-dim: rgba(0, 212, 170, 0.15);
    --accent-blue: #3b82f6;
    --accent-blue-dim: rgba(59, 130, 246, 0.15);
    --accent-purple: #8b5cf6;
    --accent-purple-dim: rgba(139, 92, 246, 0.15);
    --accent-orange: #f59e0b;
    --accent-orange-dim: rgba(245, 158, 11, 0.15);
    --accent-red: #ef4444;
    --accent-red-dim: rgba(239, 68, 68, 0.15);
    --accent-green: #22c55e;
    --accent-green-dim: rgba(34, 197, 94, 0.15);
    --gradient-teal: linear-gradient(135deg, #00d4aa, #00b4d8);
    --gradient-blue: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-orange: linear-gradient(135deg, #f59e0b, #ef4444);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Light Theme Override ────────────────────────────────── */
[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f0f2f6;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f6fa;
    --bg-sidebar: #ffffff;
    --border-color: #e0e3eb;
    --border-hover: #c5c9d6;
    --text-primary: #1a1d2b;
    --text-secondary: #5b6078;
    --text-muted: #8a8fa6;
    --accent-teal: #00b894;
    --accent-teal-dim: rgba(0, 184, 148, 0.10);
    --accent-blue: #2563eb;
    --accent-blue-dim: rgba(37, 99, 235, 0.08);
    --accent-purple: #7c3aed;
    --accent-purple-dim: rgba(124, 58, 237, 0.08);
    --accent-orange: #e67e22;
    --accent-orange-dim: rgba(230, 126, 34, 0.08);
    --accent-red: #dc2626;
    --accent-red-dim: rgba(220, 38, 38, 0.08);
    --accent-green: #16a34a;
    --accent-green-dim: rgba(22, 163, 74, 0.08);
    --gradient-teal: linear-gradient(135deg, #00b894, #00a8cc);
    --gradient-blue: linear-gradient(135deg, #2563eb, #7c3aed);
    --gradient-orange: linear-gradient(135deg, #e67e22, #dc2626);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.09);
}

[data-theme="light"] .sidebar {
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .btn-teal {
    color: #ffffff;
}

[data-theme="light"] .btn-teal:hover {
    color: #ffffff;
}



[data-theme="light"] ::-webkit-scrollbar-track { background: #f0f2f6; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c5c9d6; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #8a8fa6; }

/* ── Modal Close Button — theme-aware ───────────────────────
   Dark mode: invert the default black X → white (visible on dark bg)
   Light mode: no filter — keep the default black X (visible on white bg)
   This fixes ALL modals across the app without touching each template.
   ─────────────────────────────────────────────────────────── */
.modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
[data-theme="light"] .modal .btn-close {
    filter: none;
}

/* ── Theme Toggle Button ─────────────────────────────────── */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    background: var(--accent-teal-dim);
}

.theme-toggle.logout-action {
    color: var(--accent-red);
}

.theme-toggle.logout-action:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
    background: var(--accent-red-dim);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Native dropdown colour-scheme follows :root (dark by default, light when toggled).
   We must NOT hardcode color-scheme here — let it inherit from :root so the
   OS-rendered <option> list respects the current theme automatically. */
input, select, textarea, datalist {
    color-scheme: inherit;
}
select, .form-select {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
option, select option, .form-select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* ── Bootstrap Dropdown Menus & Items ─────────────────────── */
.dropdown-menu {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
}
.dropdown-item {
    color: var(--text-primary) !important;
    transition: var(--transition);
}
.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--bg-card-hover) !important;
    color: var(--text-primary) !important;
}
.dropdown-item.text-danger {
    color: var(--accent-red) !important;
}
.dropdown-item.text-danger:hover {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: var(--accent-red) !important;
}

a {
    color: var(--accent-teal);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: #33e6c0;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ──────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 24px 32px;
    transition: var(--transition);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand h1 .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand small {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* ── Logo Lightbox ───────────────────────────────────────── */
.logo-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.logo-lightbox.visible {
    display: flex;
    opacity: 1;
    animation: lightboxFadeIn 0.3s ease forwards;
}

.logo-lightbox img {
    max-width: 340px;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 16px;
    background: #fff;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: lightboxZoomIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-lightbox-close {
    position: absolute;
    top: 24px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.logo-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes lightboxZoomIn {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-nav .nav-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 12px 12px 8px;
}

.sidebar-nav .nav-item {
    margin-bottom: 2px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-nav .nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav .nav-link:hover .nav-icon {
    filter: brightness(1.15) saturate(1.2);
    transform: scale(1.08);
}

.sidebar-nav .nav-link.active {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
}

.sidebar-nav .nav-link.active .nav-icon {
    filter: brightness(1.1) saturate(1.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Nav Icon Pill System ────────────────────────────────── */
.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    margin-right: 10px;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.25s ease;
    background: rgba(139, 143, 163, 0.10);
    color: var(--text-secondary);
}

/* Per-icon accent colors — Main section */
.nav-icon.icon-dashboard   { background: rgba(59, 130, 246, 0.14);  color: #3b82f6; }
.nav-icon.icon-market      { background: rgba(0, 212, 170, 0.14);   color: #00d4aa; }
.nav-icon.icon-heatmap     { background: rgba(245, 158, 11, 0.14);  color: #f59e0b; }
.nav-icon.icon-pricing     { background: rgba(139, 92, 246, 0.14);  color: #8b5cf6; }
.nav-icon.icon-buyers      { background: rgba(34, 197, 94, 0.14);   color: #22c55e; }
.nav-icon.icon-competitors { background: rgba(239, 68, 68, 0.14);   color: #ef4444; }
.nav-icon.icon-suppliers   { background: rgba(251, 146, 60, 0.14);  color: #fb923c; }

/* Per-icon accent colors — Operations section */
.nav-icon.icon-orders      { background: rgba(0, 212, 170, 0.14);   color: #00d4aa; }

/* Per-icon accent colors — Partners section */
.nav-icon.icon-oems        { background: rgba(59, 130, 246, 0.14);  color: #60a5fa; }
.nav-icon.icon-clients     { background: rgba(139, 92, 246, 0.14);  color: #a78bfa; }

/* Per-icon accent colors — Tools section */
.nav-icon.icon-calc        { background: rgba(59, 130, 246, 0.14);  color: #3b82f6; }
.nav-icon.icon-compliance  { background: rgba(34, 197, 94, 0.14);   color: #22c55e; }
.nav-icon.icon-resources   { background: rgba(245, 158, 11, 0.14);  color: #f59e0b; }
.nav-icon.icon-followups   { background: rgba(239, 68, 68, 0.14);   color: #ef4444; }

/* Light-theme adjustments for nav icons */
[data-theme="light"] .nav-icon.icon-dashboard   { background: rgba(37,99,235,0.09);   color: #2563eb; }
[data-theme="light"] .nav-icon.icon-market      { background: rgba(0,184,148,0.09);   color: #00b894; }
[data-theme="light"] .nav-icon.icon-heatmap     { background: rgba(230,126,34,0.09);  color: #e67e22; }
[data-theme="light"] .nav-icon.icon-pricing     { background: rgba(124,58,237,0.09);  color: #7c3aed; }
[data-theme="light"] .nav-icon.icon-buyers      { background: rgba(22,163,74,0.09);   color: #16a34a; }
[data-theme="light"] .nav-icon.icon-competitors { background: rgba(220,38,38,0.09);   color: #dc2626; }
[data-theme="light"] .nav-icon.icon-suppliers   { background: rgba(234,88,12,0.09);   color: #ea580c; }
[data-theme="light"] .nav-icon.icon-orders      { background: rgba(0,184,148,0.09);   color: #00b894; }
[data-theme="light"] .nav-icon.icon-oems        { background: rgba(37,99,235,0.09);   color: #2563eb; }
[data-theme="light"] .nav-icon.icon-clients     { background: rgba(124,58,237,0.09);  color: #7c3aed; }
[data-theme="light"] .nav-icon.icon-calc        { background: rgba(37,99,235,0.09);   color: #2563eb; }
[data-theme="light"] .nav-icon.icon-compliance  { background: rgba(22,163,74,0.09);   color: #16a34a; }
[data-theme="light"] .nav-icon.icon-resources   { background: rgba(230,126,34,0.09);  color: #e67e22; }
[data-theme="light"] .nav-icon.icon-followups   { background: rgba(220,38,38,0.09);   color: #dc2626; }

/* ── Mobile Toggle ───────────────────────────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--accent-teal);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1199;
    backdrop-filter: blur(4px);
}

/* ── Top Header Bar ──────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--bg-primary);
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.top-bar:has(.custom-dropdown.active),
.top-bar.has-active-dropdown {
    z-index: 1060;
}

.top-bar .custom-dropdown.active {
    z-index: 1060;
}

.top-bar .custom-dropdown.active .dropdown-options {
    z-index: 1065;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar .page-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.top-bar .page-title p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Product Selector ────────────────────────────────────── */
/* ── Custom Dropdown ────────────────────────────────────── */
.custom-dropdown {
    position: relative;
    min-width: 220px;
    font-family: 'Inter', sans-serif;
    user-select: none;
}

.dropdown-trigger {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.dropdown-trigger:hover {
    border-color: var(--accent-teal);
    background: var(--bg-card-hover);
}

.custom-dropdown.active .dropdown-trigger {
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px var(--accent-teal-dim);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    animation: fadeInDown 0.2s ease;
}

.custom-dropdown.active .dropdown-options {
    display: block;
}

.dropdown-option {
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover,
.dropdown-option.hover {
    background: var(--bg-card-hover);
}

.dropdown-option.active {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
}

.option-name {
    font-weight: 600;
    font-size: 14px;
}

.option-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Cards ───────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-teal);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 14px;
}

.stat-card .stat-icon.teal { background: var(--accent-teal-dim); color: var(--accent-teal); }
.stat-card .stat-icon.blue { background: var(--accent-blue-dim); color: var(--accent-blue); }
.stat-card .stat-icon.purple { background: var(--accent-purple-dim); color: var(--accent-purple); }
.stat-card .stat-icon.orange { background: var(--accent-orange-dim); color: var(--accent-orange); }
.stat-card .stat-icon.green { background: var(--accent-green-dim); color: var(--accent-green); }
.stat-card .stat-icon.red { background: var(--accent-red-dim); color: var(--accent-red); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ── Opportunity Cards ───────────────────────────────────── */
.opportunity-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.opportunity-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.opportunity-card.rank-1::before { background: var(--gradient-teal); }
.opportunity-card.rank-2::before { background: var(--gradient-blue); }
.opportunity-card.rank-3::before { background: var(--gradient-orange); }

.opportunity-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.opportunity-card .opp-rank {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
}

.opportunity-card.rank-1 .opp-rank { background: var(--accent-teal-dim); color: var(--accent-teal); }
.opportunity-card.rank-2 .opp-rank { background: var(--accent-blue-dim); color: var(--accent-blue); }
.opportunity-card.rank-3 .opp-rank { background: var(--accent-orange-dim); color: var(--accent-orange); }

.opportunity-card .opp-country {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.opportunity-card .opp-price {
    font-size: 14px;
    color: var(--accent-teal);
    font-weight: 600;
    margin-bottom: 16px;
}

.opportunity-card .opp-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.opportunity-card .opp-meta-item {
    font-size: 12px;
}

.opportunity-card .opp-meta-item .meta-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.opportunity-card .opp-meta-item .meta-value {
    color: var(--text-primary);
    font-weight: 600;
}

.opp-insight {
    margin-top: 16px;
    padding: 12px;
    background: var(--accent-teal-dim);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--accent-teal);
    font-weight: 500;
    line-height: 1.5;
    border-left: 3px solid var(--accent-teal);
}

/* ── Badge Styles ────────────────────────────────────────── */
.badge-demand-high {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-demand-medium {
    background: var(--accent-orange-dim);
    color: var(--accent-orange);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-demand-low {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-risk-low {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-risk-medium {
    background: var(--accent-orange-dim);
    color: var(--accent-orange);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-risk-high {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* ── Data Table ──────────────────────────────────────────── */
.data-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.table-responsive-custom {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 75vh;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.data-table-wrapper .table-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.data-table-wrapper .table-header h5 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: var(--bg-secondary);
    padding: 12px 18px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody td {
    padding: 14px 18px;
    font-size: 13.5px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ── Bootstrap .table-hover override for themed pages ──── */
.table-hover > tbody > tr:hover > * {
    --bs-table-hover-bg: var(--bg-card-hover);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-color: var(--text-primary);
    background-color: var(--bg-card-hover) !important;
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr.top-row td:first-child {
    position: relative;
    padding-left: 28px;
}

.data-table tbody tr.top-row td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-teal);
}

/* ── Chart Container ─────────────────────────────────────── */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.chart-container .chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    max-height: 400px;
}

/* ── Forms / Inputs ──────────────────────────────────────── */
.form-control-dark {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    font-family: 'Inter', sans-serif !important;
    transition: var(--transition);
}

.form-control-dark:focus {
    border-color: var(--accent-teal) !important;
    box-shadow: 0 0 0 3px var(--accent-teal-dim) !important;
}

.form-control-dark:-webkit-autofill,
.form-control-dark:-webkit-autofill:hover, 
.form-control-dark:-webkit-autofill:focus, 
.form-control-dark:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-secondary) inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-control-dark::placeholder {
    color: var(--text-muted) !important;
}

/* Filter inputs that have an absolutely-positioned icon on the left */
.form-control-icon-left {
    padding-left: 32px !important;
}

.form-label-dark {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-teal {
    background: var(--gradient-teal);
    color: #0f1117;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
}

.btn-teal:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
    color: #0f1117;
}

.btn-outline-teal {
    background: transparent;
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal);
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
}

.btn-outline-teal:hover {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
}

.btn-icon-action {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-icon-action:hover {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
    border-color: var(--accent-teal);
}

/* ── Result Card (Calculator) ────────────────────────────── */
.result-card {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.08), rgba(0, 180, 216, 0.05));
    border: 1px solid rgba(0, 212, 170, 0.25);
    border-radius: 14px;
    padding: 28px;
}

.result-card .result-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--accent-teal);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.result-item:last-child {
    border-bottom: none;
}

.result-item .ri-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-item .ri-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.result-item .ri-value.highlight {
    color: var(--accent-teal);
    font-size: 20px;
}

/* ── Compliance Checklist ────────────────────────────────── */
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.checklist-icon.required {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
}

.checklist-icon.optional {
    background: var(--accent-orange-dim);
    color: var(--accent-orange);
}

.checklist-text h6 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.checklist-text p {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Supplier Cards ──────────────────────────────────────── */
.supplier-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: var(--transition);
}

.supplier-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.supplier-card .supplier-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.supplier-card .supplier-location {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.supplier-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.supplier-meta .sm-item {
    font-size: 12px;
}

.supplier-meta .sm-item .sm-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.supplier-meta .sm-item .sm-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Star rating */
.stars {
    color: var(--accent-orange);
    font-size: 14px;
    letter-spacing: 2px;
}
.stars .empty {
    color: var(--text-muted);
}

/* ── Markup Card ─────────────────────────────────────────── */
.markup-card {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.06), rgba(59, 130, 246, 0.06));
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 14px;
    padding: 28px;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.markup-card .markup-value {
    font-size: 48px;
    font-weight: 800;
    background: var(--gradient-teal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 6px;
}

.markup-card .markup-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
    margin-bottom: 20px;
}

.section-header h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-bar .filter-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-bar .filter-badge:hover,
.filter-bar .filter-badge.active {
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
    border-color: var(--accent-teal);
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--border-color);
}

.empty-state p {
    font-size: 14px;
}

/* ── Insight Box ─────────────────────────────────────────── */
.insight-box {
    background: var(--accent-blue-dim);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-left: 4px solid var(--accent-blue);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.insight-box i {
    color: var(--accent-blue);
    font-size: 18px;
    margin-top: 2px;
}

.insight-box p {
    font-size: 13.5px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.5;
}

/* ── Country Detail Hero ─────────────────────────────────── */
.country-hero {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 32px;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.country-hero .ch-info h3 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
}

.country-hero .ch-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.country-hero .ch-stats {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.country-hero .ch-stat-item {
    text-align: center;
}

.country-hero .ch-stat-item .ch-val {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-teal);
}

.country-hero .ch-stat-item .ch-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Risk Indicators ─────────────────────────────────────── */
.risk-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.risk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 13px;
}

.risk-item i.positive { color: var(--accent-green); }
.risk-item i.negative { color: var(--accent-red); }

/* ── Tooltips ────────────────────────────────────────────── */
.info-tooltip {
    position: relative;
    cursor: help;
    outline: none; /* remove focus outline on tap */
}

.info-tooltip .tooltip-content {
    visibility: hidden;
    width: max-content;
    max-width: 220px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    text-align: center;
    border-radius: 8px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1050;
    top: 130%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    font-size: 11.5px;
    font-weight: 500;
    pointer-events: none;
    white-space: normal;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
}

/* Tooltip arrow */
.info-tooltip .tooltip-content::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent var(--border-color) transparent;
}

.info-tooltip:hover .tooltip-content,
.info-tooltip:focus .tooltip-content,
.info-tooltip:active .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
}

/* ── Resources Page ──────────────────────────────────────── */
.portal-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.portal-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-accent);
    opacity: 0;
    transition: var(--transition);
}

.portal-card:hover {
    border-color: var(--card-accent);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    transform: translateY(-4px);
    color: inherit;
    text-decoration: none;
}

.portal-card:hover::before { opacity: 1; }

.portal-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 4px;
}

.portal-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.portal-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    transition: var(--transition);
}

.portal-card:hover .portal-icon-wrap { transform: scale(1.1); }

.portal-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.portal-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
    transition: var(--transition);
}

.portal-card:hover .portal-name { color: var(--card-accent); }

.portal-full-name {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 10px;
    line-height: 1.4;
}

.portal-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
    margin-bottom: 14px;
}

.portal-link-hint {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    word-break: break-all;
    transition: var(--transition);
}

.portal-card:hover .portal-link-hint {
    color: var(--card-accent);
    border-color: var(--card-accent);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 992px) ────────────────────────────────────── */
@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-bar > div {
        width: 100%;
        max-width: 100%;
    }

    .country-hero {
        flex-direction: column;
        text-align: center;
    }

    .country-hero .ch-stats {
        justify-content: center;
    }

    .opportunity-card .opp-meta {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ── Mobile (≤ 576px) ────────────────────────────────────── */
@media (max-width: 576px) {
    .main-content {
        padding: 16px;
    }

    .top-bar .page-title h2 {
        font-size: 20px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .opportunity-card {
        padding: 18px;
    }

    .opportunity-card .opp-country {
        font-size: 18px;
    }

    .data-table-wrapper {
        border-radius: 8px;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .chart-container {
        padding: 16px;
    }

    .country-hero {
        padding: 20px;
    }

    .country-hero .ch-info h3 {
        font-size: 22px;
    }

    .country-hero .ch-stat-item .ch-val {
        font-size: 20px;
    }

    .markup-card .markup-value {
        font-size: 36px;
    }

    .supplier-meta {
        grid-template-columns: 1fr 1fr;
    }

    .filter-bar {
        gap: 8px;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .result-item .ri-value.highlight {
        font-size: 18px;
    }

    /* ── Mobile input zoom prevention ──────────────────────── */
    /* iOS Safari & Chrome zoom in on inputs with font-size    */
    /* smaller than 16px — set to 16px to suppress this        */
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* ── Table Scroll on Small Screens ───────────────────────── */
@media (max-width: 768px) {
    .table-responsive-custom {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive-custom .data-table {
        min-width: 600px;
    }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.4s ease-out forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.10s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.20s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.30s; }

/* ═══════════════════════════════════════════════════════════
   BUYER INTELLIGENCE — Pipeline & Enrichment UI
   ═══════════════════════════════════════════════════════════ */

/* ── Pipeline Strip ──────────────────────────────────────── */
.pipeline-strip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.pipeline-strip::-webkit-scrollbar {
    display: none;
}

.pipeline-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.pipeline-stages {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex: 1;
}

.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: 1px solid transparent;
    min-width: 72px;
}

.pipeline-stage:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
}

.ps-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.ps-icon.blue   { background: var(--accent-blue-dim);   color: var(--accent-blue); }
.ps-icon.purple { background: var(--accent-purple-dim); color: var(--accent-purple); }
.ps-icon.orange { background: var(--accent-orange-dim); color: var(--accent-orange); }
.ps-icon.teal   { background: var(--accent-teal-dim);   color: var(--accent-teal); }
.ps-icon.green  { background: var(--accent-green-dim);  color: var(--accent-green); }
.ps-icon.red    { background: var(--accent-red-dim);    color: var(--accent-red); }

.ps-count {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.ps-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
}

.ps-arrow {
    color: var(--text-muted);
    font-size: 10px;
    opacity: 0.5;
}

/* Active stage highlight */
.active-stage-blue   { background: var(--accent-blue-dim)   !important; border-color: var(--accent-blue)   !important; }
.active-stage-purple { background: var(--accent-purple-dim) !important; border-color: var(--accent-purple) !important; }
.active-stage-orange { background: var(--accent-orange-dim) !important; border-color: var(--accent-orange) !important; }
.active-stage-teal   { background: var(--accent-teal-dim)   !important; border-color: var(--accent-teal)   !important; }
.active-stage-green  { background: var(--accent-green-dim)  !important; border-color: var(--accent-green)  !important; }
.active-stage-red    { background: var(--accent-red-dim)    !important; border-color: var(--accent-red)    !important; }

/* ── Status Pill + Inline Dropdown ──────────────────────── */
.pipeline-status-selector {
    position: relative;
    display: inline-block;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    white-space: nowrap;
}

.status-pill:hover { opacity: 0.85; }

.status-not-contacted { background: var(--accent-blue-dim);   color: var(--accent-blue); }
.status-pitched       { background: var(--accent-purple-dim); color: var(--accent-purple); }
.status-negotiating   { background: var(--accent-orange-dim); color: var(--accent-orange); }
.status-sample-sent   { background: var(--accent-teal-dim);   color: var(--accent-teal); }
.status-won           { background: var(--accent-green-dim);  color: var(--accent-green); }
.status-lost          { background: var(--accent-red-dim);    color: var(--accent-red); }

.status-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    display: none;
    animation: fadeInDown 0.18s ease;
    overflow: hidden;
}

.status-menu.open { display: block; }

.status-menu-item {
    padding: 9px 14px;
    font-size: 12.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.status-menu-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.status-menu-item.active { color: var(--accent-teal); font-weight: 600; }

/* ── Contact Icons ───────────────────────────────────────── */
.contact-icons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.contact-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.contact-icon.email    { background: var(--accent-blue-dim);   color: var(--accent-blue); }
.contact-icon.whatsapp { background: var(--accent-green-dim);  color: var(--accent-green); }
.contact-icon.phone    { background: var(--accent-teal-dim);   color: var(--accent-teal); }
.contact-icon.website  { background: var(--accent-purple-dim); color: var(--accent-purple); }
.contact-icon.linkedin { background: rgba(0,119,181,0.15);     color: #0077b5; }

.contact-icon:hover { transform: scale(1.15); }

/* ── Buyer Type Badge ────────────────────────────────────── */
.buyer-type-badge {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Edit icon button ────────────────────────────────────── */
.btn-icon-edit {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-edit:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    background: var(--accent-teal-dim);
}

/* ── Buyer Edit Modal ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.25s ease;
}

.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-box-header h5 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.modal-close-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.modal-box-body {
    padding: 24px;
}

.modal-box-footer {
    display: flex;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

/* Custom Select Styling to fix Mobile Dark Mode */
select.form-control-dark, select.form-select-dark {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    /* Explicit background-color for mobile browsers that ignore shorthand */
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    /* Custom SVG Arrow matching the text-secondary color (#8b8fa3) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b8fa3' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 12px 12px !important;
    padding-right: 40px !important;
    color-scheme: dark !important;
    border-radius: 8px !important;
    outline: none !important;
}

select.form-control-dark:focus, select.form-select-dark:focus {
    border-color: var(--accent-teal) !important;
    box-shadow: 0 0 0 3px var(--accent-teal-dim) !important;
    outline: none !important;
}

[data-theme="light"] select.form-control-dark,
[data-theme="light"] select.form-select-dark {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    /* Custom SVG Arrow matching light theme text-secondary color (#5b6078) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235b6078' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    color-scheme: light !important;
}

select.form-control-dark option, select.form-select-dark option {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Dark select inside modal */
.form-select-dark {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    font-family: 'Inter', sans-serif !important;
    transition: var(--transition);
}

.form-select-dark:focus {
    border-color: var(--accent-teal) !important;
    box-shadow: 0 0 0 3px var(--accent-teal-dim) !important;
    outline: none;
}

/* ── Flash Alert ─────────────────────────────────────────── */
.alert-flash {
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
}

.alert-flash.alert-success {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

/* ═══════════════════════════════════════════════════════════
   HEAT MAP PAGE
   ═══════════════════════════════════════════════════════════ */

/* ── Map controls row ────────────────────────────────────── */
.heatmap-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 20px;
}

.hm-legend {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.legend-gradient {
    width: 130px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #a78bfa, #3b82f6, #00b4d8, #00d4aa);
}

.legend-low, .legend-high {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.hm-layer-select {
    min-width: 200px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
}

/* ── Leaflet info panel (hover card) ─────────────────────── */
.hm-info-panel {
    background: var(--bg-card, #1e2130);
    border: 1px solid var(--border-color, #2a2d3e);
    border-radius: 12px;
    padding: 14px 18px;
    min-width: 200px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: var(--text-primary, #e8eaf0);
    font-size: 13px;
}

.hm-info-panel .info-country {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-teal, #00d4aa);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color, #2a2d3e);
    padding-bottom: 8px;
}

.hm-info-panel .info-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 3px 0;
    font-size: 12.5px;
}

.hm-info-panel .info-row span {
    color: var(--text-muted, #5c607a);
    font-weight: 500;
}

.hm-info-panel .info-row strong {
    color: var(--text-primary, #e8eaf0);
}

.hm-info-panel p {
    color: var(--text-muted, #5c607a);
    font-size: 12px;
}

/* ── Leaflet tooltip ─────────────────────────────────────── */
.hm-tooltip {
    background: var(--bg-card, #1e2130) !important;
    border: 1px solid var(--border-color, #2a2d3e) !important;
    color: var(--text-primary, #e8eaf0) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    padding: 4px 10px !important;
    box-shadow: none !important;
}

/* Remove Leaflet default blue triangle */
.hm-tooltip::before { display: none !important; }

/* ── Score Bar (in table) ────────────────────────────────── */
.score-bar-outer {
    width: 80px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.score-bar-inner {
    height: 100%;
    background: var(--gradient-teal);
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ── Leaflet zoom control theme fix ─────────────────────── */
.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
    color: var(--accent-teal) !important;
}

@media (max-width: 768px) {
    .pipeline-stages { gap: 4px; }
    .pipeline-stage  { min-width: 60px; padding: 6px 8px; }
    .ps-count        { font-size: 15px; }
    .heatmap-controls { flex-direction: column; align-items: stretch; gap: 12px; }
    .hm-legend { flex-wrap: wrap; gap: 6px; }
    .legend-label { width: 100%; margin-bottom: 2px; }
    .hm-controls-right { width: 100%; min-width: auto !important; }
    .hm-layer-select  { width: 100%; }
    #marketMap        { height: 360px !important; }
}

/* ── Task Cards ──────────────────────────────────────────────
   Follow-up Task Reminder styles — matches the premium theme
   ──────────────────────────────────────────────────────────── */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    transition: var(--transition);
}

.task-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.task-card.task-overdue {
    border-left: 4px solid var(--accent-red);
    background: linear-gradient(to right, rgba(239,68,68,0.04), var(--bg-card));
}

.task-card.task-today {
    border-left: 4px solid var(--accent-orange);
    background: linear-gradient(to right, rgba(245,158,11,0.04), var(--bg-card));
}

.task-card.task-done {
    opacity: 0.55;
}

.task-left {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.task-check {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

.task-check:hover,
.task-check.checked {
    color: var(--accent-teal);
}

.task-body {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.task-title-done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.task-date-label {
    font-size: 11px;
    color: var(--text-muted);
}

.task-overdue-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-red);
}

.task-today-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-orange);
}

.task-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: flex-start;
}

/* Alert flash (buyers / tasks pages) */
.alert-flash {
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
}
.alert-flash.alert-success {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    border: 1px solid rgba(34,197,94,0.25);
}
.alert-flash.alert-warning {
    background: var(--accent-orange-dim);
    color: var(--accent-orange);
    border: 1px solid rgba(245,158,11,0.25);
}
.alert-flash.alert-danger {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border: 1px solid rgba(239,68,68,0.25);
}
.alert-flash.alert-info {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border: 1px solid rgba(59,130,246,0.25);
}

@media (max-width: 576px) {
    .task-actions { 
        flex-direction: row; 
        width: 100%; 
        justify-content: flex-end; 
        margin-top: 8px;
    }
    .task-card { 
        flex-direction: column; 
        align-items: flex-start;
    }
}

/* ── Modal Close Button — large tap target ───────────────── */
.modal-close-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.modal-close-btn:hover,
.modal-close-btn:focus {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    transform: scale(1.1);
    outline: none;
    box-shadow: none;
}

.modal-close-btn:active {
    transform: scale(0.93);
    background: rgba(239, 68, 68, 0.22);
}

/* ── Custom Modal ────────────────────────────────────────── */

.custom-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    color: var(--text-primary);
}

.custom-modal .modal-header {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 20px 24px;
}

.custom-modal .modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.custom-modal .modal-body {
    padding: 24px;
    background: var(--bg-card);
}

.custom-modal .modal-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 16px 24px;
}

/* ── Settings Option Dashing Style ───────────────────────── */
.settings-option {
    padding: 16px 20px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.settings-option:hover {
    border-color: var(--accent-teal);
    box-shadow: 0 4px 16px var(--accent-teal-dim);
    transform: translateY(-2px);
}

.settings-option h6 {
    color: var(--text-primary);
    font-weight: 700;
}


/* ═══════════════════════════════════════════════════════════
   Mobile Bottom Navigation Bar
   — Fixed bottom dock, mobile only (≤768px)
   — Mirrors Portfolio Tracker's mobile-bottom-nav pattern
   ═══════════════════════════════════════════════════════════ */

/* Hidden on desktop */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 68px;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border-color);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        z-index: 1001;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
        /* Respect iPhone home indicator */
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Each tap target */
    .mbn-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        background: none;
        border: none;
        font-family: inherit;
        cursor: pointer;
        text-decoration: none !important;
        position: relative;
        overflow: hidden;
        -webkit-tap-highlight-color: transparent;
        transition: opacity 0.15s ease;
    }

    /* Reuse the sidebar nav-icon pill — scaled up for touch */
    .mbn-item .nav-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 1.1rem;
        margin-right: 0;
        transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                    box-shadow 0.2s ease;
    }

    /* Bounce + depress on tap */
    .mbn-item:active .nav-icon {
        transform: scale(0.88) translateY(2px);
    }

    /* Active page — lift & glow the pill */
    .mbn-item.mbn-active .nav-icon {
        filter: brightness(1.15) saturate(1.3);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
        transform: translateY(-3px) scale(1.06);
    }

    /* Ripple on tap */
    .mbn-item .mbn-ripple {
        position: absolute;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        background: rgba(0, 212, 170, 0.15);
        pointer-events: none;
        transform: scale(0);
        animation: mbnRipple 0.4s ease-out forwards;
        margin-top: -28px;
        margin-left: -28px;
    }

    @keyframes mbnRipple {
        0%   { transform: scale(0); opacity: 0.5; }
        100% { transform: scale(2.2); opacity: 0; }
    }

    /* Notification badge */
    .mbn-badge {
        position: absolute;
        top: 10px;
        right: calc(50% - 28px);
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        line-height: 1;
        border: 1.5px solid var(--bg-sidebar);
    }

    /* Push page content above the bar */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 16px !important;
        padding-bottom: calc(68px + env(safe-area-inset-bottom) + 16px) !important;
    }

    .sidebar {
        transform: translateX(-100%);
        overflow-y: auto;
        padding-bottom: calc(68px + env(safe-area-inset-bottom) + 16px);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}


/* Hidden on desktop */
.quick-access-bar {
    display: none;
}

@media (max-width: 768px) {
    .quick-access-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;           /* Firefox */
        padding: 10px 2px 14px;
        margin: -8px 0 16px;
        /* subtle fade edges to hint scrollability */
        mask-image: linear-gradient(to right, transparent 0px, black 10px, black calc(100% - 10px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0px, black 10px, black calc(100% - 10px), transparent 100%);
    }

    .quick-access-bar::-webkit-scrollbar {
        display: none;
    }

    /* ── Individual chip ──────────────────────────────────── */
    .qa-chip {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        flex-shrink: 0;
        text-decoration: none !important;
        padding: 10px 14px;
        border-radius: 14px;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-secondary);
        transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
        min-width: 68px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .qa-chip:active {
        transform: scale(0.93);
        opacity: 0.85;
    }

    @media (hover: hover) {
        .qa-chip:hover {
            border-color: var(--border-hover);
            background: var(--bg-card-hover);
            color: var(--text-primary);
            transform: translateY(-2px);
            box-shadow: var(--shadow-sm);
        }
    }

    /* Active chip — current page */
    .qa-chip.qa-active {
        border-color: var(--accent-teal);
        background: var(--accent-teal-dim);
        color: var(--accent-teal);
        box-shadow: 0 0 0 1px var(--accent-teal-dim), 0 4px 12px rgba(0,212,170,0.15);
    }

    /* ── Chip icon pill ───────────────────────────────────── */
    .qa-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 15px;
        flex-shrink: 0;
        transition: all 0.22s ease;
        background: rgba(139, 143, 163, 0.10);
        color: var(--text-secondary);
    }

    /* Mirror the sidebar per-icon colors */
    .qa-icon.icon-dashboard   { background: rgba(59, 130, 246, 0.14);  color: #3b82f6; }
    .qa-icon.icon-market      { background: rgba(0, 212, 170, 0.14);   color: #00d4aa; }
    .qa-icon.icon-buyers      { background: rgba(34, 197, 94, 0.14);   color: #22c55e; }
    .qa-icon.icon-orders      { background: rgba(0, 212, 170, 0.14);   color: #00d4aa; }
    .qa-icon.icon-clients     { background: rgba(139, 92, 246, 0.14);  color: #a78bfa; }
    .qa-icon.icon-followups   { background: rgba(239, 68, 68, 0.14);   color: #ef4444; }
    .qa-icon.icon-calc        { background: rgba(59, 130, 246, 0.14);  color: #3b82f6; }

    /* When the chip is active, intensify its icon pill */
    .qa-chip.qa-active .qa-icon {
        filter: brightness(1.1) saturate(1.3);
        box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    }

    /* ── Chip label ───────────────────────────────────────── */
    .qa-label {
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.2px;
        white-space: nowrap;
        color: inherit;
    }

    /* ── Notification badge ───────────────────────────────── */
    .qa-badge {
        position: absolute;
        top: 6px;
        right: 6px;
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        line-height: 1;
        border: 1.5px solid var(--bg-card);
    }

    /* Light-theme icon color overrides */
    [data-theme="light"] .qa-icon.icon-dashboard   { background: rgba(37,99,235,0.09);   color: #2563eb; }
    [data-theme="light"] .qa-icon.icon-market      { background: rgba(0,184,148,0.09);   color: #00b894; }
    [data-theme="light"] .qa-icon.icon-buyers      { background: rgba(22,163,74,0.09);   color: #16a34a; }
    [data-theme="light"] .qa-icon.icon-orders      { background: rgba(0,184,148,0.09);   color: #00b894; }
    [data-theme="light"] .qa-icon.icon-clients     { background: rgba(124,58,237,0.09);  color: #7c3aed; }
    [data-theme="light"] .qa-icon.icon-followups   { background: rgba(220,38,38,0.09);   color: #dc2626; }
    [data-theme="light"] .qa-icon.icon-calc        { background: rgba(37,99,235,0.09);   color: #2563eb; }

    /* Ensure main-content doesn't get left margin on mobile */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 16px !important;
        padding-bottom: calc(68px + env(safe-area-inset-bottom) + 16px) !important;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}

/* ═══════════════════════════════════════════════════════════
   AI Chatbot Widget — Floating Chat Panel
   ═══════════════════════════════════════════════════════════ */

/* ── Floating Action Button ─────────────────────────────── */
.chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: none;
    background: var(--gradient-teal);
    color: #fff;
    font-size: 22px;
    cursor: grab;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatFabPulse 3s ease-in-out infinite;
    user-select: none;
    touch-action: none;
}

/* Dragging state */
.chat-fab.dragging {
    cursor: grabbing !important;
    transition: none !important;
    animation: none !important;
    opacity: 0.88;
    box-shadow: 0 8px 32px rgba(0, 212, 170, 0.55), 0 2px 8px rgba(0,0,0,0.25);
    transform: scale(1.12);
}

/* Drag hint tooltip */
.chat-fab::after {
    content: 'Hold & drag to move';
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    white-space: nowrap;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(4px);
}

.chat-fab:not(.active):hover::after {
    opacity: 1;
    transform: translateY(0);
}

.chat-fab.dragging::after {
    display: none;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 212, 170, 0.55);
}

.chat-fab.active {
    border-radius: 50%;
    animation: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.chat-fab.active:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

@keyframes chatFabPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 212, 170, 0.35); }
    50%      { box-shadow: 0 4px 30px rgba(0, 212, 170, 0.55); }
}

/* ── Chat Panel ─────────────────────────────────────────── */
.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 420px;
    max-height: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
    z-index: 1100;
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-panel.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Chat Header ────────────────────────────────────────── */
.chat-header {
    background: var(--gradient-teal);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
}

.chat-header-info h6 {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.chat-header-info small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}

.chat-header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Messages Area ──────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 380px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* ── Chat Bubbles ───────────────────────────────────────── */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: chatBubbleIn 0.25s ease;
}

@keyframes chatBubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-bubble-user {
    align-self: flex-end;
    background: var(--gradient-teal);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* ── AI Message Markdown Formatting ─────────────────────── */
.chat-bubble-ai strong { color: var(--accent-teal); font-weight: 600; }

.chat-bubble-ai ul, .chat-bubble-ai ol {
    margin: 6px 0;
    padding-left: 18px;
}

.chat-bubble-ai li {
    margin-bottom: 3px;
}

.chat-bubble-ai table {
    width: 100%;
    margin: 8px 0;
    border-collapse: collapse;
    font-size: 12px;
}

.chat-bubble-ai table th,
.chat-bubble-ai table td {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.chat-bubble-ai table th {
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
}

.chat-bubble-ai code {
    background: var(--bg-card);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent-teal);
}

.chat-bubble-ai p {
    margin: 0 0 6px 0;
}

.chat-bubble-ai p:last-child {
    margin-bottom: 0;
}

/* ── Typing Indicator ───────────────────────────────────── */
.chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chatTypingBounce 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Welcome Message ────────────────────────────────────── */
.chat-welcome {
    text-align: center;
    padding: 20px 16px;
}

.chat-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}

.chat-welcome h6 {
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

.chat-welcome p {
    color: var(--text-secondary);
    font-size: 12.5px;
    margin-bottom: 14px;
    line-height: 1.5;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-suggestion-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-suggestion-btn:hover {
    border-color: var(--accent-teal);
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
}

.chat-suggestion-btn i {
    font-size: 11px;
    opacity: 0.6;
}

/* ── Feature Selector Grid ─────────────────────────────── */
.chat-feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.chat-feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.chat-feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-teal);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.chat-feature-card:hover {
    border-color: var(--accent-teal);
    background: var(--accent-teal-dim);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-feature-card:hover::before {
    opacity: 1;
}

.chat-feature-card > i {
    font-size: 18px;
    color: var(--accent-teal);
    margin-bottom: 2px;
}

.chat-feature-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.chat-feature-card-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-feature-card:hover .chat-feature-card-name {
    color: var(--accent-teal);
}


/* ── Input Bar ──────────────────────────────────────────── */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color 0.2s ease;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    border-color: var(--accent-teal);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: var(--gradient-teal);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(0, 212, 170, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Error Message ──────────────────────────────────────── */
.chat-bubble-error {
    align-self: flex-start;
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    font-size: 13px;
    max-width: 85%;
    animation: chatBubbleIn 0.25s ease;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-fab {
        bottom: 80px;   /* Above mobile bottom nav */
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 20px;
        border-radius: 14px;
    }

    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 75vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }

    .chat-messages {
        max-height: calc(75vh - 140px);
    }
}

/* ── Light Theme Overrides ──────────────────────────────── */
[data-theme="light"] .chat-panel {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .chat-fab {
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.3);
}

/* ── Supplier Controls Grid ─────────────────────────────── */
.supplier-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .supplier-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 8px;
    }
    .supplier-controls > * {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }
}

[data-theme="light"] .chat-fab.active {
    box-shadow: var(--shadow-md);
}

/* ── QBE (Query By Example) Grid Filter Styles ──────────────── */
.qbe-header-row {
    background: rgba(15, 23, 42, 0.45);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .qbe-header-row {
    background: rgba(241, 245, 249, 0.7);
}

.qbe-header-row th {
    padding: 8px 10px !important;
    vertical-align: middle;
}

.qbe-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.qbe-input, .qbe-select {
    width: 100%;
    height: 32px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.qbe-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
    font-size: 11px;
}

.qbe-input:focus, .qbe-select:focus {
    outline: none;
    border-color: var(--accent-teal);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-teal-dim);
}

.qbe-input.is-active, .qbe-select.is-active {
    border-color: var(--accent-teal);
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
    font-weight: 600;
}

.qbe-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 13px;
}

.qbe-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    background: var(--accent-teal-dim);
    color: var(--accent-teal);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.qbe-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-red);
    background: var(--accent-red-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qbe-reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-1px);
}

/* ── Grid Actions Column Differentiation & Custom Theme ────────── */
.grid-actions-header,
.grid-actions-cell {
    border-left: 2px solid rgba(0, 212, 170, 0.35) !important;
    background: rgba(0, 212, 170, 0.04) !important;
    text-align: center !important;
}

.grid-actions-header {
    background: rgba(0, 212, 170, 0.12) !important;
    color: var(--accent-teal) !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
}

[data-theme="light"] .grid-actions-header,
[data-theme="light"] .grid-actions-cell {
    background: rgba(0, 212, 170, 0.06) !important;
}

[data-theme="light"] .grid-actions-header {
    background: rgba(0, 212, 170, 0.18) !important;
    color: #00876c !important;
}

.invoice-row:hover .grid-actions-cell {
    background: rgba(0, 212, 170, 0.12) !important;
}

/* ── Scroll To Top with Circular Progress ────────────────── */
.scroll-to-top {
    position: fixed;
    top: 50%;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--accent-teal);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-50%) scale(0.8);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.2s ease,
                box-shadow 0.2s ease;
    box-shadow: var(--shadow-lg);
    padding: 0;
    outline: none;
}

@media (max-width: 768px) {
    .scroll-to-top {
        right: 14px; /* Slightly tighter margin for smaller screens */
    }
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

.scroll-to-top:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 10px 30px rgba(0, 212, 170, 0.35);
}

.scroll-top-icon {
    font-size: 1rem;
    position: absolute;
    z-index: 2;
    transition: transform 0.2s ease;
}

.scroll-to-top:hover .scroll-top-icon {
    transform: translateY(-2px);
}

/* SVG Progress Ring */
.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg); /* Start progress from top 12 o'clock */
    pointer-events: none;
}

.progress-ring-bg {
    fill: transparent;
    stroke: var(--border-color);
    stroke-width: 3;
}

.progress-ring-circle {
    fill: transparent;
    stroke: var(--accent-teal);
    stroke-width: 3;
    stroke-linecap: round;
    /* Circumference = 2 * PI * r = 2 * PI * 20 ≈ 125.66 */
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.1s linear;
}

/* ── Theme-aware Close Button (Alerts & Modals) ────────── */
.btn-close {
    opacity: 0.75;
    transition: opacity 0.2s ease, filter 0.2s ease;
}
:root:not([data-theme="light"]) .btn-close,
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
[data-theme="light"] .btn-close {
    filter: none !important;
}
.btn-close:hover {
    opacity: 1;
}





