:root {
  --bi-navy: #0d1b2e;
  --bi-blue: #5078dc;
  --bi-sky: #64b4f0;
  --bi-card: #f0f3fb;
  --bi-border: #c8d0ec;
  --bi-text: #0d1b2e;
  --bi-muted: #5a6b8a;
}

.bi-body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bi-card);
  color: var(--bi-text);
}

.bi-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.bi-sidebar {
  background: var(--bi-navy);
  color: #e8eef9;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}

.bi-brand-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bi-sky);
  margin: 0;
}

.bi-brand-title {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.bi-brand-sub {
  margin: 0.5rem 0 0;
  font-size: 10px;
  color: #9eb4d8;
  line-height: 1.4;
}

.bi-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1.5rem;
  flex: 1;
}

.bi-nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #c5d4ef;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bi-nav-btn:hover,
.bi-nav-btn.is-active {
  background: rgba(80, 120, 220, 0.25);
  border-color: rgba(100, 180, 240, 0.35);
  color: #fff;
}

.bi-sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(200, 208, 236, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 11px;
}

.bi-link-back {
  color: var(--bi-sky);
  text-decoration: none;
  font-weight: 700;
}

.bi-link-muted {
  background: none;
  border: none;
  color: #9eb4d8;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.bi-main {
  padding: 1.25rem 1.5rem 2rem;
  overflow: auto;
}

.bi-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.bi-topbar-eyebrow {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--bi-muted);
  font-weight: 700;
}

.bi-topbar-email {
  margin: 0.25rem 0 0;
  font-size: 14px;
  font-weight: 700;
}

.bi-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bi-as-of {
  margin: 0;
  font-size: 11px;
  color: var(--bi-muted);
}

.bi-btn {
  background: var(--bi-blue);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.bi-btn--ghost {
  background: #fff;
  color: var(--bi-blue);
  border: 1px solid var(--bi-border);
}

.bi-page {
  display: none;
}

.bi-page.is-active {
  display: block;
}

.bi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.bi-kpi-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bi-kpi-grid--compact .bi-kpi-card {
  padding: 0.75rem;
}

.bi-kpi-card {
  background: #fff;
  border: 1px solid var(--bi-border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.bi-kpi-label {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bi-muted);
  font-weight: 700;
}

.bi-kpi-value {
  margin: 0.35rem 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--bi-navy);
}

.bi-panel {
  background: #fff;
  border: 1px solid var(--bi-border);
  border-radius: 0.85rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.bi-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 13px;
  font-weight: 800;
  color: var(--bi-navy);
}

.bi-panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.bi-panel-row--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bi-panel--nested {
  margin: 0;
}

.bi-muted {
  font-size: 11px;
  color: var(--bi-muted);
  margin: 0 0 0.75rem;
}

.bi-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.bi-input {
  border: 1px solid var(--bi-border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 12px;
  min-width: 220px;
}

.bi-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.bi-pill {
  border: 1px solid var(--bi-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.bi-pill.is-active {
  background: var(--bi-blue);
  border-color: var(--bi-blue);
  color: #fff;
}

.bi-table-wrap {
  overflow: auto;
}

.bi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.bi-table th,
.bi-table td {
  border-bottom: 1px solid var(--bi-border);
  padding: 0.5rem 0.4rem;
  text-align: left;
}

.bi-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bi-muted);
}

.bi-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.bi-badge--active { background: #d1fae5; color: #065f46; }
.bi-badge--at_risk { background: #fef3c7; color: #92400e; }
.bi-badge--trial { background: #dbeafe; color: #1e40af; }
.bi-badge--churned { background: #fee2e2; color: #991b1b; }

.bi-jurisdiction-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.bi-jurisdiction-card {
  background: #fff;
  border: 1px solid var(--bi-border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.bi-portal-badges,
.bi-portal-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bi-portal-badge {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--bi-border);
  background: var(--bi-card);
}

.bi-portal-intel-card {
  flex: 1 1 320px;
  max-width: 100%;
}

.bi-portal-intel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bi-health-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--bi-border);
}

.bi-health-badge--green { background: #e8f8ee; color: #1b6b3a; }
.bi-health-badge--yellow { background: #fff8e6; color: #8a6400; }
.bi-health-badge--red { background: #fdecec; color: #9b1c1c; }
.bi-health-badge--unknown { background: #f3f4f6; color: #4b5563; }

.bi-coverage-bar {
  display: inline-block;
  vertical-align: middle;
  width: 72px;
  height: 6px;
  margin-left: 0.5rem;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bi-coverage-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.bi-coverage-bar--green > span { background: #22a05c; }
.bi-coverage-bar--yellow > span { background: #d9a400; }
.bi-coverage-bar--red > span { background: #d64545; }
.bi-coverage-bar--gray > span { background: #9ca3af; }

.bi-candidate-list {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 12px;
}

.bi-table--compact th,
.bi-table--compact td {
  font-size: 11px;
  padding: 0.35rem 0.5rem;
}

.bi-btn--sm {
  font-size: 10px;
  padding: 0.2rem 0.45rem;
}

.bi-detail-panel {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid var(--bi-border);
  border-radius: 0.85rem;
  padding: 1rem;
  font-size: 12px;
  line-height: 1.55;
}

.bi-funnel-step {
  background: #fff;
  border: 1px solid var(--bi-border);
  border-radius: 0.5rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.35rem;
  font-size: 12px;
  font-weight: 600;
}

.bi-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--bi-navy);
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  font-size: 12px;
  z-index: 50;
}

.hidden { display: none !important; }

@media (max-width: 1100px) {
  .bi-shell { grid-template-columns: 1fr; }
  .bi-sidebar { flex-direction: row; flex-wrap: wrap; }
  .bi-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bi-panel-row { grid-template-columns: 1fr; }
  .bi-jurisdiction-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
