﻿:root {
  --bg: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --danger: #dc4458;
  --card: #ffffff;
  --border: #dbe4ee;
  --panel: #f8fafc;
  --panel-2: #f1f5f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #ffffff;
  font-family: "IBM Plex Sans", "Source Han Sans SC", "PingFang SC", sans-serif;
  overflow-x: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.help-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid #93c5fd;
  color: #2563eb;
  background: #eff6ff;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  cursor: help;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}

select {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 36%, transparent);
  border-color: var(--accent);
}

button,
.link-btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.15s ease, filter 0.2s ease;
}

button:hover,
.link-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.12);
}

.secondary-btn {
  color: #2563eb;
  background: #ffffff;
  border: 1px solid var(--border);
  min-height: 32px;
  padding: 5px 12px;
  line-height: 20px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  min-height: 32px;
  line-height: 1;
}

.top-app-nav .account-bar {
  margin-right: -12px;
}

.account-name {
  max-width: 180px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-link {
  padding: 8px 12px;
}

.account-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.account-menu-button {
  width: 28px;
  height: 32px;
  min-width: 28px;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  color: #64748b;
  background: transparent;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.account-menu-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.account-menu-button:hover,
.account-menu-button[aria-expanded="true"] {
  color: #0b63d8;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.account-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 120;
  min-width: 132px;
  border: 1px solid #dbe7f5;
  border-radius: 10px;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}

.account-menu[hidden] {
  display: none !important;
}

.account-menu-item {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: #334155;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  font-size: 13px;
  text-align: left;
}

.account-menu-item:hover {
  color: #0b63d8;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.account-logout-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: none;
  border-radius: 10px;
  color: #2563eb;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  line-height: 0;
  vertical-align: middle;
}

.account-logout-button::before {
  content: "";
  display: block;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / contain no-repeat;
}

.account-logout-button:hover {
  color: #0b63d8;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.role-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.role-nav a {
  color: #2563eb;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
}

.role-nav a.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent);
}

.top-app-nav {
  width: 100vw;
  min-height: 68px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: -16px calc((100% - 100vw) / 2) 14px;
  padding: 0 clamp(24px, 4vw, 56px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
}

.page > .top-app-nav {
  margin-top: -26px;
}

.upload-module-page > .top-app-nav,
.chat-shell > .top-app-nav {
  margin-top: -16px;
}

.top-app-brand {
  color: #172033;
  font-size: 16px;
  padding-right: 26px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.top-module-nav {
  margin-top: 0;
  gap: 12px;
  justify-content: flex-start;
}

.top-module-nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 9px;
  border-color: transparent;
  background: transparent;
  color: #334155;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 400;
}

.top-module-nav a:hover {
  color: #2563eb;
  background: #eff6ff;
}

.top-module-nav a.active {
  color: #ffffff;
  background: #0b63d8;
  box-shadow: 0 8px 18px rgba(11, 99, 216, 0.2);
}

.top-app-nav + .module-header {
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 18px 4px 14px;
  box-shadow: none;
}

.top-actions,
.sidebar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions {
  justify-content: flex-end;
}

.page {
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.page.narrow {
  width: min(860px, calc(100% - 48px));
}

.hero {
  margin-bottom: 18px;
}

.page-hero,
.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.module-page {
  width: min(1180px, calc(100% - 48px));
}

.upload-module-page {
  width: calc(100% - 32px);
  max-width: none;
  min-height: 100vh;
  padding: 16px 0 24px;
}

.upload-module-page .upload-card {
  min-height: calc(100vh - 164px);
  display: flex;
  flex-direction: column;
}

.upload-module-page .upload-card form {
  flex: 0 0 auto;
}

.upload-module-page .result {
  flex: 1;
}

.module-header {
  min-height: 116px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.module-header h1 {
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.18;
}

.module-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: #2563eb;
  display: inline-grid;
  place-items: center;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  transform: translateY(-1px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.28);
  padding: 24px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.modal-backdrop-front {
  z-index: 1010;
}

.modal-card {
  width: min(440px, 100%);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  font-size: 22px;
}

.modal-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.confirm-dialog {
  width: min(460px, calc(100vw - 48px));
}

.confirm-message {
  margin: 6px 0 18px;
  color: #334155;
  line-height: 1.7;
}

.modal-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.eyebrow {
  letter-spacing: 0.2em;
  font-weight: 400;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

.hero h1 {
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.18;
  margin-bottom: 0;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.upload-card form {
  display: grid;
  gap: 12px;
}

.workspace-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  width: min(880px, 100%);
  margin: clamp(44px, 12vh, 118px) auto 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.workspace-item {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 6px;
  min-height: 156px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.workspace-item-blue {
  background: linear-gradient(135deg, #ffffff 0%, #f5f9ff 100%);
}

.workspace-item-green {
  background: linear-gradient(135deg, #ffffff 0%, #f6fbf7 100%);
}

.workspace-item-purple {
  background: linear-gradient(135deg, #ffffff 0%, #f8f6ff 100%);
}

.workspace-item::after {
  content: none;
}

.workspace-item:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.08);
}

.workspace-kicker {
  display: none;
}

.workspace-item strong {
  display: block;
  font-size: 25px;
}

.workspace-item small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.workspace-item-green .workspace-kicker {
  color: #047857;
  background: #ecfdf5;
}

.workspace-item-purple .workspace-kicker {
  color: #6d28d9;
  background: #f5f3ff;
}

.kb-picker {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}

.kb-picker select {
  margin-top: 0;
}

.file-picker {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-picker input {
  margin-top: 0;
  display: none;
}

.file-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result {
  margin-top: 14px;
  min-height: 44px;
  white-space: pre-wrap;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
}

.kb-console-header {
  min-height: 118px;
}

.module-subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.kb-workbench-tabs {
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 9px 12px;
  overflow: auto hidden;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
}

.kb-workbench-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  color: #334155;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 400;
}

.kb-workbench-tabs button span {
  color: #64748b;
  font-weight: 400;
}

.kb-workbench-tabs button:hover,
.kb-workbench-tabs button.active {
  color: #ffffff;
  background: #0b63d8;
  transform: none;
  filter: none;
  box-shadow: 0 8px 18px rgba(11, 99, 216, 0.2);
}

.kb-workbench-tabs button:hover span,
.kb-workbench-tabs button.active span {
  color: #ffffff;
}

.kb-tab-panel[hidden] {
  display: none !important;
}

.kb-feature-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  min-height: calc(100vh - 256px);
}

.kb-graph-panel,
.kb-security-main,
.kb-push-main,
.kb-graph-aside section,
.kb-security-side section,
.kb-push-side section,
.kb-push-control-panel,
.kb-push-filter-row,
.kb-push-queue-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 32, 51, 0.04);
}

.kb-graph-panel,
.kb-security-main,
.kb-push-main {
  min-width: 0;
  padding: 18px;
}

.kb-graph-head,
.kb-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.kb-graph-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.kb-graph-legend strong,
.kb-section-title strong,
.kb-push-control-panel strong,
.kb-push-filter-row > strong,
.kb-graph-aside strong,
.kb-security-side strong,
.kb-push-side strong {
  color: #26384d;
  font-size: 14px;
  font-weight: 400;
}

.kb-graph-legend span {
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
}

.kb-graph-legend span::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #60a5fa;
}

.kb-graph-legend .tag::before {
  background: #34d399;
}

.kb-graph-legend .document::before {
  background: #a78bfa;
}

.kb-graph-search {
  width: min(320px, 100%);
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.kb-graph-search input {
  height: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.kb-graph-controls,
.kb-push-strategy-tabs,
.kb-push-filter-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.kb-graph-controls button,
.kb-push-strategy-tabs button,
.kb-push-filter-row button {
  min-height: 30px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #334155;
  background: #ffffff;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
}

.kb-graph-controls button:hover,
.kb-graph-controls button.active,
.kb-push-strategy-tabs button:hover,
.kb-push-strategy-tabs button.active,
.kb-push-filter-row button:hover,
.kb-push-filter-row button.active {
  border-color: #93c5fd;
  color: #0b63d8;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-push-filter-row button em {
  color: #0b63d8;
  font-style: normal;
  font-size: 12px;
}

.kb-graph-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kb-graph-metrics article {
  border: 1px solid #e5edf6;
  border-radius: 10px;
  background: #f8fbff;
  padding: 12px;
}

.kb-graph-metrics small,
.kb-section-title span {
  color: var(--muted);
  font-size: 12px;
}

.kb-graph-metrics strong {
  display: block;
  margin-top: 4px;
  color: #071a33;
  font-size: 20px;
  font-weight: 400;
}

.kb-graph-canvas {
  position: relative;
  min-height: 520px;
  border: 1px solid #e6edf5;
  border-radius: 12px;
  background:
    linear-gradient(#eef4fb 1px, transparent 1px),
    linear-gradient(90deg, #eef4fb 1px, transparent 1px),
    #fbfdff;
  background-size: 28px 28px;
  overflow: hidden;
}

.kb-graph-canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.kb-graph-canvas line {
  stroke: #bfd1e6;
  stroke-width: 0.35;
}

.kb-graph-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 118px;
  min-height: 64px;
  border: 1px solid #d8e5f4;
  border-radius: 14px;
  color: #203047;
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.kb-graph-node span {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #0b63d8;
  background: #eaf2ff;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 400;
}

.kb-graph-node.tag span {
  color: #047857;
  background: #dcfce7;
}

.kb-graph-node.document span {
  color: #6d28d9;
  background: #f3e8ff;
}

.kb-graph-node strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
}

.kb-graph-node.active {
  border-color: #0b63d8;
  box-shadow: 0 12px 26px rgba(11, 99, 216, 0.18);
}

.kb-graph-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.kb-graph-aside,
.kb-security-side,
.kb-push-side {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.kb-graph-aside section,
.kb-security-side section,
.kb-push-side section {
  padding: 16px;
}

.kb-graph-aside span {
  color: var(--muted);
  font-size: 12px;
}

.kb-graph-aside h3 {
  margin-top: 8px;
  color: #26384d;
  font-size: 16px;
  font-weight: 400;
}

.kb-graph-aside p,
.kb-security-side p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
}

.kb-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kb-tag-cloud button {
  min-height: 30px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #334155;
  background: #ffffff;
  padding: 0 10px;
  font-size: 12px;
}

.kb-tag-cloud button:hover,
.kb-tag-cloud button.active {
  border-color: #93c5fd;
  color: #0b63d8;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-security-side dl {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.kb-security-side dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-security-side dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.kb-security-side dd {
  margin: 0;
  color: #0b63d8;
  font-size: 20px;
  font-weight: 400;
}

.kb-bulk-permission-panel {
  border: 1px solid #e6edf5;
  border-radius: 10px;
  background: #f8fbff;
  margin-bottom: 14px;
  padding: 14px;
}

.kb-bulk-permission-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.kb-bulk-permission-head strong,
.kb-bulk-permission-head span {
  display: block;
}

.kb-bulk-permission-head strong,
.kb-security-side section > strong,
#securityPanel .kb-section-title strong {
  color: #334155;
  font-size: 14px;
  font-weight: 400;
}

#securityPanel .kb-section-title span {
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
}

.kb-bulk-permission-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.kb-bulk-permission-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kb-bulk-permission-controls label {
  flex: 0 0 240px;
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
}

.kb-bulk-permission-controls select {
  height: 40px;
  margin-top: 0;
  font-size: 13px;
  font-weight: 400;
}

.kb-bulk-permission-checks {
  display: flex;
  flex-wrap: wrap;
  flex: 0 1 auto;
  gap: 8px;
  padding-bottom: 2px;
}

.kb-bulk-permission-controls > button {
  height: 34px;
  min-height: 34px;
  align-self: center;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  background: #eaf2ff;
  box-shadow: none;
  color: #0b63d8;
  font-size: 13px;
  font-weight: 400;
  padding: 0 13px;
  white-space: nowrap;
}

.kb-bulk-permission-controls > button:hover {
  background: #dbeafe;
  transform: none;
  filter: none;
}

.kb-bulk-permission-controls > button:disabled {
  border-color: #bfdbfe;
  color: #8aaee0;
  background: #eaf2ff;
  cursor: not-allowed;
}

.kb-bulk-permission-item {
  min-height: 32px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #334155;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}

.kb-bulk-permission-item input {
  width: auto;
  margin: 0;
  accent-color: #60a5fa;
}

.kb-bulk-empty {
  color: var(--muted);
  font-size: 13px;
}

.kb-permission-matrix {
  border: 1px solid #e6edf5;
  border-radius: 10px;
  overflow: auto;
}

.kb-permission-filters {
  border-bottom: 1px solid #e6edf5;
  background: #ffffff;
  display: flex;
  padding: 12px 14px;
}

.kb-permission-filters input {
  width: min(420px, 100%);
  min-height: 36px;
  border: 1px solid #d8e5f4;
  border-radius: 9px;
  color: #334155;
  background: #ffffff;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 400;
}

.kb-permission-table {
  width: 100%;
  min-width: 980px;
}

.kb-permission-row {
  display: grid;
  grid-template-columns: 140px 130px 150px repeat(var(--kb-count), minmax(112px, 1fr));
  align-items: stretch;
  border-bottom: 1px solid #e6edf5;
}

.kb-permission-row.head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8fafc;
  color: #52637a;
  font-size: 13px;
  font-weight: 400;
}

.kb-permission-row > span,
.kb-permission-check {
  min-height: 56px;
  border-right: 1px solid #e6edf5;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 400;
}

.kb-permission-row.head > span:nth-child(n + 4) {
  justify-content: center;
  text-align: center;
}

.kb-permission-column-filter {
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.kb-permission-column-filter > span:not(.kb-permission-filter-control) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-permission-filter-control {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  place-items: center;
}

.kb-permission-filter-button {
  width: 18px;
  height: 18px;
  min-height: 18px;
  border: 0;
  border-radius: 4px;
  color: #52637a;
  background: transparent;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  cursor: pointer;
  transform: none;
  filter: none;
}

.kb-permission-filter-button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.kb-permission-filter-button:hover,
.kb-permission-filter-button:focus,
.kb-permission-column-filter.active .kb-permission-filter-button {
  background: #eff6ff;
  color: #2563eb;
  transform: none;
  filter: none;
}

.kb-permission-filter-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 30;
  display: none;
  width: max-content;
  min-width: 118px;
  max-width: 180px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
  padding: 6px;
  text-align: left;
  transform: translateX(-50%);
}

.kb-permission-filter-menu.open {
  display: grid;
  gap: 2px;
}

.kb-permission-filter-menu button {
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  color: #334155;
  background: #ffffff;
  display: block;
  margin: 0;
  padding: 0 10px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  transform: none;
  filter: none;
}

.kb-permission-filter-menu button:hover,
.kb-permission-filter-menu button:focus {
  color: #2563eb;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.kb-permission-filter-menu button.active {
  color: #1d4ed8;
  background: #eaf2ff;
}

.kb-permission-text-cell {
  display: block !important;
  min-width: 0;
  overflow: hidden;
  line-height: 56px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-permission-user {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  gap: 3px;
}

.kb-permission-user strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: 14px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-permission-user small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-permission-check {
  justify-content: center;
}

.kb-permission-check input {
  display: none;
}

.kb-permission-check span {
  width: 34px;
  height: 22px;
  border-radius: 999px;
  background: #eaf2ff;
  position: relative;
}

.kb-permission-check span::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.kb-permission-check input:checked + span {
  background: #bfdbfe;
}

.kb-permission-check input:checked + span::before {
  background: #60a5fa;
}

.kb-permission-check input:checked + span::before {
  transform: translateX(12px);
}

.kb-push-main {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.kb-push-control-panel,
.kb-push-filter-row,
.kb-push-queue-panel {
  padding: 16px;
}

.kb-push-queue-list {
  display: grid;
  gap: 10px;
}

.kb-push-queue-list article {
  min-height: 64px;
  border: 1px solid #e6edf5;
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.kb-push-queue-list article > span {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: #2563eb;
  background: #eaf2ff;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 400;
}

.kb-push-queue-list strong,
.kb-push-queue-list small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-push-queue-list strong {
  color: #203047;
  font-size: 14px;
  font-weight: 400;
}

.kb-push-queue-list small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.kb-push-user-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.kb-push-user-list span {
  min-height: 30px;
  border-radius: 9px;
  color: #334155;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
}

.kb-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kb-stats-grid article {
  min-height: 86px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
}

.kb-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  font-weight: 400;
}

.kb-stat-icon.blue {
  color: #1d4ed8;
  background: #eaf2ff;
}

.kb-stat-icon.green {
  color: #059669;
  background: #e8fbf2;
}

.kb-stat-icon.orange {
  color: #d97706;
  background: #fff4df;
}

.kb-stat-icon.red {
  color: #dc2626;
  background: #fff1f2;
}

.kb-stat-icon.slate {
  color: #475569;
  background: #eef4fb;
}

.kb-stats-grid small {
  color: var(--muted);
  font-size: 12px;
}

.kb-stat-label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kb-info-tip {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid #c7d8ee;
  border-radius: 999px;
  color: #2563eb;
  background: #f8fbff;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  cursor: help;
}

.kb-info-tip::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: 238px;
  border: 1px solid #d7e3f2;
  border-radius: 8px;
  color: #334155;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.kb-info-tip:hover::after,
.kb-info-tip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.kb-stats-grid strong {
  display: block;
  margin-top: 4px;
  color: #071a33;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.kb-console-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 256px);
}

.kb-console-side {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.kb-side-card,
.kb-document-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 32, 51, 0.04);
}

.kb-upload-form {
  display: grid;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.kb-upload-form input[type="file"] {
  display: none;
}

.kb-upload-dropzone {
  min-height: 126px;
  border: 1px dashed #bfd1e6;
  border-radius: 10px;
  color: #64748b;
  background: #ffffff;
  display: grid;
  place-items: center;
  gap: 6px;
  margin: 0;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.kb-upload-dropzone:hover,
.kb-upload-dropzone.drag-over {
  border-color: #60a5fa;
  background: #f8fbff;
  transform: translateY(-1px);
}

.kb-upload-symbol {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #2563eb;
  background: #eaf2ff;
  display: inline-grid;
  place-items: center;
}

.kb-upload-symbol svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kb-upload-dropzone strong {
  color: #334155;
  font-size: 14px;
  font-weight: 400;
}

.license-customer {
  /* 客户名水印：看得见但不抢戏 */
  margin-right: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
}

.kb-upload-dropzone small {
  color: #94a3b8;
  font-size: 12px;
  /* 分三行列出格式，行距太挤会糊成一团 */
  line-height: 1.7;
}

.kb-upload-form button,
.kb-document-toolbar button {
  font-weight: 400;
}

.kb-document-toolbar button {
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: none;
  color: #0b63d8;
  padding: 0 13px;
  font-size: 13px;
}

.kb-document-toolbar button:hover {
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-manage-actions {
  display: grid;
  grid-template-columns: minmax(96px, 1.25fr) minmax(68px, 0.9fr) minmax(58px, 0.8fr);
  gap: 8px;
}

.kb-manage-actions button {
  min-width: 0;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 13px;
  font-weight: 500;
}

.danger-text {
  color: #dc2626;
}

.kb-side-card {
  padding: 14px;
}

.kb-side-card > strong,
.kb-side-card-head span {
  color: #26384d;
  font-size: 14px;
  font-weight: 400;
}

.kb-side-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kb-mini-icon-btn {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  color: #2563eb;
  background: #ffffff;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.kb-mini-icon-btn:hover {
  border-color: #93c5fd;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-category-list {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.kb-category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}

.kb-category-row.active {
  background: #eaf2ff;
}

.kb-side-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kb-side-tag-list button {
  min-height: 28px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #2563eb;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 400;
}

.kb-side-tag-list button:hover {
  border-color: #93c5fd;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-side-tag-list em {
  color: #64748b;
  font-style: normal;
  font-size: 11px;
}

.kb-side-tag-empty {
  color: var(--muted);
  font-size: 12px;
}

.kb-category-main {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: #334155;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-weight: 400;
  font-size: 13px;
}

.kb-category-main:hover,
.kb-category-row.active .kb-category-main {
  color: #0b63d8;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-category-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-right: 5px;
}

.kb-category-action {
  width: 25px;
  height: 25px;
  min-height: 25px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #64748b;
  background: transparent;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.kb-category-action:hover {
  border-color: #d8e5f4;
  color: #2563eb;
  background: #ffffff;
  transform: none;
  filter: none;
}

.kb-category-action.danger-text:hover {
  color: #dc2626;
  background: #fff1f2;
}

.kb-category-list em {
  color: #0b63d8;
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
}

.kb-upload-result {
  max-height: 180px;
  margin-top: 0;
  overflow: auto;
  font-size: 12px;
}

.kb-document-panel {
  min-width: 0;
  min-height: calc(100vh - 256px);
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.kb-document-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.kb-document-toolbar .kb-document-search {
  flex: 1 1 auto;
}

.kb-document-toolbar button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* 工具栏按钮的 display 规则会压过 hidden 属性，显式兜住 */
.kb-document-toolbar button[hidden] {
  display: none !important;
}

.kb-document-search {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.kb-document-search span {
  color: #64748b;
  font-size: 18px;
}

.kb-document-search input {
  min-width: 0;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  padding: 0;
}

.kb-file-table {
  min-width: 0;
  flex: 1;
  overflow: auto;
  border: 1px solid #e6edf5;
  border-radius: 10px;
}

.kb-file-row {
  display: grid;
  /* 首列 44px 放勾选框；操作列放下"切块 / 重解析 / 删除"三个按钮要 96px */
  grid-template-columns: 44px minmax(280px, 1.6fr) 82px 96px 126px minmax(150px, 0.8fr) 110px 150px 96px;
  align-items: center;
  min-width: 1224px;
  min-height: 52px;
  border-bottom: 1px solid #e6edf5;
}

.kb-file-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 48px;
  color: #5e6f86;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 400;
}

/* 表头首列与正文的文件名文本对齐：正文列前面有 28px 图标 + 10px 间距，
   表头不补这段缩进的话，"文档名称"四个字就悬在图标上方而不是名字上方。 */
.kb-file-row.head > span:nth-child(2) {
  padding-left: 52px;
}

/* 勾选列：居中，不吃行内边距 */
.kb-file-check-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
}

.kb-file-check-cell input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #2563eb;
  cursor: pointer;
}

.kb-bulk-delete-btn {
  color: #dc2626 !important;
  border-color: #fecaca !important;
}

.kb-bulk-delete-btn:hover {
  background: #fff1f2 !important;
}

.kb-file-row > span {
  min-width: 0;
  padding: 0 14px;
  color: #334155;
  font-size: 13px;
  font-weight: 400;
}

.kb-file-row:not(.head):hover {
  background: #f8fbff;
}

.kb-file-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 文件名外层包裹 span 默认 min-width:auto，flex 不会把它压缩到列宽以内，
   长文件名就会顶穿"类型"列。钉住 min-width:0 让内部省略号生效。 */
.kb-file-name-cell > span:not(.kb-file-icon) {
  flex: 1;
  min-width: 0;
}

.kb-file-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #2563eb;
  background: #eaf2ff;
  display: inline-grid;
  place-items: center;
  font-style: normal;
  font-weight: 400;
}

.kb-file-title,
.kb-file-name-cell small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-file-title {
  color: #334155;
  font-size: 13px;
  font-weight: 400;
}

.kb-file-name-cell small {
  margin-top: 3px;
  color: #94a3b8;
  font-size: 12px;
}

.kb-file-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.kb-file-delete-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: #8a9bb0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kb-file-delete-btn:hover {
  color: #dc2626;
  background: #fff1f2;
  filter: none;
  transform: none;
}

.kb-file-delete-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 切块预览按钮：与删除按钮同规格，悬停用品牌蓝而不是警示红 */
.kb-file-chunks-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: #8a9bb0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kb-file-chunks-btn:hover {
  color: #0b63d8;
  background: #eaf2ff;
  filter: none;
  transform: none;
}

.kb-file-chunks-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 版本徽标：同名重传（内容变化）后显示 V2/V3…，悬停看历史台账 */
.version-dialog { max-width: 760px; width: min(760px, 94vw); }
.kb-version-sub { color: #64748b; font-size: 13px; margin: -4px 0 10px; }
.kb-version-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.kb-version-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-version-table th, .kb-version-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eef2f7; white-space: nowrap; }
.kb-version-table th { background: #f8fafc; color: #52637a; font-weight: 500; }
.kb-version-table tr:last-child td { border-bottom: 0; }
.kb-version-table tr.is-current td { background: #f5f9ff; color: #0b63d8; }
.kb-version-note { color: #7a8ca1; font-size: 12px; line-height: 1.6; margin: 10px 0 0; }
.kb-version-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  cursor: pointer;
  min-height: 0;
  line-height: 1.5;
  margin-left: 0;
  margin-right: 6px;
  font-size: 11px;
  color: #3b4fb8;
  color: #4338ca;
  font-size: 11px;
  font-style: normal;
  line-height: 1.5;
  vertical-align: 1px;
}

/* --- 切块预览弹窗 ------------------------------------------------------ */
.kb-chunk-dialog {
  width: min(860px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.kb-chunk-dialog .modal-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 12px;
}

.kb-chunk-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 8px;
}

.kb-chunk-empty {
  color: #64748b;
  font-size: 13px;
  margin: 8px 0;
}

.kb-chunk-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 12px;
}

.kb-chunk-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.kb-chunk-card header b {
  color: #0b63d8;
  font-size: 12px;
}

/* 标题路径 + 页码：切块挂在文档结构里的位置，引用定位就来自这里 */
.kb-chunk-card header span {
  font-size: 12px;
  color: #45637f;
  background: #eaf2ff;
  border: 1px solid #cfe0f5;
  border-radius: 999px;
  padding: 1px 8px;
}

.kb-chunk-card header small {
  margin-left: auto;
  color: #94a3b8;
  font-size: 11px;
}

.kb-chunk-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  color: #1e293b;
  max-height: 200px;
  overflow-y: auto;
}

.kb-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-style: normal;
  color: #059669;
  background: #e8fbf2;
  font-size: 12px;
  font-weight: 400;
}

.kb-status-pill.processing {
  color: #d97706;
  background: #fff4df;
}

.kb-status-pill.failed {
  color: #dc2626;
  background: #fff1f2;
}

.kb-status-pill.archived {
  color: #475569;
  background: #eef4fb;
}

.kb-tags-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.kb-tags-cell i,
.kb-tags-cell em {
  flex: 0 1 auto;
  max-width: 86px;
  min-height: 24px;
  border-radius: 999px;
  color: #2563eb;
  background: #eaf2ff;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
}

.kb-tags-cell em {
  color: #64748b;
  background: #f1f5f9;
}

.kb-table-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.upload-page :where(h1, h2, h3, strong, b, button, .kb-file-title, .kb-file-row.head, .kb-status-pill, .kb-tags-cell i, .kb-tags-cell em, .kb-category-main, .kb-category-action, .kb-side-card-head span, .kb-workbench-tabs button, .kb-section-title strong, .kb-graph-legend strong, .kb-push-control-panel strong, .kb-push-filter-row > strong, .kb-graph-aside strong, .kb-security-side strong, .kb-push-side strong) {
  font-weight: 400 !important;
}

.upload-page :where(h1, h2, h3, strong, b, .kb-file-title, .kb-file-row.head, .kb-category-main span, .kb-side-card-head span) {
  color: #334155;
}

.upload-page .modal-header h2 {
  color: #334155;
  font-size: 16px;
  font-weight: 400;
}

.upload-page .modal-actions button {
  min-height: 40px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #2563eb;
  background: #ffffff;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 400;
}

.upload-page .modal-actions button:hover:not(:disabled),
.upload-page .modal-actions button:focus-visible:not(:disabled) {
  border-color: #93c5fd;
  color: #0b63d8;
  background: #ffffff;
  transform: none;
  filter: none;
}

.upload-page .modal-actions button:active:not(:disabled) {
  border-color: #2563eb;
  color: #ffffff;
  background: #2563eb;
  transform: none;
  filter: none;
}

.kb-upload-dialog {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 24px 26px;
}

.kb-upload-dialog .modal-header {
  align-items: flex-start;
}

.kb-upload-dialog .modal-header h2 {
  color: #334155;
  font-size: 16px;
  font-weight: 400;
}

.kb-upload-dialog .modal-header p {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}

.kb-upload-dialog-label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 400;
}

.kb-pending-file-list {
  display: grid;
  gap: 8px;
}

.kb-pending-file-list div {
  min-height: 40px;
  border: 1px solid #dbe6f3;
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.kb-pending-file-list span {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  color: #2563eb;
  background: #eaf2ff;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 400;
}

.kb-pending-file-list strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 400;
}

.kb-pending-file-list em {
  color: #64748b;
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
}

.kb-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kb-choice-list button {
  min-height: 32px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #334155;
  background: #ffffff;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 400;
}

.kb-choice-list button:hover,
.kb-choice-list button.active {
  border-color: #93c5fd;
  color: #0b63d8;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.kb-choice-list button.kb-choice-add {
  border-style: dashed;
  color: #2563eb;
  background: #f8fbff;
}

.kb-choice-list button.kb-choice-add:hover {
  border-color: #60a5fa;
  background: #eaf2ff;
}

.kb-choice-inline {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.kb-choice-inline input {
  width: 112px;
  min-height: 32px;
  margin: 0;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 400;
}

.kb-custom-tag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.kb-custom-tag input {
  margin: 0;
  min-height: 40px;
  font-size: 13px;
  font-weight: 400;
  background: #ffffff;
}

.kb-custom-tag button {
  min-width: 72px;
  min-height: 40px;
  font-size: 13px;
  font-weight: 400;
}

.compact-result:empty {
  display: none;
}

.system-result-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.system-result-tools button {
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  color: #0b63d8;
  background: #ffffff;
  padding: 0 14px;
  font-size: 13px;
}

.system-result-tools button:hover:not(:disabled) {
  color: #0756bd;
  border-color: #93c5fd;
  background: #ffffff;
}

.system-result-tools button:active:not(:disabled) {
  color: #ffffff;
  border-color: #0b63d8;
  background: #0b63d8;
}

.system-result-tools button:disabled {
  cursor: default;
  opacity: 0.72;
}

.login-page {
  min-height: 100vh;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(430px, 100%);
  background: color-mix(in oklab, var(--card) 92%, white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 14px 34px rgba(25, 34, 45, 0.1);
}

.login-page .auth-panel h1 {
  font-size: 30px;
  font-weight: 400;
  text-align: center;
  color: #334155;
  margin-bottom: 18px;
}

.auth-form,
.admin-form {
  display: grid;
  gap: 12px;
}

/* 首次设置页：沿用登录页的外壳，只多两段说明文字的样式 */
.setup-intro {
  margin: 0 0 18px;
  color: #5a6b7f;
  font-size: 13px;
  line-height: 1.8;
}

.setup-hint {
  margin: 16px 0 0;
  color: #8a99ac;
  font-size: 12px;
}

.setup-warning {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff4f4;
  color: #a3342f;
  font-size: 13px;
  line-height: 1.7;
}

.login-page .password-field {
  position: relative;
  display: block;
}

.login-page .password-field input {
  padding-right: 46px;
}

.login-page .password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #2563eb;
  background: transparent;
  display: inline-grid;
  place-items: center;
  transform: translateY(-50%);
}

.login-page .password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.login-page .password-toggle .eye-closed {
  display: none;
}

.login-page .password-toggle.showing .eye-open {
  display: none;
}

.login-page .password-toggle.showing .eye-closed {
  display: block;
}

.login-page .password-toggle:hover,
.login-page .password-toggle:focus-visible {
  color: #0b63d8;
  background: #eff6ff;
  transform: translateY(-50%);
}

.login-page .login-submit {
  margin-top: 22px;
  color: #2563eb;
  background: #ffffff;
  border: 1px solid #bfdbfe;
}

.login-page .login-submit:hover,
.login-page .login-submit:focus-visible {
  color: #0b63d8;
  background: #ffffff;
  border-color: #93c5fd;
}

.login-page .login-submit:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

.login-page .login-submit:active {
  color: #ffffff;
  border-color: #2563eb;
  background: #2563eb;
}

.form-status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
}

.admin-role-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.role-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.role-editor-actions select,
.inline-role-select {
  width: auto;
  min-width: 128px;
  margin-top: 0;
}

.permission-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.permission-grid section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px;
}

.permission-grid section > strong {
  display: block;
  color: #102033;
  font-size: 15px;
  margin-bottom: 10px;
}

.permission-grid section > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-check {
  min-height: 34px;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #334155;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-weight: 500;
  cursor: pointer;
}

.permission-check input {
  width: auto;
  margin: 0;
}

.permission-check:has(input:checked) {
  border-color: #93c5fd;
  color: #0b63d8;
  background: #eaf2ff;
}

.table-scroll {
  margin-top: 12px;
  overflow: auto;
}

.admin-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  font-size: 14px;
}

.admin-table th {
  background: var(--panel-2);
}

.system-page {
  min-height: 100vh;
  background: #f6f8fb;
}

.system-shell {
  min-height: 100vh;
}

.system-shell > .top-app-nav {
  width: 100%;
  margin: 0;
}

.system-management-page {
  min-height: calc(100vh - 68px);
  background: #f6f8fb;
  color: #0b1f3a;
}

.system-management-topbar {
  min-height: 58px;
  border-bottom: 1px solid #e5ebf3;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
}

.system-management-topbar > strong {
  padding-right: 22px;
  border-right: 1px solid #d9e3f0;
  color: #102033;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.system-management-topbar nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.system-management-topbar nav button {
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #4f6075;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
}

.system-management-topbar nav button:hover {
  color: #0b63d8;
  background: #eef5ff;
}

.system-management-topbar nav button.active {
  color: #ffffff;
  background: #0b63d8;
  box-shadow: 0 8px 18px rgba(11, 99, 216, 0.2);
}

.system-tab-panel {
  padding: 24px 32px 36px;
}

.system-tab-panel[hidden] {
  display: none !important;
}

.system-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.system-section-head h2 {
  color: #26384d;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.25;
}

.system-section-head p {
  margin-top: 0;
  color: #5c6f87;
  font-size: 13px;
}

.system-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

#openChangePasswordBtn {
  display: none !important;
}

.system-light-button,
.system-primary-button {
  min-height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 400;
}

.system-light-button {
  border: 1px solid #bfdbfe;
  color: #0b63d8;
  background: #eaf2ff;
}

.system-light-button:hover {
  color: #0756bd;
  border-color: #93c5fd;
  background: #dbeafe;
}

.system-primary-button {
  border: 1px solid #bfdbfe;
  color: #0b63d8;
  background: #eaf2ff;
  box-shadow: none;
}

.system-add-user-button {
  color: #0b63d8;
  border: 1px solid #bfdbfe;
  background: #eaf2ff;
  box-shadow: none;
}

.system-add-experience-button {
  color: #0b63d8;
  border: 1px solid #bfdbfe;
  background: #eaf2ff;
  box-shadow: none;
}

.experience-control-hidden {
  display: none !important;
}

.system-add-role-button {
  border: 1px solid #bfdbfe;
  color: #0b63d8;
  background: #eaf2ff;
  box-shadow: none;
}

.system-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.system-stat-grid.three {
  grid-template-columns: repeat(3, minmax(200px, 1fr));
}

.system-stat-card {
  min-height: 92px;
  border: 1px solid #e3eaf3;
  border-radius: 16px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(10, 35, 70, 0.04);
}

.system-stat-card span {
  color: #667990;
  font-size: 13px;
}

.system-stat-card strong {
  display: block;
  margin-top: 12px;
  color: #071a33;
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
}

.system-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-style: normal;
  font-weight: 400;
}

.system-stat-icon.blue {
  color: #0b63d8;
  background: #eaf2ff;
}

.system-stat-icon.green {
  color: #10b981;
  background: #e9fbf3;
}

.system-stat-icon.amber {
  color: #f59e0b;
  background: #fff5df;
}

.system-stat-icon.orange {
  color: #f97316;
  background: #fff1e7;
}

.system-user-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 16px;
}

.system-user-search,
.system-search-field {
  height: 42px;
  border: 1px solid #dce6f2;
  border-radius: 10px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: #8ca0b7;
  font-size: 14px;
}

.system-user-search {
  width: min(380px, 100%);
}

.system-search-field {
  width: 100%;
}

.system-user-search input,
.system-search-field input {
  min-width: 0;
  flex: 1;
  width: auto;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
  padding: 0;
  color: #102033;
  font: inherit;
}

.system-user-search:focus-within,
.system-search-field:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.16);
}

.system-search-count {
  border-radius: 999px;
  background: #eaf2ff;
  color: #0b63d8;
  padding: 4px 9px;
  font-size: 12px;
}

.system-message {
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #0b63d8;
  padding: 10px 14px;
}

.system-message.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #dc2626;
}

.system-table-card {
  overflow-x: auto;
  border: 1px solid #e3eaf3;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(10, 35, 70, 0.04);
  /* single grid owner: guarantees header and data share identical column widths */
  display: grid;
  grid-template-columns: minmax(250px, 1.35fr) 150px 150px 120px 190px 170px 150px;
  grid-template-rows: auto;
  min-width: 1060px;
}

#userTableBody {
  display: contents; /* lift data rows into the table-card grid */
}

.system-user-row {
  /* span all 7 columns, then re-grid internally using subgrid */
  grid-column: 1 / -1;
  min-height: 62px;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-top: 1px solid #edf2f8;
  color: #344961;
  font-size: 14px;
}

.system-user-head {
  min-height: 54px;
  border-top: 0;
  background: #fbfdff;
  color: #5c6f87;
}

/* 第 2-7 列表头内容水平居中 */
.system-user-head > :not(:first-child) {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 第 2-7 列数据内容水平居中 */
.system-user-row:not(.system-user-head) > :not(:first-child) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.system-head-filter,
.system-head-sort {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.system-head-filter > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-head-filter-control {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.system-head-filter-button,
.system-head-sort button {
  border: 0;
  color: #52637a;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transform: none;
  filter: none;
}

.system-head-filter-button {
  width: 18px;
  height: 18px;
  min-height: 18px;
  border-radius: 4px;
}

.system-head-filter-button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.system-head-filter-button:hover,
.system-head-filter-button:focus,
.system-head-filter.active .system-head-filter-button,
.system-head-sort button:hover,
.system-head-sort button:focus,
.system-head-sort button.active {
  color: #2563eb;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.system-head-sort button {
  min-height: 24px;
  border-radius: 6px;
  gap: 5px;
  padding: 0 6px;
}

.system-head-sort button span {
  color: inherit;
  font-size: 13px;
  line-height: 1;
}

.system-head-filter-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 40;
  display: none;
  width: max-content;
  min-width: 120px;
  max-width: 190px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
  padding: 6px;
  text-align: left;
  transform: translateX(-50%);
}

.system-head-filter-menu.open {
  display: grid;
  gap: 2px;
}

.system-head-filter-menu button {
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  color: #334155;
  background: #ffffff;
  display: block;
  margin: 0;
  padding: 0 10px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  transform: none;
  filter: none;
}

.system-head-filter-menu button:hover,
.system-head-filter-menu button:focus {
  color: #2563eb;
  background: #eff6ff;
  transform: none;
  filter: none;
}

.system-head-filter-menu button.active {
  color: #1d4ed8;
  background: #eaf2ff;
}

.system-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.system-user-info b {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid;
  place-items: center;
  font-style: normal;
  font-weight: 400;
}

.system-user-info span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.system-user-info strong {
  overflow: hidden;
  color: #102033;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-user-info small {
  overflow: hidden;
  color: #93a2b5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-role-chip,
.system-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-style: normal;
  font-size: 12px;
  white-space: nowrap;
}

.system-role-chip {
  color: #0b63d8;
  background: #eaf2ff;
}

.system-role-chip.admin {
  color: #b45309;
  background: #fef3c7;
}

.system-role-chip.muted {
  color: #64748b;
  background: #f1f5f9;
}

.system-status-chip.active {
  color: #059669;
  background: #dcfce7;
}

.system-status-chip.pending {
  color: #d97706;
  background: #fff7ed;
}

.system-status-chip.disabled {
  color: #64748b;
  background: #f1f5f9;
}

.system-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.system-row-icon-button {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  color: #8a9bb0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.system-row-icon-button:hover {
  color: #0b63d8;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

.system-row-icon-button.danger {
  color: #8a9bb0;
}

.system-row-icon-button.danger:hover {
  color: #dc2626;
  background: #fff1f2;
}

.system-row-icon-button:disabled {
  color: #cbd5e1;
  background: transparent;
  cursor: not-allowed;
}

.system-row-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.system-row-actions .inline-role-select {
  width: 138px;
  min-width: 138px;
}

.system-empty-row {
  padding: 26px;
  color: #7a8ca4;
  text-align: center;
}

.system-running {
  display: inline-flex;
  align-items: center;
  color: #8a9bb0;
  font-size: 13px;
}

.system-running b {
  color: #10b981;
  font-weight: 400;
}

.system-placeholder-card {
  min-height: 320px;
  border: 1px solid #e3eaf3;
  border-radius: 16px;
  background: #ffffff;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: #7a8ca4;
}

.system-placeholder-card h3 {
  margin: 0;
  color: #102033;
  font-size: 20px;
  font-weight: 400;
}

.system-placeholder-card p {
  margin: 0;
}

.system-role-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.system-role-list-card,
.system-role-detail-card,
.system-permission-group,
.system-role-members,
.system-log-card {
  border: 1px solid #e3eaf3;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(10, 35, 70, 0.04);
}

.system-role-list-card {
  padding: 16px;
  position: sticky;
  top: 72px;
}

.system-role-card-head,
.system-role-detail-head,
.system-permission-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.system-role-card-head {
  align-items: center;
}

.system-role-card-head .system-add-role-button {
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
}

.system-role-card-head strong,
.system-role-detail-head h3,
.system-permission-group-head strong {
  display: block;
  color: #26384d;
  font-weight: 400;
}

.system-role-card-head strong,
.system-permission-group-head strong {
  font-size: 14px;
}

.system-role-card-head span,
.system-role-detail-head span,
.system-permission-group-head small {
  color: #7a8ca4;
  font-size: 13px;
}

.system-role-search {
  margin: 14px 0;
}

.system-role-list {
  display: grid;
  gap: 10px;
}

.system-role-list-item {
  width: 100%;
  border: 1px solid #e7eef7;
  border-radius: 12px;
  background: #ffffff;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: #344961;
  text-align: left;
}

.system-role-list-item:hover,
.system-role-list-item.active {
  border-color: #bfdbfe;
  background: #f5f9ff;
  transform: none;
  filter: none;
}

.system-role-list-item b,
.system-role-member b {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: #0b63d8;
  background: #eaf2ff;
  display: grid;
  place-items: center;
  font-style: normal;
  font-weight: 400;
}

.system-role-list-item span,
.system-role-member span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.system-role-list-item strong,
.system-role-member strong {
  overflow: hidden;
  color: #344961;
  font-size: 14px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-role-list-item small,
.system-role-member small {
  overflow: hidden;
  color: #7a8ca4;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-role-list-item i {
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  padding: 4px 8px;
  font-size: 12px;
  font-style: normal;
}

.system-role-list-item.active i {
  color: #0b63d8;
  background: #eaf2ff;
}

.system-role-detail-card {
  padding: 18px;
}

.system-role-detail-head {
  padding-bottom: 16px;
  border-bottom: 1px solid #edf2f8;
}

.system-role-detail-head h3 {
  margin: 6px 0;
  font-size: 15px;
}

.system-role-detail-head p {
  margin: 0;
  color: #5c6f87;
  font-size: 13px;
}

.system-role-tools {
  display: flex;
  gap: 8px;
}

.system-role-tools button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  color: #8a9bb0;
  background: #f1f5f9;
  display: grid;
  place-items: center;
  padding: 0;
}

.system-role-tools button:hover {
  color: #dc2626;
  background: #fff1f2;
  transform: none;
  filter: none;
}

.system-role-tools button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.system-role-edit-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(280px, 1fr);
  gap: 14px;
  margin: 16px 0;
}

.system-role-edit-grid label,
.system-dialog-grid label {
  display: grid;
  gap: 8px;
  color: #4f6075;
  font-size: 13px;
}

.system-role-edit-grid input,
.system-dialog-grid input,
.system-dialog-grid select,
.system-dialog-grid textarea {
  min-height: 40px;
  margin: 0;
  border: 1px solid #dce6f2;
  border-radius: 10px;
  background: #ffffff;
  color: #102033;
  padding: 0 12px;
  font: inherit;
  outline: none;
}

.system-dialog-grid textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

.system-dialog-full {
  grid-column: 1 / -1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.system-role-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.system-role-summary-strip article {
  border: 1px solid #edf2f8;
  border-radius: 12px;
  background: #fbfdff;
  padding: 14px;
}

.system-role-summary-strip span {
  color: #7a8ca4;
  font-size: 12px;
}

.system-role-summary-strip strong {
  display: block;
  margin-top: 8px;
  color: #0b63d8;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
}

.system-permission-groups {
  display: grid;
  gap: 14px;
}

.system-permission-group {
  padding: 16px;
}

.system-permission-group-head span {
  border-radius: 999px;
  color: #0b63d8;
  background: #eaf2ff;
  padding: 4px 9px;
  font-size: 12px;
}

.system-permission-group-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.system-permission-group-actions button {
  min-height: 30px;
  border: 1px solid #d9e4f2;
  border-radius: 8px;
  background: #ffffff;
  color: #4f6075;
  padding: 0 10px;
}

.system-permission-group-actions button:hover {
  color: #0b63d8;
  border-color: #bfdbfe;
  background: #f5f9ff;
  transform: none;
  filter: none;
}

.system-permission-group-actions button:disabled {
  color: #a8b5c6;
  cursor: not-allowed;
}

.system-permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.system-permission-item {
  min-height: 40px;
  border: 1px solid #e3eaf3;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: #344961;
  font-size: 13px;
  cursor: pointer;
}

.system-permission-item.active {
  border-color: #bfdbfe;
  color: #0b63d8;
  background: #eff6ff;
}

.system-permission-item input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #0b63d8;
}

.system-role-members {
  margin-top: 16px;
  padding: 16px;
}

.system-role-member-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.system-role-member {
  min-height: 52px;
  border-top: 1px solid #edf2f8;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.system-role-member:first-child {
  border-top: 0;
  padding-top: 0;
}

.system-role-member em {
  border-radius: 999px;
  color: #059669;
  background: #dcfce7;
  padding: 4px 9px;
  font-size: 12px;
  font-style: normal;
}

.system-log-card {
  width: min(760px, 100%);
  overflow: hidden;
}

.system-log-row {
  min-height: 56px;
  border-top: 1px solid #edf2f8;
  display: grid;
  grid-template-columns: 34px 1fr 76px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.system-log-row:first-child {
  border-top: 0;
}

.system-log-row b {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #0b63d8;
  background: #eaf2ff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 400;
}

.system-log-row span {
  display: grid;
  gap: 4px;
}

.system-log-row strong {
  color: #344961;
  font-size: 13px;
  font-weight: 400;
}

.system-log-row small,
.system-log-row em {
  color: #7a8ca4;
  font-size: 12px;
  font-style: normal;
}

.system-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.34);
  display: grid;
  place-items: center;
  padding: 24px;
}

.system-modal-backdrop[hidden] {
  display: none !important;
}

.system-user-dialog {
  width: min(680px, 100%);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
  padding: 22px;
}

.system-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.system-dialog-head h3 {
  margin: 0;
  color: #102033;
  font-size: 20px;
  font-weight: 400;
}

.system-dialog-head button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  color: #64748b;
  background: #f1f5f9;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 20px;
}

.system-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.system-dialog-grid--col1 {
  grid-template-columns: 1fr;
}

#changePasswordDialog .system-user-dialog {
  width: min(420px, 100%);
}

.system-dialog-head--centered {
  position: relative;
  justify-content: center;
}

.system-dialog-head--centered h3 {
  text-align: center;
}

.system-dialog-head--centered button {
  position: absolute;
  right: 0;
}

.pw-field {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-field input {
  flex: 1;
  padding-right: 40px;
}

.pw-toggle {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 6px;
}

.pw-toggle:hover {
  color: #475569;
  background: #f1f5f9;
}

.pw-toggle svg {
  width: 18px;
  height: 18px;
}

.system-dialog-inline-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 0;
  padding-top: 25px;
}

.system-inline-add-button {
  width: 110px;
  min-height: 40px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #0b63d8;
  background: #ffffff;
  font-size: 14px;
}

.system-inline-add-button:hover:not(:disabled) {
  border-color: #93c5fd;
  color: #0756bd;
  background: #ffffff;
}

.system-inline-add-button:active:not(:disabled) {
  border-color: #0b63d8;
  color: #ffffff;
  background: #0b63d8;
}

.system-inline-add-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.system-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e8eef6;
}

.system-dialog-actions button {
  min-width: 128px;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #d9e4f2;
  color: #344961;
  background: #ffffff;
}

.system-dialog-actions button:last-child {
  border-color: #bfdbfe;
  color: #0b63d8;
  background: #ffffff;
}

.system-dialog-actions button:last-child:hover:not(:disabled) {
  border-color: #93c5fd;
  color: #0756bd;
  background: #ffffff;
}

.system-dialog-actions button:last-child:active:not(:disabled) {
  border-color: #0b63d8;
  color: #ffffff;
  background: #0b63d8;
}

.system-page :where(h1, h2, h3, strong, b, button, .system-user-head, .system-role-chip, .system-status-chip) {
  font-weight: 400;
}

.chat-page {
  height: 100vh;
  overflow: hidden;
}

.chat-shell {
  height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-module-header {
  min-height: 104px;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.chat-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
  /* 行高锁死为容器高度：默认 auto 行会被侧栏的长会话列表撑高，
     把输入框顶出视口，而页面本身又不可滚动。 */
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.chat-shell.sidebar-collapsed .chat-layout {
  grid-template-columns: 1fr;
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.chat-shell.sidebar-collapsed .chat-sidebar {
  display: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-top h2 {
  margin: 0;
  color: #26384d;
  font-size: 16px;
  font-weight: 400;
}

.sidebar-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#newChatBtn {
  background: var(--accent);
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-icon-button,
.chat-sidebar-restore {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #2563eb;
  background: #eff6ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-icon-button:hover,
.chat-sidebar-restore:hover {
  background: #dbeafe;
  filter: none;
  transform: none;
}

.chat-icon-button svg,
.chat-sidebar-restore svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-sidebar-restore {
  display: none;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.chat-shell.sidebar-collapsed .chat-sidebar-restore {
  display: inline-flex;
}

.session-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-panel h3 {
  color: #26384d;
  font-size: 14px;
  font-weight: 400;
}

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 4px;
}

.session-item {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  padding: 10px;
}

.session-item.active {
  border-color: var(--accent);
  background: var(--panel-2);
}

.session-title {
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-main {
  position: relative;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-main-tools {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 28px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.chat-main-tools .chat-icon-button {
  background: rgba(239, 246, 255, 0.94);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.chat-main-tools .chat-sidebar-restore {
  pointer-events: auto;
}

.chat-main-tools #toggleChatFullscreenBtn {
  margin-left: auto;
}

.chat-main-tools .icon-restore,
.chat-main-tools .active .icon-expand {
  display: none;
}

.chat-main-tools .active .icon-restore {
  display: block;
}

.chat-shell.chat-main-fullscreen {
  padding: 0;
}

.chat-shell.chat-main-fullscreen > .top-app-nav {
  display: none;
}

.chat-shell.chat-main-fullscreen .chat-layout {
  position: fixed;
  inset: 0;
  z-index: 1400;
  grid-template-columns: 1fr;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.chat-shell.chat-main-fullscreen .chat-sidebar,
.chat-shell.chat-main-fullscreen .chat-sidebar-restore {
  display: none;
}

.chat-shell.chat-main-fullscreen .chat-main {
  padding: 16px;
}

.chat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.chat-main-header h2 {
  color: #26384d;
  font-size: 16px;
  font-weight: 400;
}

.session-label {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

.filter-label {
  margin-top: 6px;
  font-size: 13px;
  color: #1f7fd1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
  max-width: min(70vw, 880px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#clearHistoryBtn {
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  font-weight: 400;
  width: 100%;
  min-height: 36px;
}

.chat-messages {
  margin-top: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  padding: 14px 20px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.chat-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  text-align: center;
  padding: 20px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #2563eb;
  background: #eaf2ff;
  border: 1px solid #dbeafe;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
}

.chat-avatar.user {
  color: #ffffff;
  background: #3b82f6;
  border-color: #3b82f6;
}

.bubble {
  width: fit-content;
  max-width: min(78%, 860px);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  font-size: 13px;
  font-weight: 400;
}

.message.user .bubble {
  max-width: min(62%, 720px);
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #fff;
  color: #1e3a8a;
  border-bottom-right-radius: 4px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
}

.message.assistant .bubble {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding-left: 0;
  box-shadow: none;
}

.message.assistant .bubble > div:first-child {
  font-weight: 400;
}

.thinking-bubble {
  width: auto;
  min-width: 190px;
  color: #496176;
}

.thinking-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #60a5fa;
  opacity: 0.35;
  animation: thinkingPulse 1.1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinkingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.bubble-time {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.message.user .bubble-time {
  color: #5b79b2;
}

.bubble-citations {
  margin: 12px 0 0;
  padding: 9px 10px;
  border: 1px solid #cfe0f5;
  border-radius: 10px;
  background: #f7fbff;
}

.bubble-citations-title {
  margin-bottom: 7px;
  color: #45637f;
  font-size: 12px;
  font-weight: 500;
}

.bubble-citations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bubble-citation-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eaf2ff;
  color: #0b63d8;
  font-size: 12px;
  line-height: 1.35;
  padding: 4px 8px;
  word-break: break-all;
}

.bubble-public-tip {
  color: #334155;
  display: block;
}

.public-tip-content p {
  margin: 2px 0;
  font-size: 13px;
  line-height: 1.7;
}

.public-tip-content p:empty {
  margin: 0;
}

.public-tip-content a {
  color: #2563eb;
  text-decoration: none;
}

.public-tip-content a:hover {
  text-decoration: underline;
}

.bubble-previews {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid #d6e8f8;
  border-radius: 10px;
  padding: 8px 10px;
}

.bubble-previews-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.bubble-previews ul {
  margin: 0;
  padding-left: 18px;
}

.bubble-previews li {
  font-size: 13px;
  line-height: 1.5;
}

.table-wrap,
.chart-wrap {
  margin-top: 12px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.table-wrap th,
.table-wrap td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
}

.table-wrap thead th {
  background: var(--panel-2);
}

.chart-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.chart-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.chat-composer {
  margin-top: 8px;
}

.composer-input-wrap {
  position: relative;
}

.chat-composer textarea {
  margin-top: 0;
  min-height: 92px;
  resize: vertical;
  border-radius: 18px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 400;
  padding: 18px 92px 44px 16px;
  width: 100%;
  box-sizing: border-box;
}

.chat-composer textarea::placeholder {
  color: #8a99ad;
  font-size: 13px;
  font-weight: 400;
}

/* 随问题贴的图：输入框上方一排缩略图 */
.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 8px 0;
}

.composer-attachment {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  padding: 4px 24px 4px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12px;
  color: #475569;
}

.composer-attachment img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 7px;
  flex: none;
}

.composer-attachment .attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment .attachment-state {
  color: #94a3b8;
}

.composer-attachment.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.composer-attachment button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.composer-attachment button:hover {
  color: #475569;
  background: transparent;
  filter: none;
  transform: none;
}

/* 历史气泡里的附图 */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.message-attachments img {
  max-width: 160px;
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: zoom-in;
}

.message-attachments .attachment-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 12px;
}

.composer-actions {
  position: absolute;
  right: 14px;
  bottom: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.composer-icon-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 999px;
  background: transparent;
  color: #8a99ad;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.composer-icon-btn:hover {
  color: #64748b;
  background: transparent;
  filter: none;
  transform: none;
}

.composer-icon-btn.recording {
  color: #dc2626;
  background: transparent;
}

.composer-icon-btn svg {
  width: 17px;
  height: 17px;
}

:is(#sendBtn, .composer-send-btn) {
  width: 34px;
  height: 34px;
  min-height: 34px;
  color: #c7d0dc;
  background: #eef2f7;
}

:is(#sendBtn, .composer-send-btn):hover {
  color: #9aa8b8;
  background: #e8eef5;
}

.composer-icon-btn:disabled {
  color: #94a3b8;
  cursor: default;
  opacity: 0.72;
}

.chat-page .account-name,
.chat-page .secondary-btn {
  font-size: 13px;
  font-weight: 400;
}

.chat-page :where(h1, h2, h3, strong, b, button, .bubble, .bubble *, .message, .message *, .session-item, .session-item *) {
  font-weight: 400;
}

@media (max-width: 960px) {
  .page,
  .page.narrow,
  .module-page {
    width: min(100% - 28px, 1000px);
  }

  .upload-module-page {
    width: calc(100% - 20px);
  }

  .module-header {
    min-height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .top-app-nav {
    min-height: auto;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }

  .top-app-brand {
    padding-right: 0;
    border-right: 0;
  }

  .top-module-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .top-module-nav a {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    white-space: nowrap;
  }

  .module-actions {
    justify-content: flex-start;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-panel {
    width: 100%;
    margin-top: 28px;
  }

  .workspace-item {
    min-height: 118px;
  }

  .kb-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kb-console-shell {
    grid-template-columns: 1fr;
  }

  .kb-feature-panel {
    grid-template-columns: 1fr;
  }

  .kb-graph-head,
  .kb-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-graph-search {
    width: 100%;
  }

  .kb-graph-metrics {
    grid-template-columns: 1fr;
  }

  .kb-bulk-permission-head,
  .kb-bulk-permission-controls {
    grid-template-columns: 1fr;
  }

  .kb-bulk-permission-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-bulk-permission-controls label {
    flex: none;
  }

  .kb-bulk-permission-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-bulk-permission-checks {
    padding-bottom: 0;
  }

  .kb-document-panel {
    min-height: 520px;
  }

  .kb-document-toolbar {
    grid-template-columns: 1fr;
  }

  .kb-manage-actions {
    grid-template-columns: 1fr;
  }

  .kb-manage-actions button {
    white-space: normal;
  }

  .kb-upload-dialog {
    width: calc(100vw - 24px);
    padding: 18px;
  }

  .kb-custom-tag {
    grid-template-columns: 1fr;
  }

  .chat-shell {
    padding: 10px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .chat-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
  }

  .chat-main {
    min-height: 0;
  }

  .page-hero,
  .admin-hero,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .account-bar,
  .top-actions {
    justify-content: flex-start;
  }

  .top-app-nav .account-bar {
    margin-right: 0;
  }

  .admin-grid,
  .admin-role-grid {
    grid-template-columns: 1fr;
  }

  .system-management-topbar,
  .system-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .system-management-topbar {
    padding: 12px 16px;
  }

  .system-management-topbar > strong {
    padding-right: 0;
    border-right: 0;
  }

  .system-tab-panel {
    padding: 18px 14px 28px;
  }

  .system-stat-grid,
  .system-stat-grid.three,
  .system-role-layout,
  .system-role-edit-grid,
  .system-role-summary-strip,
  .system-dialog-grid {
    grid-template-columns: 1fr;
  }

  .system-actions {
    justify-content: flex-start;
  }

  .system-dialog-inline-actions {
    padding-top: 0;
  }

  .system-role-list-card {
    position: static;
  }

  .file-picker {
    flex-direction: column;
    align-items: stretch;
  }

  .file-status {
    white-space: normal;
  }
}

/* --- streaming answer ------------------------------------------------- */
/* Text arrives token by token; the caret tells the reader it is still being
   written, which reads very differently from a frozen bubble. */
.stream-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.stream-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #0b63d8;
  animation: stream-caret 1s steps(2, start) infinite;
}

@keyframes stream-caret {
  to { visibility: hidden; }
}

/* --- citation location ------------------------------------------------ */
.bubble-citation-badge {
  gap: 6px;
}

/* 可点击的引用（跳转原文）：保持徽章外观，仅加悬停反馈 */
a.bubble-citation-badge {
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

a.bubble-citation-badge:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.citation-name {
  font-weight: 500;
}

/* The page / section the answer was taken from, so the claim can be checked. */
.citation-location {
  padding: 1px 6px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cfe0f5;
  color: #45637f;
  font-size: 11px;
  white-space: nowrap;
}

/* --- starter questions ------------------------------------------------ */
/* An empty chat gives a trial user nothing to do; these make the first
   successful question one click away. */
.chat-starters {
  margin-top: 18px;
  width: 100%;
  max-width: 680px;
}

.chat-starters-title {
  margin-bottom: 10px;
  color: #6b7c92;
  font-size: 13px;
}

.chat-starters-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.chat-starter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #dbe6f3;
  border-radius: 12px;
  background: #ffffff;
  color: #1f2d3d;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.chat-starter:hover {
  border-color: #0b63d8;
  box-shadow: 0 4px 14px rgba(11, 99, 216, 0.12);
  transform: translateY(-1px);
}

.chat-starter-hint {
  color: #7b8ca1;
  font-size: 12px;
}

/* --- reasoning stream -------------------------------------------------- */
/* Thinking models emit several seconds of reasoning before the answer. Showing
   it keeps the user oriented instead of watching a frozen bubble. */
.stream-reasoning {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed #d5dce6;
  border-radius: 10px;
  background: #fafbfd;
  color: #6b7c92;
  font-size: 12px;
}

.stream-reasoning > summary {
  cursor: pointer;
  color: #7b8ca1;
  font-size: 12px;
  user-select: none;
}

.stream-reasoning-text {
  margin-top: 6px;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* --- answer feedback --------------------------------------------------- */
.bubble-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #eef2f7;
}

.bubble-feedback-label {
  color: #8a99ac;
  font-size: 12px;
}

.bubble-feedback-btn {
  padding: 2px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bubble-feedback-btn:hover:not(:disabled) {
  border-color: #0b63d8;
  background: #f2f7ff;
}

.bubble-feedback-btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.bubble-feedback-btn.is-active {
  border-color: #0b63d8;
  background: #eaf2ff;
  opacity: 1;
}

/* --- security banner --------------------------------------------------- */
.security-banner {
  position: sticky;
  top: 0;
  z-index: 999;
  padding: 9px 16px;
  background: #fff4e5;
  border-bottom: 1px solid #ffd8a8;
  color: #8a4b08;
  font-size: 13px;
  text-align: center;
}

/* --- model picker ------------------------------------------------------ */
.model-picker[hidden] {
  display: none;
}

/* Says what the choice costs, so "why is this slow" never becomes a support
   question. Full text is on the title attribute. */
.model-hint {
  display: block;
  margin-top: 4px;
  color: #7b8ca1;
  font-size: 11px;
  line-height: 1.5;
  cursor: help;
}

/* --- starter question editor ------------------------------------------ */
.starter-editor {
  padding: 18px 20px;
  border: 1px solid #e6ecf4;
  border-radius: 12px;
  background: #ffffff;
}

.starter-title-field {
  display: block;
  margin-bottom: 16px;
  max-width: 420px;
}

.starter-title-field > span {
  display: block;
  margin-bottom: 6px;
  color: #45637f;
  font-size: 13px;
}

.starter-title-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  font-size: 13px;
}

.starter-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.starter-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: center;
}

.starter-row input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  font-size: 13px;
}

.starter-remove {
  padding: 7px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #b4232a;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.starter-remove:hover {
  border-color: #b4232a;
  background: #fff5f5;
}

.starter-note {
  margin-top: 12px;
  color: #8a99ac;
  font-size: 12px;
}

@media (max-width: 720px) {
  .starter-row {
    grid-template-columns: 1fr;
  }
}

.chat-models-editor { display: grid; gap: 12px; margin: 4px 0 14px; }
.cm-row { display: grid; grid-template-columns: 150px minmax(180px, 1fr) minmax(180px, 1fr) auto auto; gap: 12px 16px; align-items: end; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.cm-row label { display: grid; gap: 6px; font-size: 13px; color: #52637a; }
.cm-row label input, .cm-row label select { margin: 0; }
.cm-row .cm-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; min-height: 42px; white-space: nowrap; }
.cm-row .cm-name { font-size: 14px; color: #1f2d3d; font-weight: 500; }
.cm-row .cm-hint { grid-column: 1 / -1; font-size: 12px; color: #7a8ca1; }
.cm-row.is-default { border-color: #bfdbfe; background: #f8fbff; }
.model-config-legacy { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 12px; }
.model-config-legacy > summary { cursor: pointer; color: #64748b; font-size: 13px; }
@media (max-width: 1100px) { .cm-row { grid-template-columns: 1fr 1fr; } }
.model-config-editor {
  padding: 18px 20px;
  border: 1px solid #e6ecf4;
  border-radius: 12px;
  background: #ffffff;
}

.model-config-status {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f7fb;
  color: #45637f;
  font-size: 13px;
}

.model-config-status[data-state="ok"] {
  background: #eefaf2;
  color: #217a4b;
}

.model-config-status[data-state="missing"] {
  background: #fff6e8;
  color: #97590a;
}

/* Key 比推荐问题长得多，420px 放不下一整条，核对末尾字符时会很难受 */
.model-config-field {
  max-width: 560px;
}

/* 切块配置卡（知识管理页侧栏，仅管理员可见） */
.kb-chunk-config {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.kb-chunk-config label {
  font-size: 13px;
  color: #52637a;
}

.kb-chunk-config input {
  margin-top: 4px;
}

.kb-chunk-note {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.6;
}

/* 上传弹窗 / 重新解析弹窗里"对这一份单独指定切块参数"的两个输入框 */
.kb-upload-chunk-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.kb-upload-chunk-fields label {
  font-size: 13px;
  color: #52637a;
}

.kb-upload-chunk-fields input {
  width: 100%;
  margin-top: 4px;
}

.kb-chunk-result {
  min-height: 16px;
  color: #16a34a;
  font-size: 12px;
}

.kb-chunk-save-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 检索设置（问答页侧栏，仅管理员可见） */
.retrieval-settings {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 12px;
}

.retrieval-settings summary {
  cursor: pointer;
  color: #52637a;
  font-size: 13px;
  user-select: none;
}

.retrieval-settings label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: #52637a;
}

.retrieval-settings small {
  display: block;
  margin-top: 3px;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.5;
}

.retrieval-settings button {
  margin-top: 12px;
  width: 100%;
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
}

.retrieval-result {
  min-height: 16px;
  margin-top: 6px;
  color: #16a34a;
  font-size: 12px;
}

/* --- 大模型统一接入网关（系统管理） --------------------------------------- */
.gw-budget-bar {
  position: relative;
  height: 10px;
  margin: 4px 0 10px;
  border-radius: 999px;
  background: #e8eef6;
  overflow: visible;
}

.gw-budget-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #2563eb;
  transition: width 0.3s ease;
}

.gw-budget-bar i[data-state="warn"] { background: #f59e0b; }
.gw-budget-bar i[data-state="danger"] { background: #dc2626; }

.gw-budget-bar em {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 18px;
  background: #f59e0b;
}

#gwState[data-state="warn"] { color: #d97706; }
#gwState[data-state="danger"] { color: #dc2626; }

.gw-result { min-height: 18px; margin: 0 0 10px; color: #16a34a; font-size: 13px; }
.gw-muted { color: #7a8ca1; font-size: 12px; }

.gw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.gw-card {
  border: 1px solid #e6ecf4;
  border-radius: 12px;
  background: #ffffff;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.gw-card-wide { grid-column: 1 / -1; }

.gw-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gw-card-head strong { color: #26384d; font-size: 14px; }
.gw-card-head > span { display: inline-flex; align-items: center; gap: 8px; color: #7a8ca1; font-size: 12px; }
.gw-card-head select, .gw-card-head input[type="date"] { margin: 0; width: auto; padding: 6px 10px; }

.gw-card label { display: block; font-size: 13px; color: #52637a; }
.gw-card label input, .gw-card label textarea { margin-top: 4px; }
.gw-check { display: inline-flex !important; align-items: center; gap: 6px; }
.gw-check input { width: auto; margin: 0; }

.gw-provider {
  border: 1px solid #e6ecf4;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #f8fbff;
}

.gw-provider-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gw-provider-name { width: 180px !important; margin: 0 !important; padding: 6px 10px !important; }
.gw-provider-id { color: #64748b; font-size: 12px; }
.gw-provider-tools { margin-left: auto; display: inline-flex; gap: 6px; }
.gw-provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin-top: 8px; }
.gw-provider-grid label small { color: #94a3b8; font-weight: 400; margin-left: 6px; }
.gw-span2 { grid-column: 1 / -1; }
.gw-probe-result { min-height: 16px; margin: 6px 0 0; font-size: 12px; color: #dc2626; }
.gw-probe-result[data-ok="true"] { color: #16a34a; }
.gw-danger { color: #dc2626 !important; border-color: #fecaca !important; }

.gw-routes label { margin-bottom: 6px; }
.gw-levels { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.gw-rule {
  display: grid;
  grid-template-columns: 24px 110px 120px minmax(0, 1fr) 120px 44px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.gw-rule input, .gw-rule select { margin: 0; padding: 6px 8px; font-size: 12px; }
.gw-rule input[type="checkbox"] { width: 16px; height: 16px; }
.gw-rule-pattern { font-family: Consolas, monospace; }

.gw-circuits { display: flex; flex-wrap: wrap; gap: 8px; }
.gw-chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: #ecfdf5; color: #047857; }
.gw-chip.danger { background: #fff1f2; color: #dc2626; }

.gw-table-wrap { overflow-x: auto; }
.gw-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.gw-table th, .gw-table td { padding: 6px 8px; border-bottom: 1px solid #eef2f7; text-align: left; white-space: nowrap; }
.gw-table th { color: #5e6f86; background: #f8fafc; font-weight: 400; }
.gw-table .gw-total td { font-weight: 600; }
.gw-ok { color: #16a34a; }
.gw-bad { color: #dc2626; }

@media (max-width: 1100px) {
  .gw-grid { grid-template-columns: 1fr; }
  .gw-provider-grid { grid-template-columns: 1fr; }
}

/* --- 智能大脑工作台 ------------------------------------------------------- */
.ag-panel[hidden] { display: none !important; }
.ag-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.ag-side { display: grid; gap: 14px; }
.ag-main { min-width: 0; }
.ag-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.ag-form-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 16px 18px; display: grid; gap: 12px; align-content: start; box-shadow: 0 10px 26px rgba(15, 32, 51, 0.04); }
.ag-form-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ag-form-head strong { color: #26384d; font-size: 14px; }
.ag-form-head > span { display: inline-flex; gap: 8px; align-items: center; }
.ag-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.ag-grid2 label, .ag-form-card > label { font-size: 13px; color: #52637a; }
.ag-scope { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.ag-scope input[hidden] { display: none; }
.ag-scope .cs-root { margin: 0; }
.ag-span2 { grid-column: 1 / -1; }
.ag-label { display: block; font-size: 13px; color: #52637a; margin-bottom: 6px; }
.ag-checklist { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.ag-checklist code { color: #64748b; font-size: 11px; }
.ag-hint { color: #7a8ca1; font-size: 12px; line-height: 1.6; }
.ag-result { min-height: 16px; color: #16a34a; font-size: 13px; margin: 0; }
.ag-ok { color: #16a34a; } .ag-bad { color: #dc2626; }
.ag-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: #eaf2ff; color: #0b63d8; font-size: 11px; font-style: normal; margin-left: 4px; }
.ag-tag.off { background: #f1f5f9; color: #64748b; }
.ag-agent-list { display: grid; gap: 6px; margin-top: 10px; }
/* 列表项：图标 + 名称 + 说明 + 选中勾 */
.ag-item { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 18px; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #26384d; min-height: 0; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
.ag-item:hover { background: #f5f8fc; border-color: #e6edf5; transform: none; filter: none; }
.ag-item.active { background: #eaf2ff; border-color: #bfdbfe; box-shadow: 0 4px 14px rgba(11, 99, 216, 0.08); }
.ag-item-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: #f1f5f9; }
.ag-item.active .ag-item-icon { background: #fff; box-shadow: inset 0 0 0 1px #bfdbfe; }
.ag-item-body { display: grid; gap: 2px; min-width: 0; }
.ag-item-title { font-size: 13.5px; font-weight: 500; color: #1f2d3d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-item.active .ag-item-title { color: #0b63d8; }
.ag-item-desc { font-size: 12px; color: #7a8ca1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-item-check { font-size: 13px; color: #0b63d8; opacity: 0; transition: opacity 0.15s; }
.ag-item.active .ag-item-check { opacity: 1; }
.ag-item-compact { grid-template-columns: 26px minmax(0, 1fr); padding: 6px 8px; }
.ag-item-compact .ag-item-icon { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; }
.ag-item-compact .ag-item-title { font-weight: 400; white-space: normal; line-height: 1.4; }
.ag-side .kb-side-card { padding: 14px 12px; }
.ag-side .kb-side-card-head { padding: 0 4px 8px; font-weight: 500; color: #26384d; }
.ag-side .cs-root { margin-top: 8px; }
.ag-side .ag-hint { margin-top: 8px; padding: 0 4px; }
.ag-agent-btn { width: 100%; text-align: left; border: 1px solid #e6edf5; border-radius: 10px; background: #fff; color: #334155; padding: 9px 12px; display: grid; gap: 3px; }
.ag-agent-btn.active { border-color: #93c5fd; background: #eaf2ff; }
.ag-agent-btn:hover { transform: none; filter: none; background: #f5f9ff; }
.ag-agent-btn strong { font-size: 13px; font-weight: 500; }
.ag-agent-btn small { color: #7a8ca1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#agAgentSaveBtn.is-dirty, #gwSaveBtn.is-dirty { background: #f59e0b !important; border-color: #f59e0b !important; color: #fff !important; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.ag-console-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ag-messages { min-height: 420px; max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 14px; display: grid; gap: 12px; align-content: start; }
.ag-empty { color: #7a8ca1; font-size: 13px; }
.ag-msg { max-width: 92%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.7; }
.ag-msg.user { justify-self: end; background: #0b63d8; color: #fff; }
.ag-msg.assistant { background: #f8fafc; border: 1px solid #e6edf5; }
.ag-meta { display: block; margin-top: 6px; color: #94a3b8; font-size: 11px; }
.ag-trace { margin-top: 8px; font-size: 12px; }
.ag-trace summary { cursor: pointer; color: #0b63d8; }
.ag-step { border-left: 3px solid #bfdbfe; padding: 4px 10px; margin: 6px 0; }
.ag-step.tool { border-color: #86efac; }
.ag-step.bad { border-color: #fca5a5; }
.ag-step pre { white-space: pre-wrap; word-break: break-all; background: #f1f5f9; border-radius: 6px; padding: 6px 8px; margin: 4px 0; font-size: 11.5px; max-height: 220px; overflow: auto; }
.ag-composer { display: flex; gap: 10px; margin-top: 12px; align-items: stretch; }
.ag-composer textarea { margin: 0; flex: 1; }
.ag-composer button { align-self: flex-end; min-height: 42px; padding: 0 22px; }
.ag-chat-composer { margin-top: 12px; }
.ag-chat-composer .ag-attach-list { margin-bottom: 8px; }
.ag-chat-composer textarea { font-size: 14px; }
.ag-chat-composer .composer-icon-btn.is-busy { animation: ag-busy 1s linear infinite; }
@keyframes ag-busy { from { opacity: 1; } 50% { opacity: 0.35; } to { opacity: 1; } }
.ag-composer-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.ag-composer-side { display: grid; gap: 6px; align-content: end; }
.ag-composer-side button { align-self: auto; min-height: 38px; padding: 0 16px; white-space: nowrap; }
.ag-attach-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-attach-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 10px; border-radius: 999px; background: #eaf2ff; color: #1e3a8a; font-size: 12px; max-width: 100%; }
.ag-attach-chip.bad { background: #fee2e2; color: #991b1b; }
.ag-attach-chip small { color: #64748b; }
.ag-attach-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 2px; min-height: 0; font-size: 12px; line-height: 1; }
.ag-msg-attach { margin-top: 6px; font-size: 12px; opacity: 0.85; }

/* --- Markdown 渲染（模型回答） ------------------------------------------ */
.md-body { line-height: 1.75; word-break: break-word; }
.md-body p { margin: 0 0 8px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body .md-h { margin: 12px 0 6px; font-weight: 600; color: #1f2d3d; line-height: 1.4; }
.md-body h3.md-h { font-size: 15px; }
.md-body h4.md-h { font-size: 14px; }
.md-body h5.md-h, .md-body h6.md-h { font-size: 13.5px; }
.md-body .md-h:first-child { margin-top: 0; }
.md-body strong { font-weight: 600; color: #1f2d3d; }
.md-body .md-list { margin: 4px 0 10px; padding-left: 22px; }
.md-body .md-list li { margin: 3px 0; }
.md-body .md-list ul, .md-body .md-list ol { margin: 3px 0 3px; padding-left: 20px; }
.md-body code { background: #f1f5f9; border-radius: 4px; padding: 1px 5px; font-size: 0.92em; }
.md-body pre.md-code { background: #0f172a; color: #e2e8f0; border-radius: 0 0 8px 8px; padding: 10px 12px; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 0 0 10px; }
.md-code-wrap { margin: 6px 0 10px; }
.md-code-tools { display: flex; align-items: center; gap: 6px; background: #1e293b; color: #94a3b8; border-radius: 8px 8px 0 0; padding: 4px 8px 4px 12px; font-size: 11.5px; }
.md-code-lang { flex: 1; text-transform: lowercase; }
.md-code-btn { min-height: 0; padding: 2px 8px; font-size: 11.5px; border-radius: 6px; background: #334155; color: #e2e8f0; border: 0; cursor: pointer; }
.md-code-btn:hover { background: #475569; transform: none; filter: none; }
.md-body pre.md-code code { background: transparent; color: inherit; padding: 0; }
.md-body hr { border: 0; border-top: 1px solid #e6edf5; margin: 10px 0; }
.md-body .md-quote { border-left: 3px solid #bfdbfe; background: #f8fafc; padding: 6px 12px; margin: 6px 0 10px; color: #475569; border-radius: 0 8px 8px 0; }
.md-body .md-table-wrap { overflow-x: auto; margin: 6px 0 10px; }
.md-body .md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md-body .md-table th, .md-body .md-table td { border: 1px solid #e6edf5; padding: 6px 10px; text-align: left; vertical-align: top; }
.md-body .md-table th { background: #f8fafc; font-weight: 600; }
.ag-step-md { font-size: 12.5px; background: #f8fafc; border-radius: 6px; padding: 6px 10px; margin: 4px 0; max-height: 260px; overflow: auto; }
.ag-list { display: grid; gap: 6px; }
.ag-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; border: 1px solid #e6edf5; border-radius: 8px; font-size: 13px; }
.ag-row code { color: #64748b; font-size: 11px; }
.ag-mini { min-height: 26px !important; padding: 2px 10px !important; font-size: 12px !important; }
.ag-tool-catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ag-tool { border: 1px solid #e6edf5; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.ag-tool p { color: #64748b; font-size: 12px; margin-top: 4px; line-height: 1.5; }
.ag-tool code { color: #64748b; font-size: 11px; }
.ag-cheatsheet { font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; color: #475569; background: #f8fafc; border-radius: 8px; padding: 10px; margin-top: 10px; }
.ag-run-out { font-size: 13px; }
.ag-log { display: grid; gap: 4px; }
.ag-run-detail { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: #f8fafc; border-radius: 8px; padding: 12px; max-height: 60vh; overflow: auto; }
.ag-run-modal { width: min(1000px, 94vw); max-width: 1000px; }
.ag-run-modal-body { max-height: 68vh; overflow: auto; display: grid; gap: 12px; padding: 4px 2px; }
.ag-run-modal-body .ag-msg { max-width: 100%; }
.ag-run-modal-body .ag-msg.user { justify-self: end; max-width: 80%; }
.ag-run-modal-body pre { white-space: pre-wrap; word-break: break-all; background: #f8fafc; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 0; }
.ag-run-h { margin: 4px 0 0; font-size: 13px; color: #52637a; font-weight: 500; }
.bq-result { margin-top: 12px; font-size: 14px; }
.bq-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bq-summary { line-height: 1.7; white-space: normal; }
.bq-chart { border: 1px solid #e6edf5; border-radius: 10px; padding: 10px 14px; display: grid; gap: 6px; }
.bq-chart-title { font-size: 12px; color: #52637a; margin-bottom: 4px; }
.bq-bar-row { display: grid; grid-template-columns: 140px 1fr 64px; gap: 10px; align-items: center; font-size: 12px; }
.bq-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #334155; }
.bq-bar { display: block; height: 14px; background: #f1f5f9; border-radius: 7px; overflow: hidden; }
.bq-bar i { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #0b63d8); border-radius: 7px; }
.bq-bar-val { text-align: right; color: #334155; font-variant-numeric: tabular-nums; }
.bq-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-top: 1px solid #eef2f7; padding-top: 10px; }
.bq-actions select { margin: 0; min-height: 26px; padding: 2px 6px; font-size: 12px; width: auto; }
.bq-result details pre { white-space: pre-wrap; word-break: break-all; background: #f8fafc; border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.bq-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.bq-stat { border: 1px solid #e6edf5; border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; }
.bq-stat b { font-size: 18px; color: #0b63d8; } .bq-stat span { font-size: 12px; color: #7a8ca1; }
@media (max-width: 1100px) { .ag-shell, .ag-two, .ag-grid2 { grid-template-columns: 1fr; } }

.model-config-help {
  margin: 4px 0 0;
  color: #45637f;
  font-size: 13px;
}

.model-config-help summary {
  cursor: pointer;
  color: #2f6fd0;
}

.model-config-help ol {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.9;
}

/* --- 入库前预检：待上传列表 ------------------------------------------------ */

.kb-preflight-status {
  margin: 0 0 8px;
  font-size: 12px;
  color: #64748b;
}

.kb-preflight-status.ok {
  color: #15803d;
}

.kb-preflight-status.warn {
  color: #b45309;
}

/* 上面的 .kb-pending-file-list div 会命中行内所有 div，这里把嵌套的两层还原回
   普通块级元素，只留最外层那行的边框和底色。 */
.kb-pending-file-list .kb-pending-file-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  padding: 10px 12px;
}

.kb-pending-file-list .kb-pending-file-main,
.kb-pending-file-list .kb-pending-file-head {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0;
  display: block;
}

.kb-pending-file-list .kb-pending-file-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.kb-pending-file-list .kb-pending-file-row.skipped {
  opacity: 0.55;
}

.kb-pending-file-list .kb-pending-file-row.preflight-duplicate,
.kb-pending-file-list .kb-pending-file-row.preflight-unsupported,
.kb-pending-file-list .kb-pending-file-row.preflight-oversize,
.kb-pending-file-list .kb-pending-file-row.preflight-empty {
  border-color: #fca5a5;
  background: #fef4f4;
}

.kb-pending-file-list .kb-pending-file-row.preflight-replace,
.kb-pending-file-list .kb-pending-file-row.preflight-version,
.kb-pending-file-list .kb-pending-file-row.preflight-name {
  border-color: #fcd9a5;
  background: #fffaf2;
}

.kb-pending-file-list input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin-top: 3px;
  accent-color: #2563eb;
}

/* 上面的 .kb-pending-file-list span 是按 22px 图标框写的，会把徽章挤成一个
   小方块 —— 这里必须用更高的特指度把宽高还原。 */
.kb-pending-file-list .kb-preflight-badge {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 1px 8px;
  background: none;
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.kb-pending-file-list .kb-preflight-badge.blocking {
  color: #b91c1c;
  background: #fee2e2;
}

.kb-pending-file-list .kb-preflight-badge.warning {
  color: #b45309;
  background: #fef3c7;
}

.kb-pending-file-reason {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.6;
  color: #64748b;
}

/* --- 入库后体检 ------------------------------------------------------------ */

.kb-health-main {
  display: grid;
  gap: 16px;
  align-content: start;
}

.kb-health-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.kb-health-head strong {
  font-size: 16px;
  color: #0f172a;
}

.kb-health-head p {
  margin: 6px 0 0;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.8;
  color: #64748b;
}

.kb-health-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.kb-health-actions select {
  height: 34px;
  margin-top: 0;
  width: auto;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
}

/* 按钮与左侧下拉框同高：文字不换行，否则"开始体检"折成两行把按钮撑高 */
.kb-health-actions button {
  height: 34px;
  min-height: 34px;
  padding: 0 16px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1;
}

.kb-health-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.kb-health-summary article {
  border: 1px solid #e6edf5;
  border-radius: 12px;
  background: #ffffff;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}

.kb-health-summary small {
  font-size: 12px;
  color: #64748b;
}

.kb-health-summary strong {
  font-size: 24px;
  color: #0f172a;
}

.kb-health-summary strong.ok {
  color: #15803d;
}

.kb-health-summary strong.warn {
  color: #b45309;
}

.kb-health-summary strong.danger {
  color: #b91c1c;
}

.kb-health-result {
  font-size: 13px;
  line-height: 1.8;
  color: #64748b;
}

.kb-health-groups {
  display: grid;
  gap: 14px;
}

.kb-health-group {
  border: 1px solid #e6edf5;
  border-left: 3px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  padding: 16px 18px;
}

.kb-health-group.severity-high {
  border-left-color: #dc2626;
}

.kb-health-group.severity-medium {
  border-left-color: #d97706;
}

.kb-health-group.severity-low {
  border-left-color: #2563eb;
}

.kb-health-group header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-health-group header strong {
  font-size: 15px;
  color: #0f172a;
}

.kb-health-group header em {
  font-style: normal;
  font-size: 12px;
  color: #64748b;
}

.kb-health-chip {
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11px;
}

.kb-health-chip.high {
  color: #b91c1c;
  background: #fee2e2;
}

.kb-health-chip.medium {
  color: #b45309;
  background: #fef3c7;
}

.kb-health-chip.low {
  color: #1d4ed8;
  background: #eaf2ff;
}

.kb-health-why,
.kb-health-action {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.8;
  color: #64748b;
}

.kb-health-action {
  color: #334155;
}

.kb-health-item-list {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.kb-health-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid #e6edf5;
  border-radius: 10px;
  background: #f8fbff;
  padding: 10px 12px;
}

.kb-health-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin-top: 3px;
  accent-color: #2563eb;
}

.kb-health-item-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.kb-health-item-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: #0f172a;
}

.kb-health-item-kb {
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  color: #2563eb;
  background: #eaf2ff;
}

.kb-health-item small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.6;
  color: #64748b;
}

.kb-health-item-related {
  color: #94a3b8;
}

/* 选中后浮在底部的操作条：清单很长时，滚到哪儿都能直接删。 */
.kb-health-action-bar {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  padding: 10px 14px;
}

.kb-health-action-bar span {
  margin-right: auto;
  font-size: 13px;
  color: #334155;
}

.kb-health-delete-btn {
  height: 32px;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 0 14px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  cursor: pointer;
}

.kb-health-delete-btn:hover {
  background: #fee2e2;
}

/* ======================================================================== */
/* 智能测试工作台（测试策略/计划 + 用例生成）                                  */
/* ======================================================================== */

.tk-shell {
  display: grid;
  grid-template-columns: 330px 18px 1fr;
  gap: 10px;
  align-items: start;
}

/* 收起左侧输入栏，把宽度全部让给内容区（长表格审阅时）。
   侧栏 display:none 后网格里只剩「把手 + 内容区」两个子元素，
   列定义必须跟着变成两列，否则内容区会掉进 18px 的把手列里。 */
.tk-shell.collapsed { grid-template-columns: 18px 1fr; }
.tk-shell.collapsed .tk-side { display: none; }

.tk-side-toggle {
  position: sticky;
  top: 96px;
  width: 18px;
  height: 72px;
  min-height: 72px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tk-side-toggle:hover {
  color: #2563eb;
  border-color: #93c5fd;
  background: #f5f9ff;
  transform: none;
  filter: none;
}

.tk-side-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.tk-side-toggle.collapsed svg { transform: rotate(180deg); }

@media (max-width: 960px) {
  .tk-shell { grid-template-columns: 1fr; }
  .tk-side-toggle { display: none; }
}

.tk-side { display: flex; flex-direction: column; gap: 14px; }

.tk-form { display: flex; flex-direction: column; gap: 10px; }

.tk-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #334155;
}

.tk-form input:not([type="checkbox"]),
.tk-form select,
.tk-form textarea {
  font: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.tk-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tk-status { font-size: 12px; color: #475569; min-height: 16px; margin: 0; }

.tk-doc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px;
  background: #f8fafc;
}

.tk-doc-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.tk-doc-item:hover { background: #eef4fd; }

/* 全局有 input { width:100%; padding:11px } 的规则，复选框中招后会把文件名
   挤成一列竖排字 —— 这里把它钉回复选框该有的尺寸。 */
.tk-doc-item input[type="checkbox"] {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: #2563eb;
  cursor: pointer;
}

.tk-doc-item span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.5;
  color: #1e293b;
}

.tk-doc-item small { flex: 0 0 auto; color: #94a3b8; font-size: 11px; }
.tk-doc-empty { color: #94a3b8; font-size: 12px; margin: 4px 2px; }

.tk-history-list { display: flex; flex-direction: column; gap: 6px; }

.tk-history-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 8px 6px 8px 10px;
}

.tk-history-item:hover { border-color: #93c5fd; background: #f5f9ff; }
.tk-history-item.active { border-color: #2563eb; background: #eaf2ff; }
.tk-history-item strong { font-size: 13px; color: #1e293b; word-break: break-all; }
.tk-history-item small { font-size: 11px; color: #64748b; }

.tk-history-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.tk-history-open:hover { background: transparent; transform: none; filter: none; }

.tk-history-del {
  flex: 0 0 auto;
  align-self: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.tk-history-item:hover .tk-history-del,
.tk-history-del:focus-visible {
  opacity: 1;
}

/* 触屏没有 hover，删除入口必须常显。 */
@media (hover: none) {
  .tk-history-del { opacity: 1; }
}

.tk-history-del:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: none;
  filter: none;
}

.tk-history-del svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tk-main {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  min-height: 380px;
}

.tk-empty { color: #64748b; font-size: 13px; line-height: 1.9; padding: 30px 10px; text-align: center; }

/* 吸顶：滚到长表格深处时「保存修改」等操作仍然可见。负外边距把
   .tk-main 的内边距吃掉，吸住时背景能盖满整行。 */
.tk-result-head {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  margin: -16px -18px 8px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #eef2f7;
  border-radius: 12px 12px 0 0;
}

.tk-result-title {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  min-width: 260px;
  flex: 1;
}

.tk-result-title:hover, .tk-result-title:focus { border-color: #cbd5e1; }
.tk-result-title-text { font-size: 16px; font-weight: 600; }
.tk-result-head small { color: #64748b; font-size: 12px; }
.tk-result-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.tk-result-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  gap: 0;
}

.tk-result-actions button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tk-danger { color: #dc2626; }

/* 有未保存修改时保存键亮起，提醒别忘了落库 */
#tkPlanSaveBtn.tk-dirty {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.tk-block { margin-top: 14px; }
.tk-block h3 { font-size: 14px; margin: 0; color: #1e293b; }
.tk-block textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
  box-sizing: border-box;
}

.tk-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.tk-add-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  gap: 0;
  border: 1px dashed #94a3b8;
  background: transparent;
  color: #475569;
  border-radius: 6px;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
  margin-top: 6px;
}

.tk-add-row-btn svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tk-add-row-btn:hover { border-color: #2563eb; color: #2563eb; background: #f5f9ff; }

.tk-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12.5px;
}

.tk-table th {
  background: #f1f5f9;
  color: #334155;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  font-weight: 600;
}

.tk-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 8px;
  vertical-align: top;
  word-break: break-word;
  line-height: 1.6;
}

/* 正在编辑的格子有明确的视觉反馈——这是"结果可人工调整"的演示点 */
.tk-table td[contenteditable="true"]:focus,
.tk-req-cell [contenteditable="true"]:focus {
  outline: 2px solid #93c5fd;
  outline-offset: -1px;
  background: #f8fbff;
}

.tk-table .tk-readonly { color: #64748b; background: #fafbfc; }
.tk-table .tk-multiline { white-space: pre-wrap; }

.tk-row-tools { width: 34px; text-align: center; }
/* 盖过 .tk-table td 的通用样式：垂直居中；34px 窄列去掉左右内边距，
   否则 28px 的图标按钮装不下、只能从左起排向右溢出，看着就偏右 */
.tk-table td.tk-row-tools {
  vertical-align: middle;
  text-align: center;
  padding: 4px 0;
}
.tk-row-tools button {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  line-height: 1;
  padding: 0;
}
.tk-row-tools button:hover { color: #dc2626; background: #fff1f2; }

.tk-cases-table { font-size: 12px; }

.tk-req-cell { background: #fbfdff; }
.tk-req-location {
  display: inline-block;
  font-size: 11px;
  color: #45637f;
  background: #eaf2ff;
  border: 1px solid #cfe0f5;
  border-radius: 999px;
  padding: 1px 8px;
  margin-bottom: 4px;
}
.tk-req-cell small { display: block; color: #64748b; font-size: 11px; line-height: 1.5; }

.tk-trace { margin-top: 12px; border-top: 1px dashed #e2e8f0; padding-top: 10px; }
.tk-trace h3 { font-size: 14px; margin: 0 0 8px; }
.tk-trace-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #f8fafc;
  font-size: 12px;
}
.tk-trace-item strong { color: #1e293b; }
.tk-trace-item em { color: #7c3aed; font-style: normal; }
.tk-trace-item span { color: #475569; line-height: 1.6; }

#tkCasesTableWrap { overflow-x: auto; }

/* --- 规范文档选择器（自定义下拉）--------------------------------------- */
.tk-doc-picker { position: relative; }

.tk-doc-trigger {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.tk-doc-trigger:hover { border-color: #93c5fd; }

.tk-doc-trigger[aria-expanded="true"] {
  border-color: #2563eb;
  outline: 2px solid color-mix(in oklab, #2563eb 30%, transparent);
}

.tk-doc-trigger span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tk-doc-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.tk-doc-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }

/* 展开面板允许比侧栏宽，长文件名不用挤成两行也能看全 */
.tk-doc-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  width: min(520px, calc(100vw - 48px));
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.tk-doc-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1e293b;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
}

.tk-doc-option:hover { background: #eef4fd; transform: none; filter: none; }

.tk-doc-option.selected { background: #eaf2ff; color: #0b63d8; }

.tk-doc-option-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.tk-doc-option-type {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 11px;
  color: #45637f;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 1px 8px;
}

.tk-doc-option.selected .tk-doc-option-type {
  color: #0b63d8;
  background: #ffffff;
  border-color: #bfdbfe;
}

.tk-doc-option-check {
  flex: 0 0 auto;
  width: 16px;
  color: #2563eb;
  font-weight: 600;
  visibility: hidden;
}

.tk-doc-option.selected .tk-doc-option-check { visibility: visible; }

/* --- 生成进度条 --------------------------------------------------------- */
.tk-progress {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.tk-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.35s ease;
}

/* 模型思考阶段还数不出进度，用滑动条表示"正在干活" */
.tk-progress.indeterminate i {
  width: 36%;
  animation: tk-progress-slide 1.1s ease-in-out infinite;
}

@keyframes tk-progress-slide {
  0% { margin-left: -36%; }
  100% { margin-left: 100%; }
}

/* --- 需求反向追溯表 ----------------------------------------------------- */
.tk-trace-summary {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.7;
}

.tk-trace-table td { vertical-align: top; }

.tk-trace-quote {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: #7c3aed;
  line-height: 1.6;
}

.tk-trace-case {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  line-height: 1.6;
}

.tk-trace-case b {
  flex: 0 0 auto;
  color: #0b63d8;
  font-size: 12px;
  font-weight: 600;
}

.tk-trace-case span { color: #1e293b; }

.tk-trace-type {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 11px;
  padding: 0 8px;
  border-radius: 999px;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.tk-trace-type.negative {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

/* 可编辑提示与未保存标记 */
.tk-edit-hint {
  margin: 2px 0 8px;
  font-size: 12px;
  color: #94a3b8;
}

.tk-table td[contenteditable="true"]:hover {
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px #dbeafe;
  cursor: text;
}

/* 有未保存改动时，保存按钮右上角亮橙点 */
.tk-dirty { position: relative; }
.tk-dirty::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f59e0b;
  border: 2px solid #fff;
}

/* --- 用例逐行编辑 -------------------------------------------------------- */
.tk-case-tools {
  width: 118px;
  text-align: center;
  white-space: nowrap;
}

th.tk-case-tools { text-align: left; }

.tk-row-btn {
  min-height: 26px;
  padding: 2px 10px;
  margin: 0 2px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}

.tk-row-btn:hover {
  border-color: #93c5fd;
  color: #2563eb;
  background: #f5f9ff;
  transform: none;
  filter: none;
}

.tk-row-btn.primary {
  border-color: transparent;
  background: #2563eb;
  color: #fff;
}

.tk-row-btn.primary:hover { background: #1d4ed8; color: #fff; }

.tk-row-btn.danger:hover {
  border-color: #fca5a5;
  color: #dc2626;
  background: #fff1f2;
}

/* 编辑中的行整体提亮，和只读行拉开视觉差 */
.tk-cases-table tr.tk-editing td {
  background: #f8fbff;
}

.tk-cases-table tr.tk-editing td[contenteditable="true"] {
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

/* 行操作图标按钮 */
.tk-case-tools { width: 76px; }

.tk-icon-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  margin: 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8a9bb0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  vertical-align: middle;
}

.tk-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tk-icon-btn:hover {
  color: #2563eb;
  background: #eaf2ff;
  transform: none;
  filter: none;
}

/* 编辑态下的"保存"：实底蓝，状态一眼可辨 */
.tk-icon-btn.primary {
  color: #fff;
  background: #2563eb;
}

.tk-icon-btn.primary:hover { background: #1d4ed8; color: #fff; }

.tk-icon-btn.danger:hover {
  color: #dc2626;
  background: #fff1f2;
}

/* 用例枚举列（类型/优先级）编辑态下的下拉框 */
.tk-cell-select {
  width: 100%;
  margin: 0;
  padding: 3px 4px;
  font: inherit;
  font-size: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
}

/* --- 表格内迷你下拉（类型/优先级）-------------------------------------- */
.tk-mini-select { position: relative; }

/* 枚举列只有 6% 宽，编辑态换成下拉后空间很紧：去掉格子多余的内边距 */
.tk-table td:has(> .tk-mini-select) { padding: 4px; }

.tk-mini-trigger {
  width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  padding: 3px 6px;
  white-space: nowrap;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tk-mini-trigger > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tk-mini-trigger:hover { border-color: #93c5fd; transform: none; filter: none; }

.tk-mini-trigger.open {
  border-color: #2563eb;
  outline: 2px solid color-mix(in oklab, #2563eb 28%, transparent);
}

.tk-mini-trigger svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.tk-mini-trigger.open svg { transform: rotate(180deg); }

.tk-mini-menu {
  position: absolute;
  z-index: 70;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  padding: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.tk-mini-option {
  display: block;
  width: 100%;
  min-height: 28px;
  padding: 4px 12px;
  white-space: nowrap;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #1e293b;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.tk-mini-option:hover { background: #eef4fd; transform: none; filter: none; }

.tk-mini-option.selected {
  background: #eaf2ff;
  color: #0b63d8;
  font-weight: 600;
}

/* --- 通用自定义下拉框（custom-select.js）------------------------------- */
.cs-root {
  position: relative;
  margin-top: 6px;
}

.cs-root .cs-native {
  display: none !important;
}

.cs-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cs-trigger:hover {
  border-color: #93c5fd;
  background: #fff;
  transform: none;
  filter: none;
}

.cs-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}

.cs-root.open .cs-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}

.cs-root.disabled .cs-trigger {
  background: var(--panel-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.75;
}

.cs-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-caret {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #64748b;
  transition: transform 0.18s ease;
}

.cs-root.open .cs-caret {
  transform: rotate(180deg);
}

.cs-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  max-height: 300px;
  overflow-y: auto;
}

.cs-root.open .cs-menu {
  display: block;
  animation: cs-menu-in 0.16s ease;
}

@keyframes cs-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-root.open .cs-menu {
    animation: none;
  }
}

.cs-menu::-webkit-scrollbar {
  width: 8px;
}

.cs-menu::-webkit-scrollbar-thumb {
  background: #d7e0ea;
  border-radius: 999px;
}

.cs-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.cs-option:hover,
.cs-option.active {
  background: #eef4fd;
  color: var(--ink);
  transform: none;
  filter: none;
}

.cs-option.selected {
  background: #eaf2ff;
  color: #0b63d8;
  font-weight: 600;
}

.cs-option.selected:hover,
.cs-option.selected.active {
  background: #dcebff;
  color: #0b63d8;
}

.cs-option-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-option .cs-check {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #0b63d8;
  opacity: 0;
}

.cs-option.selected .cs-check {
  opacity: 1;
}
