/* Tracking at every level of the territory model */

/* ---------- Tree ---------- */

.bbi-mt-tree__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 0;
}

.bbi-mt-tree__head b { display: block; font-size: 15px; font-weight: 800; color: var(--bbi-ink); }
.bbi-mt-tree__head small { display: block; margin-top: 1px; font-size: 12px; font-weight: 700; color: var(--bbi-muted); }

.bbi-mt-tree__foot {
  position: absolute;
  left: 18px;
  right: 14px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bbi-muted);
}

.bbi-mt-tree__foot svg { width: 15px; height: 15px; flex: none; color: var(--bbi-indigo); }

.bbi-mt-row {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e6eaf3;
  box-shadow: var(--bbi-shadow-sm);
  transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

/* The selected node and the branch its counts cover */
.bbi-mt-row::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--bbi-indigo);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bbi-mt-row.is-branch { background: #fafbff; border-color: rgba(94, 114, 228, 0.25); }
.bbi-mt-row.is-branch::before { opacity: 0.7; }

.bbi-mt-row.is-selected {
  background: #f0f2fb;
  border-color: rgba(94, 114, 228, 0.6);
  box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.13);
}

.bbi-mt-row.is-selected::before { opacity: 1; }

.bbi-mt-chev { display: grid; place-items: center; width: 12px; height: 12px; flex: none; color: #a3aec4; }
.bbi-mt-chev svg { width: 12px; height: 12px; }
.bbi-mt-chev.is-open svg { transform: rotate(90deg); }

.bbi-mt-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
}

.bbi-mt-ico svg { width: 14px; height: 14px; }
.bbi-mt-ico--root { background: linear-gradient(135deg, #344767, #1e2a4a); color: #fff; }
.bbi-mt-ico--region { background: rgba(94, 114, 228, 0.13); color: var(--bbi-indigo); }
.bbi-mt-ico--segment { background: rgba(130, 94, 228, 0.13); color: var(--bbi-purple); }

.bbi-mt-av { width: 28px; height: 28px; box-shadow: 0 0 0 2px #fff, var(--bbi-shadow-sm); }

.bbi-mt-row__name { flex: 1; min-width: 0; line-height: 1.2; }

.bbi-mt-row__name b {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  color: var(--bbi-ink);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bbi-mt-row__name small { display: block; font-size: 11.5px; font-weight: 700; color: var(--bbi-muted); white-space: nowrap; }
.bbi-mt-row__name small:empty { display: none; }
.bbi-mt-row__name small.is-warn { font-weight: 800; color: #e8590c; }

.bbi-mt-row__count {
  flex: none;
  font-size: 13px;
  font-weight: 800;
  color: var(--bbi-muted);
  font-variant-numeric: tabular-nums;
}

/* Exceptions held by a territory */
.bbi-mt-flag {
  position: absolute;
  top: -9px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff5f8f, #f0386b);
  box-shadow: 0 0 0 2px #fff, 0 6px 12px -6px rgba(240, 56, 107, 0.7);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.25s ease, transform 0.4s var(--bbi-spring);
}

.bbi-mt-flag svg { width: 10px; height: 10px; }
.bbi-mt-flag.is-on { opacity: 1; transform: none; }

/* ---------- Account List panel ---------- */

.bbi-mt-panel { padding: 16px 18px; }

.bbi-mt-panel__head,
.bbi-mt-crumbs { transition: opacity 0.16s ease; }

.bbi-mt-panel__head.is-swap,
.bbi-mt-crumbs.is-swap { opacity: 0; }

.bbi-mt-panel__head { display: flex; align-items: center; height: 36px; }
.bbi-mt-panel__title { white-space: nowrap; }
.bbi-mt-panel__title b { font-size: 18px; font-weight: 800; color: var(--bbi-ink); letter-spacing: -0.01em; }
.bbi-mt-panel__title span { margin-left: 6px; font-size: 14px; font-weight: 700; color: var(--bbi-muted); }

.bbi-mt-crumbs { display: flex; align-items: center; gap: 6px; height: 22px; margin-top: 8px; }
.bbi-mt-crumbs i { font-style: normal; font-size: 13px; font-weight: 700; color: #b4bdd0; }

.bbi-mt-crumb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--bbi-surface-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--bbi-muted);
  white-space: nowrap;
}

.bbi-mt-crumb svg { width: 11px; height: 11px; }
.bbi-mt-crumb.is-current { background: var(--bbi-navy-deep); color: #fff; }

/* Tiles */
.bbi-mt-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.bbi-mt-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  height: 64px;
  padding: 0 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e6eaf3;
  box-shadow: var(--bbi-shadow-sm);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s var(--bbi-ease);
}

.bbi-mt-tile__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bbi-muted);
  white-space: nowrap;
}

.bbi-mt-tile__label svg { width: 13px; height: 13px; flex: none; }
.bbi-mt-tile--lost .bbi-mt-tile__label svg { transform: rotate(90deg); }

.bbi-mt-tile b {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--bbi-ink);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.bbi-mt-tile--gained b { color: var(--bbi-good); }
.bbi-mt-tile--lost b { color: var(--bbi-bad); }
.bbi-mt-tile--exceptions b { color: var(--bbi-bad); }
.bbi-mt-tile--unrouted b { color: #e8590c; }
.bbi-mt-tile--locked b { color: #d97706; }
.bbi-mt-tile.is-zero b { color: #b4bdd0; }

.bbi-mt-tile.is-active {
  border-color: transparent;
  background: var(--bbi-grad-brand);
  box-shadow: 0 12px 22px -10px rgba(94, 114, 228, 0.7);
}

.bbi-mt-tile.is-active .bbi-mt-tile__label,
.bbi-mt-tile.is-active b { color: #fff; }

.bbi-mt-tile.is-pressed { transform: scale(0.95); }

/* What the counts cover */
.bbi-mt-scope {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 20px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bbi-muted);
  white-space: nowrap;
  transition: color 0.3s ease;
}

.bbi-mt-scope__icon { display: grid; place-items: center; width: 15px; height: 15px; color: var(--bbi-indigo); }
.bbi-mt-scope__icon svg { width: 15px; height: 15px; }
.bbi-mt-scope.is-exc { color: #c22a57; }
.bbi-mt-scope.is-exc .bbi-mt-scope__icon { color: var(--bbi-bad); }

/* Account list */
.bbi-mt-list { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--bbi-line); }

.bbi-mt-list__head { display: flex; align-items: baseline; justify-content: space-between; height: 20px; }
.bbi-mt-list__head b { font-size: 14px; font-weight: 800; color: var(--bbi-ink); }
.bbi-mt-list__head span { font-size: 12px; font-weight: 700; color: var(--bbi-muted); }

.bbi-mt-list__rows { display: grid; gap: 8px; margin-top: 8px; transition: opacity 0.18s ease; }
.bbi-mt-list__rows.is-out { opacity: 0; }

.bbi-mt-acct {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 12px 0 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e6eaf3;
}

.bbi-mt-acct.is-exc { background: #fff8fa; border-color: var(--bbi-bad-edge); }

.bbi-mt-acct__sq { width: 30px; height: 30px; flex: none; border-radius: 9px; }
.bbi-mt-sq--indigo { background: var(--bbi-grad-brand); }
.bbi-mt-sq--purple { background: linear-gradient(135deg, #a58bf0, #825ee4); }
.bbi-mt-sq--pink { background: linear-gradient(135deg, #ff5fb5, #ff026c); }
.bbi-mt-sq--orange { background: linear-gradient(135deg, #fc8453, #fc5f08); }
.bbi-mt-sq--teal { background: linear-gradient(135deg, #2dcecc, #11a7c4); }
.bbi-mt-sq--green { background: var(--bbi-grad-good); }

.bbi-mt-acct__main { flex: 1; min-width: 0; line-height: 1.25; }

.bbi-mt-acct__main b {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 800;
  color: var(--bbi-ink);
  white-space: nowrap;
}

.bbi-mt-acct__main b svg { width: 13px; height: 13px; color: #d97706; }

.bbi-mt-acct__main small {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bbi-muted);
  white-space: nowrap;
}

.bbi-mt-acct__main .bbi-avatar { width: 17px; height: 17px; box-shadow: none; }

.bbi-mt-acct__routed { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.bbi-mt-acct__routed small { font-size: 11px; font-weight: 700; color: var(--bbi-muted); }

.bbi-mt-acct__routed em {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(94, 114, 228, 0.1);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bbi-indigo);
  white-space: nowrap;
}

.bbi-mt-acct.is-exc .bbi-mt-acct__routed em { background: var(--bbi-bad-bg); color: var(--bbi-bad); }
