.entity-governance-page {
  --entity-governance-accent: #ee6a47;
  --entity-governance-ink: #2f3440;
  --entity-governance-muted: #767d89;
}

.entity-governance-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

/* Governance list summaries use the same restrained SmartAdmin card language
   while keeping the POC to the two decisions users need at a glance. */
.entity-dashboard-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 680px;
}

.graph-build-error {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid rgba(239, 68, 68, .35);
  border-radius: 10px;
  background: rgba(127, 29, 29, .18);
}
.graph-build-error header,
.graph-build-error footer { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.graph-build-error header { justify-content: flex-start; margin-bottom: 12px; }
.graph-build-error dl { margin: 0; }
.graph-build-error footer { justify-content: flex-start; margin-top: 14px; }

/* The current-build table has eight compact columns. Keep the action column
   usable at desktop widths instead of letting fixed-layout squeeze it into a
   vertical strip beside the horizontal scrollbar. */
.graph-build-table { min-width: 1080px; table-layout: auto !important; }
.graph-build-table th:last-child,
.graph-build-table td:last-child { min-width: 150px; width: 150px; white-space: nowrap; }
.graph-build-table .kb-row-action { white-space: nowrap; }

.entity-dashboard-metrics article {
  min-height: 88px;
}

.entity-governance-metrics article,
.entity-governance-card,
.entity-governance-form-panel,
.entity-governance-detail-head {
  border: 1px solid var(--console-line, #e2e5ea);
  border-radius: 8px;
  background: var(--console-surface, #fff);
  box-shadow: 0 2px 10px rgba(29, 34, 43, .035);
}

.entity-governance-metrics article {
  min-height: 92px;
  padding: 14px 16px;
}

.entity-governance-metrics span,
.entity-governance-metrics small {
  display: block;
  color: var(--entity-governance-muted);
  font-size: 11px;
}

.entity-governance-metrics strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--entity-governance-ink);
  font-size: 24px;
  line-height: 1.25;
}

.entity-governance-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 12px;
  padding: 4px;
  border: 1px solid var(--console-line, #e2e5ea);
  border-radius: 7px;
  background: #f7f8fa;
}

.entity-governance-tabs button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #666e7a;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.entity-governance-tabs button.active {
  background: #fff;
  color: #313741;
  font-weight: 700;
  box-shadow: 0 1px 5px rgba(31, 37, 46, .09);
}

.entity-governance-tabs button span {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  margin-left: 5px;
  border-radius: 9px;
  background: #ffebe4;
  color: #b84f32;
  font-size: 10px;
}

.entity-governance-primary-actions,
.entity-governance-primary-actions + div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entity-governance-filters {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 150px 140px;
  gap: 8px;
  padding: 0 16px 12px;
}

.entity-candidate-table td.confidence-low strong,
.relation-candidate-table td.confidence-low strong {
  color: #b84f32;
}

.entity-candidate-table td.confidence-low small,
.relation-candidate-table td.confidence-low small {
  display: block;
  color: #b84f32;
}

.entity-governance-filters input,
.entity-governance-filters select,
.entity-governance-page .kb-list-filters select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d9dde3;
  border-radius: 6px;
  background: #fff;
  color: #343a44;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
}

.entity-governance-batch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  margin: 0 16px 12px;
  padding: 0 12px;
  border: 1px solid #e3e6eb;
  border-radius: 6px;
  background: #f8f9fb;
  color: #6b727d;
  font-size: 12px;
}

.entity-governance-table tr.is-selected {
  background: #fff8f4;
}

/* The shared kb-table gives six-column lists a 100% width budget.  Entity
   governance has eight columns, so reserve space for confirmation and row
   actions explicitly; otherwise the last columns collapse to zero width at
   common desktop/tablet viewports. */
.static-menu-page #rag-app .entity-governance-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

/* [KS 修正 2026-09-15 / 第2批 A-03] 实体名称列被挤成逐字竖排。
   实测真值（本表共 7 列，无勾选框列；实体名称 = 第 1 列、类型 = 第 2 列）：
     1440 视口改前：实体名称 47px、类型 222px、操作 181px
     1920 视口改前：实体名称 54px、类型 259px
   根因：本表 table-layout:fixed，列宽份额即最终宽度。原份额给第 1 列（实体名称）
   仅 4%、第 2 列（类型）19%，而"类型"内容只有 2 个汉字，富余宽度全被浪费，
   实体名称因此只够 2~3 个汉字，被迫逐字换行竖排。
   修正：实体名称 4%→30%（≥28% 可显示中文词组），类型 19%→14%（≤15%），
   省下的份额匀给其余各列；7 列合计仍为 100%。
   作用域：仅 .entity-governance-table，其它表未被触碰。 */
.static-menu-page #rag-app .entity-governance-table th:nth-child(1) { width: 30%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(2) { width: 14%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(3) { width: 14%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(4) { width: 13%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(5) { width: 11%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(6) { width: 10%; }
.static-menu-page #rag-app .entity-governance-table th:nth-child(7) { width: 8%; }

/* [KS 修正 2026-09-15 / 第2批 A-03] 本表实测只有 7 列（原规则引用了不存在的第 8 列，
   为空转声明）。此处收窄为第 7 列（操作列），语义与原注释一致：保证操作按钮不塌陷。 */
.static-menu-page #rag-app .entity-governance-table td:nth-child(7) {
  min-width: 0;
}

.entity-status-stack {
  display: inline-flex;
  min-width: 86px;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.entity-status-stack .graph-status-pill {
  white-space: nowrap;
}

.entity-status-detail {
  color: #7b828d;
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
}

.entity-governance-table td:nth-child(2) strong,
.entity-inbox-table td:nth-child(2) strong {
  color: #2f3540;
}

.entity-governance-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  margin: 14px 0;
  padding: 0 13px;
  border: 1px solid #cfe4d8;
  border-radius: 7px;
  background: #f0f8f3;
  color: #34684a;
  font-size: 12px;
}

.entity-governance-notice.warning {
  border-color: #f1d8a8;
  background: #fff8e9;
  color: #805b14;
}

.entity-governance-notice button {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}

.entity-governance-form-panel {
  margin-top: 16px;
  overflow: hidden;
}

.entity-governance-form-panel > header,
.entity-governance-card > header {
  padding: 15px 18px 12px;
  border-bottom: 1px solid #eceef1;
}

.entity-governance-form-panel h2,
.entity-governance-card h2 {
  margin: 0;
  color: var(--entity-governance-ink);
  font-size: 15px;
}

.entity-governance-form-panel header p,
.entity-governance-card header p {
  margin: 2px 0 0;
  color: var(--entity-governance-muted);
  font-size: 11px;
}

.entity-governance-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 18px;
  padding: 18px;
}

.entity-governance-form-grid label,
.entity-merge-reason,
.entity-split-grid label {
  display: grid;
  gap: 6px;
  color: #505762;
  font-size: 12px;
}

.entity-governance-form-grid label.wide {
  grid-column: 1 / -1;
}

.entity-governance-form-grid input,
.entity-governance-form-grid select,
.entity-governance-form-grid textarea,
.entity-merge-reason textarea,
.entity-split-grid input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  background: #fff;
  color: #303640;
  padding: 9px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

.entity-governance-form-grid input,
.entity-governance-form-grid select,
.entity-split-grid input {
  min-height: 38px;
}

.entity-governance-form-grid input:focus,
.entity-governance-form-grid select:focus,
.entity-governance-form-grid textarea:focus,
.entity-merge-reason textarea:focus,
.entity-split-grid input:focus {
  outline: 2px solid rgba(238, 106, 71, .14);
  border-color: #ee8d72;
}

.entity-governance-form-panel > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid #eceef1;
  background: #fafbfc;
}

.entity-governance-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0 12px;
  padding: 13px 16px;
}

.entity-governance-detail-head > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entity-governance-detail-head > div:last-child {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.entity-type-mark {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  background: #f0f2f5;
  color: #505863;
  font-size: 11px;
  font-weight: 700;
}

.button.danger {
  border-color: #e7c6c2;
  background: #fff;
  color: #a4463c;
}

.button.danger:hover:not(:disabled) {
  background: #fff3f1;
}

.entity-governance-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entity-governance-card.wide {
  grid-column: 1 / -1;
}

.entity-governance-dl,
.entity-merge-impact {
  margin: 0;
  padding: 8px 18px 14px;
}

.entity-governance-dl div,
.entity-merge-impact div {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #eff1f3;
}

.entity-governance-dl div:last-child,
.entity-merge-impact div:last-child {
  border-bottom: 0;
}

.entity-governance-dl dt,
.entity-merge-impact dt {
  color: #7a818c;
  font-size: 11px;
}

.entity-governance-dl dd,
.entity-merge-impact dd {
  margin: 0;
  color: #343a44;
  font-size: 12px;
}

.entity-impact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 14px 16px 8px;
}

.entity-impact-grid article {
  padding: 12px;
  border: 1px solid #eceef1;
  border-radius: 6px;
  background: #fafbfc;
}

.entity-impact-grid span,
.entity-impact-grid small {
  display: block;
  color: #7b828d;
  font-size: 10px;
}

.entity-impact-grid strong {
  display: block;
  margin: 3px 0;
  color: #2e3540;
  font-size: 20px;
}

.entity-safe-delete,
.entity-impact-warning,
.entity-edit-impact {
  margin: 3px 16px 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.55;
}

.entity-safe-delete {
  background: #eff8f3;
  color: #397052;
}

.entity-impact-warning,
.entity-edit-impact {
  border: 1px solid #f0dcb6;
  background: #fff9ec;
  color: #72561d;
}

.entity-evidence-list,
.entity-history-list {
  margin: 0;
  padding: 12px 18px 15px;
  list-style: none;
}

.entity-evidence-list li,
.entity-history-list li {
  padding: 10px 0;
  border-bottom: 1px solid #eff1f3;
}

.entity-evidence-list li:last-child,
.entity-history-list li:last-child {
  border-bottom: 0;
}

.entity-evidence-list strong,
.entity-evidence-list small,
.entity-history-list span,
.entity-history-list strong,
.entity-history-list small {
  display: block;
}

.entity-evidence-list strong,
.entity-history-list strong {
  color: #363c46;
  font-size: 12px;
}

.entity-evidence-list small,
.entity-history-list small,
.entity-history-list span {
  color: #858b95;
  font-size: 10px;
}

.entity-evidence-list p {
  margin: 5px 0 0;
  color: #5f6671;
  font-size: 11px;
  line-height: 1.65;
}

.entity-history-list li {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 220px;
  gap: 12px;
  align-items: center;
}

.entity-edit-impact {
  display: flex;
  gap: 12px;
  margin: 0 18px 18px;
}

.entity-edit-impact strong {
  flex: 0 0 auto;
}

.entity-merge-options {
  display: grid;
  gap: 8px;
  padding: 16px 18px 4px;
}

.entity-merge-options label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e1e4e9;
  border-radius: 6px;
  cursor: pointer;
}

.entity-merge-options strong,
.entity-merge-options small {
  display: block;
}

.entity-merge-options strong {
  color: #323842;
  font-size: 12px;
}

.entity-merge-options small {
  margin-top: 2px;
  color: #7d848f;
  font-size: 10px;
}

.entity-merge-reason {
  margin: 5px 18px 18px;
}

.entity-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.entity-split-grid article {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e4e7eb;
  border-radius: 7px;
  background: #fafbfc;
}

.entity-split-grid h3 {
  margin: 0;
  color: #333944;
  font-size: 13px;
}

.entity-api-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 18px 12px;
  color: #69727e;
  font-size: 11px;
}

.entity-api-status .button.text {
  border: 0;
  padding: 0;
  color: #45678f;
  background: transparent;
  font-size: 11px;
}

.entity-api-status .button.text:hover:not(:disabled) {
  color: #254b75;
  text-decoration: underline;
}

.relation-api-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 18px 12px;
  color: #69727e;
  font-size: 11px;
}

.relation-api-status .button.text {
  border: 0;
  padding: 0;
  color: #45678f;
  background: transparent;
  font-size: 11px;
}

.relation-api-status .button.text:hover:not(:disabled) {
  color: #254b75;
  text-decoration: underline;
}

.graph-api-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 18px 12px;
  color: #69727e;
  font-size: 11px;
}

.graph-api-status .button.text {
  border: 0;
  padding: 0;
  color: #45678f;
  background: transparent;
  font-size: 11px;
}

.graph-api-status .button.text:hover:not(:disabled) {
  color: #254b75;
  text-decoration: underline;
}

.graph-api-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid #d8dee6;
  border-radius: 999px;
  font-size: 11px;
}

.graph-api-badge.ready { color: #286a49; border-color: #b9ddc7; background: #f0faf3; }
.graph-api-badge.processing { color: #8b6421; border-color: #efd8a6; background: #fff9eb; }
.graph-api-badge.blocked { color: #9a4141; border-color: #ecc1c1; background: #fff3f3; }
.graph-api-badge.neutral { color: #69727e; background: #f7f8fa; }

@media (max-width: 1100px) {
  .entity-governance-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entity-governance-filters {
    grid-template-columns: minmax(0, 1fr) 150px 140px;
  }
}

/* Local-only publishing scenario controls. Keep the state explicit without
   making the simulation panel compete with the main release workflow. */
.graph-simulation-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px dashed var(--console-line, #d9dee7);
  border-radius: 8px;
  background: rgba(255,255,255,.68);
}
.graph-simulation-panel > div { display: grid; gap: 2px; min-width: 0; flex: 1; }
.graph-simulation-panel strong { color: var(--ink, #293241); font-size: 12px; }
.graph-simulation-panel span { color: var(--console-muted, #697386); font-size: 11px; }
.graph-simulation-panel label { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--console-muted, #697386); font-size: 11px; }
.graph-simulation-panel select { min-width: 132px; }
.graph-simulation-panel.active { border-color: color-mix(in srgb, var(--accent, #e9784d) 45%, var(--console-line, #d9dee7)); background: color-mix(in srgb, var(--accent, #e9784d) 7%, #fff); }
.graph-simulation-panel.active strong { color: var(--accent, #e9784d); }
.graph-readonly-note.simulation { border-color: color-mix(in srgb, var(--accent, #e9784d) 35%, var(--console-line, #d9dee7)); background: color-mix(in srgb, var(--accent, #e9784d) 6%, #fff); }
@media (max-width: 760px) {
  .graph-simulation-panel { align-items: stretch; flex-direction: column; gap: 8px; }
  .graph-simulation-panel label { justify-content: space-between; }
  .graph-simulation-panel select { flex: 1; }
}

/* The relationship list has nine columns on desktop. At compact widths use
   the same readable card treatment as the entity lists so the page itself
   stays within the viewport while every row action remains reachable. */
@media (max-width: 900px) {
  .static-menu-page #rag-app .relation-governance-table {
    width: 100%;
    min-width: 0;
    display: block;
  }
  .static-menu-page #rag-app .relation-governance-table thead { display: none; }
  .static-menu-page #rag-app .relation-governance-table tbody,
  .static-menu-page #rag-app .relation-governance-table tr,
  .static-menu-page #rag-app .relation-governance-table td {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .static-menu-page #rag-app .relation-governance-table tbody { padding: 0 14px; }
  .static-menu-page #rag-app .relation-governance-table tbody tr {
    margin: 14px 0;
    padding: 6px 0;
    border: 1px solid var(--console-line, var(--line));
    border-radius: 6px;
  }
  .static-menu-page #rag-app .relation-governance-table td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 12px;
    border-bottom: 0;
  }
  .static-menu-page #rag-app .relation-governance-table td::before {
    content: attr(data-label);
    color: var(--console-muted, var(--ink-soft));
    font-size: .6rem;
  }
  .static-menu-page #rag-app .relation-governance-table .kb-row-action {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px 7px !important;
  }
  .static-menu-page #rag-app .relation-governance-table .kb-row-action::before { display: none; }
  .static-menu-page #rag-app .relation-governance-table .kb-row-action .button { width: auto; }
}
/* Compact inline recognition stays within the existing console palette. */
.inline-ai-panel { margin: 0 16px 12px; padding: 14px 16px; }
.inline-ai-panel p { margin: 8px 0; }
.inline-ai-panel fieldset { border: 0; padding: 4px 0 12px; margin: 0; }
.inline-ai-panel fieldset label { display: inline-flex; align-items: center; gap: 5px; margin-right: 20px; }
.inline-ai-panel > div:last-of-type { margin-top: 12px; display: flex; gap: 8px; }
.inline-ai-panel progress { width: min(380px, 100%); }
.entity-state-summary { margin: 10px 16px; color: var(--console-muted, #697386); font-size: 12px; line-height: 1.6; }
