/* ═══════════════════════════════════════════════════════════
   NIVA Botmaster — Shared Stylesheet
   Light theme · Sora font · Clean enterprise UI
   ═══════════════════════════════════════════════════════════ */

/* ── GLOBAL PROGRESS LOADER ──────────────────────────────── */

/* Top progress bar */
#niva-loader {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  z-index: 99999;
  pointer-events: none;
  background: linear-gradient(90deg, #C72C48, #E28743, #EFCB68, #5AB07F, #3B70B5, #6C4BA5);
  border-radius: 0 3px 3px 0;
  opacity: 0;
  will-change: width, opacity;
  box-shadow: 0 0 10px rgba(107, 74, 165, 0.55);
}

#niva-loader::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: nl-shimmer 1s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.2s;
}

#niva-loader.nl-running::after { opacity: 1; }

@keyframes nl-shimmer {
  0%   { transform: translateX(-100px) }
  100% { transform: translateX(120px)  }
}

@keyframes nl-crawl {
  0%   { width: 0%  }
  3%   { width: 10% }
  12%  { width: 30% }
  40%  { width: 55% }
  100% { width: 82% }
}

/* ── LOGO OVERLAY (page navigation) ─────────────────────── */
#niva-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 252, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

#niva-loader-overlay.nl-overlay-on {
  opacity: 1;
  pointer-events: all;
}

/* Logo card + ring wrapper */
.nl-logo-wrap {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Spinning gradient ring — uses logo's own gradient colors */
.nl-ring {
  position: absolute;
  inset: -8px; /* 84 + 16 = 100px circle */
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #C72C48 0%,
    #E28743 18%,
    #EFCB68 32%,
    #5AB07F 48%,
    #3B70B5 62%,
    #6C4BA5 75%,
    #9B4F96 84%,
    transparent 84%
  );
  -webkit-mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 4px),
    #fff       calc(100% - 3px)
  );
  mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 4px),
    #fff       calc(100% - 3px)
  );
  animation: nl-ring-spin 1.5s linear infinite;
  filter: blur(0.3px);
}

@keyframes nl-ring-spin {
  to { transform: rotate(360deg); }
}

/* White card behind logo */
.nl-logo-card {
  width: 68px;
  height: 68px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 2px 8px  rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Logo image — gentle pulse + color-shift glow */
.nl-logo-img {
  width: 34px;
  height: auto;
  animation: nl-logo-pulse 1.6s ease-in-out infinite;
}

@keyframes nl-logo-pulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 2px  8px rgba(107,  74, 165, 0.20));
  }
  50% {
    transform: scale(1.10);
    filter: drop-shadow(0 4px 16px rgba(199,  44,  72, 0.40));
  }
}

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

:root {
  --white:        #ffffff;
  --off:          #f8f9fc;
  --off2:         #f1f3f8;
  --border:       #e4e7ef;
  --border2:      #d0d5e8;
  --black:        #0d0f1a;
  --dark:         #1a1d2e;
  --muted:        #6b7399;
  --muted2:       #9ba3c4;
  --accent:       #111827;
  --accent2:      #374151;
  --accent-light: #f3f4f6;
  --accent-mid:   #e5e7eb;
  --primary:      #111827;
  --green:        #16a34a;
  --green-light:  #dcfce7;
  --amber:        #d97706;
  --amber-light:  #fef3c7;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --sidebar-w:    240px;
  --header-h:     60px;
  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10);
  --transition:   all 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  background: var(--off);
  color: var(--dark);
  line-height: 1.6;
  height: 100%;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
.bm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.bm-sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.bm-sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.bm-logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.bm-logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--dark);
  letter-spacing: .04em;
}

.bm-logo-text span {
  color: var(--accent);
}

.bm-bot-info {
  margin: 16px 14px 8px;
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.bm-bot-info-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 3px;
}

.bm-bot-info-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-bot-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--green);
  margin-top: 3px;
  font-weight: 500;
}

.bm-bot-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.bm-nav {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
}

.bm-nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 10px 10px 6px;
}

.bm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.bm-nav-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.bm-nav-item:hover {
  background: var(--off);
  color: var(--dark);
}

.bm-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.bm-nav-item.active i {
  color: var(--accent);
}

.bm-nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.bm-sidebar-footer {
  padding: 10px 4px 10px;
  border-top: 1px solid var(--border);
}

.bm-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.bm-user-card:hover { background: var(--off); }

.bm-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bm-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.2;
}

.bm-user-role {
  font-size: 11px;
  color: var(--muted2);
}

.bm-user-card .bi-box-arrow-right {
  margin-left: auto;
  color: var(--muted2);
  font-size: 14px;
}

/* ── MAIN CONTENT ── */
.bm-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.bm-topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.bm-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.bm-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.bm-icon-btn--alert {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
.bm-icon-btn--alert:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

.bm-icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: #dc2626;
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  border: 1.5px solid var(--white);
}

.bm-topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.bm-topbar-bot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 0 4px;
}

.bm-topbar-bot-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-topbar-bot-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: .04em;
}
.bm-topbar-bot-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.bm-icon-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--off);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}

.bm-icon-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-mid);
}

.bm-icon-btn i { font-size: 16px; }

.bm-content {
  flex: 1;
  padding: 28px;
}

/* ══════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════ */
.bm-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.bm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.bm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
}

.bm-card-sub {
  font-size: 12px;
  color: var(--muted2);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════ */
.bm-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.bm-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.bm-stat:hover {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow-lg);
}

.bm-stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.bm-stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.bm-stat-icon.green  { background: var(--green-light);  color: var(--green);  }
.bm-stat-icon.amber  { background: var(--amber-light);  color: var(--amber);  }
.bm-stat-icon.red    { background: var(--red-light);    color: var(--red);    }

.bm-stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  font-family: 'DM Mono', monospace;
}

.bm-stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.bm-stat-change {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.bm-stat-change.up   { color: var(--green); }
.bm-stat-change.down { color: var(--red); }

/* ══════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════ */
.bm-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.bm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.bm-table thead tr {
  background: var(--off);
  border-bottom: 1px solid var(--border);
}

.bm-table th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: left;
  white-space: nowrap;
}

.bm-table td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--dark);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.bm-table tbody tr:last-child td { border-bottom: none; }

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

.bm-table tbody tr:hover {
  background: var(--off);
}

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */
.bm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.bm-badge-green    { background: var(--green-light);  color: #15803d; }
.bm-badge-amber    { background: var(--amber-light);  color: #92400e; }
.bm-badge-red      { background: var(--red-light);    color: #991b1b; }
.bm-badge-purple   { background: var(--accent-light); color: var(--accent); }
.bm-badge-gray     { background: var(--off2);         color: var(--muted); }
.bm-badge-success  { background: var(--green-light);  color: #15803d; }
.bm-badge-warning  { background: var(--amber-light);  color: #92400e; }
.bm-badge-secondary{ background: var(--off2);         color: var(--muted); }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.bm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: 'Sora', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.bm-btn-primary {
  background: var(--accent);
  color: white;
}

.bm-btn-primary:hover {
  background: #374151;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.20);
}

.bm-btn-outline {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--border2);
}

.bm-btn-outline:hover {
  background: var(--off);
  border-color: var(--accent-mid);
}

.bm-btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fca5a5;
}

.bm-btn-danger:hover {
  background: var(--red);
  color: white;
}

.bm-btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-mid);
}

.bm-btn-ghost:hover {
  background: var(--accent-light);
}

.bm-btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.bm-btn-success {
  background: #16a34a;
  color: white;
}
.bm-btn-success:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(22,163,74,.3);
}

.bm-btn-secondary {
  background: var(--off2);
  color: var(--text);
  border: 1px solid var(--border);
}
.bm-btn-secondary:hover {
  background: var(--border);
}

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */
.bm-form-group {
  margin-bottom: 18px;
}

.bm-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 6px;
}

.bm-label span {
  color: var(--red);
  margin-left: 2px;
}

.bm-input, .bm-select, .bm-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  color: var(--dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.bm-input:focus, .bm-select:focus, .bm-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

.bm-input::placeholder, .bm-textarea::placeholder {
  color: var(--muted2);
}

.bm-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.bm-form-hint,
.bm-hint {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 5px;
}

/* ══════════════════════════════════════════════
   TOGGLE SWITCH
══════════════════════════════════════════════ */
.bm-toggle {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.bm-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.bm-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  cursor: pointer;
  transition: var(--transition);
}

.bm-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.bm-toggle input:checked + .bm-toggle-slider {
  background: var(--accent);
}

.bm-toggle input:checked + .bm-toggle-slider::before {
  transform: translateX(16px);
}

/* Small toggle variant */
.bm-toggle.bm-toggle-sm { width: 30px; height: 18px; }
.bm-toggle.bm-toggle-sm .bm-toggle-slider { border-radius: 18px; }
.bm-toggle.bm-toggle-sm .bm-toggle-slider::before { width: 12px; height: 12px; left: 3px; top: 3px; }
.bm-toggle.bm-toggle-sm input:checked + .bm-toggle-slider::before { transform: translateX(12px); }

/* ══════════════════════════════════════════════
   PERSONA TAG
══════════════════════════════════════════════ */
.persona-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.persona-chip.default-chip {
  background: var(--green-light);
  border-color: #86efac;
  color: var(--green);
}

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.bm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted2);
}

.bm-empty i {
  font-size: 40px;
  margin-bottom: 16px;
  color: var(--border2);
}

.bm-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.bm-empty-sub {
  font-size: 13px;
}

/* ══════════════════════════════════════════════
   SEARCH
══════════════════════════════════════════════ */
.bm-search-wrap {
  position: relative;
}

.bm-search-wrap i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted2);
  font-size: 14px;
  pointer-events: none;
}

.bm-search-wrap .bm-input {
  padding-left: 34px;
}

/* ══════════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════════ */
.bm-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.bm-page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.2;
}

.bm-page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   SECTION DIVIDER
══════════════════════════════════════════════ */
.bm-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ══════════════════════════════════════════════
   CHAT BUBBLES
══════════════════════════════════════════════ */
.chat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-row.user-row {
  flex-direction: row-reverse;
}

.chat-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-av.bot-av {
  background: var(--accent-light);
  color: var(--accent);
}

.chat-av.user-av {
  background: var(--accent);
  color: white;
  overflow: hidden;
}

.chat-bubble {
  max-width: 72%;
  min-width: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.bot-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
  color: var(--dark);
}

.chat-bubble.user-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 3px;
}

.chat-meta {
  font-size: 10px;
  color: var(--muted2);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════ */
.bm-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
}

.bm-page-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: var(--transition);
}

.bm-page-btn:hover, .bm-page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.bm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.bm-modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.bm-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform .2s ease;
}

.bm-modal-backdrop.open .bm-modal {
  transform: translateY(0);
}

.bm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.bm-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.bm-modal-close {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--off);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: var(--transition);
}

.bm-modal-close:hover {
  background: var(--red-light);
  color: var(--red);
}

.bm-modal-body {
  margin-bottom: 20px;
}

.bm-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.bm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ══════════════════════════════════════════════
   ALERTS / TOAST
══════════════════════════════════════════════ */
.bm-toast-area {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
  min-width: 260px;
  animation: slideIn .25s ease;
}

.bm-toast.success { border-left: 3px solid var(--green); }
.bm-toast.error   { border-left: 3px solid var(--red);   }
.bm-toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .bm-sidebar { transform: translateX(-100%); }
  .bm-sidebar.open { transform: translateX(0); }
  .bm-main { margin-left: 0; }
  .bm-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════
   LIVE SUPPORT / ESCALATION
══════════════════════════════════════════════ */

.bm-nav-badge--alert {
  background: var(--danger, #e53935);
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
  0%,100% { opacity:1; } 50% { opacity:.6; }
}

.bm-tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); padding-bottom:0; }
.bm-tab  { padding:8px 18px; font-size:13px; font-weight:500; color:var(--muted2); text-decoration:none; border-bottom:2px solid transparent; margin-bottom:-1px; transition:.15s; }
.bm-tab:hover { color:var(--text); }
.bm-tab.active { color:var(--primary); border-bottom-color:var(--primary); }

.esc-row {
  display:flex; align-items:stretch; cursor:pointer; border-bottom:1px solid var(--border);
  transition:background .12s;
}
.esc-row:last-child { border-bottom:none; }
.esc-row:hover { background:var(--bg2); }

.esc-priority { width:4px; flex-shrink:0; }
.esc-priority--urgent { background:#e53935; }
.esc-priority--high   { background:#f57c00; }
.esc-priority--medium { background:#1976d2; }
.esc-priority--low    { background:var(--border); }

.esc-main    { flex:1; padding:14px 16px; min-width:0; }
.esc-title   { font-weight:600; font-size:14px; display:flex; align-items:center; gap:8px; }
.esc-channel { font-size:11px; font-weight:400; color:var(--muted2); }
.esc-reason  { font-size:13px; color:var(--text2); margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.esc-meta    { display:flex; gap:14px; font-size:11px; color:var(--muted2); margin-top:6px; }
.esc-unread  { color:var(--primary); font-weight:600; }

.esc-actions { display:flex; align-items:center; gap:8px; padding:14px 16px; flex-shrink:0; }

.esc-status { font-size:11px; padding:2px 8px; border-radius:20px; font-weight:600; }
.esc-status--pending    { background:#fff3e0; color:#f57c00; }
.esc-status--active,
.esc-status--claimed    { background:#e3f2fd; color:#1565c0; }
.esc-status--resolved   { background:#e8f5e9; color:#2e7d32; }
.esc-status--dismissed  { background:var(--bg2); color:var(--muted2); }
.esc-status--bot_resumed{ background:#f3e5f5; color:#6a1b9a; }

.esc-priority-badge { font-size:10px; padding:2px 6px; border-radius:4px; text-transform:uppercase; font-weight:700; letter-spacing:.3px; }
.esc-priority-badge--urgent { background:#ffebee; color:#c62828; }
.esc-priority-badge--high   { background:#fff3e0; color:#e65100; }
.esc-priority-badge--medium { background:#e3f2fd; color:#1565c0; }
.esc-priority-badge--low    { background:var(--bg2); color:var(--muted2); }

.esc-detail-layout {
  display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start;
}
@media (max-width:900px) { .esc-detail-layout { grid-template-columns:1fr; } }

.esc-chat-panel {
  display:flex; flex-direction:column; background:var(--surface);
  border:1px solid var(--border); border-radius:12px; overflow:hidden;
  height:calc(100vh - 160px);
}

.esc-messages {
  flex:1; overflow-y:auto; padding:20px; display:flex; flex-direction:column; gap:14px;
}

.esc-msg { display:flex; flex-direction:column; max-width:72%; }
.esc-msg--user   { align-self:flex-start; }
.esc-msg--agent  { align-self:flex-end; }
.esc-msg--system { align-self:center; max-width:90%; }

.esc-msg-label { font-size:11px; font-weight:600; color:var(--muted2); margin-bottom:4px; }
.esc-msg--agent .esc-msg-label  { text-align:right; }
.esc-msg--system .esc-msg-label { text-align:center; }

.esc-msg-bubble {
  padding:10px 14px; border-radius:12px; font-size:13px; line-height:1.5; word-break:break-word;
}
.esc-msg--user   .esc-msg-bubble { background:var(--bg2); color:var(--text); border-bottom-left-radius:4px; }
.esc-msg--agent  .esc-msg-bubble { background:var(--primary); color:#fff; border-bottom-right-radius:4px; }
.esc-msg--system .esc-msg-bubble { background:transparent; color:var(--muted2); font-size:12px; text-align:center; font-style:italic; padding:4px 0; }

.esc-msg-time { font-size:10px; color:var(--muted2); margin-top:3px; }
.esc-msg--agent .esc-msg-time { text-align:right; }

.esc-reply-bar { display:flex; align-items:flex-end; gap:8px; padding:12px 16px; border-top:1px solid var(--border); background:var(--surface); }
.esc-reply-bar--closed { justify-content:center; padding:16px; }
.esc-reply-input {
  flex:1; background:var(--bg2); border:1px solid var(--border); border-radius:8px;
  padding:8px 12px; font-size:13px; color:var(--text); resize:none;
  font-family:inherit; line-height:1.4; outline:none;
}
.esc-reply-input:focus { border-color:var(--primary); }

.esc-context-panel { overflow-y:auto; max-height:calc(100vh - 160px); }
.esc-dl { display:grid; grid-template-columns:auto 1fr; gap:4px 16px; font-size:13px; margin:0; }
.esc-dl dt { color:var(--muted2); font-weight:500; }
.esc-dl dd { color:var(--text); margin:0; }

.bm-alert { padding:12px 16px; border-radius:8px; font-size:13px; }
.bm-alert-danger { background:#ffebee; color:#c62828; border:1px solid #ffcdd2; }

.bm-btn-danger-ghost { background:transparent; color:var(--danger,#e53935); border:1px solid var(--danger,#e53935); }
.bm-btn-danger-ghost:hover { background:#ffebee; }
.bm-btn-sm { padding:4px 10px; font-size:12px; }

.bm-toggle-row { display:flex; align-items:center; justify-content:space-between; gap:20px; cursor:pointer; }

.bm-empty-state { text-align:center; padding:48px 24px; }

/* ═══════════════════════════════════════════════════════
   UX POLISH — Micro-interactions & Animations
   ═══════════════════════════════════════════════════════ */

/* ── Keyframes ─────────────────────────────────────────── */
@keyframes bmFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes bmSpin    { to { transform: rotate(360deg); } }
@keyframes bmRipple  { to { transform: scale(4); opacity: 0; } }
@keyframes bmShimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
@keyframes bmToastBar {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
@keyframes bmToastOut {
  to { opacity: 0; transform: translateX(110%); }
}

/* ── Page entrance ─────────────────────────────────────── */
.bm-page-header {
  animation: bmFadeUp 0.26s ease both;
}
.bm-stat-grid .bm-stat {
  animation: bmFadeUp 0.28s ease both 0.02s;
}
.bm-stat-grid .bm-stat:nth-child(2) { animation-delay: 0.07s; }
.bm-stat-grid .bm-stat:nth-child(3) { animation-delay: 0.12s; }
.bm-stat-grid .bm-stat:nth-child(4) { animation-delay: 0.17s; }

.bm-content > .bm-card {
  animation: bmFadeUp 0.3s ease both 0.06s;
}

/* ── Card hover lift ───────────────────────────────────── */
.bm-card {
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.bm-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  border-color: var(--border2);
  transform: translateY(-1px);
}

/* ── Button press + ripple ─────────────────────────────── */
.bm-btn {
  overflow: hidden;
  position: relative;
}
.bm-btn:active:not(:disabled):not(.bm-loading) {
  transform: scale(0.97) !important;
  box-shadow: none !important;
  transition-duration: 0.06s !important;
}
.bm-btn:disabled,
.bm-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.bm-btn.bm-loading {
  pointer-events: none;
  opacity: 0.75;
}

/* Loading spinner inside button */
.bm-btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: bmSpin 0.65s linear infinite;
  flex-shrink: 0;
  vertical-align: middle;
}
/* For light-background buttons, spinner border needs color */
.bm-btn-outline .bm-btn-spinner,
.bm-btn-ghost .bm-btn-spinner,
.bm-btn-secondary .bm-btn-spinner,
.bm-btn-danger .bm-btn-spinner {
  border-color: rgba(0,0,0,0.15);
  border-top-color: currentColor;
}

/* Ripple */
.bm-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.12;
  transform: scale(0);
  animation: bmRipple 0.55s ease-out forwards;
  pointer-events: none;
}

/* ── Input / form focus ────────────────────────────────── */
.bm-input:hover:not(:focus),
.bm-select:hover:not(:focus),
.bm-textarea:hover:not(:focus) {
  border-color: var(--border2);
}
.bm-input:focus,
.bm-select:focus,
.bm-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}

/* ── Nav active bar indicator ─────────────────────────── */
.bm-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 22%;
  height: 56%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  animation: bmFadeIn 0.18s ease;
}

/* ── Toggle spring feel ─────────────────────────────────── */
.bm-toggle-slider::before {
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.15s ease,
              box-shadow 0.15s ease !important;
}
.bm-toggle input:checked + .bm-toggle-slider::before {
  box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}

/* ── Enhanced toast ─────────────────────────────────────── */
.bm-toast {
  position: relative;
  overflow: hidden;
  padding-right: 36px;
  align-items: flex-start;
}
.bm-toast i:first-child { margin-top: 1px; }

.bm-toast-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.bm-toast-close:hover {
  background: var(--off2);
  color: var(--dark);
}

.bm-toast-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  animation: bmToastBar var(--toast-dur, 3.5s) linear forwards;
}
.bm-toast.success .bm-toast-bar { background: var(--green); }
.bm-toast.error   .bm-toast-bar { background: var(--red);   }
.bm-toast.info    .bm-toast-bar { background: #4f46e5;      }
.bm-toast.warning .bm-toast-bar { background: var(--amber); }

.bm-toast.bm-removing {
  animation: bmToastOut 0.22s ease forwards;
}

/* ── Modal scale-in ─────────────────────────────────────── */
.bm-modal {
  transform: scale(0.94) translateY(10px);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.34, 1.2, 0.64, 1),
              opacity 0.2s ease;
}
.bm-modal-backdrop.open .bm-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ── Skeleton ───────────────────────────────────────────── */
.bm-skeleton {
  background: linear-gradient(
    90deg,
    var(--off2) 25%,
    var(--border) 50%,
    var(--off2) 75%
  );
  background-size: 1200px 100%;
  animation: bmShimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  display: block;
}
.bm-skeleton-line { height: 13px; margin-bottom: 8px; }
.bm-skeleton-line.w-80 { width: 80%; }
.bm-skeleton-line.w-60 { width: 60%; }
.bm-skeleton-line.w-40 { width: 40%; }
.bm-skeleton-block { height: 40px; border-radius: var(--radius); }
.bm-skeleton-circle { border-radius: 50%; }

/* ── Scroll-to-top ──────────────────────────────────────── */
.bm-scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 200;
}
.bm-scroll-top.bm-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.bm-scroll-top:hover { transform: translateY(-2px); }

/* ── Focus ring (keyboard nav) ──────────────────────────── */
.bm-btn:focus-visible,
.bm-input:focus-visible,
.bm-select:focus-visible,
.bm-textarea:focus-visible,
.bm-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Smooth tab transition ──────────────────────────────── */
.bm-tab {
  transition: color 0.15s ease, border-color 0.15s ease;
}
.bm-tab.active {
  position: relative;
}

/* ── Icon button hover ──────────────────────────────────── */
.bm-icon-btn {
  transition: background 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, transform 0.15s ease;
}
.bm-icon-btn:hover {
  transform: translateY(-1px);
}
.bm-icon-btn:active {
  transform: scale(0.92);
}

/* ── Notification panel slide-in ────────────────────────── */
@keyframes bmDropDown {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
.bm-notif-panel {
  animation: bmDropDown 0.2s cubic-bezier(0.34, 1.1, 0.64, 1) both;
}

/* ── Sidebar smooth open (mobile) ───────────────────────── */
.bm-sidebar {
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Badge pulse on new notifications ──────────────────── */
@keyframes bmBadgePop {
  0%   { transform: scale(1);   }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.88); }
  100% { transform: scale(1);   }
}
.bm-icon-badge.bm-pop {
  animation: bmBadgePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Stat number count-up feel (opacity only — JS drives value) ─ */
.bm-stat-num {
  transition: opacity 0.3s ease;
}

/* ── Table row left-glow on hover ───────────────────────── */
.bm-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}