/*
 * 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;
}
/* Operator Money under impersonation: dimmed but still clickable (read/config). */
.bo-nav a.is-secondary {
  color: #94a3b8;
  opacity: 0.72;
}
.bo-nav a.is-secondary:hover {
  opacity: 1;
  color: #e2e8f0;
}
.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-subsection.is-secondary {
  opacity: 0.55;
}
.bo-nav a.bo-nav-leaf {
  padding-inline-start: 2.75rem;
}
.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;
}

/* Branded error shell (ADR-011) — reuses the auth card so /error never needs layout chrome. */
.bo-error-status {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.bo-error-reference {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
}
.bo-error-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.bo-error-btn-secondary {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-weight: 600;
}
.bo-error-btn-secondary:hover {
  background: var(--bg);
  text-decoration: none;
}
.bo-auth-btn:focus-visible,
.bo-error-btn-secondary:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
}

@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-menu {
  position: relative;
  display: inline-block;
  margin-inline-end: 0.5rem;
}
.bo-locale-menu-summary {
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent);
}
.bo-locale-menu-summary::-webkit-details-marker {
  display: none;
}
.bo-locale-menu-list {
  position: absolute;
  inset-inline-end: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 10rem;
  margin-top: 0.25rem;
  padding: 0.25rem;
  border-radius: 6px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}
.bo-locale-menu-list a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.35rem 0.55rem;
  border-radius: 4px;
  text-decoration: none;
}
.bo-locale-menu-list a.is-active {
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent);
}
.bo-locale-menu-list a:hover,
.bo-locale-menu-list a:focus-visible {
  text-decoration: none;
  color: var(--text);
}
html[lang="zh"] .bo-content,
html[lang="ja"] .bo-content {
  word-break: break-word;
  overflow-wrap: anywhere;
}
html[lang="ar"] .bo-content {
  overflow-wrap: anywhere;
}

/* 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,
.bo-tabs a.is-pressed,
.bo-tabs a[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent);
}
.bo-tabs.bo-filter-group {
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.35rem;
}

.bo-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.bo-filter-bar .bo-tabs {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}
.bo-sort-group .bo-sort-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-inline-end: 0.25rem;
}

/* 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--block {
  background: color-mix(in srgb, #ef4444 16%, transparent);
  color: #b91c1c;
  border-color: color-mix(in srgb, #ef4444 38%, transparent);
}
.bo-badge--muted {
  opacity: 0.9;
}
.bo-badge--e2e {
  background: color-mix(in srgb, #6366f1 16%, transparent);
  color: #4338ca;
  border-color: color-mix(in srgb, #6366f1 38%, transparent);
}
.bo-tree-item.is-context > .bo-tree-node > summary > .bo-directory-node-link,
.bo-tree-item.is-context > .bo-tree-leaf > .bo-directory-node-link {
  opacity: 0.72;
}
.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;
}

/* Operator→Manager impersonation chrome (body.bo-impersonating) ------------ */
body.bo-impersonating .bo-sidebar {
  box-shadow: inset 4px 0 0 #d97706;
}
body.bo-impersonating .bo-nav-section--acting-as {
  color: #fbbf24;
  margin-top: 1rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(251, 191, 36, 0.28);
}
body.bo-impersonating .bo-nav-leaf--as-manager {
  color: #fde68a;
  border-inline-start-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
body.bo-impersonating .bo-nav-leaf--as-manager:hover {
  background: rgba(245, 158, 11, 0.16);
  color: #fffbeb;
}
body.bo-impersonating .bo-impersonation-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  background: linear-gradient(90deg, #fff7ed 0%, #fffbeb 55%, #fef3c7 100%);
  color: #9a3412;
  border-bottom: 2px solid #f59e0b;
  font-weight: 500;
}
body.bo-impersonating .bo-impersonation-exit {
  display: inline;
  margin-inline-start: auto;
}
body.bo-impersonating .bo-content {
  border-top: 3px solid #f59e0b;
}
.bo-acting-as-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
}
.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;
}
button.bo-button.bo-button--danger,
button[type="submit"].bo-button--danger,
.bo-button.bo-button--danger {
  background: var(--error-text, #b91c1c);
  border-color: var(--error-text, #b91c1c);
  color: #fff;
}
button.bo-button.bo-button--danger:hover,
button[type="submit"].bo-button--danger:hover,
.bo-button.bo-button--danger:hover {
  filter: brightness(0.95);
  background: var(--error-text, #b91c1c);
}
.bo-button--secondary {
  background: transparent;
  color: var(--text, #0f172a);
  border: 1px solid var(--border, #cbd5e1);
}
.bo-button--secondary:hover {
  background: color-mix(in srgb, var(--brand-accent, #2563eb) 8%, transparent);
}
.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 {
  /* Logical inset matches the disclosure chevron so RTL/LTR leaves align. */
  padding-inline-start: 1.1em;
}

/* Users directory workspace (ADR-013) -------------------------------------- */
.bo-directory {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}
.bo-directory-nav-wrap {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bo-directory-nav-summary {
  cursor: pointer;
  font-weight: 600;
}
.bo-directory-nav {
  margin-block-start: 0.75rem;
  max-height: 18rem;
  overflow: auto;
}
.bo-directory-search {
  margin-block-start: 0.75rem;
}
.bo-directory-search-label {
  display: block;
  margin-block-end: 0.35rem;
  color: var(--text-muted);
}
.bo-directory-search input[type="search"] {
  width: 100%;
  max-width: 24rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  font: inherit;
}
.bo-directory-search-results {
  margin-block-start: 0.5rem;
}
.bo-directory-hits {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bo-directory-hits a {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  padding: 0.35rem 0;
  text-decoration: none;
}
.bo-directory-hit-user,
.bo-directory-hit-parent,
.bo-directory-hint,
.bo-directory-empty {
  color: var(--text-muted);
}
.bo-directory-pane {
  min-width: 0;
}
.bo-directory-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
}
.bo-directory-count {
  display: inline-block;
  margin-inline-start: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--border);
  font-size: 0.8em;
}
.bo-tree-item.is-current > .bo-tree-node > summary > .bo-directory-node-link,
.bo-tree-item.is-current > .bo-tree-leaf > .bo-directory-node-link {
  font-weight: 700;
  text-decoration: underline;
}
.bo-directory-node-link:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}
.bo-tree {
  padding-inline-start: 0.75rem;
  padding-inline-end: 0;
}
.bo-directory-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-block-start: 1rem;
}
.bo-account-cell,
.bo-status-cell,
.bo-funds-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}
.bo-account-user,
.bo-account-email,
.bo-funds-na {
  color: var(--text-muted);
  font-size: 0.9em;
}
.bo-funds-readiness {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9em;
}
@media (max-width: 720px) {
  .bo-table--workspace th:nth-child(n+4),
  .bo-table--workspace td:nth-child(n+4) {
    min-width: 10rem;
  }
}
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request {
  display: inline;
}
@media (min-width: 960px) {
  .bo-directory {
    display: grid;
    grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
    align-items: start;
    gap: 1.25rem;
  }
  .bo-directory-nav-wrap {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .bo-directory-nav-summary {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .bo-directory-nav {
    flex: 1 1 auto;
    max-height: none;
    overflow: auto;
  }
}

/* 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-insight-mix-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1rem 1.25rem;
  align-items: start;
  margin: 0 0 1.25rem;
}
.bo-insight-mix-row > .bo-section {
  max-width: none;
  margin-block: 0;
  padding: 1rem 1.15rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
}
.bo-insight-mix-row > .bo-section + .bo-section {
  padding-top: 1rem;
}
.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-personal-details {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem 1rem 0.85rem;
  background: var(--surface, #fff);
  min-width: 0;
}
.bo-personal-details > summary {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 0;
  list-style: disclosure-closed;
}
.bo-personal-details[open] > summary {
  list-style: disclosure-open;
  margin-bottom: 0.35rem;
}
.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;
  }
}
.bo-field-help {
  margin: 0.35rem 0 0;
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
  line-height: 1.4;
}
.bo-currency-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.bo-currency-search input {
  min-width: 12rem;
  max-width: 24rem;
  flex: 1 1 12rem;
}
#operational-currencies-table .bo-inline-form {
  display: inline-flex;
  margin-inline-end: 0.35rem;
}
#operational-currencies-table th button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  font-weight: inherit;
  cursor: pointer;
  text-align: inherit;
}
#operational-currencies-table th button:hover,
#operational-currencies-table th button:focus-visible {
  color: var(--text);
}
#operational-currencies-table th[aria-sort="ascending"] button::after {
  content: " \2191";
}
#operational-currencies-table th[aria-sort="descending"] button::after {
  content: " \2193";
}
#operational-currencies-table [data-currency-status-filter]:not([data-currency-status-filter="off"]) {
  color: var(--text);
}
.bo-wizard-steps ol {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}
.bo-wizard-steps li {
  display: flex;
  align-items: center;
  flex: 1 1 8rem;
  min-width: 0;
  padding: 0;
}
.bo-wizard-steps li + li::before {
  content: "";
  flex: 1 1 1.5rem;
  height: 2px;
  margin-inline: 0.35rem;
  background: var(--border, #cbd5e1);
  align-self: flex-start;
  margin-top: 0.85rem;
}
.bo-wizard-steps li.is-complete + li::before,
.bo-wizard-steps li.is-current + li::before {
  background: var(--brand-accent, #2563eb);
}
.bo-wizard-steps a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.bo-wizard-steps__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 1.7rem;
  border-radius: 999px;
  border: 2px solid var(--border, #cbd5e1);
  font-size: 0.8rem;
  font-weight: 700;
}
.bo-wizard-steps li.is-complete .bo-wizard-steps__marker {
  background: var(--brand-accent, #2563eb);
  border-color: var(--brand-accent, #2563eb);
  color: #fff;
}
.bo-wizard-steps li.is-current .bo-wizard-steps__marker {
  border-color: var(--brand-accent, #2563eb);
  color: var(--brand-accent, #2563eb);
}
.bo-wizard-steps li.is-upcoming .bo-wizard-steps__label {
  color: var(--text-muted, #64748b);
}
.bo-wizard-steps li.is-current a {
  font-weight: 700;
}
.bo-wizard-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  padding: 1.25rem 1.35rem;
  margin: 0 0 1.25rem;
}
.bo-wizard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}
.bo-wizard-discovery {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e2e8f0);
}
.bo-field-provenance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
}
.bo-checklist {
  list-style: none;
  padding: 0;
}
.bo-checklist li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.55rem 0;
}
.bo-checklist li.is-blocker {
  color: var(--danger, #b91c1c);
}
.bo-checklist li.is-warning {
  color: var(--warn, #a16207);
}

/* HAD website workspace ---------------------------------------------------- */
.bo-had-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem 1.25rem;
  align-items: start;
  margin: 0 0 1.25rem;
}
.bo-had-section-card.bo-wizard-panel {
  margin: 0;
  height: 100%;
}
.bo-had-section-card .bo-form {
  max-width: none;
}
@media (min-width: 48rem) {
  .bo-had-section-card--wide {
    grid-column: span 2;
  }
}
.bo-had-section-result {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.bo-had-section-result--ok {
  color: #047857;
}
.bo-had-section-result--error {
  color: var(--error-text, #b91c1c);
}
.bo-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  padding: 1.25rem 1.35rem;
  margin: 0 0 1.25rem;
}
.bo-treasury-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
  margin: 0 0 1.25rem;
}
.bo-treasury-stack {
  display: grid;
  gap: 1rem;
  align-content: start;
}
.bo-treasury-row .bo-panel,
.bo-treasury-row > .bo-section {
  margin: 0;
}
@media (min-width: 901px) {
  .bo-treasury-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  }
}
.bo-fund-mgmt-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.bo-fund-mgmt-row .bo-panel {
  margin: 0;
}
.bo-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.bo-section-head h2 {
  margin: 0;
}
@media (max-width: 900px) {
  .bo-fund-mgmt-row {
    grid-template-columns: 1fr;
  }
}
.bo-dl {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
  gap: 0.55rem 1rem;
  margin: 0;
}
.bo-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}
.bo-dl dd {
  margin: 0;
}
.bo-had-website-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
}
.bo-had-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}
.bo-dialog--wide {
  max-width: min(64rem, calc(100vw - 2rem));
}
.bo-dialog--wide .bo-dialog-body {
  max-height: min(90vh, 56rem);
}
.bo-had-quick-edit {
  padding: 0 1.25rem 1.25rem;
}
.bo-had-quick-edit__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin: 0 0 1rem;
}
.bo-had-quick-edit .bo-had-section-grid {
  margin-bottom: 1rem;
}
button.bo-button.bo-button--warn,
button[type="submit"].bo-button--warn,
.bo-button.bo-button--warn {
  background: #b45309;
  border-color: #b45309;
  color: #fff;
}
button.bo-button.bo-button--warn:hover,
button[type="submit"].bo-button--warn:hover,
.bo-button.bo-button--warn:hover {
  filter: brightness(0.95);
  background: #b45309;
}
.bo-button__icon {
  margin-inline-end: 0.35rem;
}
.bo-readiness {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
}
.bo-readiness-lede {
  margin: 0 0 0.75rem;
  font-weight: 600;
}
.bo-readiness-groups {
  display: grid;
  gap: 0.75rem;
}
.bo-readiness-card {
  background: #fff;
  border: 1px solid #fcd34d;
  padding: 0.75rem;
}
.bo-readiness-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.bo-readiness-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}
.bo-readiness-chip {
  background: #fef3c7;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
}
.bo-readiness-details,
.bo-readiness-warnings {
  margin-top: 0.5rem;
}
.bo-readiness-details ul {
  margin: 0.35rem 0 0;
  padding-inline-start: 1.1rem;
}
