:root {
  --sidebar: #0f1c33;
  --sidebar-soft: #1a2a45;
  --canvas: #f4f7fb;
  --ink: #172033;
  --muted: #6c7890;
  --brand: #2856d8;
  --line: #e4e9f2;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.eyebrow {
  color: #75829a;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 10% 10%, rgba(58, 111, 255, .22), transparent 32%),
    radial-gradient(circle at 90% 85%, rgba(63, 204, 188, .14), transparent 35%),
    linear-gradient(135deg, #0a1428, #152642 54%, #0c1a31);
}

.login-panel {
  width: min(500px, 100%);
  padding: 2.6rem;
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, .97);
}

.auth-tabs {
  padding: .25rem;
  border-radius: .75rem;
  background: #edf2fa;
}

.auth-tabs .nav-link {
  padding: .55rem .45rem;
  color: #637089;
  font-size: .82rem;
  font-weight: 700;
}

.auth-tabs .nav-link.active {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 .35rem .85rem rgba(40, 86, 216, .22);
}

.email-code-button {
  min-width: 7.5rem;
}

.captcha-gate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.75rem;
  font-weight: 600;
}

.captcha-gate-button.is-passed {
  color: #0f7a43;
  border-color: #8fd6ad;
  background: #eefaf3;
}

.captcha-modal-content {
  border: 0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1rem 2.5rem rgba(20, 36, 72, .18);
}

.captcha-modal-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .4rem;
  padding: .65rem .8rem 0;
}

.captcha-stage {
  position: relative;
  margin: .35rem 1rem 0;
  border-radius: .85rem;
  background: #e8edf5;
  overflow: hidden;
  cursor: crosshair;
  user-select: none;
}

.captcha-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: contain;
  pointer-events: none;
}

.captcha-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .72);
  color: #5b6b84;
  font-weight: 600;
}

.captcha-prompt {
  margin: .85rem 1rem 1.1rem;
  padding: .75rem .9rem;
  border-radius: .75rem;
  background: #f3f6fb;
  color: #243352;
  font-weight: 700;
  text-align: center;
}

.captcha-feedback {
  margin: -.35rem 1rem 1rem;
  text-align: center;
  font-size: .92rem;
}

.captcha-feedback.is-error {
  color: #b42318;
}

.captcha-feedback.is-success {
  color: #0f7a43;
}

.captcha-stage.is-shake {
  animation: captcha-shake .35s linear;
}

@keyframes captcha-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.login-panel h1 {
  font-size: 2rem;
  font-weight: 750;
}

.brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  margin-bottom: 1.3rem;
  border-radius: 1rem;
  color: #fff;
  background: linear-gradient(145deg, #3469ef, #173da8);
  box-shadow: 0 .7rem 1.8rem rgba(38, 82, 200, .28);
  font-size: 1.35rem;
}

.brand-mark-sm {
  width: 2.55rem;
  height: 2.55rem;
  margin: 0;
  border-radius: .75rem;
  box-shadow: none;
}

.security-note {
  margin-top: 1.35rem;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
}

.app-shell.d-none {
  display: none !important;
}

.boot-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--canvas);
}

.boot-panel {
  text-align: center;
}

/* Optimistic shell restore before app.js finishes /auth/csrf. */
html[data-auth-boot="app"] #bootView,
html[data-auth-boot="app"] #loginView {
  display: none !important;
}

html[data-auth-boot="app"] #appView {
  display: block !important;
}

@media (min-width: 992px) {
  html[data-auth-boot="app"] #appView {
    display: grid !important;
  }
}

/*
 * Super-admin nav stays hidden until role is known.
 * Early head script sets data-auth-role from sessionStorage so refresh
 * does not flash 会员管理 / 调试预警 for ordinary members.
 */
.sidebar-nav .super-admin-only {
  display: none !important;
}

html[data-auth-role="super_admin"] .sidebar-nav a.nav-link.super-admin-only {
  display: flex !important;
}

html[data-auth-role="super_admin"] .sidebar-nav .nav-section.super-admin-only {
  display: block !important;
}

html[data-auth-role="agent"] .sidebar-nav .coupon-nav,
html[data-auth-role="super_admin"] .sidebar-nav .coupon-nav {
  display: flex !important;
}

.sidebar {
  --bs-offcanvas-bg: var(--sidebar);
  width: 270px !important;
  color: #fff;
  background-color: var(--sidebar) !important;
  border: 0;
}

.sidebar-head {
  height: 82px;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-head strong,
.sidebar-head small {
  display: block;
}

.sidebar-head small {
  color: rgba(255, 255, 255, .5);
  font-size: .7rem;
}

.sidebar-nav {
  gap: .28rem;
  padding: 1.25rem .85rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .72rem .85rem;
  border-radius: .65rem;
  color: rgba(255, 255, 255, .68);
  font-size: .9rem;
  font-weight: 600;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, #315fd9, #274db6);
  box-shadow: 0 .55rem 1.3rem rgba(13, 33, 84, .35);
}

.nav-section {
  padding: 1.25rem .85rem .35rem;
  color: rgba(255, 255, 255, .35);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.sidebar-foot {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  background: var(--sidebar-soft);
}

.user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #14346e;
  background: #bcd2ff;
  font-weight: 800;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-meta strong,
.user-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  color: rgba(255, 255, 255, .45);
  font-size: .7rem;
}

.content-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  margin: .1rem 0 0;
  font-size: 1.35rem;
  font-weight: 750;
}

.page-content {
  padding: clamp(1rem, 3vw, 2.5rem);
}

.metric-card,
.panel-card {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: #fff;
  box-shadow: 0 .35rem 1.25rem rgba(31, 45, 74, .045);
}

.metric-card {
  padding: 1.25rem;
}

.metric-card .metric-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: .75rem;
  color: var(--brand);
  background: #eaf0ff;
}

.metric-card strong {
  display: block;
  margin-top: 1rem;
  font-size: 1.65rem;
}

.metric-card span {
  color: var(--muted);
  font-size: .82rem;
}

.panel-card {
  padding: 1.25rem;
}

/* 表格行内「操作」菜单会 portal 到 body（见 installTableDropdownPortal），
   避免 .table-responsive 裁切；手机端不再用 overflow:visible，防止宽表撑出视口。 */
.dropdown-menu[data-gow64-portal="1"] {
  z-index: 1080;
  max-width: calc(100vw - 1rem);
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table th {
  color: #738097;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  color: #263247;
  font-size: .84rem;
  vertical-align: middle;
}

.code-cell {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .75rem;
}

.binding-id-tip {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  font-size: .95rem;
  text-decoration: none !important;
}

.binding-id-tip:focus,
.binding-id-tip:hover {
  color: var(--brand) !important;
}

.popover .user-select-all {
  font-size: .78rem;
  word-break: break-all;
}

.empty-state {
  padding: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}

.empty-state i {
  display: block;
  margin-bottom: .8rem;
  font-size: 2.2rem;
  opacity: .45;
}

.btn-icon {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

@media (min-width: 992px) {
  .app-shell:not(.d-none) {
    display: grid !important;
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none !important;
    visibility: visible !important;
  }
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
  }

  .login-panel {
    padding: 2rem 1.4rem;
  }
}

.payment-modal-content {
  overflow: hidden;
}

.payment-frame {
  display: block;
  width: 100%;
  height: min(70vh, 640px);
  border: 0;
  background: #f8fafc;
}

/* bzconfig editor + AI Coding — fullscreen modal overlay */
body.bz-editor-open {
  overflow: hidden;
}

.bz-shell {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #e8edf5;
  overflow: hidden;
}

.bz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: .75rem 1rem;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  flex-shrink: 0;
  /* panel-card defaults to height:100%; that would swallow the whole modal. */
  height: auto;
}

.bz-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}

.bz-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--bz-files-w, 240px) minmax(0, 1fr) var(--bz-chat-w, 380px);
  gap: 0;
  align-items: stretch;
  transition: grid-template-columns .2s ease;
}

.bz-shell.bz-files-collapsed {
  --bz-files-w: 0px;
}

.bz-shell.bz-chat-collapsed {
  --bz-chat-w: 0px;
}

.bz-body > * {
  min-height: 0;
  min-width: 0;
}

.bz-files,
.bz-code,
.bz-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  box-shadow: none;
}

.bz-shell > .bz-body > .panel-card {
  height: 100%;
}

.bz-files {
  border-right: 1px solid var(--line);
}

.bz-chat {
  position: relative;
  border-left: 1px solid var(--line);
}

.bz-chat-resizer {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}

.bz-chat-resizer:hover,
.bz-shell.bz-dragging .bz-chat-resizer {
  background: rgba(47, 91, 255, .28);
}

.bz-shell.bz-dragging {
  user-select: none;
  cursor: col-resize;
}

.bz-shell.bz-dragging .bz-body {
  transition: none;
}

.ai-msg-user-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(31, 45, 74, .12);
  background: #eaf0ff;
  border-color: #9eb6ff;
}

.bz-shell.bz-files-collapsed .bz-files,
.bz-shell.bz-chat-collapsed .bz-chat {
  border: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
}

.bz-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}

.bz-pane-head-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bz-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
}

.bz-collapse-btn {
  flex-shrink: 0;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #f7f9fc;
  color: #4a5568;
  font-size: .85rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}

.bz-collapse-btn:hover {
  background: #e8eeff;
  color: var(--brand, #2f5bff);
  border-color: #c9d6ff;
}

.bz-rail {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 1.55rem;
  min-height: 4.5rem;
  padding: .45rem .15rem;
  border: 1px solid var(--line);
  background: #fff;
  color: #40506a;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  box-shadow: 0 .25rem .75rem rgba(31, 45, 74, .08);
  display: none;
  align-items: center;
  justify-content: center;
  gap: .25rem;
}

.bz-rail:hover {
  background: #eef3ff;
  color: var(--brand, #2f5bff);
}

.bz-rail-files {
  left: 0;
  border-radius: 0 .5rem .5rem 0;
  border-left: 0;
}

.bz-rail-chat {
  right: 0;
  border-radius: .5rem 0 0 .5rem;
  border-right: 0;
}

.bz-shell.bz-files-collapsed .bz-rail-files,
.bz-shell.bz-chat-collapsed .bz-rail-chat {
  display: inline-flex;
}

.bz-code {
  position: relative;
}

.bz-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: .35rem;
  -webkit-overflow-scrolling: touch;
}

.bz-topbar-more {
  display: none;
}

.bz-file {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  border: 0;
  background: transparent;
  text-align: left;
  padding: .4rem .5rem;
  border-radius: .4rem;
  font-size: .8rem;
  color: var(--ink);
}

.bz-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bz-file small {
  flex-shrink: 0;
  color: var(--muted);
}

.bz-file:hover {
  background: #f1f4fa;
}

.bz-file.active {
  background: #e8eeff;
  font-weight: 600;
}

.bz-code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.bz-code-head-left {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}

.bz-code-head-left strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bz-code-badges {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.bz-badge {
  font-size: .76rem;
  color: var(--muted);
}

.bz-badge[data-kind="ok"],
.ai-status[data-kind="ok"] {
  color: #0f7b4a;
}

.bz-badge[data-kind="warn"],
.ai-status[data-kind="warn"] {
  color: #92670a;
}

.bz-badge[data-kind="danger"],
.ai-status[data-kind="danger"] {
  color: #b42318;
}

.bz-monaco {
  flex: 1;
  min-height: 0;
}

.bz-code-foot {
  padding: .5rem 1rem;
  border-top: 1px solid var(--line);
}

.ai-status {
  padding: .45rem 1rem;
  font-size: .78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.ai-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: .7rem;
  background: linear-gradient(180deg, #f7f9fc, #eef2f9);
}

.ai-msg {
  margin-bottom: .6rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  font-size: .83rem;
  overflow-wrap: anywhere;
}

.ai-msg-body {
  white-space: pre-wrap;
}

.ai-msg-user {
  background: #f2f6ff;
  border-color: #ccdaff;
}

.ai-msg-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .74rem;
  color: #46506a;
}

.ai-msg-system {
  color: #5a6478;
}

/* Rendered Markdown inside assistant bubbles */
.ai-msg-body.ai-md {
  white-space: normal;
  line-height: 1.45;
}

.ai-msg-body.ai-md.ai-md-streaming {
  white-space: pre-wrap;
}

.ai-md > :first-child {
  margin-top: 0;
}

.ai-md > :last-child {
  margin-bottom: 0;
}

.ai-md p,
.ai-md ul,
.ai-md ol,
.ai-md pre,
.ai-md blockquote,
.ai-md table {
  margin: 0 0 .55em;
}

.ai-md h1,
.ai-md h2,
.ai-md h3,
.ai-md h4 {
  margin: .7em 0 .35em;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.3;
}

.ai-md h1 { font-size: 1.1em; }
.ai-md h2 { font-size: 1.05em; }

.ai-md ul,
.ai-md ol {
  padding-left: 1.35em;
}

.ai-md li {
  margin: .15em 0;
}

.ai-md li > p {
  margin: 0;
}

.ai-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  padding: .1em .35em;
  border-radius: .25rem;
  background: #eef1f7;
  color: #2b3348;
}

.ai-md pre {
  padding: .55rem .65rem;
  border-radius: .4rem;
  background: #1e2433;
  color: #e8ecf5;
  overflow: auto;
  max-height: 16rem;
}

.ai-md pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: .78rem;
  white-space: pre;
}

.ai-md blockquote {
  margin-left: 0;
  padding: .15rem .7rem;
  border-left: 3px solid #c5cede;
  color: #5a6478;
  background: #f7f9fc;
}

.ai-md a {
  color: #2f5bff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  display: block;
  overflow-x: auto;
}

.ai-md th,
.ai-md td {
  border: 1px solid var(--line);
  padding: .25rem .4rem;
  text-align: left;
}

.ai-md th {
  background: #f2f5fb;
  font-weight: 600;
}

.ai-md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: .7em 0;
}

.ai-msg-blocked {
  background: #fff5f5;
  border-color: #f1aeb5;
  box-shadow: inset 3px 0 0 #dc3545;
}

.ai-msg-blocked .ai-msg-role {
  color: #b02a37;
}

.ai-msg-blocked .ai-msg-role::after {
  content: " · 已拦截";
}

.ai-msg-role {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .2rem;
}

.ai-compose {
  padding: .7rem;
  border-top: 1px solid var(--line);
}

.ai-compose-actions {
  display: flex;
  gap: .4rem;
  margin-top: .5rem;
  align-items: stretch;
}

.ai-run-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-width: 5.5rem;
  font-weight: 600;
}

.ai-run-btn .bi {
  font-size: 1rem;
  line-height: 1;
}

.ai-run-btn.ai-run-busy {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}

.ai-compose-meta {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .5rem;
}

@media (max-width: 1400px) {
  .bz-shell:not(.bz-files-collapsed) {
    --bz-files-w: 200px;
  }

  .bz-shell:not(.bz-chat-collapsed) {
    --bz-chat-w: 320px;
  }
}

@media (max-width: 900px) {
  /* Phone / narrow tablet: editor fills the viewport; files & AI are overlays. */
  .bz-shell {
    padding:
      env(safe-area-inset-top, 0)
      env(safe-area-inset-right, 0)
      env(safe-area-inset-bottom, 0)
      env(safe-area-inset-left, 0);
  }

  .bz-topbar {
    align-items: center;
    gap: .55rem;
    padding: .55rem .7rem;
  }

  .bz-topbar-info h5 {
    font-size: .95rem;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bz-topbar-actions {
    gap: .3rem;
  }

  .bz-topbar-actions .bz-action-secondary {
    display: none;
  }

  .bz-topbar-more {
    display: inline-flex;
  }

  .bz-chat-resizer,
  .bz-rail,
  .bz-code-foot {
    display: none !important;
  }

  .bz-body {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  .bz-shell.bz-files-collapsed,
  .bz-shell.bz-chat-collapsed {
    --bz-files-w: 0px;
    --bz-chat-w: 0px;
  }

  .bz-code {
    grid-area: 1 / 1;
    height: 100%;
    min-height: 0;
    border: 0;
    z-index: 1;
  }

  .bz-monaco {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .bz-code-head {
    gap: .45rem;
    padding: .45rem .6rem;
  }

  .bz-code-head-left {
    gap: .35rem;
  }

  .bz-code-badges {
    gap: .35rem;
    align-items: center;
  }

  .bz-badge {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bz-mobile-toggle {
    display: inline-grid !important;
    width: auto;
    min-width: 2.4rem;
    padding: 0 .45rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
  }

  .bz-desktop-toggle {
    display: none !important;
  }

  .bz-mobile-backdrop {
    display: none;
    grid-area: 1 / 1;
    z-index: 3;
    border: 0;
    background: rgba(20, 28, 45, .42);
    backdrop-filter: blur(1px);
  }

  .bz-shell.bz-overlay-open .bz-mobile-backdrop {
    display: block;
  }

  .bz-files,
  .bz-chat {
    grid-area: 1 / 1;
    height: 100%;
    min-height: 0;
    border: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform .2s ease, opacity .18s ease;
  }

  .bz-files {
    position: relative;
    z-index: 4;
    width: min(86vw, 320px);
    max-width: 100%;
    justify-self: start;
    box-shadow: 10px 0 28px rgba(31, 45, 74, .22);
    border-right: 1px solid var(--line);
    transform: translateX(0);
  }

  .bz-shell.bz-files-collapsed .bz-files {
    display: flex;
    transform: translateX(calc(-100% - 12px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .bz-chat {
    position: relative;
    z-index: 5;
    width: 100%;
    box-shadow: 0 -10px 32px rgba(31, 45, 74, .2);
    transform: translateY(0);
  }

  .bz-shell.bz-chat-collapsed .bz-chat {
    display: flex;
    transform: translateY(calc(100% + 12px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .bz-chat-head .bz-collapse-btn {
    width: auto;
    min-width: 2.4rem;
    padding: 0 .5rem;
    font-size: .72rem;
    font-weight: 700;
  }

  .ai-compose-actions {
    flex-wrap: wrap;
  }

  .ai-run-btn {
    min-width: 4.5rem;
    flex: 1 1 100%;
  }

  .ai-compose-actions .btn {
    flex: 1 1 auto;
  }
}

@media (min-width: 901px) {
  .bz-topbar-more,
  .bz-mobile-backdrop,
  .bz-mobile-toggle {
    display: none !important;
  }
}

/* Shared KB editor (super-admin AI LLM page) */
.kb-editor {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: .75rem;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: .6rem;
  overflow: hidden;
  background: #f7f9fc;
}

.kb-doc-list {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .45rem;
  overflow: auto;
  max-height: 560px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.kb-doc-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  background: transparent;
  text-align: left;
  color: inherit;
}

.kb-doc-item:hover {
  background: #f2f6ff;
  border-color: #d7e1ff;
}

.kb-doc-item.active {
  background: #eaf0ff;
  border-color: #b8c9ff;
}

.kb-doc-item-title {
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.kb-doc-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  font-size: .68rem;
  color: var(--muted);
}

.kb-doc-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
}

.kb-doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem;
  align-items: center;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
}

.kb-doc-heading {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}

.kb-doc-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.kb-doc-editor {
  flex: 1;
  min-height: 360px;
  max-height: 560px;
  resize: vertical;
  border: 0 !important;
  border-radius: 0 !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  line-height: 1.45;
  padding: .75rem .85rem;
  box-shadow: none !important;
}

.kb-doc-editor:disabled {
  background: #f7f9fc;
  color: #5a6478;
}

@media (max-width: 900px) {
  .kb-editor {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .kb-doc-list {
    max-height: 180px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

.res-crypto-drop{cursor:pointer;background:#fff;transition:border-color .15s,background .15s}
.res-crypto-drop.border-primary{background:#eef3ff}
