/* ═══════════════════════════════════════════════════════════════════
   BRAVO1 Admin — Shared Design System
   Premium SaaS aesthetic. No emojis. Pure SVG icons.
═══════════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg { display: block; }
button { cursor: pointer; font-family: inherit; }
a { text-decoration: none; color: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Tokens ── */
:root {
  /* Surfaces */
  --s0: #F5F5F2;        /* page bg — warm off-white */
  --s1: #FFFFFF;        /* primary surface — cards, panels */
  --s2: #F0F0EC;        /* secondary — subtle fills */
  --s3: #E8E8E4;        /* tertiary — dividers, hover */

  /* Text */
  --t1: #1A1A17;        /* primary — near-black, warm */
  --t2: #6B6B65;        /* secondary — refined grey */
  --t3: #A0A09A;        /* tertiary — muted */

  /* Brand */
  --accent: #66804F;
  --accent-h: #516640;
  --accent-l: #EDF1E8;
  --accent-m: rgba(102,128,79,0.12);

  /* Border */
  --b1: rgba(0,0,0,0.06);
  --b2: rgba(0,0,0,0.10);
  --b3: rgba(0,0,0,0.16);

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.10), 0 2px 10px rgba(0,0,0,0.06);
  --shadow-focus: 0 0 0 3px rgba(102,128,79,0.18);

  /* Status */
  --c-new:       #3B82F6;
  --c-new-g:     rgba(59,130,246,0.06);
  --c-new-b:     rgba(59,130,246,0.18);
  --c-wait:      #D97706;
  --c-wait-g:    rgba(217,119,6,0.06);
  --c-wait-b:    rgba(217,119,6,0.20);
  --c-urgent:    #DC2626;
  --c-urgent-g:  rgba(220,38,38,0.06);
  --c-urgent-b:  rgba(220,38,38,0.20);
  --c-done:      #059669;
  --c-done-g:    rgba(5,150,105,0.05);
  --c-done-b:    rgba(5,150,105,0.16);
  --c-resolved:  #94A3B8;

  /* Nav */
  --nav-bg: #111110;
  --nav-w: 220px;
  --nav-collapsed: 58px;
  --header-h: 54px;
  --mobile-nav-h: 60px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Type */
  --ff-display: 'Space Grotesk', -apple-system, sans-serif;
  --ff-body:    'DM Sans', -apple-system, sans-serif;
  --ff-mono:    'SF Mono', 'Fira Code', 'Fira Mono', ui-monospace, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16,1,0.3,1);
  --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
}

/* ── Base ── */
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--ff-body);
  background: var(--s0);
  color: var(--t1);
  min-height: 100vh;
  line-height: 1.5;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.b1-sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--nav-w);
  height: 100vh;
  background: var(--nav-bg);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width 0.22s var(--ease-out);
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.04);
}
body.nav-collapsed .b1-sidebar { width: var(--nav-collapsed); }

/* Logo row */
.b1-nav-logo {
  padding: 16px 14px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}
.b1-nav-logo img { height: 28px; width: auto; max-width: 120px; object-fit: contain; flex-shrink: 0; }
.b1-nav-logo-badge {
  margin-left: auto;
  font-size: 9px; font-weight: 600; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.15s;
}
body.nav-collapsed .b1-nav-logo-badge,
body.nav-collapsed .b1-nav-label,
body.nav-collapsed .b1-nav-section,
body.nav-collapsed .b1-nav-badge { opacity: 0; pointer-events: none; }

/* Nav sections */
.b1-nav-section {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.25);
  padding: 16px 16px 5px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}

/* Nav links */
.b1-nav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; padding: 6px 0; }
.b1-nav-scroll::-webkit-scrollbar { display: none; }

.b1-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 16px;
  margin: 1px 8px;
  border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 500;
  color: rgba(255,255,255,0.50);
  text-decoration: none;
  transition: background 0.13s, color 0.13s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.b1-nav-link:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.88); }
.b1-nav-link.active {
  background: rgba(102,128,79,0.18);
  color: #B5C8A0;
}
.b1-nav-link.active .b1-nav-icon svg { opacity: 1; }

.b1-nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.b1-nav-icon svg { opacity: 0.6; transition: opacity 0.13s; }
.b1-nav-link:hover .b1-nav-icon svg { opacity: 1; }

.b1-nav-label { flex: 1; transition: opacity 0.15s; }

.b1-nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  background: rgba(102,128,79,0.25);
  color: #B5C8A0;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
  transition: opacity 0.15s;
}
.b1-nav-badge.urgent { background: rgba(220,38,38,0.25); color: #FCA5A5; }

/* Collapsed tooltip */
body.nav-collapsed .b1-nav-link { padding: 10px 0; margin: 1px 10px; justify-content: center; }
body.nav-collapsed .b1-nav-section { padding: 14px 0 5px; text-align: center; }

/* Nav bottom — user + collapse */
.b1-nav-bottom {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.b1-nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  overflow: hidden; white-space: nowrap;
}
.b1-nav-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: rgba(102,128,79,0.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #B5C8A0;
}
.b1-nav-user-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.80); }
.b1-nav-user-role { font-size: 10px; color: rgba(255,255,255,0.28); }
.b1-nav-logout {
  margin-left: auto; flex-shrink: 0;
  color: rgba(255,255,255,0.25);
  background: none; border: none;
  padding: 4px; border-radius: 4px;
  transition: color 0.13s;
}
.b1-nav-logout:hover { color: rgba(255,255,255,0.65); }
body.nav-collapsed .b1-nav-user { justify-content: center; padding: 9px 0; }
body.nav-collapsed .b1-nav-user-name,
body.nav-collapsed .b1-nav-user-role,
body.nav-collapsed .b1-nav-logout { display: none; }

/* Collapse toggle */
.b1-nav-toggle {
  display: flex; align-items: center; justify-content: center;
  margin: 6px 8px 0;
  padding: 7px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,0.25);
  background: none; border: none;
  transition: background 0.13s, color 0.13s;
  width: calc(100% - 16px);
}
.b1-nav-toggle:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.55); }
.b1-nav-toggle svg { transition: transform 0.22s var(--ease-out); }
body.nav-collapsed .b1-nav-toggle svg { transform: rotate(180deg); }

/* ════════════════════════════════════════
   SIDEBAR OVERLAY (mobile)
════════════════════════════════════════ */
.b1-nav-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.b1-nav-overlay.open { display: block; }

/* ════════════════════════════════════════
   MAIN LAYOUT
════════════════════════════════════════ */
.b1-main {
  margin-left: var(--nav-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left 0.22s var(--ease-out);
}
body.nav-collapsed .b1-main { margin-left: var(--nav-collapsed); }

/* ════════════════════════════════════════
   TOPBAR
════════════════════════════════════════ */
.b1-topbar {
  height: var(--header-h);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--b1);
  display: flex; align-items: center;
  padding: 0 20px 0 24px;
  gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.b1-topbar-mobile-btn {
  display: none;
  background: none; border: none;
  color: var(--t2); padding: 6px; border-radius: var(--r-sm);
  transition: background 0.13s;
  flex-shrink: 0;
}
.b1-topbar-mobile-btn:hover { background: var(--s2); }
.b1-topbar-title {
  font-family: var(--ff-display);
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--t1);
  flex: 1;
}
.b1-topbar-search {
  display: flex; align-items: center;
  gap: 7px; padding: 6px 12px;
  background: var(--s2); border-radius: var(--r-md);
  border: 1px solid var(--b1);
  color: var(--t3); font-size: 12px;
  min-width: 160px; cursor: text;
  transition: border-color 0.13s, background 0.13s;
}
.b1-topbar-search:hover { border-color: var(--b2); background: var(--s1); }
.b1-topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.b1-icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  color: var(--t2);
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  position: relative;
}
.b1-icon-btn:hover { background: var(--s2); border-color: var(--b1); color: var(--t1); }
.b1-icon-btn .badge-dot {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c-urgent);
  border: 2px solid var(--s1);
  display: none;
}
.b1-icon-btn .badge-dot.show { display: block; }

/* ════════════════════════════════════════
   PAGE CONTENT
════════════════════════════════════════ */
.b1-content { padding: 24px; flex: 1; }
.b1-page-header { margin-bottom: 20px; }
.b1-page-title { font-family: var(--ff-display); font-size: 18px; font-weight: 700; letter-spacing: -0.03em; color: var(--t1); }
.b1-page-sub { font-size: 12px; color: var(--t3); margin-top: 2px; }

/* ════════════════════════════════════════
   CARDS
════════════════════════════════════════ */
.b1-card {
  background: var(--s1);
  border-radius: var(--r-lg);
  border: 1px solid var(--b1);
  box-shadow: var(--shadow-xs);
}
.b1-card-body { padding: 18px 20px; }
.b1-card-header { padding: 14px 20px 12px; border-bottom: 1px solid var(--b1); display: flex; align-items: center; justify-content: space-between; }
.b1-card-title { font-family: var(--ff-display); font-size: 13px; font-weight: 600; }

/* KPI cards */
.b1-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.b1-kpi {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: default;
}
.b1-kpi:hover { box-shadow: var(--shadow-sm); border-color: var(--b2); }
.b1-kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--t3); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.b1-kpi-value { font-family: var(--ff-display); font-size: 24px; font-weight: 700; letter-spacing: -0.04em; color: var(--t1); line-height: 1; }
.b1-kpi-trend { font-size: 11px; color: var(--t3); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.b1-kpi-trend.up { color: var(--accent); }
.b1-kpi-trend.down { color: var(--c-urgent); }
.b1-kpi-accent { width: 4px; position: absolute; left: 0; top: 14px; bottom: 14px; border-radius: 0 2px 2px 0; }

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-family: var(--ff-display); font-size: 12px; font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  transition: background 0.13s, border-color 0.13s, box-shadow 0.13s, opacity 0.13s;
  white-space: nowrap; cursor: pointer;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { opacity: 0.88; transform: scale(0.99); }
.btn svg { flex-shrink: 0; }

/* Primary */
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent-h); }
.btn-primary:hover { background: var(--accent-h); }

/* Secondary */
.btn-secondary { background: var(--s1); color: var(--t1); border-color: var(--b2); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--s2); border-color: var(--b2); }

/* Ghost */
.btn-ghost { background: transparent; color: var(--t2); border-color: transparent; }
.btn-ghost:hover { background: var(--s2); color: var(--t1); }

/* Danger */
.btn-danger { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

/* Sizes */
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: var(--r-xs); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 9px 18px; font-size: 13px; }
.btn-icon-only { padding: 6px; }

/* ════════════════════════════════════════
   STATUS GLOW SYSTEM
   Applied to table rows AND convo list items
════════════════════════════════════════ */

/* Conversation list items */
.status-new {
  border-left: 2px solid var(--c-new);
  background: linear-gradient(to right, var(--c-new-g) 0%, transparent 80%);
}
.status-waiting {
  border-left: 2px solid var(--c-wait);
  background: linear-gradient(to right, var(--c-wait-g) 0%, transparent 80%);
}
.status-urgent {
  border-left: 2px solid var(--c-urgent);
  background: linear-gradient(to right, var(--c-urgent-g) 0%, transparent 80%);
  animation: urgent-pulse 3s ease-in-out infinite;
}
@keyframes urgent-pulse {
  0%,100% { background: linear-gradient(to right, var(--c-urgent-g) 0%, transparent 80%); }
  50%      { background: linear-gradient(to right, rgba(220,38,38,0.10) 0%, transparent 80%); }
}
.status-responded {
  border-left: 2px solid var(--c-done);
  background: linear-gradient(to right, var(--c-done-g) 0%, transparent 80%);
}
.status-resolved {
  border-left: 2px solid var(--b2);
}

/* Table row variants */
tr.status-new td:first-child   { border-left: 3px solid var(--c-new); }
tr.status-waiting td:first-child { border-left: 3px solid var(--c-wait); }
tr.status-urgent td:first-child  { border-left: 3px solid var(--c-urgent); }
tr.status-responded td:first-child { border-left: 3px solid var(--c-done); }
tr.status-new  { background: linear-gradient(to right, rgba(59,130,246,0.03) 0%, transparent 30%); }
tr.status-waiting { background: linear-gradient(to right, rgba(217,119,6,0.04) 0%, transparent 30%); }
tr.status-urgent  { background: linear-gradient(to right, rgba(220,38,38,0.04) 0%, transparent 30%); }
tr.status-responded { background: linear-gradient(to right, rgba(5,150,105,0.03) 0%, transparent 30%); }

/* ════════════════════════════════════════
   BADGES
════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid;
}
.badge-new     { background: rgba(59,130,246,0.08);  color: #1D4ED8; border-color: rgba(59,130,246,0.16); }
.badge-wait    { background: rgba(217,119,6,0.08);   color: #B45309; border-color: rgba(217,119,6,0.18); }
.badge-urgent  { background: rgba(220,38,38,0.08);   color: #B91C1C; border-color: rgba(220,38,38,0.18); }
.badge-done    { background: rgba(5,150,105,0.08);   color: #047857; border-color: rgba(5,150,105,0.16); }
.badge-grey    { background: var(--s2); color: var(--t2); border-color: var(--b2); }
.badge-accent  { background: var(--accent-l); color: var(--accent-h); border-color: rgba(102,128,79,0.2); }
.badge-purple  { background: rgba(124,58,237,0.08); color: #6D28D9; border-color: rgba(124,58,237,0.18); }
.badge-verified { background: rgba(5,150,105,0.08); color: #047857; border-color: rgba(5,150,105,0.16); }

/* Lead statuses */
.ls-new           { background: rgba(59,130,246,0.08);  color: #1D4ED8; border-color: rgba(59,130,246,0.16); }
.ls-contacted     { background: rgba(124,58,237,0.08); color: #6D28D9; border-color: rgba(124,58,237,0.18); }
.ls-hot           { background: rgba(220,38,38,0.08);   color: #B91C1C; border-color: rgba(220,38,38,0.18); }
.ls-converted     { background: rgba(5,150,105,0.08);   color: #047857; border-color: rgba(5,150,105,0.16); }
.ls-never_purchased { background: var(--s2); color: var(--t2); border-color: var(--b2); }
.ls-unsubscribed  { background: rgba(217,119,6,0.08); color: #B45309; border-color: rgba(217,119,6,0.18); }

/* ════════════════════════════════════════
   TABLE
════════════════════════════════════════ */
.b1-table-wrap {
  background: var(--s1); border-radius: var(--r-lg);
  border: 1px solid var(--b1); overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.b1-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.b1-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
.b1-table thead tr { background: var(--s0); }
.b1-table th {
  padding: 10px 14px;
  text-align: left; font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--t3); white-space: nowrap; border-bottom: 1px solid var(--b1);
}
.b1-table th.sortable { cursor: pointer; user-select: none; transition: color 0.12s; }
.b1-table th.sortable:hover { color: var(--t1); }
.b1-table th.sort-asc::after  { content: ' ↑'; color: var(--accent); }
.b1-table th.sort-desc::after { content: ' ↓'; color: var(--accent); }
.b1-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--b1);
  vertical-align: middle;
  color: var(--t2);
  transition: background 0.1s;
}
.b1-table tr:last-child td { border-bottom: none; }
.b1-table tr:hover td { background: var(--s2); }
.b1-table tr.selected td { background: rgba(102,128,79,0.05); }
.td-primary { font-weight: 600; color: var(--t1); }
.td-mono { font-family: var(--ff-mono); font-size: 11px; color: var(--t3); }

/* ════════════════════════════════════════
   FORMS
════════════════════════════════════════ */
.b1-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--b2); border-radius: var(--r-sm);
  font-size: 13px; font-family: var(--ff-body);
  background: var(--s1); color: var(--t1);
  outline: none; transition: border-color 0.13s, box-shadow 0.13s;
}
.b1-input::placeholder { color: var(--t3); }
.b1-input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.b1-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.b1-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A0A09A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
.b1-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--t3); margin-bottom: 5px; }
.b1-form-group { margin-bottom: 14px; }
.b1-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }

/* ════════════════════════════════════════
   TOOLBAR
════════════════════════════════════════ */
.b1-toolbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--s1); border-radius: var(--r-md);
  border: 1px solid var(--b1);
  padding: 10px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}
.b1-search {
  position: relative; flex: 1; min-width: 180px;
}
.b1-search svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--t3); pointer-events: none;
}
.b1-search-input {
  width: 100%; padding: 7px 10px 7px 32px;
  border: 1px solid var(--b2); border-radius: var(--r-sm);
  font-size: 12.5px; font-family: var(--ff-body);
  background: var(--s0); color: var(--t1); outline: none;
  transition: border-color 0.13s, box-shadow 0.13s;
}
.b1-search-input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); background: var(--s1); }
.b1-toolbar-select {
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--b2); border-radius: var(--r-sm);
  font-size: 12px; font-family: var(--ff-body);
  background: var(--s0);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23A0A09A' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  color: var(--t2); cursor: pointer;
  outline: none; transition: border-color 0.13s;
}
.b1-toolbar-select:focus { border-color: var(--accent); }

/* ════════════════════════════════════════
   FILTER TABS
════════════════════════════════════════ */
.b1-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 12px; }
.b1-tab {
  padding: 5px 11px; border-radius: 20px; font-size: 11px; font-weight: 600;
  cursor: pointer; color: var(--t3); background: var(--s1);
  border: 1px solid var(--b1); white-space: nowrap;
  transition: all 0.13s;
}
.b1-tab:hover { background: var(--s2); color: var(--t2); }
.b1-tab.active { background: var(--t1); color: #fff; border-color: var(--t1); }

/* ════════════════════════════════════════
   PAGINATION
════════════════════════════════════════ */
.b1-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--b1);
  font-size: 12px; color: var(--t3);
  background: var(--s0);
}
.b1-page-btns { display: flex; gap: 3px; }
.b1-page-btn {
  padding: 4px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--b2); background: var(--s1);
  font-size: 11px; font-weight: 600; color: var(--t2);
  transition: all 0.12s;
}
.b1-page-btn:hover { background: var(--s2); }
.b1-page-btn.active { background: var(--t1); color: #fff; border-color: var(--t1); }
.b1-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ════════════════════════════════════════
   MODALS
════════════════════════════════════════ */
.b1-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(4px);
  z-index: 500; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.b1-modal-backdrop.open { display: flex; }
.b1-modal {
  background: var(--s1); border-radius: var(--r-xl);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--b1);
  animation: modal-in 0.2s var(--ease-out);
}
.b1-modal-lg  { max-width: 700px; }
.b1-modal-xl  { max-width: 880px; }
@keyframes modal-in { from{opacity:0;transform:translateY(12px) scale(0.98)} to{opacity:1;transform:none} }
.b1-modal-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--b1);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.b1-modal-title { font-family: var(--ff-display); font-size: 14px; font-weight: 700; color: var(--t1); }
.b1-modal-sub { font-size: 12px; color: var(--t3); margin-top: 2px; }
.b1-modal-close {
  background: none; border: none; color: var(--t3);
  padding: 4px; border-radius: 4px; font-size: 18px; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.b1-modal-close:hover { background: var(--s2); color: var(--t1); }
.b1-modal-body { padding: 20px 22px; }
.b1-modal-footer { padding: 14px 22px; border-top: 1px solid var(--b1); display: flex; gap: 8px; justify-content: flex-end; }

/* ════════════════════════════════════════
   TOAST
════════════════════════════════════════ */
#b1-toasts {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.b1-toast {
  background: var(--t1); color: #fff;
  padding: 10px 16px; border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.22s var(--ease-out);
  pointer-events: all; max-width: 280px;
  border: 1px solid rgba(255,255,255,0.07);
}
.b1-toast.success { background: var(--accent-h); border-color: rgba(255,255,255,0.1); }
.b1-toast.error   { background: #B91C1C; }
.b1-toast.info    { background: #1D4ED8; }
@keyframes toast-in  { from{opacity:0;transform:translateX(16px)} to{opacity:1;transform:none} }
@keyframes toast-out { from{opacity:1} to{opacity:0;transform:translateX(16px)} }

/* ════════════════════════════════════════
   SKELETON
════════════════════════════════════════ */
.skel {
  background: linear-gradient(90deg, var(--s2) 25%, var(--s3) 50%, var(--s2) 75%);
  background-size: 200% 100%;
  animation: skel-move 1.4s infinite;
  border-radius: var(--r-xs);
}
@keyframes skel-move { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ════════════════════════════════════════
   UTILITY
════════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--b1); margin: 14px 0; }
.text-primary   { color: var(--t1); }
.text-secondary { color: var(--t2); }
.text-muted     { color: var(--t3); }
.text-accent    { color: var(--accent); }
.font-display   { font-family: var(--ff-display); }
.mono           { font-family: var(--ff-mono); font-size: 11px; }
.flex           { display: flex; }
.items-center   { align-items: center; }
.gap-2          { gap: 8px; }
.gap-1          { gap: 4px; }
.ml-auto        { margin-left: auto; }

/* Notification panel */
.b1-notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 300px; background: var(--s1);
  border-radius: var(--r-lg); border: 1px solid var(--b2);
  box-shadow: var(--shadow-lg); z-index: 300; display: none; overflow: hidden;
  animation: dropdown-in 0.16s var(--ease-out);
}
.b1-notif-panel.open { display: block; }
@keyframes dropdown-in { from{opacity:0;transform:translateY(-6px) scale(0.97)} to{opacity:1;transform:none} }
.b1-notif-header { padding: 12px 16px 10px; font-family: var(--ff-display); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--b1); display: flex; align-items: center; justify-content: space-between; }
.b1-notif-item { padding: 10px 16px; border-bottom: 1px solid var(--b1); cursor: pointer; display: flex; gap: 10px; align-items: flex-start; transition: background 0.1s; }
.b1-notif-item:hover { background: var(--s2); }
.b1-notif-item:last-child { border-bottom: none; }
.b1-notif-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.b1-notif-text { font-size: 12px; color: var(--t2); line-height: 1.45; }
.b1-notif-time { font-size: 10px; color: var(--t3); margin-top: 2px; }
.b1-notif-empty { padding: 24px 16px; text-align: center; font-size: 12px; color: var(--t3); }

/* ════════════════════════════════════════
   MOBILE BOTTOM NAV
════════════════════════════════════════ */
.b1-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--b1);
  z-index: 200;
  padding: 0 4px;
}
.b1-bottom-nav-inner { display: flex; height: 100%; }
.b1-bottom-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--t3);
  font-size: 10px; font-weight: 600;
  border-radius: var(--r-sm); margin: 6px 2px;
  transition: color 0.13s, background 0.13s;
  position: relative;
}
.b1-bottom-tab:hover { color: var(--t2); background: var(--s2); }
.b1-bottom-tab.active { color: var(--accent); }
.b1-bottom-tab.active svg { color: var(--accent); }
.b1-bottom-tab svg { color: var(--t3); transition: color 0.13s; }
.b1-bottom-tab.active svg { color: var(--accent); }
.b1-bottom-tab-badge {
  position: absolute; top: 5px; right: calc(50% - 16px);
  background: var(--c-urgent); color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px; border-radius: 10px;
  min-width: 14px; text-align: center;
  border: 2px solid white;
}

/* Mobile slide drawer ("More") */
.b1-drawer {
  position: fixed; inset: 0; z-index: 300;
  display: none;
}
.b1-drawer.open { display: block; }
.b1-drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
}
.b1-drawer-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--s1);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 16px 0 calc(env(safe-area-inset-bottom) + 12px);
  animation: drawer-up 0.25s var(--ease-out);
  max-height: 80vh; overflow-y: auto;
}
@keyframes drawer-up { from{transform:translateY(100%)} to{transform:none} }
.b1-drawer-handle { width: 36px; height: 3px; background: var(--b2); border-radius: 10px; margin: 0 auto 16px; }
.b1-drawer-link {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; color: var(--t2); font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background 0.1s;
}
.b1-drawer-link:hover { background: var(--s2); }
.b1-drawer-link.active { color: var(--accent); }
.b1-drawer-section { padding: 10px 20px 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--t3); }

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 1024px) {
  .b1-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .b1-sidebar { transform: translateX(-100%); transition: transform 0.25s var(--ease-out), width 0.22s var(--ease-out); width: var(--nav-w) !important; }
  .b1-sidebar.mobile-open { transform: translateX(0); }
  .b1-main { margin-left: 0 !important; padding-bottom: var(--mobile-nav-h); }
  .b1-bottom-nav { display: block; }
  .b1-topbar { padding: 0 14px; }
  .b1-topbar-mobile-btn { display: flex; }
  .b1-topbar-search { display: none; }
  .b1-content { padding: 14px; }
  .b1-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .b1-kpi-value { font-size: 20px; }
  .b1-toolbar { padding: 8px 12px; gap: 6px; }
  .b1-form-row { grid-template-columns: 1fr; }
  .b1-modal { max-height: calc(100vh - 30px); border-radius: var(--r-xl) var(--r-xl) 0 0; align-self: flex-end; }
  .b1-modal-backdrop { align-items: flex-end; padding: 0; }
  #b1-toasts { bottom: calc(var(--mobile-nav-h) + 12px); right: 12px; }
  .b1-nav-toggle { display: none; }
}

@media (max-width: 480px) {
  .b1-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .b1-kpi { padding: 12px 14px; }
  .b1-kpi-value { font-size: 18px; }
  .b1-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
  .b1-tabs::-webkit-scrollbar { display: none; }
  .b1-tab { flex-shrink: 0; }
}

/* ════════════════════════════════════════
   MOBILE ADMIN — COMPREHENSIVE FIXES
════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Tables: always scrollable, never clip ── */
  .b1-table-wrap,
  .table-wrap,
  .b1-table-scroll { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .b1-table, .catalog-table { min-width: 540px; }

  /* ── Toolbars: wrap on small screens ── */
  .b1-toolbar { flex-wrap: wrap; gap: 8px; }
  .b1-toolbar .b1-search { width: 100%; }

  /* ── Form grids: single column ── */
  .field-row, .field-row-3, .b1-form-row { grid-template-columns: 1fr !important; }

  /* ── Stats bars: 2-col instead of 4-5 ── */
  .stats-bar { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }

  /* ── Content area padding ── */
  .content { padding: 12px !important; }

  /* ── Dashboard inline grids ── */
  .b1-content [style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
  .b1-content [style*="grid-template-columns:repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Modals and drawers: full screen on mobile ── */
  .b1-modal { width: 100% !important; max-width: 100% !important; }
  .drawer-panel { width: 100% !important; max-width: 100% !important; }

  /* ── Button groups: stack ── */
  .b1-btn-group { flex-wrap: wrap; }
  .b1-btn-group .btn { flex: 1; justify-content: center; min-width: 80px; }

  /* ── Badge filters: horizontal scroll ── */
  .filter-tabs-row, .segments-bar, .b1-filter-row {
    overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .filter-tabs-row::-webkit-scrollbar, .segments-bar::-webkit-scrollbar { display: none; }

  /* ── Chat inbox: full-screen panel switching ── */
  .chat-layout { display: block !important; height: calc(100vh - var(--topbar-h) - var(--mobile-nav-h)); overflow: hidden; }
  .convo-list { width: 100% !important; height: 100%; display: flex !important; flex-direction: column; }
  .convo-list.mobile-hidden { display: none !important; }
  .chat-main-panel { display: none; flex-direction: column; height: 100%; }
  .chat-main-panel.mobile-visible { display: flex !important; }

  /* ── Leads table: hide lower-priority columns ── */
  .hide-mobile { display: none !important; }

  /* ── Campaign create: full-width steps ── */
  .wizard-steps { overflow-x: auto; flex-wrap: nowrap; }
  .wizard-step { flex-shrink: 0; }

  /* ── Team page: card stacking ── */
  .team-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* Stats bars down to 2 columns for narrow phones */
  .stats-bar { grid-template-columns: 1fr 1fr !important; }
  .b1-content { padding: 10px; }
}
