/* =====================================================================
   Zenve BI — B2B / Enterprise Executive Control Center & Dashboards
   Suite (9 Subdomains):
     1. B2B Dashboard        (#b2b-dashboard / #b2b / #b2b-enterprise)
     2. Enterprise Customers  (#enterprise-customers)
     3. Corporate Accounts    (#corporate-accounts)
     4. B2B Orders            (#b2b-orders)
     5. B2B Sales             (#b2b-sales)
     6. B2B Revenue           (#b2b-revenue)
     7. Contracts             (#contracts / #b2b-contracts)
     8. Enterprise Pricing    (#enterprise-pricing)
     9. B2B Receivables       (#b2b-receivables)
   ===================================================================== */

html.zb2b-locked,
body.zb2b-locked {
  overflow: hidden !important;
  height: 100% !important;
}

#zb2b-root {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 224px !important;
  width: calc(100vw - 224px) !important;
  max-width: calc(100vw - 224px) !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 60 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
  background: var(--background, #f8fafc) !important;
  color: var(--foreground, #0f172a) !important;
  font-family: var(--font-sans, "Manrope", sans-serif);
  display: none;
  animation: zb2bFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box !important;
  scrollbar-width: thin !important;
  scrollbar-color: #cbd5e1 #f8fafc !important;
}

#zb2b-root.zb2b-open,
#zb2b-root.zpanel-open {
  display: block !important;
}

#zb2b-root::-webkit-scrollbar {
  width: 8px !important;
}
#zb2b-root::-webkit-scrollbar-track {
  background: #f8fafc !important;
}
#zb2b-root::-webkit-scrollbar-thumb {
  background: #cbd5e1 !important;
  border-radius: 6px !important;
}
#zb2b-root::-webkit-scrollbar-thumb:hover {
  background: #94a3b8 !important;
}

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

@media (max-width: 1023px) {
  #zb2b-root {
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }
}

#zb2b-root * { box-sizing: border-box; }
#zb2b-root button, #zb2b-root input, #zb2b-root select {
  font-family: inherit; color: inherit;
}

/* Header */
.zb2b-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  background: color-mix(in oklab, var(--background, #ffffff) 96%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
  flex-wrap: wrap;
}

.zb2b-head-left { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.zb2b-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.zb2b-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.015em; color: var(--foreground, #0f172a); white-space: nowrap; }
.zb2b-sub { font-size: 12px; margin: 0; color: var(--muted-foreground, #64748b); line-height: 1.4; }

.zb2b-live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(79,70,229,0.12); border: 1px solid rgba(79,70,229,0.3); color: #4338ca;
  font-size: 11px; font-family: "IBM Plex Mono", monospace; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

.zb2b-pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4f46e5; box-shadow: 0 0 8px #4f46e5;
  animation: zb2bPulse 1.8s infinite;
}

@keyframes zb2bPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.4); }
}

.zb2b-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.zb2b-btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border, rgba(0,0,0,0.12));
  background: var(--card, #ffffff); cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--foreground, #0f172a);
  transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; white-space: nowrap;
}
.zb2b-btn:hover { background: var(--accent, #f1f5f9); border-color: rgba(0,0,0,0.2); }
.zb2b-btn.primary { background: rgba(79,70,229,0.14); border-color: rgba(79,70,229,0.5); color: #4338ca; }
.zb2b-btn.primary:hover { background: rgba(79,70,229,0.22); color: #3730a3; }
.zb2b-btn.success { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.4); color: #059669; }
.zb2b-btn.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #dc2626; }

/* Tabs Bar (9 Subdomains) */
.zb2b-tabs-bar {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  overflow: hidden !important;
}
.zb2b-tabs-bar::-webkit-scrollbar { display: none; }

.zb2b-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: none; background: transparent;
  color: var(--muted-foreground, #64748b); font-size: 11px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
  transition: all 0.15s ease; margin-bottom: -1px;
}
.zb2b-tab:hover { color: var(--foreground, #0f172a); background: rgba(0,0,0,0.04); border-radius: 6px 6px 0 0; }
.zb2b-tab.active {
  color: #4338ca; border-bottom-color: #4f46e5;
  background: rgba(79,70,229,0.08); border-radius: 6px 6px 0 0;
}
.zb2b-tab-badge {
  font-size: 9px; padding: 1px 6px; border-radius: 999px;
  background: rgba(0,0,0,0.06); font-family: "IBM Plex Mono", monospace; font-weight: 600; color: #475569;
}
.zb2b-tab-badge.warn { background: rgba(245,158,11,0.18); color: #d97706; }
.zb2b-tab-badge.danger { background: rgba(239,68,68,0.15); color: #dc2626; }
.zb2b-tab.active .zb2b-tab-badge { background: rgba(79,70,229,0.18); color: #3730a3; }

/* Body Content */
.zb2b-body,
#zb2b-root .zb2b-body,
#zb2b-root div.zb2b-body,
#zb2b-root main.zb2b-body {
  padding: 24px 28px 64px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 20px !important;
}

/* KPI Grid */
.zb2b-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.zb2b-kpi {
  background: var(--card, #ffffff);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-radius: 12px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.zb2b-kpi:hover {
  transform: translateY(-2px);
  border-color: rgba(79,70,229,0.3);
  box-shadow: 0 4px 12px rgba(79,70,229,0.06);
}

.zb2b-kpi-top { display: flex; align-items: center; justify-content: space-between; }
.zb2b-kpi-label { font-size: 11px; font-weight: 600; color: var(--muted-foreground, #64748b); text-transform: uppercase; letter-spacing: 0.04em; }
.zb2b-kpi-icon { font-size: 16px; }
.zb2b-kpi-val { font-size: 22px; font-weight: 700; color: var(--foreground, #0f172a); font-family: "Sora", sans-serif; letter-spacing: -0.02em; }
.zb2b-kpi-bottom { display: flex; align-items: center; gap: 8px; font-size: 11px; flex-wrap: wrap; }
.zb2b-delta { font-weight: 700; font-family: "IBM Plex Mono", monospace; }
.zb2b-delta.up { color: #059669; }
.zb2b-delta.down { color: #dc2626; }
.zb2b-delta.warn { color: #d97706; }
.zb2b-delta.neutral { color: #64748b; }
.zb2b-subtext { color: var(--muted-foreground, #64748b); font-size: 11px; }

/* Cards & Grids */
.zb2b-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.zb2b-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) {
  .zb2b-grid-2, .zb2b-grid-3 { grid-template-columns: 1fr; }
}

.zb2b-card {
  background: var(--card, #ffffff);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-radius: 12px;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.zb2b-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.zb2b-card-title { font-size: 14px; font-weight: 700; margin: 0; color: var(--foreground, #0f172a); letter-spacing: -0.01em; }
.zb2b-card-sub { font-size: 11px; margin: 2px 0 0; color: var(--muted-foreground, #64748b); }

/* Tables */
.zb2b-table-wrap { overflow-x: auto; width: 100%; }
.zb2b-table {
  width: 100%; border-collapse: collapse; text-align: left; font-size: 12px;
}
.zb2b-table th {
  padding: 10px 12px; color: var(--muted-foreground, #64748b);
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
  font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em;
  background: var(--background, #f8fafc);
}
.zb2b-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border, rgba(0,0,0,0.05));
  color: var(--foreground, #0f172a);
}
.zb2b-table tr:hover td { background: rgba(79,70,229,0.03); }

/* Pills & Badges */
.zb2b-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600;
  text-transform: capitalize;
}
.zb2b-pill.active, .zb2b-pill.healthy, .zb2b-pill.cleared { background: rgba(16,185,129,0.14); color: #059669; }
.zb2b-pill.pending, .zb2b-pill.warning { background: rgba(245,158,11,0.15); color: #d97706; }
.zb2b-pill.critical, .zb2b-pill.overdue { background: rgba(239,68,68,0.14); color: #dc2626; }
.zb2b-pill.corporate { background: rgba(79,70,229,0.12); color: #4338ca; }

/* Modals */
.zb2b-modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.zb2b-modal {
  background: #ffffff; border-radius: 14px; width: 100%; max-width: 580px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.18); border: 1px solid rgba(0,0,0,0.1);
  padding: 24px; display: flex; flex-direction: column; gap: 16px;
  max-height: 90vh; overflow-y: auto; color: #0f172a;
}
.zb2b-modal-head { display: flex; align-items: center; justify-content: space-between; }
.zb2b-modal-title { font-size: 16px; font-weight: 700; margin: 0; color: #0f172a; }

.zb2b-form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.zb2b-form-group label { font-size: 11px; font-weight: 600; color: #475569; }
.zb2b-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.zb2b-input, .zb2b-select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid #cbd5e1;
  font-size: 12px; background: #ffffff; color: #0f172a; outline: none;
}
.zb2b-input:focus, .zb2b-select:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
