/*
 * Backoffice shell styling. Layered on top of portal.css (shared design tokens + theme accents); this
 * sheet only adds the admin shell chrome (sidebar + topbar + dashboard cards). Deliberately minimal -
 * a navigational shell for the deferred Phase 4 CRUD, not an AdminLTE port.
 */

body.backoffice {
  background: var(--bg);
}

.bo-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar ------------------------------------------------------------------- */
.bo-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #03413e;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}
.theme-hadbet.backoffice .bo-sidebar {
  background: #344055;
}
.bo-brand {
  display: block;
  padding: 0 1.5rem 1.25rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.bo-brand-logo {
  display: block;
  height: 2.25rem;
  width: auto;
  max-width: 100%;
}
.bo-brand:hover {
  text-decoration: none;
}
.bo-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  flex: 1;
}
.bo-nav a {
  padding: 0.6rem 1.5rem;
  color: #cbd5e1;
  font-weight: 500;
  border-inline-start: 3px solid transparent;
}
.bo-nav a:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #ffffff;
  text-decoration: none;
}
.bo-nav a.active {
  color: #ffffff;
  border-inline-start-color: var(--brand-accent);
  background: rgba(148, 163, 184, 0.12);
}
.bo-nav a.is-disabled {
  color: #64748b;
  cursor: not-allowed;
  pointer-events: none;
}
.bo-nav a.is-disabled:hover {
  background: none;
}
.bo-nav-section {
  display: block;
  margin-top: 0.85rem;
  padding: 0.35rem 1.5rem 0.2rem;
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}
.bo-nav-section:first-of-type {
  margin-top: 0.5rem;
}
.bo-nav-subsection {
  display: block;
  margin-top: 0.45rem;
  padding: 0.2rem 1.5rem 0.1rem 2rem;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  user-select: none;
}
.bo-nav a.bo-nav-leaf {
  padding-inline-start: 2rem;
}
.bo-back {
  padding: 0.75rem 1.5rem 0;
  color: #94a3b8;
  font-size: 0.85rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* Mobile disclosure bar ----------------------------------------------------- */
/* Hidden on desktop (the sidebar is the nav); shown + styled in the mobile media query below. */
.bo-mobilebar {
  display: none;
}

/* Overflow-safe wrapper for wide content (e.g. the upcoming Phase 4 HTMX grids) so tables scroll
   inside the content column instead of forcing horizontal page overflow on small screens. */
.bo-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Main column --------------------------------------------------------------- */
.bo-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.bo-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  min-height: 56px;
}
.bo-user {
  color: var(--text-muted);
}
.bo-user strong {
  color: var(--text);
}
.bo-content {
  padding: 1.75rem;
  min-width: 0;
}
.bo-subtitle {
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}
.bo-welcome {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}
.bo-welcome strong {
  color: var(--text);
}

/* Profile summary (HTMX-refreshable) --------------------------------------- */
.bo-deflist {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
}
.bo-deflist dt {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.bo-deflist dd {
  margin: 0;
  color: var(--text);
}
.bo-card button {
  background: var(--brand-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.bo-card button:hover {
  filter: brightness(1.05);
}

/* Dashboard cards ----------------------------------------------------------- */
.bo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.bo-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.bo-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}
.bo-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.bo-card.is-disabled {
  opacity: 0.75;
}
/* Dashboard card corner badge only — do not share absolute positioning with table status badges. */
.bo-card > .bo-badge {
  position: absolute;
  top: 1rem;
  inset-inline-end: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Login landing (OIDC) ------------------------------------------------------ */
.bo-auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.bo-auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  text-align: center;
  overflow: hidden;
}
.bo-auth-logo {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  margin: 0;
  object-fit: cover;
  background: #0b3d2e;
}
.bo-auth-body {
  padding: 1.5rem 2rem 2rem;
}
.bo-auth-title {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}
.bo-auth-intro {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}
.bo-auth-btn {
  display: block;
  width: 100%;
  background: var(--brand-accent);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-weight: 600;
}
.bo-auth-btn:hover {
  filter: brightness(1.05);
  text-decoration: none;
}
.bo-auth-card .alert {
  margin-bottom: 1rem;
}

@media (max-width: 720px) {
  /* Stack the shell; the desktop sidebar is replaced by the collapsed mobile disclosure bar so we
     never reflow the full nav into a tall wrapped band (the cause of the prior clipping/overlap). */
  .bo-shell {
    flex-direction: column;
  }
  .bo-sidebar {
    display: none;
  }

  /* Mobile disclosure bar (native <details>, collapsed by default). */
  .bo-mobilebar {
    display: block;
    background: #0f172a;
    color: #cbd5e1;
  }
  .theme-hadbet.backoffice .bo-mobilebar {
    background: #344055;
  }
  .bo-mobilebar-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
  }
  /* Hide the native disclosure triangle; we render our own caret on the Menu pill. */
  .bo-mobilebar-summary::-webkit-details-marker {
    display: none;
  }
  .bo-mobilebar-summary .bo-brand {
    padding: 0;
    border: none;
  }
  .bo-menu-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.7rem;
  }
  .bo-menu-label::after {
    content: "\25be"; /* down triangle when collapsed */
  }
  .bo-mobilebar[open] .bo-menu-label::after {
    content: "\25b4"; /* up triangle when expanded */
  }
  .bo-nav--mobile {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
  }
  .bo-nav--mobile a {
    padding: 0.6rem 1rem;
    border-left: 3px solid transparent;
  }
  .bo-nav--mobile .bo-back {
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    border-left: none;
    margin-top: 0.25rem;
    padding: 0.75rem 1rem 0;
  }

  /* Topbar wraps and truncates instead of overflowing on narrow screens. */
  .bo-topbar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
  }
  .bo-user {
    min-width: 0;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Content breathing room + single-column cards so nothing is clipped. */
  .bo-content {
    padding: 1.25rem 1rem;
  }
  .bo-cards {
    grid-template-columns: 1fr;
  }
}

/* Player CRUD forms --------------------------------------------------------- */
.bo-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0 0 0.5rem;
}
.bo-page-header h1 {
  margin: 0;
}
.is-hidden {
  display: none;
}
.bo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}
.bo-topbar {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}
.bo-topbar .logout-form {
  position: relative;
  z-index: 1;
}
.bo-locale {
  display: inline-flex;
  gap: 0.35rem;
  margin-inline-end: 0.5rem;
}
.bo-locale a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  text-decoration: none;
}
.bo-locale a.is-active {
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent);
}
.bo-locale a:hover {
  text-decoration: none;
  color: var(--text);
}

/* RTL shell --------------------------------------------------------------- */
[dir="rtl"] .bo-nav a {
  border-left: none;
  border-right: 3px solid transparent;
}
[dir="rtl"] .bo-nav a.active {
  border-right-color: var(--brand-accent);
  border-left-color: transparent;
}
[dir="rtl"] .bo-card > .bo-badge {
  inset-inline-end: 1rem;
  inset-inline-start: auto;
}
.bo-button {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  background: var(--brand-accent, #2563eb);
  color: #fff;
  border-radius: var(--radius-sm, 4px);
  text-decoration: none;
  font-weight: 600;
}
.bo-form {
  max-width: 36rem;
  display: grid;
  gap: 1rem;
}
.bo-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.bo-label-optional {
  font-weight: 500;
  color: var(--text-muted, #64748b);
  margin-inline-start: 0.25rem;
}
.bo-field input,
.bo-field select,
.bo-field textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm, 4px);
}
.bo-hint {
  display: block;
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.85rem;
}
.bo-username-status {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}
.bo-username-status.is-ok {
  color: #047857;
}
.bo-username-status.is-error {
  color: #b91c1c;
}
.bo-username-status.is-muted {
  color: #64748b;
}
.field-error {
  color: #b91c1c;
  font-size: 0.85rem;
}

/* Tables ------------------------------------------------------------------- */
.bo-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.bo-table th,
.bo-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: middle;
}
.bo-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.bo-table tbody tr:hover {
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.bo-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 0.75rem !important;
}

/* Tabs / filter chips ------------------------------------------------------ */
.bo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.bo-tabs a {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm, 4px);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.bo-tabs a:hover {
  text-decoration: none;
  background: var(--bg);
  color: var(--text);
}
.bo-tabs a.is-active {
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent);
}

/* Status / role badges ----------------------------------------------------- */
.bo-badge,
.bo-badge-role {
  position: static;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.bo-badge--ok {
  background: color-mix(in srgb, #10b981 15%, transparent);
  color: #047857;
  border-color: color-mix(in srgb, #10b981 35%, transparent);
}
.bo-badge--warn {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #b45309;
  border-color: color-mix(in srgb, #f59e0b 40%, transparent);
}
.bo-badge--muted {
  opacity: 0.9;
}
.bo-badge-role {
  background: color-mix(in srgb, var(--brand-accent) 10%, transparent);
  color: var(--brand-accent-strong, var(--brand-accent));
  border-color: color-mix(in srgb, var(--brand-accent) 30%, transparent);
}

/* Honesty / flash banners -------------------------------------------------- */
.bo-banner {
  margin: 0;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.bo-banner--warn {
  background: #fffbeb;
  color: #92400e;
  border-bottom-color: #fcd34d;
}
.bo-banner code {
  font-size: 0.85em;
}
.bo-flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm, 4px);
  background: color-mix(in srgb, #10b981 12%, transparent);
  color: #065f46;
  margin: 0 0 1rem;
}
.bo-flash-error {
  background: color-mix(in srgb, #ef4444 12%, transparent);
  color: #991b1b;
}
.bo-flash-credential {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}
.bo-otp-copy {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin: 0.35rem 0 0;
  padding: 0.4rem 0.65rem;
  border: 1px solid #93c5fd;
  border-radius: 0.375rem;
  background: #dbeafe;
  color: inherit;
  cursor: pointer;
  text-align: start;
  max-width: 100%;
}
.bo-otp-copy:hover {
  background: #bfdbfe;
}
.bo-otp-copy:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.bo-otp-copy code {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  word-break: break-all;
}
.bo-otp-copy-status {
  font-size: 0.75rem;
  opacity: 0.85;
}
.bo-flash-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
  margin: 0 0 0.75rem;
}
.bo-section {
  margin-block: 1.25rem 1.75rem;
  max-width: 48rem;
}
.bo-section + .bo-section {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}
.bo-two-col {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-block: 1.25rem 1.75rem;
}
.bo-two-col > .bo-section {
  max-width: none;
  margin-block: 0;
}
.bo-two-col > .bo-section + .bo-section {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}
/* Wide section: drop the default 48rem cap (e.g. keys table + filter aside). */
.bo-section--wide {
  max-width: none;
}
/* Main (70%) + aside (30%). Form-first DOM stacks filters above content on narrow viewports;
   ≥960px places main in column 1 and aside in column 2. Grid columns follow document direction
   (inline-start → inline-end), so RTL reverses physical left/right without hardcoded sides. */
.bo-main-aside {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
.bo-main-aside > .bo-main-aside__aside {
  max-width: none;
}
@media (min-width: 960px) {
  .bo-two-col {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .bo-two-col > .bo-section + .bo-section {
    border-top: none;
    padding-top: 0;
  }
  .bo-main-aside {
    grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
    align-items: start;
  }
  .bo-main-aside > .bo-main-aside__main {
    grid-column: 1;
  }
  .bo-main-aside > .bo-main-aside__aside {
    grid-column: 2;
  }
}
.bo-section-status:empty {
  display: none;
}
.bo-section-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.htmx-indicator {
  display: none;
  color: var(--text-muted, #64748b);
  font-size: 0.9rem;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}
.bo-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Quick Edit native dialog ------------------------------------------------- */
.bo-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: min(36rem, calc(100vw - 2rem));
  width: 100%;
  color: inherit;
  background: var(--surface, #fff);
  box-shadow: 0 18px 48px color-mix(in srgb, #0f172a 22%, transparent);
}
.bo-dialog::backdrop {
  background: color-mix(in srgb, #0f172a 45%, transparent);
}
.bo-dialog-body {
  max-height: min(85vh, 52rem);
  overflow: auto;
}
.bo-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 1;
}
.bo-dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}
.bo-dialog-close {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font: inherit;
}
.bo-dialog-content {
  padding: 1rem 1.25rem 1.25rem;
}
.bo-dialog-lede,
.bo-dialog-footer-note {
  color: var(--text-muted, #64748b);
  font-size: 0.92rem;
  margin: 0 0 1rem;
}
.bo-dialog-footer-note {
  margin-top: 1.25rem;
  margin-bottom: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.bo-quick-edit .bo-section {
  max-width: none;
  margin-block: 0.75rem 1.25rem;
}
.bo-quick-edit .bo-section + .bo-section {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}
.bo-link-button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent, #1d4ed8);
  cursor: pointer;
  text-decoration: underline;
}
.bo-table .bo-actions {
  margin: 0;
  gap: 0.65rem 0.85rem;
}

/* Page-local bulk lifecycle ------------------------------------------------ */
.bo-bulk-col {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}
.bo-bulk-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}
.bo-bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 0.85rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand-accent, #1d4ed8) 6%, var(--surface, #fff));
}
.bo-bulk-toolbar[hidden] {
  display: none !important;
}
.bo-bulk-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  width: 100%;
  margin: 0;
}
.bo-bulk-count {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted, #64748b);
}
.bo-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.bo-button--danger {
  background: var(--error-text, #b91c1c);
  border-color: var(--error-text, #b91c1c);
  color: #fff;
}
.bo-button--danger:hover {
  filter: brightness(0.95);
}
.bo-bulk-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.bo-bulk-delete-confirm label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
}
.bo-bulk-delete-input {
  max-width: 16rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  font: inherit;
}

/* Hierarchy tree ----------------------------------------------------------- */
.bo-tree-panel {
  margin: 0 0 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bo-tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.75rem;
}
.bo-tree-item {
  margin: 0.15rem 0;
}
.bo-tree-node > summary {
  cursor: pointer;
  list-style: none;
}
.bo-tree-node > summary::-webkit-details-marker {
  display: none;
}
.bo-tree-node > summary::before {
  content: "▸ ";
  color: var(--text-muted);
}
.bo-tree-node[open] > summary::before {
  content: "▾ ";
}
.bo-tree-leaf {
  /* Match summary text offset after the disclosure chevron so leaf labels align. */
  padding-left: 1.1em;
}

/* Reports KPI + chart ------------------------------------------------------ */
.bo-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.bo-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.bo-kpi h3 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.bo-kpi-value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.bo-chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  max-width: 640px;
}
.bo-chart-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}
.bo-inline-form {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin-right: 0.35rem;
}

/* Connection / status super-row — wrapping label-above-value cells, no card chrome */
.bo-super-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1.25rem;
  margin: 0.75rem 0 1.25rem;
}
.bo-super-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 7.5rem;
  max-width: 100%;
}
.bo-super-cell--action {
  min-width: auto;
  margin-inline-start: auto;
}
.bo-super-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bo-super-value {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-word;
}
.bo-page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Agent / Manager detail+edit: Profile | Manage two-panel shell */
.bo-entity-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-block: 1rem 1.75rem;
  width: 100%;
  max-width: none;
}
.bo-entity-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.bo-entity-group__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
}
.bo-entity-subgroup {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.1rem 1.15rem;
  background: var(--surface, #fff);
  min-width: 0;
}
.bo-entity-subgroup > h3,
.bo-entity-subgroup > .bo-entity-subgroup__title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.bo-entity-subgroup .bo-section {
  margin-block: 0;
  max-width: none;
}
.bo-entity-subgroup .bo-section + .bo-section {
  border-top: none;
  padding-top: 0;
}
.bo-entity-subgroup .bo-deflist {
  margin: 0;
}
.bo-entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}
.bo-field-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.bo-field-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted, #64748b);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  background: transparent;
  padding: 0;
}
.bo-field-info:focus-visible {
  outline: 2px solid var(--focus, #2563eb);
  outline-offset: 2px;
}
@media (min-width: 960px) {
  .bo-entity-layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
