:root {
  /* Core brand colors */
  --bb-blue: #18426e;
  --bb-yellow: #fddd01;
  --bb-black: #090a09;
  --bb-accent: #2563eb;

  /* Brand tonal scale */
  --bb-lightblue: #99c6d9;
  --bb-lightblue-50: #ccdeec;
  --bb-lightblue-25: #e5eef6;
  --bb-paper: #f6f5f1;

  /* Ink neutrals */
  --bb-ink-80: #2f3a47;
  --bb-ink-60: #5a6775;
  --bb-ink-40: #8b95a0;
  --bb-ink-20: #c9cfd5;
  --bb-ink-10: #e6e9ec;

  /* Semantic foreground / background / border aliases */
  --fg-1: var(--bb-black);
  --fg-2: var(--bb-ink-80);
  --fg-3: var(--bb-ink-60);
  --fg-inverse: #ffffff;
  --fg-accent: var(--bb-blue);
  --bg-1: #ffffff;
  --bg-2: var(--bb-paper);
  --bg-3: var(--bb-lightblue-25);
  --bg-dark: var(--bb-blue);
  --bg-darker: var(--bb-black);
  --border-1: var(--bb-ink-10);
  --border-2: var(--bb-ink-20);
  --border-strong: var(--bb-ink-60);

  /* Legacy surfaces / text (keep for backwards compat) */
  --bb-bg: #f5f5f7;
  --bb-line: #e5e7eb;
  --bb-text: var(--bb-black);
  --bb-text-2: #374151;
  --bb-text-3: #6b7280;
  --bb-muted: #64748b;
  --bb-surface: #ffffff;
  --bb-surface-2: #f8fafc;
  --bb-bg-2: #f8fafc;
  --bb-bg-subtle: #f8fafc;
  --bb-border: var(--bb-line);
  --bb-text-1: var(--bb-text);
  --bb-hint: #475569;
  --bb-input-readonly-bg: #f8fafc;

  /* Semantic states */
  --bb-danger-bg: #fef2f2;
  --bb-danger-text: #dc2626;
  --bb-danger-border: #fecaca;
  --bb-success-bg: #f0fdf4;
  --bb-success-text: #16a34a;
  --bb-success-border: #bbf7d0;
  --bb-green: #16a34a;
  --bb-danger: #dc2626;

  /* Schedule timeline lane palette (indexed by asset discovery order) */
  --bb-lane-0: var(--bb-success-text);
  --bb-lane-1: var(--bb-accent);
  --bb-lane-2: #8b5cf6;
  --bb-lane-3: #d97706;
  --bb-lane-4: #0891b2;
  --bb-lane-5: #be185d;

  --bb-warn-bg: #fef3c7;
  --bb-warn-text: #92400e;
  --bb-warn-border: #fcd34d;

  /* Shadows — cool BB-Blue tint (never warm black) */
  --bb-shadow-sm: 0 1px 2px rgba(24,66,110,.06), 0 1px 1px rgba(9,10,9,.04);
  --bb-shadow-md: 0 4px 12px rgba(24,66,110,.10), 0 2px 4px rgba(9,10,9,.04);
  --bb-shadow-lg: 0 12px 32px rgba(24,66,110,.14), 0 4px 10px rgba(9,10,9,.06);
  --bb-shadow-inset: inset 0 0 0 1px rgba(24,66,110,.10);

  /* Typography weights */
  --bb-weight-light: 300;
  --bb-weight-regular: 400;
  --bb-weight-medium: 500;
  --bb-weight-bold: 700;

  /* Letter-spacing scale */
  --bb-track-tight-1: -0.01em;
  --bb-track-tight-2: -0.005em;
  --bb-track-loose-1: 0.02em;
  --bb-track-loose-2: 0.04em;
  --bb-track-caps: 0.08em;

  --bb-r: 16px;
}

body {
  font-family: "Montserrat", sans-serif;
}

.bb-auth-shell {
  min-height: 100vh;
  background: var(--bb-bg);
}

.bb-auth-card {
  width: 100%;
  max-width: 26rem;
  border: 1px solid var(--bb-line);
  border-radius: 1rem;
  background: #fff;
  box-shadow: var(--bb-shadow-sm);
}

.bb-logo-wrap {
  display: inline-flex;
  align-items: center;
  border-radius: 0.75rem;
  background: var(--bb-blue);
  padding: 0.625rem 1.125rem;
}

.bb-logo-img {
  max-height: 48px;
  max-width: 130px;
  width: auto;
  height: auto;
  display: block;
  flex-shrink: 0;
}

.bb-logo-img--light {
  filter: brightness(0) invert(1);
}

.bb-logo-text {
  color: #fff;
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.03em;
}

.bb-logo-em {
  margin-left: 0.25rem;
  display: inline-block;
  border-radius: 0.375rem;
  border: 1px solid color-mix(in srgb, var(--bb-yellow) 30%, transparent);
  padding: 0 0.35rem;
  color: var(--bb-yellow);
  font-size: 0.875rem;
  font-style: normal;
}

.bb-title {
  margin: 0;
  color: var(--bb-blue);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.bb-title-lg {
  font-size: 2rem;
}

.bb-title-md {
  font-size: 1.5rem;
}

.bb-title-sm {
  font-size: 1.125rem;
}

/* ============================================================
   Typography layer — brand spec scale
   ============================================================ */
.bb-h1 {
  font-size: 30px;
  line-height: 36px;
  font-weight: var(--bb-weight-bold);
  letter-spacing: var(--bb-track-tight-1);
  margin: 0;
}

.bb-h2 {
  font-size: 22px;
  line-height: 28px;
  font-weight: var(--bb-weight-bold);
  letter-spacing: var(--bb-track-tight-2);
  margin: 0;
}

.bb-h3 {
  font-size: 16px;
  line-height: 22px;
  font-weight: var(--bb-weight-medium);
  margin: 0;
}

.bb-intro {
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--bb-weight-light);
}

.bb-subhead {
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--bb-weight-bold);
}

.bb-body {
  font-size: 15px;
  line-height: 22px;
  font-weight: var(--bb-weight-light);
}

.bb-body-on-dark {
  font-size: 15px;
  line-height: 22px;
  font-weight: var(--bb-weight-regular);
}

.bb-kicker,
.bb-list-title {
  font-size: 12px;
  line-height: 18px;
  font-weight: var(--bb-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--bb-track-caps);
}

.bb-caption {
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--bb-weight-regular);
}

.bb-quote {
  font-size: 18px;
  line-height: 26px;
  font-weight: var(--bb-weight-medium);
}

/* ============================================================ */

.bb-subtitle {
  margin: 0;
  color: var(--bb-muted);
  font-size: 0.813rem;
}

.bb-label {
  margin-bottom: 0.375rem;
  display: block;
  color: var(--bb-blue);
  font-size: 0.813rem;
  font-weight: 600;
}

.bb-input,
.bb-select {
  width: 100%;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.7rem 0.75rem;
  font-size: 0.875rem;
}

.bb-textarea {
  width: 100%;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.7rem 0.75rem;
  font-size: 0.875rem;
  resize: vertical;
}

.bb-input:focus,
.bb-select:focus,
.bb-textarea:focus {
  outline: none;
  border-color: var(--bb-accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.bb-input[readonly] {
  color: var(--bb-muted);
  background: var(--bb-input-readonly-bg);
}

.bb-btn-primary {
  width: 100%;
  border: 0;
  border-radius: 0.75rem;
  background: var(--bb-accent);
  padding: 0.75rem 0.875rem;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

.bb-btn-primary:hover {
  filter: brightness(0.97);
}

.bb-btn-secondary {
  border: 1px solid var(--bb-line);
  border-radius: 0.625rem;
  background: #fff;
  color: var(--bb-blue);
  padding: 0.45rem 0.8rem;
  font-size: 0.813rem;
  font-weight: 600;
}

.bb-btn-secondary:hover {
  background: #f8fafc;
}

.bb-btn-link {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--bb-blue);
  font-size: 0.813rem;
  text-decoration: underline;
}

.bb-link-row {
  text-align: center;
}

.bb-link {
  color: var(--bb-blue);
  font-size: 0.813rem;
  text-decoration: none;
}

.bb-link:hover {
  text-decoration: underline;
}

.bb-quick-login {
  border-top: 1px solid var(--bb-line);
  padding-top: 16px;
}

.bb-quick-login-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--bb-line);
  border-radius: 8px;
  background: var(--bb-bg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bb-quick-login-card:hover {
  border-color: var(--bb-blue);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--bb-blue) 10%, transparent);
}

.bb-quick-login-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.bb-quick-login-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.bb-quick-login-info strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--bb-text);
}

.bb-quick-login-info small {
  font-size: 11px;
  color: var(--bb-text-2);
}

.message {
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.625rem 0.75rem;
  font-size: 0.813rem;
}

.is-error {
  border-color: var(--bb-danger-border);
  color: var(--bb-danger-text);
  background: var(--bb-danger-bg);
}

.is-success {
  border-color: var(--bb-success-border);
  color: var(--bb-success-text);
  background: var(--bb-success-bg);
}

.hidden {
  display: none !important;
}

.bb-step-title {
  margin: 0;
  color: var(--bb-blue);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.bb-hint {
  margin: 0.5rem 0 0.75rem;
  color: var(--bb-hint);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.bb-page-shell {
  min-height: 100vh;
  background: var(--bb-bg);
}

/* ── Hero Header ── */

.bb-hero-header {
  background: linear-gradient(
    color-mix(in srgb, var(--bb-blue) 98%, transparent) 0%,
    color-mix(in srgb, var(--bb-blue) 88%, transparent) 100%
  );
}

.bb-navbar {
  height: 88px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bb-hero-header .bb-logo-wrap {
  width: 150px;
  height: 100%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  border-bottom-right-radius: 28px;
  border-bottom-left-radius: 28px;
  box-shadow: var(--bb-shadow-md);
  padding: 0;
}

.bb-hero-header .bb-logo-text {
  color: var(--bb-blue);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.4px;
}

.bb-hero-header .bb-logo-em {
  font-style: normal;
  color: var(--bb-yellow);
  background: var(--bb-blue);
  padding: 2px 5px;
  border-radius: 4px;
  margin-left: 2px;
  font-size: 15px;
  border: none;
}

.bb-hero-strip {
  height: 20px;
}

/* ── Legacy Topbar (kept for backward compat) ── */

.bb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bb-blue);
  color: #fff;
}

.bb-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

/* ── Nav Links (hero-header context) ── */

.bb-nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
  margin-left: auto;
}

.bb-nav-link {
  text-decoration: none;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding-bottom: 4px;
  border-bottom: 3px solid transparent;
  transition: border-color 0.2s;
}

.bb-nav-link:hover {
  border-color: rgba(253, 221, 1, 0.5);
}

.bb-nav-link.active {
  border-bottom: 3px solid var(--bb-yellow);
}

.bb-nav-settings {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 6px 14px;
  transition: all 0.2s;
  margin-left: 8px;
}

.bb-nav-settings:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.6);
}

.bb-nav-settings.active {
  background: var(--bb-yellow);
  color: var(--bb-blue);
  border-color: var(--bb-yellow);
}

.bb-nav-settings svg {
  flex-shrink: 0;
}

.bb-nav-profile-wrap {
  position: relative;
  margin-left: 12px;
  flex-shrink: 0;
}

.bb-nav-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.bb-nav-profile:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--bb-yellow);
}

.bb-nav-profile-wrap.open .bb-nav-profile {
  background: var(--bb-yellow);
  color: var(--bb-blue);
  border-color: var(--bb-yellow);
}

.bb-profile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(24,66,110,.15);
  padding: 12px 0;
  z-index: 100;
}

.bb-nav-profile-wrap.open .bb-profile-dropdown {
  display: block;
}

.bb-profile-dropdown-name {
  padding: 4px 16px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bb-text);
}

.bb-profile-dropdown-role {
  padding: 0 16px 4px;
  font-size: 11px;
  color: var(--bb-text-2);
}

.bb-profile-dropdown-divider {
  border: none;
  border-top: 1px solid var(--bb-border);
  margin: 8px 0;
}

.bb-profile-dropdown-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--bb-text-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.bb-profile-dropdown-logout:hover {
  background: var(--bb-danger-bg);
  color: var(--bb-danger-text);
}

.bb-profile-dropdown-logout svg {
  flex-shrink: 0;
}

.bb-btn-logout {
  border: 2px solid var(--bb-yellow);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  padding: 0.45rem 1rem;
  font-size: 0.813rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.bb-btn-logout:hover {
  background: var(--bb-yellow);
  color: var(--bb-blue);
}

.bb-content-wrap {
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.bb-admin-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .bb-admin-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
}

.bb-card {
  border: 1px solid var(--bb-line);
  border-radius: 1rem;
  background: #fff;
  box-shadow: var(--bb-shadow-sm);
}

.bb-role-text {
  color: var(--bb-muted);
}

.bb-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
}

.bb-table {
  width: 100%;
  border-collapse: collapse;
}

.bb-table th,
.bb-table td {
  border-bottom: 1px solid var(--bb-line);
  padding: 0.7rem 0.75rem;
  text-align: left;
  font-size: 0.813rem;
}

.bb-table th {
  background: #f8fafc;
  color: var(--bb-blue);
  font-weight: 700;
}

.bb-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.bb-th-sortable:hover {
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
}
.bb-th-sortable::after {
  content: " ⇅";
  opacity: 0.35;
  font-size: 0.75em;
}
.bb-th-sorted-asc::after {
  content: " ↑";
  opacity: 1;
  color: var(--bb-blue);
}
.bb-th-sorted-desc::after {
  content: " ↓";
  opacity: 1;
  color: var(--bb-blue);
}

/* Audit log tables (settings prototype) */
.bb-audit-table.bb-table th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bb-text-3);
  background: var(--bb-bg);
}

.bb-audit-table.bb-table tbody tr:hover td {
  background: #fafafa;
}

.bb-table-empty {
  color: var(--bb-muted);
  text-align: center !important;
}

.bb-btn-table {
  border: 1px solid var(--bb-line);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--bb-blue);
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.bb-btn-table:hover {
  background: #f8fafc;
}

.bb-btn-table:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f8fafc;
}

.bb-btn-table-danger {
  border-color: var(--bb-danger-border);
  color: var(--bb-danger-text);
}

.bb-window-btn {
  border: 1px solid var(--bb-line);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--bb-text-3);
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.bb-window-btn:hover {
  background: #f1f5f9;
  color: var(--bb-blue);
}

.bb-window-btn--active {
  background: var(--bb-blue);
  border-color: var(--bb-blue);
  color: #fff;
}

.bb-window-btn--active:hover {
  background: var(--bb-blue);
  color: #fff;
}

/* Radio-button pill selector used for shared window controls */
.bb-window-selector {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bb-window-selector input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bb-window-selector label {
  border: 1px solid var(--bb-line);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--bb-text-3);
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.bb-window-selector label:hover {
  background: #f1f5f9;
  color: var(--bb-blue);
}

.bb-window-selector input[type="radio"]:checked + label {
  background: var(--bb-blue);
  border-color: var(--bb-blue);
  color: #fff;
}

/* Master data: active price source selector */
.bb-active-source-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bb-active-source-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid var(--bb-accent, #2563eb);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0.02) 100%);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}

.bb-active-source-banner--empty {
  border-color: var(--bb-line);
  background: var(--bb-bg-2, #f8fafc);
  box-shadow: none;
}

.bb-active-source-banner__icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: var(--bb-accent, #2563eb);
  color: #fff;
  font-size: 1.25rem;
}

.bb-active-source-banner--empty .bb-active-source-banner__icon {
  background: var(--bb-text-3);
}

.bb-active-source-banner__body {
  flex: 1;
  min-width: 0;
}

.bb-active-source-banner__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bb-accent, #2563eb);
  margin-bottom: 0.25rem;
}

.bb-active-source-banner--empty .bb-active-source-banner__label {
  color: var(--bb-text-3);
}

.bb-active-source-banner__name {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--bb-text, #111827);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.bb-active-source-banner__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--bb-text-2);
}

.bb-active-source-banner__hint {
  font-size: 0.875rem;
  color: var(--bb-text-3);
  margin: 0.25rem 0 0;
}

.bb-active-source-banner__sync {
  flex-shrink: 0;
  align-self: center;
  width: auto;
  padding: 0.5rem 1.25rem;
}

.bb-source-selector-wrap {
  padding: 0 0.25rem;
}

.bb-source-selector-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bb-text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.bb-source-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bb-source-selector__form {
  margin: 0;
  display: inline;
}

.bb-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 2px solid var(--bb-line);
  border-radius: 2rem;
  background: #fff;
  color: var(--bb-text-2);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.bb-source-pill:hover {
  border-color: var(--bb-accent, #2563eb);
  color: var(--bb-accent, #2563eb);
  background: rgba(37, 99, 235, 0.04);
}

.bb-source-pill--active {
  border-color: var(--bb-accent, #2563eb);
  background: var(--bb-accent, #2563eb);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.bb-source-pill--active:hover {
  background: var(--bb-accent, #2563eb);
  color: #fff;
  filter: brightness(1.05);
}

.bb-source-pill__check {
  font-size: 0.7rem;
}

.bb-source-type-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bb-bg-2, #f1f5f9);
  color: var(--bb-text-2);
}

.bb-source-pill--active .bb-source-type-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.bb-table--sources tbody tr.bb-table-row-active td {
  background: rgba(37, 99, 235, 0.06);
}

.bb-table--sources tbody tr.bb-table-row-active td:first-child {
  box-shadow: inset 3px 0 0 var(--bb-accent, #2563eb);
}

.bb-source-row-active-tag {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bb-accent, #2563eb);
  color: #fff;
  vertical-align: middle;
}

.bb-sync-status-ok {
  color: var(--bb-green, #16a34a);
  font-weight: 600;
}

.bb-sync-status-failed {
  color: var(--bb-danger, #dc2626);
  font-weight: 600;
}

.bb-btn-table-danger:hover {
  background: var(--bb-danger-bg);
}

.bb-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ── Hamburger Button ── */

.bb-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--bb-yellow);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* ── Mobile Menu Overlay ── */

.bb-mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bb-blue);
  z-index: 1000;
  flex-direction: column;
  padding: 20px;
}

.bb-mobile-menu.open {
  display: flex;
}

.bb-mobile-menu-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--bb-yellow);
  font-size: 32px;
  cursor: pointer;
  margin-bottom: 40px;
  line-height: 1;
}

.bb-mobile-menu-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
}

.bb-mobile-menu-logo .bb-logo-wrap {
  width: 140px;
  height: 60px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  padding: 0;
}

.bb-mobile-menu-logo .bb-logo-text {
  color: var(--bb-blue);
  font-weight: 800;
  font-size: 17px;
}

.bb-mobile-menu-logo .bb-logo-em {
  font-style: normal;
  color: var(--bb-yellow);
  background: var(--bb-blue);
  padding: 2px 5px;
  border-radius: 4px;
  margin-left: 2px;
  font-size: 15px;
  border: none;
}

.bb-mobile-menu-links {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-left: 20px;
}

.bb-mobile-menu-links a {
  text-decoration: none;
  color: #fff;
  font-size: 18px;
  font-weight: 500;
}

.bb-mobile-menu-links a.active {
  color: var(--bb-yellow);
  font-weight: 600;
}

.bb-mobile-menu-logout {
  margin-top: 40px;
  margin-left: 20px;
  background: transparent;
  border: 2px solid var(--bb-yellow);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 24px;
  cursor: pointer;
  font-family: inherit;
  width: fit-content;
}

/* ── Responsive: nav vs hamburger ── */

@media (max-width: 1024px) {
  .bb-nav-links {
    display: none !important;
  }
  .bb-hamburger {
    display: block !important;
  }
  .bb-content-wrap {
    padding: 20px 16px;
  }
}

@media (min-width: 1025px) {
  .bb-hamburger {
    display: none !important;
  }
  .bb-nav-links {
    display: flex !important;
  }
}

/* ── Settings Sidebar Layout ── */

.bb-settings-layout {
  display: flex;
  align-items: stretch;
  /* Hard-bounded to viewport so the sidebar and main panel scroll independently. */
  height: calc(100vh - 108px);
  min-height: 0;
  overflow: hidden;
}

.bb-settings-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bb-surface);
  border-right: 1px solid var(--bb-line);
  padding: 24px 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.bb-settings-main {
  flex: 1;
  padding: 40px;
  min-height: 0;
  overflow-y: auto;
  max-width: 1000px;
}

/* Wider main column when account settings sidebar wraps platform tool pages */
.bb-settings-main.bb-settings-main--platform-tool {
  max-width: none;
  min-width: 0;
}

/* Clients page nests bb-am-layout inside the settings main — fill parent, not viewport */
.bb-settings-main.bb-settings-main--platform-tool .bb-am-layout {
  height: 100%;
  min-height: 0;
}

.bb-settings-main.bb-settings-main--platform-tool:has(.bb-am-layout) {
  overflow: hidden;
  padding: 0;
}

.bb-data-browser-panels {
  margin-top: 1.5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bb-data-browser-hero-band,
.bb-etl-hero-band {
  padding-bottom: 0.25rem;
}

.bb-sidebar-section-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--bb-text-3);
  padding: 0 20px 8px;
  margin-top: 16px;
}

.bb-sidebar-section-lbl:first-child {
  margin-top: 0;
}

.bb-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--bb-text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.bb-sidebar-item:hover {
  background: var(--bb-bg);
  color: var(--bb-text);
}

.bb-sidebar-item.active {
  background: color-mix(in srgb, var(--bb-blue) 8%, white);
  color: var(--bb-blue);
  border-left-color: var(--bb-blue);
  font-weight: 600;
}

.bb-sidebar-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* Nested group under a settings section (e.g. Master data → Collectors, …) */
.bb-sidebar-group-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.55px;
  text-transform: uppercase;
  color: var(--bb-text-3);
  padding: 6px 20px 4px 20px;
  margin-top: 2px;
}

.bb-sidebar-item.bb-sidebar-subitem {
  padding: 8px 16px 8px 36px;
  font-size: 12px;
  font-weight: 500;
}

.bb-sidebar-item.bb-sidebar-subitem .bb-sidebar-icon {
  font-size: 14px;
  width: 18px;
}

.bb-section-panel {
  display: none;
}

.bb-section-panel.active {
  display: block;
}

.bb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.bb-section-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--bb-text-3);
  margin-bottom: 6px;
}

.bb-section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--bb-text);
}

/* ── Stats Bar (Dashboard KPIs) ── */

.bb-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  box-shadow: var(--bb-shadow-md);
  margin-bottom: 36px;
}

.bb-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  padding: 28px 32px;
}

.bb-stat + .bb-stat {
  border-left: 1px solid var(--bb-line);
}

.bb-stat-value {
  font-size: 42px;
  font-weight: 700;
  color: var(--bb-blue);
  line-height: 1;
  letter-spacing: -0.03em;
}

.bb-stat-divider {
  height: 3px;
  background: currentColor;
  margin: 8px 0 6px;
  align-self: flex-end;
  border-radius: 2px;
}

.bb-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--bb-text-3);
}

@media (max-width: 768px) {
  .bb-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .bb-stat + .bb-stat {
    border-left: none;
  }
  .bb-stat:nth-child(odd) {
    border-right: 1px solid var(--bb-line);
  }
  .bb-stat:nth-child(1),
  .bb-stat:nth-child(2) {
    border-bottom: 1px solid var(--bb-line);
  }
  .bb-stat {
    padding: 20px 24px;
  }
  .bb-stat-value {
    font-size: 32px;
  }
}

/* ── Sidebar "Create" Button ── */

.bb-sidebar-create-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 16px 12px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bb-surface);
  background: var(--bb-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
  text-decoration: none;
}

.bb-sidebar-create-btn:hover {
  filter: brightness(0.92);
}

/* ── Status Badges (from demo settings.html) ── */

.bb-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}

.bb-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bb-badge-active {
  background: rgba(28, 122, 53, 0.1);
  color: var(--bb-success-text);
}
.bb-badge-active::before {
  background: var(--bb-success-text);
}

.bb-badge-inactive {
  background: rgba(24,66,110,.05);
  color: var(--bb-text-3);
}
.bb-badge-inactive::before {
  background: var(--bb-text-3);
}

.bb-badge-error {
  background: color-mix(in srgb, var(--bb-danger-text) 10%, transparent);
  color: var(--bb-danger-text);
}
.bb-badge-error::before {
  background: var(--bb-danger-text);
}

.bb-badge-stock {
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  color: var(--bb-accent);
}
.bb-badge-stock::before {
  background: var(--bb-accent);
}

.bb-badge-decommissioned {
  background: rgba(24,66,110,.05);
  color: var(--bb-text-3);
}
.bb-badge-decommissioned::before {
  background: #9ca3af;
}

/* ── Audit log event pills (settings.html prototype) ── */

.bb-audit-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.bb-audit-pill--login {
  background: #e0f2fe;
  color: #0369a1;
}
.bb-audit-pill--logout {
  background: rgba(24,66,110,.06);
  color: var(--bb-text-2);
}
.bb-audit-pill--setting {
  background: rgba(253, 224, 71, 0.35);
  color: var(--bb-warn-text);
}
.bb-audit-pill--user-mgmt {
  background: rgba(28, 122, 53, 0.12);
  color: var(--bb-success-text);
}
.bb-audit-pill--strategy {
  background: #e0e7ff;
  color: #4338ca;
}
.bb-audit-pill--asset {
  background: #f3e8ff;
  color: #7e22ce;
}
.bb-audit-pill--override {
  background: rgba(251, 146, 60, 0.2);
  color: #c2410c;
}
.bb-audit-pill--api {
  background: rgba(244, 114, 182, 0.2);
  color: #9d174d;
}
.bb-audit-pill--default {
  background: #f3f4f6;
  color: var(--bb-text-2);
}

.bb-text-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--bb-text-2);
}

.bb-btn-export-csv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── Inline Form Area ── */

.bb-inline-form {
  border-bottom: 1px solid var(--bb-line);
  padding: 20px 24px;
  background: #fafbfc;
}

.bb-inline-form .bb-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-inline-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--bb-line);
  margin-top: 16px;
}

/* ── Settings organisation form (prototype form-grid) ── */

.bb-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}

.bb-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bb-form-group-full {
  grid-column: 1 / -1;
}

.bb-form-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-org-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bb-line);
  font-size: 12px;
  color: var(--bb-text-3);
}

@media (max-width: 900px) {
  .bb-form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Card Header (demo pattern) ── */

.bb-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--bb-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Compact Price Series strip (platform masterdata — electricity) */
.bb-price-series-panel .bb-section-eyebrow {
  margin-bottom: 8px;
}
.bb-price-series-table-wrap .bb-table th,
.bb-price-series-table-wrap .bb-table td {
  padding: 6px 10px;
  font-size: 12px;
}
.bb-price-series-table-wrap .bb-table thead th {
  font-size: 11px;
  padding-top: 4px;
  padding-bottom: 4px;
}
.bb-price-series-actions-col {
  width: 1%;
  white-space: nowrap;
}

.bb-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  border: none;
  background: var(--bb-blue);
  color: white;
}

.bb-btn-add:hover {
  opacity: 0.85;
}

/* ── Clients / Organisations (availability-manager layout) ── */

.bb-page-am {
  overflow: hidden;
}

.bb-am-layout {
  display: flex;
  align-items: stretch;
  /* Hard-bounded to viewport so inner overflow:auto containers actually scroll.
     Was min-height which let the layout grow indefinitely with the form, hiding
     the Save button below the viewport with no scrollbar. */
  height: calc(100vh - 108px);
  min-height: 0;
  overflow: hidden;
}

.bb-client-list-panel {
  flex: 0 0 auto;
  width: min(400px, 38vw);
  min-width: 360px;
  max-width: min(560px, 50vw);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bb-line);
  background: var(--bb-surface);
  overflow: hidden;
  box-sizing: border-box;
}

.bb-client-list-header {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.bb-client-list-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 24px 28px 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-width: min-content;
  box-sizing: border-box;
}

.bb-client-list-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--bb-text);
  letter-spacing: -0.03em;
  flex: 0 1 auto;
  min-width: 0;
}

.bb-client-list-header-row .bb-btn-am-primary {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Drag handle between organisation list and detail panel (platform accounts) */
.bb-client-list-resize-handle {
  flex: 0 0 8px;
  width: 8px;
  margin: 0 -4px;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  position: relative;
  z-index: 3;
  align-self: stretch;
}

.bb-client-list-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  border-radius: 1px;
  background: var(--bb-line);
  transition: background 0.12s;
}

.bb-client-list-resize-handle:hover::after,
.bb-client-list-resize-handle.is-dragging::after {
  background: var(--bb-blue);
  width: 3px;
  left: 2px;
}

#account-sidebar-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

#account-sidebar-list .bb-client-list-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bb-client-list-subtitle {
  padding: 0 28px 8px;
  font-size: 12px;
  color: var(--bb-text-3);
  font-weight: 500;
}

.bb-client-list-search {
  margin: 0 28px 12px;
  position: relative;
}

.bb-client-list-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--bb-line);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--bb-text);
  background: var(--bb-bg);
}

.bb-client-list-search input:focus {
  outline: none;
  border-color: var(--bb-blue);
}

.bb-client-list-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bb-text-3);
  pointer-events: none;
}

.bb-client-list-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.bb-client-list-empty {
  padding: 24px 28px;
  font-size: 13px;
  color: var(--bb-text-3);
}

.bb-client-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--bb-line);
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  width: 100%;
  border-left: 3px solid transparent;
  box-sizing: border-box;
  background: var(--bb-surface);
  font: inherit;
}

.bb-client-row:hover {
  background: var(--bb-bg);
}

.bb-client-row.selected {
  background: #eef4fb;
  border-left-color: var(--bb-blue);
  padding-left: 25px;
}

.bb-client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bb-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.bb-client-avatar--green {
  background: var(--bb-success-text);
}
.bb-client-avatar--orange {
  background: var(--bb-warn-text);
}
.bb-client-avatar--slate {
  background: #475569;
}
.bb-client-avatar--blue {
  background: var(--bb-blue);
}

.bb-client-info {
  flex: 1;
  min-width: 0;
}

.bb-client-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--bb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bb-client-meta {
  font-size: 11px;
  color: var(--bb-text-3);
  margin-top: 2px;
  font-weight: 500;
}

.bb-client-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.bb-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.bb-alert-badge-ok {
  background: rgba(28, 122, 53, 0.1);
  color: var(--bb-success-text);
}

.bb-login-as-client {
  font-size: 11px;
  font-weight: 600;
  color: var(--bb-blue);
  background: color-mix(in srgb, var(--bb-blue) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--bb-blue) 18%, transparent);
  border-radius: 999px;
  padding: 4px 11px;
  pointer-events: none;
}

.bb-am-detail-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Single inner scroll container — see .bb-am-detail-root. Removing overflow here
     prevents the double-scroll trap that hid the Locations form Save button. */
  overflow: hidden;
  background: var(--bb-bg);
}

.bb-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--bb-text-3);
  text-align: center;
  padding: 40px;
}

.bb-detail-empty svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.bb-detail-empty-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--bb-text-2);
  margin-bottom: 6px;
}

.bb-detail-empty-sub {
  font-size: 13px;
  color: var(--bb-text-3);
  max-width: 360px;
}

.bb-am-detail-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.bb-detail-header {
  padding: 24px 32px 0;
  border-bottom: 1px solid var(--bb-line);
  background: var(--bb-surface);
  flex-shrink: 0;
}

.bb-detail-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.bb-detail-client-name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--bb-text);
  letter-spacing: -0.03em;
}

.bb-detail-client-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--bb-text-3);
  font-weight: 500;
}

.bb-detail-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bb-btn-am-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bb-blue);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.bb-btn-am-primary:hover:not(:disabled) {
  opacity: 0.88;
}

.bb-btn-am-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bb-btn-am-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bb-bg);
  color: var(--bb-text);
  border: 1px solid var(--bb-line);
  border-radius: 20px;
  padding: 9px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.bb-btn-am-outline:hover:not(:disabled) {
  opacity: 0.88;
}

.bb-btn-am-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bb-btn-am-outline-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bb-bg);
  color: var(--bb-text);
  border: 1px solid var(--bb-line);
  border-radius: 16px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bb-btn-am-outline-sm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bb-detail-tabs {
  display: flex;
  gap: 0;
  margin-top: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.bb-detail-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bb-text-3);
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  white-space: nowrap;
}

.bb-detail-tab:hover {
  color: var(--bb-text-2);
}

.bb-detail-tab.active {
  color: var(--bb-blue);
  border-bottom-color: var(--bb-yellow);
}

.bb-detail-body {
  padding: 24px 32px 80px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.bb-detail-tab-panel[hidden] {
  display: none !important;
}

.bb-detail-tab-panel:not([hidden]) {
  display: block;
}

.bb-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.bb-am-card {
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  padding: 20px 22px;
  box-shadow: var(--bb-shadow-sm);
}

.bb-am-eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-am-dl {
  margin: 0;
  display: grid;
  gap: 10px 16px;
}

.bb-am-dl dt {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--bb-text-3);
}

.bb-am-dl dd {
  margin: 0;
  font-size: 14px;
  color: var(--bb-text-2);
  font-weight: 500;
}

.bb-am-dl div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: baseline;
}

.bb-am-kpi-ok {
  color: var(--bb-success-text);
  font-weight: 700;
}

.bb-am-kpi-warn {
  color: var(--bb-danger-text);
  font-weight: 700;
}

.bb-am-muted {
  margin: 0;
  font-size: 13px;
  color: var(--bb-text-3);
}

.bb-am-alerts {
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  padding: 20px 22px;
}

.bb-am-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.bb-am-table-wrap {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  overflow: hidden;
}

.bb-am-create-header {
  padding: 24px 32px 0;
}

.bb-am-create-title {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--bb-text);
}

.bb-am-create-card {
  margin: 20px 32px 40px;
}

.bb-am-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bb-am-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.bb-am-form-section-title {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--bb-text);
}

.bb-am-req {
  color: var(--bb-danger-text);
}

.bb-am-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--bb-text-3);
}

.bb-am-form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* Platform accounts: nav + settings sidebar + org list + detail — bounded flex shell */
.bb-page-shell.bb-page-am {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.bb-page-shell.bb-page-am > .bb-hero-header {
  flex-shrink: 0;
}

.bb-page-shell.bb-page-am > .bb-settings-layout {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
}

.bb-page-shell.bb-page-am .bb-settings-sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  align-self: stretch;
}

.bb-page-shell.bb-page-am .bb-settings-main.bb-settings-main--platform-tool {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: none;
}

.bb-page-shell.bb-page-am .bb-am-layout {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.bb-page-shell.bb-page-am .bb-client-list-panel {
  width: 400px;
  min-width: 360px;
  max-width: min(640px, 55vw);
}

@media (max-width: 900px) {
  .bb-page-shell.bb-page-am {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .bb-page-shell.bb-page-am > .bb-settings-layout {
    flex: none;
    overflow: visible;
  }

  .bb-page-shell.bb-page-am .bb-settings-main.bb-settings-main--platform-tool {
    overflow: visible;
  }

  .bb-page-shell.bb-page-am .bb-am-layout {
    flex: none;
    height: auto;
    min-height: 0;
  }

  .bb-page-shell.bb-page-am .bb-client-list-panel {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .bb-client-list-resize-handle {
    display: none;
  }

  .bb-am-layout {
    flex-direction: column;
    min-height: auto;
  }
  .bb-client-list-panel {
    width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--bb-line);
  }
}

/* Operational dashboard (prototype-aligned: hero + stats strip + quick links) */
.bb-op-page {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bb-op-hero-card {
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  background: var(--bb-surface);
  box-shadow: var(--bb-shadow-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.bb-op-hero-top {
  padding: 1.5rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--bb-line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bb-blue) 6%, transparent) 0%, var(--bb-surface) 55%);
}

.bb-op-page-title {
  margin: 0.15rem 0 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--bb-blue);
  line-height: 1.2;
}

.bb-op-hero-lead {
  margin-top: 0.65rem;
  max-width: 58rem;
  line-height: 1.55;
  font-size: 0.9rem;
}

.bb-op-stats-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}

.bb-op-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  padding: 1.35rem 1.5rem 1.25rem;
  min-height: 5.5rem;
  justify-content: center;
}

.bb-op-stat + .bb-op-stat {
  border-left: 1px solid var(--bb-line);
}

.bb-op-stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--bb-blue);
  line-height: 1;
}

.bb-op-stat-value--accent {
  font-size: 1.85rem;
}

.bb-op-stat-label {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-op-stat-hint {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--bb-muted);
  font-weight: 500;
}

@media (max-width: 768px) {
  .bb-op-stats-bar {
    grid-template-columns: 1fr;
  }
  .bb-op-stat + .bb-op-stat {
    border-left: none;
    border-top: 1px solid var(--bb-line);
  }
  .bb-op-stat {
    align-items: flex-start;
    text-align: left;
  }
}

.bb-op-quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bb-op-quick-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1.15rem 1.25rem;
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  box-shadow: var(--bb-shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bb-op-quick-link:hover {
  border-color: color-mix(in srgb, var(--bb-blue) 28%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bb-blue) 8%, transparent);
}

.bb-op-quick-link-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  color: var(--bb-blue);
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.bb-op-quick-link-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bb-text);
}

.bb-op-quick-link-desc {
  font-size: 0.78rem;
  color: var(--bb-muted);
  line-height: 1.35;
}

.bb-op-component-wrap {
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  background: var(--bb-surface);
  box-shadow: var(--bb-shadow-md);
  padding: 1.35rem 1.35rem 1.5rem;
}

.bb-op-component-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--bb-line);
}

.bb-op-section-title-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.bb-op-section-icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--bb-accent) 10%, white) 0%, color-mix(in srgb, var(--bb-accent) 20%, white) 100%);
  color: var(--bb-blue);
  font-size: 1.15rem;
}

.bb-op-mqtt-panel {
  border-radius: var(--bb-r);
  box-shadow: var(--bb-shadow-sm);
}

.bb-op-mqtt-panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-op-placeholder-card {
  border-left: 4px solid #94a3b8;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bb-surface) 100%);
}

.bb-op-more-card .bb-op-more-inner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.bb-op-more-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #64748b;
  font-size: 1.1rem;
}

/* Legacy hero class (older templates) */
.bb-op-dashboard-hero {
  border-left: 4px solid var(--bb-accent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--bb-accent) 6%, transparent) 0%, var(--bb-surface) 48%);
}

/* Pills: connection + feature flags */
.bb-op-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--bb-line);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bb-op-pill--state {
  text-transform: none;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0;
}

.bb-op-pill--connected {
  background: #ecfdf5;
  color: #047857;
  border-color: #6ee7b7;
}

.bb-op-pill--error {
  background: var(--bb-danger-bg);
  color: var(--bb-danger-text);
  border-color: var(--bb-danger-border);
}

.bb-op-pill--disconnected {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.bb-op-pill--connecting {
  background: var(--bb-warn-bg);
  color: var(--bb-warn-text);
  border-color: var(--bb-warn-border);
}

.bb-op-pill--disabled {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
}

.bb-op-pill--feature-on {
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  color: var(--bb-accent);
  border-color: color-mix(in srgb, var(--bb-accent) 40%, white);
}

.bb-op-pill--feature-off {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.bb-op-pill--trace-on {
  background: var(--bb-warn-bg);
  color: var(--bb-warn-text);
  border-color: var(--bb-warn-border);
}

.bb-op-pill--anon {
  background: #faf5ff;
  color: #7e22ce;
  border-color: #d8b4fe;
  text-transform: none;
  font-weight: 600;
  font-size: 0.8125rem;
}

.bb-op-error-text {
  color: var(--bb-danger-text);
  font-weight: 600;
}

/* Event type chips */
.bb-op-event {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.bb-op-event--ok {
  background: #d1fae5;
  color: var(--bb-success-text);
}

.bb-op-event--danger {
  background: var(--bb-danger-bg);
  color: var(--bb-danger-text);
}

.bb-op-event--warn {
  background: var(--bb-warn-bg);
  color: var(--bb-warn-text);
}

.bb-op-event--info {
  background: color-mix(in srgb, var(--bb-accent) 20%, white);
  color: var(--bb-accent);
}

.bb-op-event--muted {
  background: #f1f5f9;
  color: #64748b;
}

/* MQTT trace mode (operational dashboard) */
.bb-mqtt-trace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.bb-mqtt-trace-btn {
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
}

.bb-mqtt-trace-feedback {
  margin-top: 8px;
  font-size: 0.875rem;
}

.bb-mqtt-trace-hint {
  font-size: 0.8rem;
  margin-top: 8px;
  margin-bottom: 0;
  color: var(--bb-text-2);
}

.bb-mqtt-trace-hint-inline {
  font-size: 0.8rem;
  font-weight: 400;
}

/* MQTT operational debug */
.bb-code-inline {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bb-input-readonly-bg);
  color: var(--bb-text-2);
  font-family: ui-monospace, monospace;
}

.bb-mqtt-debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.bb-mqtt-debug-span-2 {
  grid-column: span 2;
}

@media (max-width: 900px) {
  .bb-mqtt-debug-grid {
    grid-template-columns: 1fr;
  }
  .bb-mqtt-debug-span-2 {
    grid-column: span 1;
  }
}

.bb-mqtt-debug-dl {
  display: grid;
  grid-template-columns: minmax(0, 140px) 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 0.875rem;
}

.bb-mqtt-debug-dl dt {
  margin: 0;
  color: var(--bb-text-3);
  font-weight: 600;
}

.bb-mqtt-debug-dl dd {
  margin: 0;
  color: var(--bb-text);
  word-break: break-word;
}

.bb-mqtt-intensity-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bb-line);
  overflow: hidden;
  min-width: 80px;
}

.bb-mqtt-intensity-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bb-accent), #38bdf8);
  min-width: 0;
  transition: width 0.2s ease;
}

.bb-mqtt-debug-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.bb-mqtt-debug-nowrap {
  white-space: nowrap;
}

.bb-mqtt-debug-col-intensity {
  width: 35%;
  min-width: 120px;
}

.bb-mqtt-debug-col-count {
  width: 4.5rem;
  text-align: right;
}

.bb-mqtt-topic-full {
  display: block;
  font-size: 0.75rem;
  margin-top: 2px;
}

.bb-mqtt-debug-topic-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bb-mqtt-debug-payload {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
}

.bb-mqtt-msg-table-hint {
  font-size: 0.8rem;
  color: var(--bb-text-2);
  margin: 0 0 10px;
}

.bb-mqtt-msg-row--clickable {
  cursor: pointer;
}

.bb-mqtt-msg-row--clickable:hover {
  background: var(--bb-input-readonly-bg);
}

.bb-mqtt-msg-row--clickable:focus-visible {
  outline: 2px solid var(--bb-accent);
  outline-offset: -2px;
}

.bb-mqtt-message-detail-host {
  margin-top: 16px;
  min-height: 0;
}

.bb-mqtt-msg-detail {
  margin-top: 4px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--bb-border, #e2e8f0);
  background: #fafbfc;
}

.bb-mqtt-msg-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bb-mqtt-msg-detail-close {
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
}

.bb-mqtt-msg-detail-meta {
  margin-bottom: 0;
}

.bb-json-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.45;
  background: var(--bb-input-readonly-bg);
  color: var(--bb-text);
  padding: 14px 16px;
  border-radius: 8px;
  max-height: min(55vh, 480px);
  overflow: auto;
  border: 1px solid var(--bb-border, #e2e8f0);
}

@media (max-width: 900px) {
  .bb-settings-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 108px);
    overflow: visible;
  }
  .bb-settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--bb-line);
    padding: 12px 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }
  .bb-sidebar-section-lbl,
  .bb-sidebar-group-lbl {
    display: none;
  }
  .bb-sidebar-item {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 8px 14px;
  }
  .bb-sidebar-item.active {
    border-left: none;
    border-bottom-color: var(--bb-blue);
  }
  .bb-sidebar-item.bb-sidebar-subitem {
    padding-left: 14px;
  }
  .bb-settings-main {
    padding: 20px 16px 60px;
  }
}

/* ── Relational DB browser (dev-tool density) ─────────────────── */
.bb-rdb-browser .bb-rdb-layout {
  align-items: flex-start;
}

.bb-rdb-browser .bb-rdb-side-card {
  min-width: 220px;
  max-width: 280px;
  flex-shrink: 0;
  padding: 0.75rem 0.875rem;
}

.bb-rdb-browser .bb-rdb-side-card .bb-card-title {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bb-text-3);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.bb-rdb-browser .bb-rdb-table-card {
  padding: 0.875rem 1rem 1rem;
  margin-bottom: 1rem;
}

.bb-rdb-browser .bb-rdb-sql-card {
  padding: 0.875rem 1rem 1rem;
}

.bb-rdb-browser .bb-rdb-filter {
  width: 100%;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.bb-rdb-browser .bb-rdb-table-list {
  max-height: min(65vh, 520px);
  overflow-y: auto;
}

.bb-rdb-browser .bb-db-table-item {
  padding: 4px 8px;
  margin-bottom: 1px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}

.bb-rdb-browser .bb-db-table-item .bb-badge {
  font-size: 0.6rem;
  min-width: 22px;
  text-align: center;
}

.bb-rdb-browser .bb-db-table-item .bb-db-table-name {
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}

.bb-rdb-browser .bb-db-selected {
  background: color-mix(in srgb, var(--bb-accent) 10%, white) !important;
  border-left: 3px solid var(--bb-accent);
}

.bb-rdb-browser #sql-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  tab-size: 2;
}

.bb-rdb-browser .bb-sql-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bb-surface, #fff);
  border: 1px solid var(--bb-border, #e5e7eb);
  border-radius: 6px;
  box-shadow: var(--bb-shadow-md);
  z-index: 50;
  margin-bottom: 4px;
}

.bb-rdb-browser .bb-sql-item {
  padding: 6px 12px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bb-rdb-browser .bb-sql-item:hover,
.bb-rdb-browser .bb-sql-item.selected {
  background: var(--bb-surface-2);
}

.bb-rdb-browser .bb-sql-type {
  font-size: 0.65rem;
  color: var(--bb-text-3, #9ca3af);
  text-transform: uppercase;
}

.bb-rdb-browser .bb-rdb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bb-line);
}

.bb-rdb-browser .bb-rdb-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.bb-rdb-browser .bb-rdb-toolbar-lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bb-text-3);
  font-weight: 600;
  margin-right: 0.15rem;
}

.bb-rdb-browser .bb-rdb-toolbar .bb-btn-table.bb-rdb-toolbar-active {
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  border-color: var(--bb-accent);
  color: var(--bb-accent);
}

.bb-rdb-browser .bb-rdb-table-scroll {
  max-height: min(70vh, 900px);
  overflow: auto;
  border: 1px solid var(--bb-line);
  border-radius: 0.5rem;
}

.bb-rdb-browser .bb-rdb-table-scroll .bb-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.bb-rdb-browser .bb-table-compact th,
.bb-rdb-browser .bb-table-compact td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  padding: 0.28rem 0.45rem;
  line-height: 1.35;
  vertical-align: top;
}

.bb-rdb-browser .bb-table-compact thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
  color: var(--bb-text-2);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--bb-line);
  box-shadow: 0 1px 0 var(--bb-line);
}

.bb-rdb-browser .bb-table-compact tbody td {
  border-bottom: 1px solid var(--bb-line);
}

.bb-rdb-browser .bb-table-compact tbody tr:hover td {
  background: #f8fafc;
}

.bb-rdb-browser .bb-table-compact td.bb-rdb-rownum {
  color: var(--bb-text-3);
  max-width: 2.75rem;
  width: 2.75rem;
  text-align: right;
  user-select: none;
}

.bb-rdb-browser .bb-table-compact td.bb-rdb-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(24rem, 38vw);
  cursor: copy;
}

.bb-rdb-browser .bb-table-compact td.bb-rdb-cell:active {
  background: #e0f2fe;
}

/* ── Shared utility classes (extracted from inline styles) ── */

.bb-text-xs   { font-size: 0.75rem; }
.bb-text-sm   { font-size: 0.8rem; }
.bb-text-muted    { color: var(--bb-text-3); }
.bb-text-muted-sm { font-size: 0.8rem; color: var(--bb-text-3); }
.bb-text-muted-xs { font-size: 0.7rem; color: var(--bb-text-3); }
.bb-text-nowrap   { white-space: nowrap; }
.bb-text-error    { color: var(--bb-danger-text); }

.bb-code-inline-xs { font-size: 0.7rem; }
.bb-code-inline-sm { font-size: 0.75rem; }
.bb-code-truncate {
  font-size: 0.7rem; max-width: 300px; overflow: hidden;
  text-overflow: ellipsis; display: inline-block; white-space: nowrap;
}
.bb-code-truncate-sm { max-width: 150px; }
.bb-code-block-pre {
  background: var(--bb-bg, #f9fafb); padding: 0.75rem; border-radius: 0.375rem;
  overflow-x: auto; font-size: 0.75rem; margin-top: 0.5rem;
}

/* ── Form utilities ── */

.bb-form-title {
  font-size: 14px; font-weight: 700; color: var(--bb-text); margin-bottom: 16px;
}
.bb-form-grid-1col {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
.bb-form-grid-2col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px;
}
.bb-form-error-text {
  color: var(--bb-danger-text); font-size: 0.8rem; margin-top: 4px;
}
.bb-label-xs { font-size: 0.65rem; margin-bottom: 0.25rem; }
.bb-badge-xs { font-size: 0.65rem; }

/* ── Table utilities ── */

.bb-table-scrollable { max-height: 500px; overflow: auto; }
.bb-table-sm, .bb-table-sm td, .bb-table-sm th { font-size: 0.8rem; }
.bb-td-truncate {
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bb-th-nowrap { white-space: nowrap; }
.bb-sortable-header {
  cursor: pointer; text-decoration: none; color: inherit;
  display: inline-flex; align-items: center; gap: 3px;
}
.bb-sort-icon          { font-size: 0.55rem; }
.bb-sort-icon-inactive { font-size: 0.55rem; opacity: 0.3; }

/* ── Card variants ── */

.bb-card-bordered-primary {
  border: 1px solid var(--bb-accent); border-radius: 0.5rem; padding: 1rem;
}

/* ── Chart ── */

.bb-chart-wrap { height: 250px; position: relative; }

/* ── Pipeline diagram ── */

.bb-pipeline-step-sub-sm { font-size: 0.65rem; margin-top: 2px; }
.bb-pipeline-step-sub-disabled { font-size: 0.65rem; margin-top: 2px; color: var(--bb-muted, #666); }

/* ── Summary/Details ── */

.bb-summary-toggle { cursor: pointer; color: var(--bb-text-3); font-size: 0.8rem; }

/* ── ETL tabs (moved from inline <style> in platform-etl.html) ── */

.bb-tab-bar {
  display: flex; gap: 0; border-bottom: 2px solid var(--bb-line, #e5e7eb);
}
.bb-tab {
  padding: 0.5rem 1rem; border: none; background: none; cursor: pointer;
  font-size: 0.875rem; font-weight: 500; color: var(--bb-text-3, #6b7280);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s; font-family: inherit;
}
.bb-tab:hover { color: var(--bb-text, #111827); }
.bb-tab.active { color: var(--bb-accent); border-bottom-color: var(--bb-accent); }
.bb-tab-panel { display: none; }
.bb-tab-panel.active { display: block; }

/* ── ETL pipeline flow: light “energy overview” style (nodes + curved connectors) ── */

.bb-pipeline-flow--light {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.2rem;
  padding: 1.25rem 1rem 1.35rem;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background-color: #eef1f7;
  background-image: radial-gradient(circle, #b8c2d1 1px, transparent 1px);
  background-size: 16px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.bb-pipeline-step--light {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
  min-width: 118px;
  max-width: 160px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.bb-pipeline-step--light.bb-pipeline-step--mqtt {
  border-left: 4px solid #ea580c;
}
.bb-pipeline-step--light.bb-pipeline-step--parser {
  border-left: 4px solid var(--bb-success-text);
}
.bb-pipeline-step--light.bb-pipeline-step--resolver {
  border-left: 4px solid #7c3aed;
}
.bb-pipeline-step--light.bb-pipeline-step--tagger {
  border-left: 4px solid #0d9488;
}
.bb-pipeline-step--light.bb-pipeline-step--influx {
  border-left: 4px solid var(--bb-accent);
}

.bb-pipeline-step-inner {
  padding: 0.7rem 0.85rem 0.75rem;
  text-align: left;
}

.bb-pipeline-flow--light .bb-pipeline-step-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bb-blue);
  margin: 0 0 0.35rem;
  line-height: 1.2;
}

.bb-pipeline-flow--light .bb-pipeline-step-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
  line-height: 1.1;
}

.bb-pipeline-flow--light .bb-pipeline-step-sub {
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 0.2rem;
  line-height: 1.3;
}

.bb-pipeline-step-external {
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.75;
}

.bb-pipeline-step--light.has-errors {
  border-color: var(--bb-danger-border);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--bb-danger-text) 12%, transparent), 0 2px 6px color-mix(in srgb, var(--bb-danger-text) 8%, transparent);
}

.bb-pipeline-step--light.has-errors .bb-pipeline-step-sub {
  color: var(--bb-danger-text);
}

a.bb-pipeline-step-link.bb-pipeline-step--light {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.bb-pipeline-step-link.bb-pipeline-step--light:hover {
  border-color: color-mix(in srgb, var(--bb-accent) 30%, white);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--bb-accent) 12%, transparent);
}

.bb-pipeline-connector {
  position: relative;
  flex: 1 1 40px;
  min-width: 36px;
  max-width: 76px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bb-pipeline-connector__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #94a3b8;
  pointer-events: none;
}

.bb-pipeline-connector__path {
  stroke: currentColor;
}

.bb-pipeline-connector__path--sink {
  color: #3b82f6;
}

.bb-pipeline-connector__label {
  position: relative;
  z-index: 1;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #475569;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bb-pipeline-connector__label--sink {
  color: var(--bb-accent);
  border-color: color-mix(in srgb, var(--bb-accent) 30%, white);
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
}

/* Legacy class names (fragments / older markup) */
.bb-pipeline-flow:not(.bb-pipeline-flow--light) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.bb-pipeline-step:not(.bb-pipeline-step--light) {
  background: var(--bb-bg, #f9fafb);
  border: 1px solid var(--bb-line, #e5e7eb);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  text-align: center;
  min-width: 120px;
}
.bb-pipeline-step:not(.bb-pipeline-step--light) .bb-pipeline-step-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--bb-text-3, #6b7280);
  margin-bottom: 0.25rem;
}
.bb-pipeline-step:not(.bb-pipeline-step--light) .bb-pipeline-step-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--bb-text, #111827);
}
.bb-pipeline-step:not(.bb-pipeline-step--light) .bb-pipeline-step-sub {
  font-size: 0.7rem;
  color: var(--bb-text-3, #6b7280);
}
.bb-pipeline-arrow {
  color: var(--bb-text-3, #6b7280);
  font-size: 1.25rem;
}
.bb-pipeline-step:not(.bb-pipeline-step--light).has-errors .bb-pipeline-step-sub {
  color: var(--bb-danger-text);
}

/* ── SQL autocomplete ── */

.bb-sql-autocomplete {
  position: absolute; bottom: 100%; left: 0; right: 0; max-height: 250px; overflow-y: auto;
  background: white; border: 1px solid var(--bb-line, #e5e7eb); border-radius: 6px;
  box-shadow: var(--bb-shadow-md); z-index: 50; margin-bottom: 4px;
}
.bb-sql-item {
  padding: 6px 12px; cursor: pointer; font-family: 'SF Mono',Menlo,Monaco,monospace;
  font-size: 0.8rem; display: flex; justify-content: space-between; align-items: center;
}
.bb-sql-item:hover, .bb-sql-item.selected { background: var(--bb-bg, #f3f4f6); }
.bb-sql-type { font-size: 0.65rem; color: var(--bb-text-3, #9ca3af); text-transform: uppercase; }
.bb-sql-editor {
  font-family: 'SF Mono',Menlo,Monaco,Consolas,monospace; font-size: 0.85rem;
  line-height: 1.5; tab-size: 2; resize: vertical;
}

/* ── DB table selected highlight ── */

.bb-db-selected {
  background: color-mix(in srgb, var(--bb-accent) 10%, white) !important;
  border-left: 3px solid var(--bb-accent);
}

/* ── System tree view ── */

.bb-tree { padding: 0; }
.bb-tree details { margin-left: 1.25rem; }
.bb-tree summary {
  cursor: pointer; padding: 5px 0; font-size: 0.85rem; font-weight: 500;
  list-style: none; display: flex; align-items: center; gap: 2px;
}
.bb-tree summary::-webkit-details-marker { display: none; }
.bb-tree summary::before {
  content: '▸'; margin-right: 6px; font-size: 0.7rem; color: var(--bb-text-3);
  transition: transform 0.15s; display: inline-block; width: 10px;
}
.bb-tree details[open] > summary::before { transform: rotate(90deg); }
.bb-tree-leaf {
  margin-left: 1.25rem; padding: 3px 0; font-size: 0.8rem;
  display: flex; align-items: center; gap: 2px;
}
.bb-tree-icon { width: 20px; text-align: center; margin-right: 5px; font-size: 0.8rem; }
.bb-tree-badge { font-size: 0.6rem; margin-left: 6px; }
.bb-tree-muted { color: var(--bb-text-3); font-size: 0.75rem; font-weight: 400; }

/* Node type colors */
.bb-tree-icon--account  { color: var(--bb-blue); }
.bb-tree-icon--site     { color: var(--bb-danger-text); }
.bb-tree-icon--edge     { color: #7c3aed; }
.bb-tree-icon--assets   { color: #0d9488; }
.bb-tree-icon--asset    { color: var(--bb-warn-text); }
.bb-tree-icon--channels { color: var(--bb-accent); }
.bb-tree-icon--channel  { color: #6366f1; }
.bb-tree-icon--field-ok { color: var(--bb-success-text); }
.bb-tree-icon--field    { color: #d1d5db; }
.bb-tree-icon--topics   { color: #ea580c; }
.bb-tree-icon--topic    { color: #f97316; }

/* ── CLICKABLE TABLE ROWS ── */
.bb-row-clickable { cursor: pointer; transition: background 0.15s; }
.bb-row-clickable:hover { background: color-mix(in srgb, var(--bb-accent) 6%, white); }

/* ── DEAD LETTER DETAIL ── */
.bb-dl-detail {
  background: var(--bb-surface); border: 1px solid var(--bb-line);
  border-radius: var(--bb-r); padding: 24px; box-shadow: var(--bb-shadow-sm);
}
.bb-dl-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--bb-line);
}
.bb-dl-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
}
.bb-dl-detail-field { margin-bottom: 14px; }
.bb-dl-detail-lbl {
  display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--bb-text-3); margin-bottom: 4px;
}
.bb-dl-detail-val { font-size: 14px; color: var(--bb-text); }
.bb-dl-detail-code {
  display: block; font-size: 13px; font-family: 'SF Mono', monospace;
  background: var(--bb-bg); border: 1px solid var(--bb-line); border-radius: 8px;
  padding: 10px 14px; word-break: break-all; color: var(--bb-text);
}
.bb-dl-detail-pre {
  font-size: 13px; font-family: 'SF Mono', monospace;
  background: var(--bb-bg); border: 1px solid var(--bb-line); border-radius: 8px;
  padding: 14px; white-space: pre-wrap; word-break: break-all;
  color: var(--bb-text); margin: 0; max-height: 300px; overflow-y: auto;
}

/* ── FLOW MAP ── */
.bb-flow-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.bb-flow-stat {
  font-size: 12px; font-weight: 600; color: var(--bb-text-3);
  background: var(--bb-surface); border: 1px solid var(--bb-line);
  border-radius: 999px; padding: 4px 12px;
}
.bb-flow-stat-val { font-weight: 700; color: var(--bb-text); margin-right: 2px; }
.bb-flow-stat-warn { border-color: var(--bb-warn-border); background: var(--bb-warn-bg); color: var(--bb-warn-text); }
.bb-flow-stat-warn .bb-flow-stat-val { color: var(--bb-warn-text); }
.bb-flow-empty-state { padding: 40px 0; }

/* Status dots */
.bb-flow-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.bb-flow-dot-green { background: var(--bb-success-text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bb-success-text) 20%, transparent); }
.bb-flow-dot-orange { background: #ea580c; box-shadow: 0 0 0 2px rgba(234,88,12,0.2); }
.bb-flow-dot-gray { background: #9ca3af; }

/* Device group card */
.bb-flow-device-group {
  background: var(--bb-surface); border: 1px solid var(--bb-line);
  border-radius: var(--bb-r); box-shadow: var(--bb-shadow-sm);
  margin-bottom: 24px; overflow: hidden;
}
.bb-flow-dg-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; padding: 20px 24px;
  border-bottom: 1px solid var(--bb-line); background: #fafbfc;
}
.bb-flow-dg-info { min-width: 0; }
.bb-flow-dg-title {
  display: flex; align-items: center;
  font-size: 15px; font-weight: 700; color: var(--bb-text); margin-bottom: 4px;
}
.bb-flow-dg-sub {
  font-size: 11px; color: var(--bb-text-3); display: flex; align-items: center; gap: 8px;
}
.bb-flow-dg-hw {
  font-family: 'SF Mono', monospace; font-size: 10px; background: var(--bb-bg);
  border: 1px solid var(--bb-line); border-radius: 4px; padding: 1px 6px;
}
.bb-flow-dg-right {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.bb-flow-topic-pill {
  display: inline-flex; align-items: center; font-size: 10px; font-weight: 600;
  color: #6366f1; background: color-mix(in srgb, var(--bb-accent) 10%, white); border: 1px solid color-mix(in srgb, var(--bb-accent) 30%, white);
  border-radius: 999px; padding: 3px 10px;
}
.bb-flow-dg-status {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; color: var(--bb-text-3);
}

/* Pipeline rows */
.bb-flow-dg-body { padding: 16px 24px; }
.bb-flow-pipeline-row {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--bb-line);
}
.bb-flow-pipeline-row:last-child { border-bottom: none; }

/* Channel pill (left side) */
.bb-flow-channel-pill {
  flex: 0 0 160px; display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; background: var(--bb-bg); border: 1px solid var(--bb-line);
  border-radius: 8px;
}
.bb-flow-channel-pill-name {
  font-family: 'SF Mono', monospace; font-weight: 700; font-size: 12px;
  color: var(--bb-text);
}
.bb-flow-channel-pill-count {
  font-size: 9px; font-weight: 600; color: var(--bb-text-3);
}
.bb-flow-channel-pill-template {
  font-size: 10px; font-weight: 600; color: var(--bb-text-2); line-height: 1.2;
}

.bb-flow-channel-fields {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 8px 0;
  padding: 8px 10px;
  background: var(--bb-bg-subtle, #f8fafc);
  border: 1px solid var(--bb-line);
  border-radius: 8px;
}
.bb-flow-channel-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.bb-flow-channel-field-row--open {
  color: var(--bb-warn-text, #b45309);
}
.bb-flow-field-icon {
  font-size: 10px;
  color: var(--bb-success-text);
  width: 14px;
  text-align: center;
}
.bb-flow-field-icon--open {
  color: var(--bb-warn-text, #b45309);
}

.bb-flow-edge-binding {
  display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}
.bb-flow-edge-binding-serial {
  font-size: 10px; font-weight: 600; font-family: ui-monospace, monospace; color: var(--bb-text-2);
}
.bb-flow-link-hint-edge strong {
  font-weight: 600; color: var(--bb-text-1);
}

/* Connector line (middle) */
.bb-flow-connector-line {
  flex: 0 0 60px; height: 0;
  border-top: 2px dashed #d1d5db; margin: 0 8px; align-self: center;
}
.bb-flow-connector-line.mapped {
  border-top-style: solid; border-color: var(--bb-success-text);
}

/* Inline asset card (right side, when mapped) */
.bb-flow-asset-inline {
  flex: 1; min-width: 0;
  background: var(--bb-bg); border: 1px solid var(--bb-line);
  border-radius: 10px; padding: 10px 14px;
}
.bb-flow-asset-inline-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.bb-asset-icon-sm {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.bb-asset-icon-sm.green  { background: #f0fdf4; }
.bb-asset-icon-sm.orange { background: var(--bb-warn-bg); }
.bb-asset-icon-sm.blue   { background: color-mix(in srgb, var(--bb-accent) 10%, white); }
.bb-flow-asset-inline-name {
  font-size: 13px; font-weight: 700; color: var(--bb-text);
}
.bb-flow-asset-inline-type {
  font-size: 10px; color: var(--bb-text-3);
}
.bb-flow-asset-inline-footer {
  display: flex; align-items: center; justify-content: flex-end;
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--bb-line);
}

/* Inline readings */
.bb-flow-readings-inline {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 2px 16px; padding: 6px 8px; background: var(--bb-surface);
  border-radius: 6px; border: 1px solid var(--bb-line);
}
.bb-flow-reading {
  display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0;
}
.bb-flow-reading-field {
  font-size: 9px; font-family: 'SF Mono', monospace; color: var(--bb-text-3);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.bb-flow-reading-val {
  font-size: 13px; font-weight: 700; color: var(--bb-text); letter-spacing: -0.3px;
}

/* Inline link form (right side, when unmapped) */
.bb-flow-link-inline {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 8px 12px; background: var(--bb-warn-bg); border: 1px dashed var(--bb-warn-border);
  border-radius: 10px;
}
.bb-flow-link-inline-row {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.bb-flow-link-hint {
  margin: 0; font-size: 11px; color: var(--bb-text-3); line-height: 1.35;
}
.bb-flow-link-select {
  flex: 1; font-size: 11px; padding: 6px 8px; border: 1px solid var(--bb-line);
  border-radius: 6px; background: var(--bb-surface); color: var(--bb-text);
  font-family: inherit; cursor: pointer; min-width: 0;
}
.bb-flow-link-select:focus { outline: none; border-color: #818cf8; }
.bb-flow-link-btn {
  display: inline-flex; align-items: center;
  background: color-mix(in srgb, var(--bb-accent) 10%, white); border: 1px solid color-mix(in srgb, var(--bb-accent) 30%, white); border-radius: 6px;
  color: #4f46e5; cursor: pointer; padding: 6px 12px; font-size: 11px;
  font-weight: 600; transition: all 0.15s; flex-shrink: 0; font-family: inherit;
}
.bb-flow-link-btn:hover { background: color-mix(in srgb, var(--bb-accent) 30%, white); }
.bb-flow-unlink-btn {
  background: none; border: 1px solid var(--bb-line); border-radius: 6px;
  color: var(--bb-text-3); cursor: pointer; padding: 4px 10px; font-size: 11px;
  font-family: inherit; transition: all 0.15s; flex-shrink: 0;
}
.bb-flow-unlink-btn:hover { background: var(--bb-danger-bg); border-color: var(--bb-danger-border); color: var(--bb-danger-text); }

/* Classification progress */
.bb-flow-dg-footer {
  padding: 12px 24px; border-top: 1px solid var(--bb-line); background: #fafbfc;
}
.bb-flow-progress-wrap {
  display: flex; align-items: center; gap: 8px;
}
.bb-flow-progress-track {
  flex: 1; height: 4px; background: var(--bb-bg); border-radius: 999px; overflow: hidden;
}
.bb-flow-progress-fill {
  height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--bb-success-text) 60%, white), var(--bb-success-text)); border-radius: 999px;
  transition: width 0.3s;
}
.bb-flow-progress-text {
  font-size: 9px; font-weight: 600; color: var(--bb-text-3); white-space: nowrap;
}

/* Unmapped section */
.bb-flow-unmapped-section {
  margin-top: 32px; padding: 20px; background: var(--bb-warn-bg);
  border: 1px solid var(--bb-warn-border); border-radius: var(--bb-r);
}
.bb-flow-unmapped-header {
  display: flex; align-items: center; font-size: 14px; font-weight: 700;
  color: var(--bb-warn-text); margin-bottom: 16px;
}
.bb-flow-unmapped-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
/* Unmapped node cards */
.bb-flow-node {
  position: relative; display: flex; align-items: stretch;
  background: var(--bb-surface); border: 1px solid var(--bb-line);
  border-radius: 12px; box-shadow: var(--bb-shadow-sm);
  overflow: hidden; transition: box-shadow 0.2s, border-color 0.2s;
}
.bb-flow-node:hover { box-shadow: 0 4px 20px rgba(24,66,110,.08); border-color: color-mix(in srgb, var(--bb-accent) 30%, white); }
.bb-flow-node-accent { width: 4px; flex-shrink: 0; border-radius: 12px 0 0 12px; }
.bb-flow-node-body { flex: 1; padding: 12px 14px; min-width: 0; }
.bb-flow-node-title {
  display: flex; align-items: center;
  font-size: 13px; font-weight: 700; color: var(--bb-text); margin-bottom: 4px;
}
.bb-flow-node-sub { font-size: 11px; color: var(--bb-text-3); margin-bottom: 6px; }
.bb-flow-node-code {
  display: block; font-size: 10px; font-family: 'SF Mono', SFMono-Regular, monospace;
  color: var(--bb-text-2); background: var(--bb-bg); border-radius: 4px;
  padding: 3px 6px; margin-bottom: 6px; word-break: break-all; border: 1px solid var(--bb-line);
}
.bb-flow-node-meta {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; color: var(--bb-text-3);
}
.bb-flow-node-unmapped { border-color: var(--bb-warn-border); }
.bb-flow-node-unmapped:hover { border-color: var(--bb-warn-text); }

.bb-flow-unmapped-fields {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--bb-warn-border);
}
.bb-flow-unmapped-fields-title {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--bb-text-3); margin-bottom: 6px;
}
.bb-flow-unmapped-field-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  font-size: 10px; padding: 4px 0; border-bottom: 1px solid var(--bb-line);
}
.bb-flow-unmapped-field-row:last-child { border-bottom: none; }
.bb-flow-unmapped-ch {
  font-family: 'SF Mono', SFMono-Regular, monospace; font-size: 9px; color: var(--bb-text-2);
  overflow: hidden; text-overflow: ellipsis;
}
.bb-flow-unmapped-sep { color: var(--bb-text-3); }
.bb-flow-unmapped-fld { font-weight: 600; color: var(--bb-text); overflow: hidden; text-overflow: ellipsis; }
.bb-flow-unmapped-val { font-variant-numeric: tabular-nums; color: var(--bb-accent); font-weight: 600; }
.bb-flow-unmapped-hits { font-size: 9px; color: var(--bb-text-3); white-space: nowrap; }

/* Flow map responsive */
@media (max-width: 900px) {
  .bb-flow-pipeline-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .bb-flow-channel-pill { flex: none; }
  .bb-flow-connector-line { display: none; }
  .bb-flow-dg-header { padding: 16px; }
  .bb-flow-dg-body { padding: 12px 16px; }
}

/* ── DB entity diagram (flow-map–style, light nodes) ── */
.bb-erd-main-wide { max-width: min(1480px, 100%); width: 100%; }
.bb-erd-page-header { align-items: flex-start; }
.bb-erd-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.bb-erd-fit-btn {
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  padding: 0.4rem 0.75rem; border-radius: 8px; border: 1px solid var(--bb-line);
  background: var(--bb-surface); color: var(--bb-accent);
}
.bb-erd-fit-btn:hover { border-color: color-mix(in srgb, var(--bb-accent) 40%, white); background: #f8fafc; }
.bb-erd-hint {
  display: block; margin-top: 0.35rem; font-size: 0.72rem; color: var(--bb-text-3); font-weight: 500;
}
.bb-erd-hint-muted { font-weight: 400; color: var(--bb-muted); }
.bb-erd-canvas-section { margin-top: 0.5rem; margin-bottom: 1rem; }
.bb-erd-network {
  width: 100%; height: min(72vh, 720px); min-height: 420px;
  border: 1px solid var(--bb-line); border-radius: var(--bb-r);
  background: #fbfcfe;
}
.bb-erd-legend {
  font-size: 0.72rem; color: var(--bb-text-3); margin: 0.5rem 0 0; max-width: 52rem; line-height: 1.45;
}
.bb-erd-details { margin-top: 1.25rem; border: 1px solid var(--bb-line); border-radius: var(--bb-r); background: var(--bb-surface); padding: 0.35rem 0.85rem; }
.bb-erd-details-summary { cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--bb-text-2); padding: 0.35rem 0; }
.bb-erd-section-nested { margin-top: 0.75rem; }
.bb-erd-section-after-details { margin-top: 1rem; }
.bb-erd-lead { color: var(--bb-text-3); margin: 0; max-width: 36rem; }
.bb-erd-back-link {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.8rem; font-weight: 600; color: var(--bb-accent);
  text-decoration: none; white-space: nowrap;
  padding: 0.4rem 0.75rem; border-radius: 8px; border: 1px solid var(--bb-line);
  background: var(--bb-surface);
}
.bb-erd-back-link:hover { border-color: color-mix(in srgb, var(--bb-accent) 40%, white); background: #f8fafc; }
.bb-erd-browser-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; color: var(--bb-accent);
  text-decoration: none; white-space: nowrap;
  padding: 0.35rem 0.65rem; border-radius: 8px; border: 1px solid var(--bb-line);
  background: #fafbfc;
}
.bb-erd-browser-link:hover { border-color: color-mix(in srgb, var(--bb-accent) 40%, white); background: #f1f5f9; }
.bb-erd-section { margin-top: 1.75rem; }
.bb-erd-section-title {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--bb-text-3); margin: 0 0 0.65rem;
}
.bb-erd-lane {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem;
}
.bb-erd-lane-standalone { margin-top: 0.35rem; }
.bb-erd-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.bb-erd-node {
  display: inline-flex; align-items: center;
  background: #fafbfc;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--bb-text-2);
  box-shadow: none;
  line-height: 1.2;
}
.bb-erd-node-accent { border-color: #c4d4e8; background: #f4f8fc; color: var(--bb-text); }
.bb-erd-node-muted { border-color: #e2e8f0; background: #f9fafb; color: var(--bb-text-3); font-weight: 600; }
.bb-erd-node-inline { padding: 0.15rem 0.4rem; font-size: 0.65rem; margin-right: 0.25rem; }
.bb-erd-connector {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font-size: 0.62rem; color: var(--bb-text-3);
  padding: 0 0.1rem;
}
.bb-erd-connector-soft { font-style: italic; opacity: 0.9; }
.bb-erd-fk { font-weight: 600; color: var(--bb-muted); }
.bb-erd-arrow { font-weight: 400; color: #94a3b8; margin: 0 0.05rem; }
.bb-erd-note {
  font-size: 0.72rem; color: var(--bb-text-3); margin: 0.5rem 0 0; max-width: 42rem;
}
.bb-erd-note-spaced { margin-top: 0.35rem; margin-bottom: 0.65rem; }
.bb-erd-section-muted {
  margin-top: 2rem; padding: 1rem 1.1rem;
  background: var(--bb-bg); border: 1px solid var(--bb-line); border-radius: var(--bb-r);
}
.bb-erd-more-list {
  margin: 0; padding-left: 1.1rem; font-size: 0.78rem; color: var(--bb-text-2); line-height: 1.55;
}
.bb-erd-more-list li { margin-bottom: 0.35rem; }
.bb-erd-error-text { color: var(--bb-danger-text); }
.bb-erd-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}
.bb-erd-table-card {
  background: #fafbfc;
  border: 1px solid #d8dee6;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.35;
}
.bb-erd-table-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.35rem;
  flex-wrap: wrap; margin-bottom: 0.35rem;
}
.bb-erd-node-table { font-size: 0.65rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.bb-erd-row-badge {
  font-size: 0.58rem; font-weight: 600; color: var(--bb-text-3);
  background: #fff; border: 1px solid var(--bb-line); border-radius: 6px; padding: 0.1rem 0.35rem;
  white-space: nowrap;
}
.bb-erd-table-card-block { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid #e8ecf1; }
.bb-erd-table-card-lbl {
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--bb-text-3); margin-bottom: 0.2rem;
}
.bb-erd-fk-mini-list { margin: 0; padding-left: 1rem; color: var(--bb-text-2); }
.bb-erd-fk-mini-list li { margin-bottom: 0.15rem; }
.bb-erd-table-card-muted { font-size: 0.65rem; color: var(--bb-text-3); font-style: italic; margin-top: 0.25rem; }
.bb-erd-lane-fk { align-items: center; flex-wrap: wrap; gap: 0.3rem 0.45rem; }
.bb-erd-fk-code { font-size: 0.62rem !important; }
.bb-erd-constraint-name {
  font-size: 0.58rem; color: var(--bb-text-3); font-weight: 600;
  margin-left: 0.25rem; max-width: 100%; word-break: break-all;
}
@media (max-width: 900px) {
  .bb-erd-page-header { flex-direction: column; align-items: flex-start; }
  .bb-erd-back-link { margin-top: 0.35rem; }
}

/* ── ASSET CARDS ── */
.bb-section-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.9px;
  text-transform: uppercase; color: var(--bb-text-3); margin-bottom: 14px;
}
.bb-asset-row-gap { margin-bottom: 28px; }

.bb-asset-card {
  background: var(--bb-surface); border-radius: var(--bb-r);
  border: 1px solid var(--bb-line); box-shadow: var(--bb-shadow-sm);
  overflow: hidden; margin-bottom: 24px;
}
.bb-asset-card.bb-asset-attention {
  border-color: var(--bb-danger-border);
  box-shadow: 0 2px 16px color-mix(in srgb, var(--bb-danger-text) 10%, transparent);
}

/* Asset header */
.bb-asset-header {
  padding: 20px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--bb-line);
}
.bb-asset-header-left { display: flex; align-items: center; gap: 16px; }
.bb-asset-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.bb-asset-icon.blue   { background: color-mix(in srgb, var(--bb-accent) 10%, white); }
.bb-asset-icon.green  { background: #f0fdf4; }
.bb-asset-icon.orange { background: var(--bb-warn-bg); }
.bb-asset-name { font-size: 16px; font-weight: 700; color: var(--bb-text); margin-bottom: 2px; }
.bb-asset-type { font-size: 11px; font-weight: 600; color: var(--bb-text-3); text-transform: uppercase; letter-spacing: 0.5px; }

/* Status badge */
.bb-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 14px;
}
.bb-status-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.bb-status-badge.active {
  background: var(--bb-success-bg); color: var(--bb-success-text);
}
.bb-status-badge.active::before {
  background: var(--bb-success-text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bb-success-text) 20%, transparent);
}
.bb-status-badge.inactive {
  background: #f9fafb; color: var(--bb-text-3);
}
.bb-status-badge.inactive::before {
  background: var(--bb-text-3);
}
.bb-status-badge.maintenance {
  background: var(--bb-warn-bg); color: var(--bb-warn-text);
}
.bb-status-badge.maintenance::before {
  background: var(--bb-warn-text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bb-warn-text) 20%, transparent);
}

/* Attention banner */
.bb-asset-attention-banner {
  background: var(--bb-danger-bg); border-bottom: 1px solid var(--bb-danger-border);
  padding: 10px 28px;
  display: flex; align-items: center; gap: 10px;
}
.bb-asset-attention-icon { font-size: 16px; }
.bb-asset-attention-text { font-size: 12px; font-weight: 600; color: var(--bb-danger-text); }
.bb-asset-attention-sub  { font-size: 12px; color: var(--bb-danger-text); }

/* Properties grid */
.bb-asset-body { padding: 24px 28px; }
.bb-asset-props-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px 32px;
}
.bb-asset-prop { display: flex; flex-direction: column; gap: 3px; }
.bb-asset-prop-lbl {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--bb-text-3);
}
.bb-asset-prop-val {
  font-size: 18px; font-weight: 700; color: var(--bb-text); letter-spacing: -0.3px;
}
.bb-asset-prop-sub { font-size: 11px; color: var(--bb-text-3); }

/* Highlight colors */
.bb-highlight-green  { color: var(--bb-success-text); }
.bb-highlight-blue   { color: var(--bb-accent); }
.bb-highlight-orange { color: var(--bb-warn-text); }
.bb-highlight-red    { color: var(--bb-danger-text); }

/* SoC / buffer level bar */
.bb-asset-soc-wrap { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--bb-line); }
.bb-asset-soc-wrap--follow { margin-top: 16px; padding-top: 16px; }
.bb-asset-soc-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.bb-asset-soc-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--bb-text-3);
}
.bb-asset-soc-value { font-size: 14px; font-weight: 700; color: var(--bb-text); }
.bb-asset-soc-track { height: 10px; background: var(--bb-bg); border-radius: 999px; overflow: hidden; }
.bb-asset-soc-fill  { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bb-asset-soc-fill.blue   { background: linear-gradient(90deg, color-mix(in srgb, var(--bb-accent) 70%, white), var(--bb-accent)); }
.bb-asset-soc-fill.green  { background: linear-gradient(90deg, color-mix(in srgb, var(--bb-success-text) 60%, white), var(--bb-success-text)); }
.bb-asset-soc-fill.orange { background: linear-gradient(90deg, #fb923c, var(--bb-warn-text)); }
.bb-asset-soc-fill.teal   { background: linear-gradient(90deg, #2dd4bf, #0d9488); }

/* Telemetry summary row */
.bb-asset-telemetry-row {
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--bb-line);
  display: flex; gap: 0; flex-wrap: wrap;
}
.bb-asset-telemetry-item {
  flex: 1; min-width: 100px; display: flex; flex-direction: column; gap: 3px;
  padding: 0 20px 0 0;
}
.bb-asset-telemetry-item + .bb-asset-telemetry-item {
  padding-left: 20px; border-left: 1px solid var(--bb-line);
}
.bb-asset-telemetry-lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--bb-text-3);
}
.bb-asset-telemetry-val { font-size: 15px; font-weight: 700; color: var(--bb-text); }

/* ── Micro-bar: thin coloured fill indicator beneath property/telemetry values ── */
.bb-microbar {
  height: 3px;
  border-radius: 2px;
  background: var(--bb-bg);
  margin-top: 5px;
  overflow: hidden;
}
.bb-microbar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--bb-accent);
  transition: width 0.4s ease;
}
.bb-microbar--power  .bb-microbar-fill { background: var(--bb-accent); }
.bb-microbar--temp   .bb-microbar-fill { background: linear-gradient(90deg, #3b82f6 0%, #ea580c 100%); }
.bb-microbar--cop    .bb-microbar-fill { background: var(--bb-success-text); }
.bb-microbar--mv     .bb-microbar-fill,
.bb-microbar--volt   .bb-microbar-fill { background: #0d9488; }
.bb-microbar--amp    .bb-microbar-fill { background: #7c3aed; }
.bb-microbar--freq   .bb-microbar-fill { background: #ca8a04; }
.bb-microbar--percent .bb-microbar-fill { background: var(--bb-accent); }

/* Asset cards responsive */
@media (max-width: 900px) {
  .bb-asset-header { padding: 16px 20px; }
  .bb-asset-body { padding: 20px; }
  .bb-asset-props-grid { grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
  .bb-asset-attention-banner { padding: 10px 20px; }
}

/* ── Asset tiles — fixed-size bento grid with inline expand (platform view) ── */
.bb-assets-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, 172px);
  grid-auto-rows: min-content;
  gap: 12px;
  align-items: start;
  justify-content: start;
}
.bb-assets-tiles .bb-platform-assets-account-header {
  grid-column: 1 / -1;
  margin-top: 12px;
}
.bb-assets-tiles .bb-platform-assets-account-header:first-child { margin-top: 0; }

/* Compact tile — button because clicking expands */
.bb-asset-tile {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  height: 172px;
  padding: 14px 14px 12px;
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  box-shadow: var(--bb-shadow-sm);
  text-align: left;
  cursor: pointer;
  font: inherit; color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  overflow: hidden;
  min-width: 0;
}
.bb-asset-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(24,66,110,.08);
  border-color: #cbd5e1;
}
.bb-asset-tile:focus-visible {
  outline: 2px solid var(--bb-accent);
  outline-offset: 2px;
}
.bb-asset-tile--attention {
  border-color: var(--bb-danger-border);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--bb-danger-text) 10%, transparent);
}

.bb-asset-tile__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.bb-asset-tile__icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.bb-asset-tile__icon.blue   { background: color-mix(in srgb, var(--bb-accent) 10%, white); }
.bb-asset-tile__icon.green  { background: #f0fdf4; }
.bb-asset-tile__icon.orange { background: var(--bb-warn-bg); }

.bb-asset-tile__status {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; margin-top: 6px;
  background: var(--bb-text-3);
}
.bb-asset-tile__status.active      { background: var(--bb-success-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bb-success-text) 18%, transparent); }
.bb-asset-tile__status.maintenance { background: var(--bb-warn-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bb-warn-text) 18%, transparent); }
.bb-asset-tile__status.inactive    { background: var(--bb-text-3); }

.bb-asset-tile__name {
  font-size: 13px; font-weight: 600; color: var(--bb-text);
  line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.bb-asset-tile__type {
  font-size: 9.5px; font-weight: 700; color: var(--bb-text-3);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.bb-asset-tile__headline {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.bb-asset-tile__value {
  font-size: 20px; font-weight: 700; color: var(--bb-text);
  letter-spacing: -0.3px; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bb-asset-tile__label {
  font-size: 9.5px; font-weight: 700; color: var(--bb-text-3);
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bb-asset-tile__headline .bb-microbar { margin-top: 4px; }

/* Expanded tile — reuses .bb-asset-card rich layout inside a 2-column slot */
.bb-asset-tile--expanded {
  grid-column: span 2;
  margin-bottom: 0 !important;
}
.bb-asset-tile__close {
  background: transparent; border: 1px solid var(--bb-line);
  color: var(--bb-text-3); cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px;
  font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.bb-asset-tile__close:hover {
  color: var(--bb-text); background: var(--bb-bg);
}

@media (max-width: 600px) {
  .bb-assets-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .bb-asset-tile--expanded { grid-column: span 2; }
}

/* ── Asset compact card view — grid of vertical tiles (customer view) ── */
.bb-assets-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  align-items: stretch;
}
/* Hide category eyebrow labels — type is now shown on each card */
.bb-assets-compact .bb-section-eyebrow { display: none; }
.bb-assets-compact .bb-asset-row-gap,
.bb-assets-compact .bb-asset-card { margin-bottom: 0; }

/* Hide attention banner — keep telemetry: definition-driven assets (e.g. CHP) only render
   POWER_FLOW / counter metrics in the telemetry row, so hiding it left those cards blank. */
.bb-assets-compact .bb-asset-attention-banner { display: none; }

.bb-assets-compact .bb-asset-telemetry-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 10px;
  padding-top: 10px;
}
.bb-assets-compact .bb-asset-telemetry-item {
  flex: unset;
  min-width: 0;
  padding: 0;
}
.bb-assets-compact .bb-asset-telemetry-item + .bb-asset-telemetry-item {
  padding-left: 0;
  border-left: none;
}
.bb-assets-compact .bb-asset-telemetry-lbl { font-size: 9px; }
.bb-assets-compact .bb-asset-telemetry-val { font-size: 13px; }


/* Vertical card header */
.bb-assets-compact .bb-asset-header {
  padding: 14px 16px 12px;
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
}
.bb-assets-compact .bb-asset-header-left { gap: 10px; width: 100%; }
.bb-assets-compact .bb-asset-icon {
  width: 34px; height: 34px; border-radius: 9px; font-size: 17px; flex-shrink: 0;
}
.bb-assets-compact .bb-asset-name  { font-size: 13px; font-weight: 600; margin-bottom: 1px; }
.bb-assets-compact .bb-asset-type  { font-size: 10px; }
.bb-assets-compact .bb-status-badge { font-size: 11px; padding: 3px 10px; }

/* Compact body — show props + gauges, tightened up */
.bb-assets-compact .bb-asset-body { padding: 0 16px 14px; }

.bb-assets-compact .bb-asset-props-grid {
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.bb-assets-compact .bb-asset-prop-val { font-size: 15px; }

/* Gauge bar — keep it but tighten spacing */
.bb-assets-compact .bb-asset-soc-wrap {
  margin-top: 12px; padding-top: 12px;
}
.bb-assets-compact .bb-asset-soc-wrap--follow { margin-top: 10px; padding-top: 10px; }
.bb-assets-compact .bb-asset-soc-header { margin-bottom: 6px; }
.bb-assets-compact .bb-asset-soc-track { height: 8px; }
.bb-assets-compact .bb-asset-soc-value { font-size: 13px; }
.bb-assets-compact .bb-asset-soc-label { font-size: 9px; }

@media (max-width: 600px) {
  .bb-assets-compact { grid-template-columns: repeat(2, 1fr); }
}

/* ── Per-card expand / collapse ── */

/* Collapsed cards in a uniform grid */
#assets-host:not(.bb-assets-compact) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch; /* all cards same height per row */
}
#assets-host:not(.bb-assets-compact) .bb-section-eyebrow { display: none; }
#assets-host:not(.bb-assets-compact) .bb-asset-row-gap { margin-bottom: 0; }

/* Collapsed card: flex column so metric pushes to bottom */
#assets-host:not(.bb-assets-compact) .bb-asset-card:not(.bb-expanded) {
  display: flex;
  flex-direction: column;
}
#assets-host:not(.bb-assets-compact) .bb-asset-card:not(.bb-expanded) .bb-asset-compact-metric {
  margin-top: auto; /* push metric to bottom for vertical alignment */
}

/* Expanded card spans the full row */
#assets-host:not(.bb-assets-compact) .bb-asset-card.bb-expanded {
  grid-column: 1 / -1;
}

.bb-asset-header--clickable { cursor: pointer; }
.bb-asset-header--clickable:hover { background: var(--bb-bg); border-radius: 8px; }
.bb-asset-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.bb-asset-close-btn {
  display: none; /* hidden when collapsed */
  align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--bb-line); background: var(--bb-bg);
  font-size: 16px; line-height: 1; color: var(--bb-text-3);
  cursor: pointer; flex-shrink: 0;
}
.bb-asset-close-btn:hover { background: #f3f4f6; color: var(--bb-text); }
.bb-asset-card.bb-expanded .bb-asset-close-btn { display: flex; }

/* Compact metric: shown when collapsed, hidden when expanded */
.bb-asset-compact-metric {
  padding: 8px 28px 16px;
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--bb-line);
}
.bb-asset-compact-metric:empty { border-top: none; }
.bb-asset-compact-metric .bb-asset-prop-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bb-text-3); }
.bb-asset-compact-metric .bb-asset-prop-val { font-size: 22px; font-weight: 700; color: var(--bb-text); }
.bb-asset-card.bb-expanded .bb-asset-compact-metric { display: none; }

/* Expandable body: hidden by default, revealed on expand */
.bb-asset-expandable {
  overflow: hidden; max-height: 0; opacity: 0;
  transition: max-height 0.3s cubic-bezier(.4,0,.2,1), opacity 0.25s ease;
}
.bb-asset-card.bb-expanded .bb-asset-expandable {
  max-height: 800px; opacity: 1;
}

/* Compact grid mode overrides */
.bb-assets-compact .bb-asset-compact-metric { padding: 4px 16px 10px; }
.bb-assets-compact .bb-asset-compact-metric .bb-asset-prop-val { font-size: 17px; }
.bb-assets-compact .bb-asset-card:not(.bb-expanded) { display: flex; flex-direction: column; }
.bb-assets-compact .bb-asset-card:not(.bb-expanded) .bb-asset-compact-metric { margin-top: auto; }
.bb-assets-compact .bb-asset-card.bb-expanded { grid-column: 1 / -1; }

/* ── View toggle button group ── */
.bb-view-toggle {
  display: inline-flex; gap: 2px;
  background: var(--bb-bg); border: 1px solid var(--bb-line);
  border-radius: 8px; padding: 2px;
}
.bb-view-toggle-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 5px 11px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--bb-text-3);
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.bb-view-toggle-btn.bb-active,
.bb-view-toggle-btn:hover {
  background: var(--bb-surface); color: var(--bb-text);
  box-shadow: var(--bb-shadow-sm);
}

/* ── Asset Definition Map (platform-asset-definitions) ── */

.bb-asdef-layout {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 16px;
  align-items: start;
}

.bb-asdef-panel {
  background: var(--bb-surface);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r);
  overflow: hidden;
}

.bb-asdef-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bb-line);
  background: #f8f9fb;
}

.bb-asdef-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--bb-text-3);
  margin: 0;
}

.bb-asdef-panel-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Definition card */
.bb-asdef-card {
  border: 2px solid var(--bb-line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}

.bb-asdef-card:hover {
  border-color: var(--bb-accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--bb-accent) 12%, transparent);
}

.bb-asdef-card.selected {
  border-color: var(--bb-accent);
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
}

.bb-asdef-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--bb-text);
  margin: 0 0 2px 0;
}

.bb-asdef-card-sub {
  font-size: 11px;
  color: var(--bb-text-3);
  margin: 0;
}

.bb-asdef-card-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Asset type color chips */
.bb-asdef-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}

.bb-asdef-type-BATTERY    { background: var(--bb-warn-bg); color: var(--bb-warn-text); }
.bb-asdef-type-HEATPUMP   { background: var(--bb-danger-bg); color: var(--bb-danger-text); }
.bb-asdef-type-POWER_METER{ background: color-mix(in srgb, var(--bb-accent) 20%, white); color: var(--bb-accent); }
.bb-asdef-type-INVERTER   { background: #dcfce7; color: var(--bb-success-text); }
.bb-asdef-type-CHARGER    { background: #d1fae5; color: var(--bb-success-text); }
.bb-asdef-type-OTHER      { background: #f3e8ff; color: #5b21b6; }

.bb-asdef-controllable {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  color: var(--bb-accent);
  border: 1px solid color-mix(in srgb, var(--bb-accent) 30%, white);
}

/* Field list (middle panel) */
.bb-asdef-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.bb-asdef-field-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bb-text-3);
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--bb-line);
}

.bb-asdef-field-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.bb-asdef-field-table tr:last-child td { border-bottom: none; }

.bb-asdef-arrow {
  color: var(--bb-accent);
  font-weight: 700;
  font-size: 14px;
}

.bb-asdef-tag-pill {
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1f5f9;
  color: var(--bb-text-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.bb-asdef-tag-pill.active {
  background: var(--bb-accent);
  color: #fff;
}

.bb-asdef-writable-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bb-warn-bg);
  color: var(--bb-warn-text);
  margin-left: 4px;
}
.bb-asdef-write-only-badge {
  background: var(--bb-danger-bg);
  color: var(--bb-danger-text);
}

/* Tag category groups (right panel) */
.bb-asdef-cat-group {
  margin-bottom: 14px;
}

.bb-asdef-cat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--bb-text-3);
  margin: 0 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bb-line);
}

.bb-asdef-cat-label-battery    { color: var(--bb-warn-text); }
.bb-asdef-cat-label-grid       { color: var(--bb-accent); }
.bb-asdef-cat-label-solar      { color: var(--bb-success-text); }
.bb-asdef-cat-label-heat       { color: var(--bb-danger-text); }
.bb-asdef-cat-label-ev         { color: var(--bb-success-text); }
.bb-asdef-cat-label-chp        { color: #5b21b6; }
.bb-asdef-cat-label-site       { color: #374151; }

.bb-asdef-tag-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bb-asdef-tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.bb-asdef-tag-row.active {
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
}

.bb-asdef-tag-name {
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: var(--bb-text-2);
  flex: 1;
}

.bb-asdef-tag-row.active .bb-asdef-tag-name {
  color: var(--bb-accent);
}

.bb-asdef-tag-unit {
  font-size: 10px;
  color: var(--bb-text-3);
  min-width: 28px;
  text-align: right;
}

.bb-asdef-widget-chip {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 5px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--bb-text-3);
  white-space: nowrap;
}

.bb-asdef-tag-row.active .bb-asdef-widget-chip {
  background: color-mix(in srgb, var(--bb-accent) 20%, white);
  color: var(--bb-accent);
}

.bb-asdef-empty {
  font-size: 12px;
  color: var(--bb-text-3);
  text-align: center;
  padding: 20px 0;
}

/* Add Field Mapping form inside field-list panel */
.bb-asdef-add-field-wrap {
  border-top: 1px solid var(--bb-line);
  padding-top: 10px;
  margin-top: 4px;
}

.bb-asdef-add-field-summary {
  font-size: 11px;
  font-weight: 600;
  color: var(--bb-accent);
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 4px 0;
}

.bb-asdef-add-field-summary::-webkit-details-marker { display: none; }

.bb-asdef-add-field-form {
  border-top: 1px solid var(--bb-line);
  padding-top: 12px;
}

.bb-asdef-add-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.bb-input-sm,
.bb-select-sm {
  font-size: 12px;
  padding: 5px 8px;
  height: auto;
}

/* Badge muted and success variants */
.bb-badge-muted {
  background: #f1f5f9;
  color: var(--bb-text-3);
}

.bb-badge-success {
  background: #dcfce7;
  color: var(--bb-success-text);
}

@media (max-width: 1100px) {
  .bb-asdef-layout {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   DEMAND & PRICE PAGE COMPONENTS
   Ported from bb1os_demo/bb1os_data_prototype/demand-price.html
   ═══════════════════════════════════════════════════════════ */

/* ── Page tab bar ──────────────────────────────────────────── */
.bb-page-tabs-bar {
  background: var(--bb-surface);
  border-bottom: 1px solid var(--bb-line);
}

.bb-page-tabs-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
}

.bb-page-tab {
  padding: 14px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--bb-text-3);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.bb-page-tab:hover { color: var(--bb-text); }
.bb-page-tab.active { color: var(--bb-blue); border-bottom-color: var(--bb-blue); }

.bb-tab-panel { display: none; }
.bb-tab-panel.active { display: block; }

/* ── KPI metrics bar ───────────────────────────────────────── */
.bb-metrics-bar {
  display: grid;
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-md);
}

.bb-metric {
  padding: 22px 28px;
}

.bb-metric + .bb-metric {
  border-left: 1px solid var(--bb-line);
}

.bb-metric-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
  margin-bottom: 6px;
}

.bb-metric-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--bb-blue);
  line-height: 1;
}

.bb-metric-val.green  { color: var(--bb-success-text); }
.bb-metric-val.orange { color: var(--bb-warn-text); }
.bb-metric-val.red    { color: var(--bb-danger-text); }

.bb-metric-sub {
  font-size: 11px;
  color: var(--bb-text-3);
  margin-top: 4px;
  font-weight: 500;
}

/* ── Chart card ────────────────────────────────────────────── */
.bb-chart-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  overflow: hidden;
}

/* ── Time range selector ───────────────────────────────────── */
.bb-time-btn {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--bb-line);
  background: var(--bb-bg);
  color: var(--bb-text-2);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 12px;
  transition: all 0.15s;
}

.bb-time-btn.active {
  background: var(--bb-text);
  color: #fff;
  border-color: var(--bb-text);
}

.bb-time-btn:not(.active):hover {
  border-color: var(--bb-text-3);
}

/* ── Price table ───────────────────────────────────────────── */
.bb-price-table-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  overflow: hidden;
}

.bb-price-table-head {
  display: grid;
  grid-template-columns: 80px 1fr 80px 80px 80px;
  padding: 12px 20px;
  background: var(--bb-bg);
  border-bottom: 1px solid var(--bb-line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-price-table-row {
  display: grid;
  grid-template-columns: 80px 1fr 80px 80px 80px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--bb-line);
  font-size: 13px;
  align-items: center;
  transition: background 0.1s;
}

.bb-price-table-row:last-child { border-bottom: none; }
.bb-price-table-row:hover { background: var(--bb-bg); }
.bb-price-table-row.current { background: color-mix(in srgb, var(--bb-blue) 8%, white); }
.bb-price-table-row.past { color: var(--bb-text-3); }

.bb-price-bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bb-price-bar-bg {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.bb-price-bar-fill {
  height: 100%;
  border-radius: 3px;
}

/* ── Price signal pills ────────────────────────────────────── */
.bb-price-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.bb-price-pill.cheap { background: var(--bb-success-bg);  color: var(--bb-success-text); }
.bb-price-pill.mid   { background: color-mix(in srgb, var(--bb-warn-border) 25%, transparent);  color: var(--bb-warn-text); }
.bb-price-pill.peak  { background: color-mix(in srgb, var(--bb-danger-text) 12%, transparent);  color: var(--bb-danger-text); }
.bb-price-pill.now   { background: var(--bb-blue);        color: #fff;    }

/* ── Price scenario card ───────────────────────────────────── */
.bb-scenario-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  padding: 24px;
}

.bb-scenario-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--bb-text);
  margin-bottom: 4px;
}

.bb-scenario-desc {
  font-size: 13px;
  color: var(--bb-text-3);
  line-height: 1.5;
  margin-bottom: 20px;
}

.bb-scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.bb-scenario-item {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--bb-line);
}

.bb-scenario-item.s-min { background: #f0faf3; border-color: rgba(28,122,53,0.25); }
.bb-scenario-item.s-avg { background: var(--bb-bg); border-color: var(--bb-line); }
.bb-scenario-item.s-max { background: var(--bb-warn-bg); border-color: color-mix(in srgb, var(--bb-warn-text) 25%, transparent); }

.bb-scenario-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
  margin-bottom: 8px;
}

.bb-scenario-val {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.bb-scenario-val.green   { color: var(--bb-success-text); }
.bb-scenario-val.neutral { color: var(--bb-text); }
.bb-scenario-val.orange  { color: var(--bb-warn-text); }

.bb-scenario-note {
  font-size: 12px;
  color: var(--bb-text-3);
  line-height: 1.4;
}

/* ── Demand table ──────────────────────────────────────────── */
.bb-demand-table-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  overflow: hidden;
}

.bb-demand-table-head {
  display: grid;
  grid-template-columns: 80px 1fr 100px 100px 100px;
  padding: 12px 20px;
  background: var(--bb-bg);
  border-bottom: 1px solid var(--bb-line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-demand-table-row {
  display: grid;
  grid-template-columns: 80px 1fr 100px 100px 100px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--bb-line);
  font-size: 13px;
  align-items: center;
  transition: background 0.1s;
}

.bb-demand-table-row:last-child { border-bottom: none; }
.bb-demand-table-row:hover      { background: var(--bb-bg); }
.bb-demand-table-row.current    { background: color-mix(in srgb, var(--bb-blue) 8%, white); }
.bb-demand-table-row.past       { color: var(--bb-text-3); }

/* ── Responsive adjustments ────────────────────────────────── */
@media (max-width: 900px) {
  .bb-page-tabs-inner { padding: 0 16px; }

  .bb-metric + .bb-metric { border-left: none; }
  .bb-metric:nth-child(odd)  { border-right: 1px solid var(--bb-line); }
  .bb-metric:nth-child(-n+4) { border-bottom: 1px solid var(--bb-line); }

  .bb-scenario-grid { grid-template-columns: 1fr; gap: 10px; }

  .bb-price-table-head,
  .bb-price-table-row { grid-template-columns: 70px 1fr 70px 60px; }
  .bb-price-table-head > *:nth-child(5),
  .bb-price-table-row  > *:nth-child(5) { display: none; }

  .bb-demand-table-head,
  .bb-demand-table-row { grid-template-columns: 70px 1fr 90px 90px; }
  .bb-demand-table-head > *:nth-child(5),
  .bb-demand-table-row  > *:nth-child(5) { display: none; }
}

/* ── ENERGY PLAN — Algorithm Cards ── */
.bb-algo-card {
  border: 2px solid var(--bb-line);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bb-bg);
}

.bb-algo-card:hover { border-color: #9ca3af; background: #f0f0f2; }

.bb-algo-card-inactive {
  border: 2px solid var(--bb-line);
  border-radius: 12px;
  padding: 14px;
  opacity: 0.55;
  background: var(--bb-bg);
}

.bb-algo-type-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}

.bb-algo-type-scripted { background: #ede9fe; color: #5b21b6; }
.bb-algo-type-math     { background: var(--bb-warn-bg); color: var(--bb-warn-text); }

/* ── DASHBOARD — Asset Grid ── */
.bb-asset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.bb-asset-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.bb-asset-card.winner {
  background: linear-gradient(160deg, #f0faf3 0%, var(--bb-surface) 60%);
  border-color: rgba(28, 122, 53, 0.30);
}

.bb-asset-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.bb-asset-card-title { display: flex; align-items: center; gap: 10px; }
.bb-asset-icon { font-size: 22px; }
.bb-asset-name { font-size: 17px; font-weight: 700; color: var(--bb-text); }
.bb-asset-sub  { font-size: 11px; color: var(--bb-text-3); font-weight: 500; margin-top: 1px; }

/* Status badges */
.bb-badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.bb-badge-idle    { background: rgba(24,66,110,.05); color: var(--bb-text-2); }
.bb-badge-active  { background: color-mix(in srgb, var(--bb-danger-text) 10%, transparent); color: var(--bb-danger-text); }
.bb-badge-winner  { background: var(--bb-success-text); color: white; }
.bb-badge-standby { background: color-mix(in srgb, var(--bb-warn-text) 10%, transparent); color: var(--bb-warn-text); }
.bb-badge-battery { background: color-mix(in srgb, var(--bb-accent) 10%, transparent); color: var(--bb-accent); }

/* Cost bar inside asset card */
.bb-asset-cost-bar   { height: 3px; border-radius: 2px; margin-bottom: 14px; }
.bb-asset-cost-label { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--bb-text-3); margin-bottom: 4px; }
.bb-asset-cost-value { font-size: 30px; font-weight: 300; letter-spacing: -1px; line-height: 1; margin-bottom: 14px; }
.bb-asset-cost-value .bb-eur { font-size: 15px; font-weight: 400; vertical-align: super; margin-right: 1px; }
.bb-asset-cost-value.bb-green { color: var(--bb-success-text); }

/* Stats rows inside card */
.bb-asset-stats { display: flex; flex-direction: column; gap: 8px; }
.bb-asset-stat-row { display: flex; justify-content: space-between; align-items: center; }
.bb-asset-stat-lbl { font-size: 12px; color: var(--bb-text-3); font-weight: 500; }
.bb-asset-stat-val { font-size: 13px; font-weight: 600; color: var(--bb-text); }
.bb-asset-stat-val.bb-green  { color: var(--bb-success-text); }
.bb-asset-stat-val.bb-orange { color: var(--bb-warn-text); }
.bb-asset-stat-val.bb-blue   { color: var(--bb-accent); }

/* Saving strip at bottom of card */
.bb-asset-saving { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--bb-line); }
.bb-asset-saving-label { font-size: 11px; color: var(--bb-text-3); font-weight: 500; margin-bottom: 3px; }
.bb-asset-saving-value { font-size: 15px; font-weight: 700; }
.bb-asset-saving-value.bb-green  { color: var(--bb-success-text); }
.bb-asset-saving-value.bb-muted  { color: var(--bb-text-3); }
.bb-asset-saving-value.bb-orange { color: var(--bb-warn-text); }
.bb-asset-saving-note { font-size: 11px; color: var(--bb-text-3); margin-top: 2px; }

/* Progress bar inside card */
.bb-progress-bar  { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bb-progress-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.bb-progress-fill.bb-green { background: var(--bb-success-text); }
.bb-progress-fill.bb-blue  { background: var(--bb-accent); }
.bb-progress-fill.bb-grey  { background: #aeaeb2; }

/* Collapsible details inside asset card */
.bb-details-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 0;
  margin: 10px 0 0;
  background: none;
  border: none;
  border-top: 1px solid var(--bb-line);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--bb-text-3);
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.2px;
}
.bb-details-toggle:hover { color: var(--bb-text); }
.bb-toggle-chevron { font-size: 10px; transition: transform 0.25s cubic-bezier(.4,0,.2,1); }
.bb-details-toggle.open .bb-toggle-chevron { transform: rotate(180deg); }

.bb-asset-details {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s cubic-bezier(.4,0,.2,1), opacity 0.22s ease;
  opacity: 0;
}
.bb-asset-details.open { max-height: 320px; opacity: 1; }

/* ── DASHBOARD — Energy per m² bar ── */
.bb-energy-bar {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.bb-energy-bar-title    { font-size: 14px; font-weight: 700; color: var(--bb-text); white-space: nowrap; flex-shrink: 0; }
.bb-energy-bar-divider  { width: 1px; align-self: stretch; background: var(--bb-line); flex-shrink: 0; }
.bb-energy-bar-metrics  { display: flex; align-items: center; gap: 40px; flex: 1; flex-wrap: wrap; }
.bb-energy-metric-val   { font-size: 20px; font-weight: 700; color: var(--bb-text); line-height: 1.2; }
.bb-energy-metric-val.bb-green { color: #059669; }
.bb-energy-metric-val.bb-blue  { color: var(--bb-blue); }
.bb-energy-metric-lbl   { font-size: 11px; color: var(--bb-text-3); font-weight: 500; margin-top: 2px; }
.bb-energy-bar-ts       { font-size: 11px; color: #9ca3af; margin-left: auto; white-space: nowrap; }

/* ── DASHBOARD — Plan summary card ── */
.bb-plan-card {
  background: var(--bb-surface);
  border-radius: var(--bb-r);
  border: 1px solid var(--bb-line);
  box-shadow: var(--bb-shadow-sm);
  padding: 24px;
}
.bb-plan-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.bb-plan-grid dt { font-size: 12px; color: var(--bb-text-3); font-weight: 500; margin-bottom: 4px; }
.bb-plan-grid dd { margin: 0; font-weight: 700; font-size: 15px; color: var(--bb-text); }

/* Responsive dashboard */
@media (max-width: 900px) {
  .bb-asset-grid { grid-template-columns: 1fr; }
  .bb-energy-bar { flex-direction: column; align-items: flex-start; gap: 16px; }
  .bb-energy-bar-divider { display: none; }
  .bb-energy-bar-ts { margin-left: 0; }
  .bb-plan-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Asset card control widgets ────────────────────────────────────────── */
.bb-asset-controls { border-top: 1px solid var(--bb-line); padding-top: 12px; margin-top: 12px; }
.bb-asset-controls-header { font-size: 11px; font-weight: 600; color: var(--bb-text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.bb-asset-control-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.bb-asset-control-lbl { flex: 0 0 140px; font-size: 13px; color: var(--bb-text-2); }
.bb-asset-control-current { font-size: 12px; color: var(--bb-text-3); min-width: 40px; }
.bb-asset-control-widget { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bb-asset-control-inline-form { display: inline; margin: 0; padding: 0; }
.bb-btn-control { padding: 4px 14px; border-radius: 6px; border: 1px solid var(--bb-line); font-size: 13px; cursor: pointer; background: var(--bb-surface); color: var(--bb-text-2); transition: background 0.15s, border-color 0.15s; }
.bb-btn-control:hover { background: var(--bb-bg); }
.bb-btn-control-on  { border-color: var(--bb-success-border); color: var(--bb-success-text); }
.bb-btn-control-off { border-color: var(--bb-danger-border);  color: var(--bb-danger-text); }
.bb-input-sm  { width: 90px; padding: 4px 8px; font-size: 13px; border: 1px solid var(--bb-line); border-radius: 6px; }
.bb-select-sm { padding: 4px 8px; font-size: 13px; border: 1px solid var(--bb-line); border-radius: 6px; background: var(--bb-surface); }
.bb-asset-control-feedback { font-size: 12px; min-height: 18px; margin-top: 4px; }

/* ── Platform asset overview — account grouping header ── */
.bb-platform-assets-account-header { display: flex; align-items: center; gap: 10px; margin: 24px 0 8px; padding: 10px 16px; background: var(--bb-surface); border: 1px solid var(--bb-line); border-radius: 8px; }
.bb-platform-assets-account-name   { font-size: 13px; font-weight: 600; color: var(--bb-text-1); letter-spacing: 0.01em; }

/* When rendered inside the compact grid, account headers + eyebrows must span all columns */
.bb-assets-compact .bb-platform-assets-account-header { grid-column: 1 / -1; margin-top: 12px; }
.bb-assets-compact .bb-platform-assets-account-header:first-child { margin-top: 0; }

/* ───────── Live MQTT stream (operational dashboard) ───────── */
.bb-mqtt-live {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bb-mqtt-live-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .bb-mqtt-live-row { grid-template-columns: 1fr; }
}
.bb-mqtt-live-card {
  padding: 16px 20px;
  min-height: 120px;
}
.bb-mqtt-live-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.bb-mqtt-live-card-head h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bb-text-2);
  margin: 0;
}
.bb-mqtt-live-card-head i { color: var(--bb-text-3); font-size: 12px; }
.bb-mqtt-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
  animation: bbMqttPulse 1.6s ease-in-out infinite;
}
@keyframes bbMqttPulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}
.bb-mqtt-live-empty {
  color: var(--bb-text-3);
  font-size: 12px;
  margin: 8px 0;
  text-align: center;
}

.bb-mqtt-stream-card {
  padding: 0;
  overflow: hidden;
}
.bb-mqtt-stream-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bb-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.bb-mqtt-stream-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bb-mqtt-stream-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bb-surface-2);
  border: 1px solid var(--bb-line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.bb-mqtt-stream-filter i { color: var(--bb-text-3); }
.bb-mqtt-stream-filter input {
  border: none; outline: none; background: transparent;
  font-size: 12px; min-width: 180px; color: var(--bb-text-1);
}
.bb-mqtt-stream-pause {
  background: white;
  border: 1px solid var(--bb-line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--bb-text-2);
}
.bb-mqtt-stream-pause[data-paused="true"] {
  background: var(--bb-warn-bg);
  border-color: var(--bb-warn-border);
  color: var(--bb-warn-text);
}

.bb-mqtt-stream-body {
  display: block;
  min-height: 420px;
}
.bb-mqtt-topic-rail {
  border-right: 1px solid var(--bb-line);
  background: var(--bb-surface-2);
  overflow: auto;
  max-height: 480px;
  padding: 8px 0;
  font-size: 11px;
}
.bb-mqtt-topic-rail table { font-size: 11px; width: 100%; }
.bb-mqtt-topic-rail th,
.bb-mqtt-topic-rail td {
  padding: 4px 10px;
  border: none;
}
.bb-mqtt-topic-rail thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bb-text-3);
  border-bottom: 1px solid var(--bb-line);
}
.bb-mqtt-topic-rail .bb-mqtt-debug-col-intensity { display: none; }

.bb-mqtt-stream-feed {
  background: #0f172a;
  color: #e2e8f0;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 480px;
  overflow: auto;
  padding: 10px 0;
  overflow-anchor: auto;
}
.bb-mqtt-stream-feed .bb-mqtt-live-empty { color: #64748b; }
.bb-mqtt-feed-row {
  display: grid;
  grid-template-columns: 92px minmax(180px, 1fr) minmax(80px, 1fr);
  gap: 12px;
  padding: 3px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.1s;
}
.bb-mqtt-feed-row:hover { background: rgba(59,130,246,0.12); }
.bb-mqtt-feed-row:focus {
  outline: none;
  background: rgba(59,130,246,0.2);
}
.bb-mqtt-feed-time  { color: #64748b; white-space: nowrap; }
.bb-mqtt-feed-topic {
  color: #7dd3fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bb-mqtt-feed-payload {
  color: var(--bb-warn-border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bb-mqtt-stream-detail {
  border-top: 1px solid var(--bb-line);
  padding: 16px 20px;
  background: var(--bb-surface-2);
  min-height: 0;
}
.bb-mqtt-stream-detail:empty { display: none; }

/* ── BI Analytics ──────────────────────────────────────────────────────── */
.bb-bi-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.bb-bi-sidebar {
  width: 260px;
  min-width: 220px;
  background: var(--bb-surface);
  border-right: 1px solid var(--bb-line);
  padding: 20px 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.bb-bi-sidebar-header .bb-select { width: 100%; }

.bb-bi-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #f6f5f1;
}

/* Dashboard list */
.bb-bi-dash-item {
  border: 1px solid var(--bb-line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bb-surface);
  cursor: pointer;
  transition: border-color 0.15s;
}
.bb-bi-dash-item:hover, .bb-bi-dash-item.active { border-color: var(--bb-blue); }
.bb-bi-dash-item-name { font-size: 0.875rem; font-weight: 600; color: var(--bb-text-1); }
.bb-bi-dash-item-meta { font-size: 0.75rem; color: var(--bb-text-3); margin-top: 2px; }
.bb-bi-dash-item-actions { display: flex; gap: 4px; margin-top: 6px; }

/* Dashboard header */
.bb-bi-dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.bb-bi-dash-controls { display: flex; align-items: center; gap: 10px; }

/* Widget grid (12-col) */
.bb-bi-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.bb-bi-widget-wrap {
  grid-column: span 6;
  grid-row: span 4;
  min-height: 200px;
}

/* Widget card */
.bb-bi-widget-card {
  background: #fff;
  border: 1px solid var(--bb-line);
  border-radius: 12px;
  box-shadow: var(--bb-shadow-sm);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bb-bi-widget-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--bb-line);
  gap: 8px;
}

.bb-bi-widget-title { font-size: 0.9rem; font-weight: 600; color: var(--bb-text-1); }

.bb-bi-widget-provenance {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.bb-bi-widget-actions { display: flex; gap: 4px; flex-shrink: 0; }
.bb-bi-widget-body { flex: 1; padding: 12px; display: flex; flex-direction: column; }

.bb-bi-widget-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--bb-text-3); font-size: 1.5rem;
}

.bb-bi-widget-card--error { border-color: var(--bb-danger-border); }
.bb-bi-widget-card--kpi .bb-bi-widget-body { justify-content: center; }

/* Empty state */
.bb-bi-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60vh; text-align: center; gap: 12px;
}
.bb-bi-empty-icon { font-size: 3rem; color: var(--bb-ink-20, #c9cfd5); }
.bb-bi-empty-title { font-size: 1.1rem; font-weight: 600; color: var(--bb-text-1); }
.bb-bi-empty-hint { font-size: 0.875rem; color: var(--bb-text-3); }

/* Overlay panel */
.bb-bi-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
}

.bb-bi-panel {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(24,66,110,.18);
  width: 560px;
  max-width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bb-bi-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--bb-line);
}

.bb-bi-panel-title { font-size: 1.05rem; font-weight: 700; }
.bb-bi-panel-body { overflow-y: auto; padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.bb-bi-step { display: flex; flex-direction: column; gap: 8px; }
.bb-bi-step--actions { flex-direction: row; gap: 10px; padding-top: 8px; }

/* Widget type grid */
.bb-bi-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bb-bi-type-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--bb-line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--bb-text-2);
  transition: border-color 0.15s, background 0.15s;
}
.bb-bi-type-btn:hover { border-color: var(--bb-blue); background: rgba(37,99,235,.04); }
.bb-bi-type-btn.active { border-color: var(--bb-blue); background: rgba(37,99,235,.08); color: var(--bb-blue); }
.bb-bi-type-btn i { font-size: 1.3rem; }

/* Series list */
.bb-bi-series-list { display: flex; flex-direction: column; gap: 6px; }
.bb-bi-series-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bb-surface-2);
  border-radius: 6px;
  font-size: 0.82rem;
}
.bb-bi-series-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bb-bi-series-label { flex: 1; }

/* Data-point picker tree */
.bb-bi-picker { display: flex; flex-direction: column; gap: 4px; }
.bb-bi-picker-site { border: 1px solid var(--bb-line); border-radius: 6px; overflow: hidden; }
.bb-bi-picker-site-label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  background: var(--bb-surface);
}
.bb-bi-picker-site-label:hover { background: var(--bb-surface-2); }
.bb-bi-picker-chevron { margin-left: auto; font-size: 0.65rem; transition: transform 0.2s; }
.bb-bi-picker-site-body { display: none; }
.bb-bi-picker-site-body.open { display: block; }
.bb-bi-picker-site-body.open ~ .bb-bi-picker-site-label .bb-bi-picker-chevron { transform: rotate(180deg); }

.bb-bi-picker-asset { border-top: 1px solid var(--bb-line); }
.bb-bi-picker-asset-label {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  font-size: 0.8rem; color: var(--bb-text-2);
  cursor: pointer;
}
.bb-bi-picker-asset-label:hover { background: var(--bb-surface-2); }

.bb-bi-picker-field-list { display: none; }
.bb-bi-picker-field-list.open { display: block; }

.bb-bi-picker-field {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 24px;
  font-size: 0.78rem; color: var(--bb-text-2);
  cursor: pointer;
}
.bb-bi-picker-field:hover { background: rgba(37,99,235,.05); color: var(--bb-blue); }
.bb-bi-picker-field-icon { color: var(--bb-blue); font-size: 0.7rem; }
.bb-bi-picker-field-unit {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--bb-text-3);
  font-style: italic;
}

/* KPI display */
.bb-bi-kpi-display {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
}

/* Responsive */
@media (max-width: 900px) {
  .bb-bi-layout { flex-direction: column; }
  .bb-bi-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--bb-line); }
  .bb-bi-widget-wrap { grid-column: span 12; }
}

/* ── Voice assistant (/m/assistant) ── */

.bb-assistant-page .bb-content-wrap.bb-assistant-wrap {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
}

.bb-assistant-boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bb-bg);
  color: var(--bb-text-3);
  transition: opacity 0.3s;
}

.bb-assistant-boot.hidden {
  opacity: 0;
  pointer-events: none;
}

.bb-assistant-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bb-assistant-voice-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bb-assistant-voice-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: var(--bb-track-caps);
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-assistant-voice-select {
  max-width: 12rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.bb-assistant-voice-mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--bb-line);
  border-radius: 50%;
  background: var(--bb-surface);
  color: var(--bb-text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.bb-assistant-voice-mute:hover {
  color: var(--bb-blue);
  border-color: var(--bb-blue);
}

.bb-assistant-voice-mute[aria-pressed="true"] {
  color: var(--bb-danger-text);
  border-color: var(--bb-danger-border);
  background: var(--bb-danger-bg);
}

.bb-assistant-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

@media (min-width: 900px) {
  .bb-assistant-grid {
    grid-template-columns: 1.1fr 1fr;
    align-items: start;
  }
}

.bb-assistant-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 16rem;
}

.bb-assistant-panel-scroll {
  flex: 1;
  min-height: 12rem;
  max-height: min(52vh, 28rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bb-assistant-empty {
  text-align: center;
  padding: 2rem 0.75rem;
  color: var(--bb-text-3);
  font-size: 0.875rem;
  line-height: 1.5;
}

.bb-assistant-empty h2 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--bb-blue);
}

.bb-assistant-empty p {
  margin: 0;
}

.bb-assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.bb-assistant-suggestion {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 999px;
  background: var(--bb-surface-2);
  color: var(--bb-text-2);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.bb-assistant-suggestion:hover,
.bb-assistant-suggestion:active {
  background: color-mix(in srgb, var(--bb-accent) 12%, white);
  border-color: color-mix(in srgb, var(--bb-accent) 35%, var(--bb-line));
  color: var(--bb-blue);
}

.bb-assistant-bubble {
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 92%;
  animation: bb-assistant-fade-in 0.25s ease-out;
}

.bb-assistant-bubble-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--bb-accent) 14%, white);
  border: 1px solid color-mix(in srgb, var(--bb-accent) 28%, var(--bb-line));
  color: var(--bb-text);
}

.bb-assistant-bubble-ai {
  align-self: flex-start;
  background: var(--bb-surface-2);
  border: 1px solid var(--bb-line);
  color: var(--bb-text);
}

.bb-assistant-bubble-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  font-size: 0.6875rem;
  color: var(--bb-text-3);
}

.bb-assistant-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bb-assistant-badge-haiku {
  background: color-mix(in srgb, var(--bb-accent) 12%, white);
  color: var(--bb-accent);
  border: 1px solid color-mix(in srgb, var(--bb-accent) 25%, var(--bb-line));
}

.bb-assistant-badge-sonnet {
  background: color-mix(in srgb, var(--bb-lane-2) 12%, white);
  color: var(--bb-lane-2);
  border: 1px solid color-mix(in srgb, var(--bb-lane-2) 25%, var(--bb-line));
}

.bb-assistant-trace {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.25rem 0;
}

.bb-assistant-trace-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--bb-warn-bg);
  color: var(--bb-warn-text);
  border: 1px solid var(--bb-warn-border);
  animation: bb-assistant-fade-in 0.2s ease-out;
}

.bb-assistant-trace-chip.done {
  background: var(--bb-success-bg);
  color: var(--bb-success-text);
  border-color: var(--bb-success-border);
}

.bb-assistant-trace-spinner {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  animation: bb-assistant-pulse 0.9s ease-in-out infinite;
}

.bb-assistant-trace-chip.done .bb-assistant-trace-spinner {
  animation: none;
}

.bb-assistant-topology-block {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bb-line);
}

.bb-assistant-topology-hint {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--bb-text-3);
  line-height: 1.4;
}

.bb-assistant-topology-empty {
  font-size: 0.8125rem;
  color: var(--bb-text-3);
  padding: 0.5rem 0;
}

.bb-assistant-topology {
  max-height: min(28vh, 14rem);
  overflow-y: auto;
  font-size: 0.75rem;
  line-height: 1.35;
}

.bb-assistant-topology-tree,
.bb-assistant-topology-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bb-assistant-topology-tree ul {
  padding-left: 0.875rem;
  border-left: 1px solid var(--bb-line);
  margin-left: 0.35rem;
}

.bb-assistant-topology-node {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.2rem 0.35rem;
  margin: 0.1rem 0;
  border-radius: 0.35rem;
  color: var(--bb-text-2);
}

.bb-assistant-topology-metrics {
  flex: 1 1 100%;
  margin-left: 3.1rem;
  font-size: 0.625rem;
  color: var(--bb-text-3);
  line-height: 1.3;
}

.bb-assistant-topology-node--focus {
  background: color-mix(in srgb, var(--bb-accent) 14%, white);
  color: var(--bb-blue);
  font-weight: 600;
}

.bb-assistant-topology-kind {
  flex-shrink: 0;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bb-text-3);
  min-width: 2.75rem;
}

.bb-assistant-topology-node--focus .bb-assistant-topology-kind {
  color: var(--bb-accent);
}

.bb-assistant-topology-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bb-assistant-viz-host {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.bb-assistant-viz-empty {
  padding: 1.5rem 0.75rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--bb-text-3);
  line-height: 1.5;
}

.bb-assistant-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.625rem;
}

.bb-assistant-kpi {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: var(--bb-surface-2);
  animation: bb-assistant-fade-in 0.3s ease-out;
}

.bb-assistant-kpi-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: var(--bb-track-loose-1);
  text-transform: uppercase;
  color: var(--bb-text-3);
  margin-bottom: 0.25rem;
}

.bb-assistant-kpi-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--bb-blue);
  line-height: 1.1;
}

.bb-assistant-kpi-unit {
  margin-left: 0.2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bb-text-3);
}

.bb-assistant-soc-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: var(--bb-surface-2);
  animation: bb-assistant-fade-in 0.3s ease-out;
}

.bb-assistant-soc-ring {
  flex-shrink: 0;
  width: 4.5rem;
  height: 4.5rem;
}

.bb-assistant-soc-meta {
  flex: 1;
  min-width: 0;
}

.bb-assistant-soc-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--bb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bb-assistant-soc-sub {
  font-size: 0.6875rem;
  color: var(--bb-text-3);
}

.bb-assistant-spark-card {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: var(--bb-surface-2);
  animation: bb-assistant-fade-in 0.3s ease-out;
}

.bb-assistant-spark-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bb-assistant-spark-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bb-text-2);
}

.bb-assistant-spark-stat {
  font-size: 0.6875rem;
  color: var(--bb-text-3);
}

.bb-assistant-spark svg {
  display: block;
  width: 100%;
  height: 3.5rem;
}

.bb-assistant-fact-card {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: var(--bb-surface-2);
  font-size: 0.75rem;
  color: var(--bb-text-2);
  animation: bb-assistant-fade-in 0.3s ease-out;
}

.bb-assistant-fact-title {
  margin-bottom: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--bb-track-loose-1);
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-assistant-fact-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.125rem 0;
}

.bb-assistant-fact-row span:first-child {
  color: var(--bb-text-3);
}

.bb-assistant-fact-row span:last-child {
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--bb-text);
}

.bb-assistant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.bb-assistant-chip {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: color-mix(in srgb, var(--bb-accent) 10%, white);
  color: var(--bb-blue);
  border: 1px solid color-mix(in srgb, var(--bb-accent) 22%, var(--bb-line));
}

/* Live asset board — CSS graphics driven by /account/stream/assistant-assets JSON SSE */
.bb-assistant-asset-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.bb-assistant-asset-board:not([hidden]) + .bb-assistant-viz-tool:not(:empty) + .bb-assistant-viz-empty,
.bb-assistant-asset-board:not([hidden]) + .bb-assistant-viz-empty {
  display: none;
}

.bb-assistant-viz-tool {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.bb-assistant-asset-type-label {
  grid-column: 1 / -1;
  margin: 0.25rem 0 0;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: var(--bb-track-caps);
  text-transform: uppercase;
  color: var(--bb-text-3);
}

.bb-assistant-asset-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--bb-line);
  border-radius: 0.75rem;
  background: var(--bb-surface);
  min-height: 7.5rem;
  animation: bb-assistant-fade-in 0.3s ease-out;
}

.bb-assistant-asset-card--attention {
  border-color: var(--bb-warn-border);
  background: color-mix(in srgb, var(--bb-warn-bg) 40%, var(--bb-surface));
}

.bb-assistant-asset-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.375rem;
}

.bb-assistant-asset-icon {
  font-size: 1.125rem;
  line-height: 1;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  flex-shrink: 0;
}

.bb-assistant-asset-icon.blue   { background: color-mix(in srgb, var(--bb-accent) 10%, white); }
.bb-assistant-asset-icon.green  { background: #f0fdf4; }
.bb-assistant-asset-icon.orange { background: var(--bb-warn-bg); }

.bb-assistant-asset-status {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.bb-assistant-asset-status.active      { background: var(--bb-success-text); }
.bb-assistant-asset-status.inactive    { background: var(--bb-text-3); }
.bb-assistant-asset-status.maintenance { background: var(--bb-warn-text); }

.bb-assistant-asset-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bb-text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.bb-assistant-asset-type {
  font-size: 0.625rem;
  color: var(--bb-text-3);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.bb-assistant-asset-graphic {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
}

.bb-assistant-asset-soc-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.bb-assistant-asset-soc-wrap .bb-assistant-soc-ring {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
}

.bb-assistant-asset-soc-wrap .bb-assistant-soc-meta {
  min-width: 0;
}

.bb-assistant-asset-soc-wrap .bb-assistant-soc-name {
  font-size: 0.6875rem;
}

.bb-assistant-asset-bar {
  width: 100%;
}

.bb-assistant-asset-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--bb-text-3);
  margin-bottom: 0.2rem;
}

.bb-assistant-asset-bar-label strong {
  color: var(--bb-text);
  font-weight: 600;
}

.bb-assistant-asset-bar-track {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--bb-surface-2);
  overflow: hidden;
}

.bb-assistant-asset-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.bb-assistant-asset-bar-fill.blue   { background: var(--bb-accent); }
.bb-assistant-asset-bar-fill.green  { background: var(--bb-success-text); }
.bb-assistant-asset-bar-fill.teal   { background: #0d9488; }

.bb-assistant-asset-headline {
  text-align: center;
  width: 100%;
}

.bb-assistant-asset-headline-val {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--bb-blue);
  line-height: 1.2;
}

.bb-assistant-asset-headline-lbl {
  display: block;
  font-size: 0.625rem;
  color: var(--bb-text-3);
  margin-top: 0.125rem;
}

.bb-assistant-asset-headline .bb-microbar {
  margin-top: 0.35rem;
}

.bb-assistant-asset-foot {
  font-size: 0.625rem;
  color: var(--bb-text-3);
  text-align: right;
}

.bb-assistant-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem 0 0.5rem;
  margin-top: auto;
  border-top: 1px solid var(--bb-line);
  background: linear-gradient(180deg, transparent 0%, var(--bb-bg) 24%);
}

.bb-assistant-status {
  min-height: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bb-text-3);
  text-align: center;
}

.bb-assistant-status.live { color: var(--bb-danger-text); }
.bb-assistant-status.thinking { color: var(--bb-warn-text); }
.bb-assistant-status.speaking { color: var(--bb-success-text); }

.bb-assistant-mic-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bb-assistant-mic {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5.25rem;
  height: 5.25rem;
  border: none;
  border-radius: 50%;
  background: var(--bb-blue);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--bb-shadow-md);
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bb-assistant-mic:active { transform: scale(0.94); }
.bb-assistant-mic:disabled { opacity: 0.45; cursor: not-allowed; }
.bb-assistant-mic svg { width: 2.375rem; height: 2.375rem; }

.bb-assistant-mic.listening {
  background: var(--bb-danger-text);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bb-danger-text) 35%, transparent);
}

.bb-assistant-mic.thinking {
  background: var(--bb-warn-text);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bb-warn-text) 35%, transparent);
}

.bb-assistant-mic.speaking {
  background: var(--bb-success-text);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bb-success-text) 35%, transparent);
}

.bb-assistant-mic-rings {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bb-assistant-mic-rings::before,
.bb-assistant-mic-rings::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--bb-danger-text);
  opacity: 0;
}

.bb-assistant-mic-wrap.listening .bb-assistant-mic-rings::before {
  animation: bb-assistant-ring 1.8s ease-out infinite;
}

.bb-assistant-mic-wrap.listening .bb-assistant-mic-rings::after {
  animation: bb-assistant-ring 1.8s ease-out infinite;
  animation-delay: 0.9s;
}

.bb-assistant-mic-wrap.thinking .bb-assistant-mic-rings::before {
  border-color: var(--bb-warn-text);
  opacity: 0.45;
  animation: bb-assistant-glow 2.2s ease-in-out infinite;
}

.bb-assistant-interim {
  max-width: 90%;
  min-height: 0;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--bb-line);
  border-radius: 999px;
  background: var(--bb-surface);
  color: var(--bb-text-2);
  font-size: 0.8125rem;
  text-align: center;
  transition: padding 0.2s, border 0.2s;
}

.bb-assistant-interim:empty {
  padding: 0;
  border: 0;
}

.bb-assistant-text-fallback {
  display: none;
  width: 100%;
  max-width: 30rem;
}

.bb-assistant-page.no-speech .bb-assistant-text-fallback {
  display: block;
}

.bb-assistant-page.no-speech .bb-assistant-mic {
  display: none;
}

@keyframes bb-assistant-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bb-assistant-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.6); }
}

@keyframes bb-assistant-ring {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes bb-assistant-glow {
  0%, 100% { transform: scale(1.05); opacity: 0.25; }
  50% { transform: scale(1.25); opacity: 0.55; }
}
