.bg-root { display: grid; gap: 16px; min-width: 0; }

.bg-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e3e3eb);
  border-left: 4px solid #50538d;
  border-radius: 10px;
}
.bg-hero--live { border-left-color: #15803d; background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 70%); }
.bg-hero--off { border-left-color: #b91c1c; background: #fef2f2; }
.bg-hero--canary { border-left-color: #b45309; background: #fffbeb; }

.bg-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--purple-surface, #ededf7);
  color: var(--purple-text, #454879);
}
.bg-status-pill--live { background: #dcfce7; color: #166534; }
.bg-status-pill--warn { background: #fef3c7; color: #92400e; }
.bg-status-pill--off { background: #fee2e2; color: #991b1b; }

.bg-hero-meta { margin: 8px 0 0; font-size: 12.5px; color: var(--muted, #62626e); }
.bg-hero-err { margin: 6px 0 0; font-size: 12.5px; font-weight: 600; color: #b91c1c; }

.bg-mode-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bg-confirm-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  font-size: 12px;
  font-weight: 600;
}

.bg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.bg-kpi-card {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 10px;
  padding: 14px 16px;
}
.bg-kpi-card--btn {
  width: 100%;
  text-align: left;
  background: var(--surface, #fff);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bg-kpi-card--btn:hover { border-color: var(--primary, #50538d); box-shadow: 0 2px 10px rgba(80, 83, 141, .08); }
.bg-kpi-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.bg-kpi-val { font-size: 24px; font-weight: 700; margin: 6px 0 4px; color: var(--ink, #17171c); }
.bg-kpi-val small { font-size: 12px; font-weight: 500; color: var(--muted, #62626e); }
.bg-kpi-sub { font-size: 12px; color: var(--muted, #62626e); line-height: 1.45; margin: 0; }

.bg-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.bg-badge--ok { background: #dcfce7; color: #166534; }
.bg-badge--info { background: #ededf7; color: #454879; }
.bg-badge--warn { background: #fef3c7; color: #92400e; }
.bg-badge--bad { background: #fee2e2; color: #991b1b; }
.bg-badge--muted { background: #f1f1f6; color: #52525b; }

.bg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line, #e3e3eb);
  padding-bottom: 10px;
}
.bg-tab {
  border: 1px solid var(--line, #e3e3eb);
  background: var(--surface, #fff);
  color: var(--ink, #17171c);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
}
.bg-tab.is-active {
  background: var(--primary, #50538d);
  border-color: var(--primary, #50538d);
  color: #fff;
}

.bg-funnel-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.bg-funnel-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 8px;
  background: #fafafa;
  font-size: 12.5px;
  text-align: left;
}
.bg-funnel-chip:hover { border-color: var(--primary, #50538d); background: #f5f5fc; }
.bg-funnel-chip strong { font-size: 16px; color: var(--primary, #50538d); }

.bg-gap-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line, #e3e3eb);
  font-size: 12.5px;
  color: var(--muted, #62626e);
}
.bg-gap-strip b { color: var(--ink, #17171c); }

.bg-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.bg-table-wrap { overflow-x: auto; margin-top: 10px; }
.bg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bg-table th, .bg-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line, #e3e3eb);
  text-align: left;
  vertical-align: top;
}
.bg-table th { font-size: 12px; color: var(--muted, #62626e); font-weight: 600; background: #fafafe; }
.bg-table td small { display: block; color: var(--muted, #62626e); font-size: 11.5px; margin-top: 2px; }

.bg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.bg-toolbar-grow { flex: 1 1 240px; }
.bg-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink, #17171c);
  padding: 6px 10px;
  background: #f5f5fa;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 8px;
  cursor: pointer;
}

.bg-task-list { display: grid; gap: 10px; margin-top: 12px; }
.bg-task-card {
  padding: 12px 14px;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 10px;
  background: #fff;
  display: grid;
  gap: 8px;
}
.bg-task-card--hot {
  border-color: #f59e0b;
  border-left: 4px solid #d97706;
  background: #fffbeb;
}
.bg-task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.bg-task-contacts { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; align-items: center; }
.bg-task-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bg-task-complete-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed var(--line, #e3e3eb);
}
.bg-task-complete-form select, .bg-task-complete-form input {
  padding: 6px 8px;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 6px;
  font-size: 12.5px;
}
.bg-task-complete-form input[name="note"] { flex: 1 1 200px; }

.bg-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted, #62626e);
}

.bg-tpl-mode {
  margin-top: 12px;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
}
.bg-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.bg-tpl-box {
  background: #fafafa;
  border: 1px solid var(--line, #e3e3eb);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}
.bg-tpl-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.bg-tpl-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  color: var(--ink, #17171c);
  font-family: inherit;
}
.bg-tpl-prompt {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11.5px;
  line-height: 1.45;
  max-height: 260px;
  overflow: auto;
  background: #f4f4fa;
  padding: 8px;
  border-radius: 6px;
}
.bg-vars-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.bg-var-chip {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--purple-surface, #ededf7);
  color: var(--purple-text, #454879);
}

.bg-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.bg-detail-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.bg-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.bg-kv { padding: 10px; border: 1px solid var(--line, #e3e3eb); border-radius: 8px; background: #fafafe; }
.bg-kv span { display: block; font-size: 11.5px; color: var(--muted, #62626e); }
.bg-kv strong { display: block; margin-top: 3px; font-size: 14px; }

.bg-mail-card {
  background: #ffffff;
  border: 1px solid #d9d8eb;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
}
.bg-mail-accent { height: 4px; background: #4f5081; }
.bg-mail-header { padding: 10px 12px; border-bottom: 1px solid #ecebf5; background: #fafafe; }
.bg-mail-brand { font-size: 10px; font-weight: 700; letter-spacing: .8px; color: #4f5081; margin-bottom: 3px; }
.bg-mail-subj { font-size: 13px; font-weight: 700; color: #102033; line-height: 1.35; }
.bg-mail-body { padding: 10px 12px; display: grid; gap: 6px; font-size: 12px; line-height: 1.5; color: #2b3044; }
.bg-mail-p { margin: 0; }
.bg-mail-bullet { padding-left: 8px; border-left: 2px solid #6b6eb2; font-size: 11.8px; }
.bg-mail-subhead { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: #4f5081; }
.bg-mail-cta {
  display: inline-block;
  margin: 4px 0;
  padding: 6px 12px;
  background: #4f5081;
  color: #ffffff;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
}
.bg-mail-sig {
  padding: 8px 12px;
  background: #f5f4fb;
  border-top: 1px solid #e4e3ee;
  font-size: 11px;
  color: #525565;
}
.bg-wa-bubble {
  background: #ffffff;
  border: 1px solid #d7e3dd;
  border-left: 4px solid #25d366;
  border-radius: 10px;
  overflow: hidden;
}
.bg-wa-bubble-text {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.48;
  color: #111b21;
  white-space: pre-wrap;
  word-break: break-word;
}
.bg-wa-bubble-btn {
  border-top: 1px solid #e9edef;
  padding: 7px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #008069;
  background: #f9fbfa;
}
