:root {
  color-scheme: light;
  --bg: #eef3f2;
  --panel: #ffffff;
  --panel-soft: #f6f9f8;
  --text: #17252f;
  --muted: #5f7180;
  --line: #cfdad8;
  --accent: #14736b;
  --accent-dark: #0d5852;
  --accent-soft: #e2f1ef;
  --blue: #2563eb;
  --amber: #9a5a0b;
  --danger: #b42318;
  --success: #137a37;
  --shadow: 0 10px 24px rgba(30, 53, 66, 0.07);
  --shadow-soft: 0 1px 2px rgba(30, 53, 66, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% -12%, rgba(20, 115, 107, 0.12), transparent 28%),
    linear-gradient(180deg, #f7faf9 0%, var(--bg) 44%, #e8efee 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  min-height: 38px;
  padding: 9px 13px;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:active:not(:disabled),
.button-link:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.secondary:hover:not(:disabled) {
  border-color: #aeb8c5;
}

.button-link {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  min-height: 38px;
  padding: 9px 13px;
  text-decoration: none;
}

.button-link:hover {
  border-color: #aeb8c5;
}

.primary-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary-link:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.small {
  min-height: 32px;
  padding: 6px 10px;
}

.app-header {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.wrap {
  margin: 0 auto;
  width: min(1760px, calc(100vw - 32px));
}

.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 56px;
}

h1,
h2 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 760;
}

h2 {
  font-size: 17px;
  font-weight: 720;
}

.nav,
.tablist,
.actions,
.filter-row,
.panel-heading {
  align-items: center;
  display: flex;
}

.nav {
  gap: 8px;
}

.nav a {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: #a8d6d1;
  color: var(--accent-dark);
}

.workspace {
  padding: 12px 0 36px;
}

.workbench-intro {
  align-items: stretch;
  background: linear-gradient(135deg, #ffffff 0%, #f4faf9 64%, #e8f4f2 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  margin-bottom: 16px;
  overflow: hidden;
  padding: 22px;
}

.case-header {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  grid-template-columns: max-content minmax(440px, 1fr) max-content;
  margin-bottom: 12px;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.case-header h2 {
  font-size: 18px;
}

.case-header p {
  color: var(--muted);
  line-height: 1.5;
  margin: 2px 0 0;
  white-space: nowrap;
}

.case-title {
  min-width: 186px;
}

.case-meta-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.rule-picker {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 7px;
  margin: 0;
  white-space: nowrap;
}

.rule-picker select {
  min-height: 30px;
  min-width: 150px;
  padding: 5px 8px;
}

.operator-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.operator-strip > span {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  max-width: 220px;
  overflow: hidden;
  padding: 5px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-dot {
  color: var(--success);
}

.system-dot::before {
  background: currentColor;
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 8px;
  margin-right: 6px;
  width: 8px;
}

.system-dot.warn {
  color: var(--amber);
}

.system-dot.error {
  color: var(--danger);
}

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.intro-copy {
  display: grid;
  gap: 10px;
}

.intro-copy h2 {
  font-size: clamp(26px, 3.2vw, 42px);
  letter-spacing: 0;
  line-height: 1.12;
  max-width: 880px;
  text-wrap: balance;
}

.intro-copy p,
.panel-heading p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  max-width: 68ch;
}

.section-kicker,
.panel-label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
}

.workflow-steps {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #dce7e5;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.workflow-steps div {
  border-bottom: 1px solid #dce7e5;
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 14px;
}

.workflow-steps div:nth-child(odd) {
  border-right: 1px solid #dce7e5;
}

.workflow-steps div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.workflow-steps strong {
  font-size: 17px;
}

.workflow-steps span {
  color: var(--muted);
  line-height: 1.45;
}

.auth-panel {
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  margin-bottom: 18px;
  padding: 22px;
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 8px 0 0;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-stack {
  display: grid;
  gap: 18px;
}

.invite-register-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.auth-form label {
  margin-bottom: 0;
}

.auth-message {
  min-height: 20px;
}

.denied-panel {
  border-color: #fecdca;
}

.user-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: space-between;
}

.user-actions div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 14px;
}

.status-item,
.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-item {
  box-shadow: var(--shadow-soft);
  min-height: 74px;
  padding: 13px 14px;
}

.status-item span,
.metric span,
label,
dt {
  color: var(--muted);
  font-size: 12px;
}

.status-item strong {
  display: block;
  font-size: 15px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.status-item.warning strong {
  color: var(--amber);
}

.tablist {
  background: #e7efed;
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 4px;
  padding: 4px;
  width: 100%;
}

.tab {
  background: transparent;
  color: var(--muted);
  flex: 1 1 0;
  min-height: 34px;
  min-width: 0;
  padding: 7px 9px;
  white-space: nowrap;
}

.tab.is-active {
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 38, 52, 0.08);
  color: var(--text);
}

.tab-panel[hidden] {
  display: none;
}

.panel {
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel-grid {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(620px, 1.08fr) minmax(560px, 0.92fr);
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading > div {
  display: grid;
  gap: 5px;
}

.field-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 5px;
  line-height: 1.35;
  margin-bottom: 10px;
}

.upload-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.upload-row label {
  margin-bottom: 0;
}

.upload-row button {
  min-height: 36px;
  white-space: nowrap;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  /* 弹窗最大高度不超过视口，避免内容（如 60 条会话）把关闭按钮顶出可视区。 */
  max-height: calc(100vh - 48px);
  max-width: 640px;
  overflow: auto;
  padding: 20px;
  width: min(640px, 100%);
}

.modal-heading {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.modal-heading h2 {
  margin: 3px 0 0;
}

.modal-summary {
  color: var(--text);
  font-weight: 650;
  line-height: 1.55;
  margin: 16px 0 10px;
}

/* 「查看令牌」弹窗：令牌明文 + 显式复制按钮 + 「这次会被审计」的提示。
   设计目标：让管理员明确知道自己在做一件有责任的操作，而非随手浏览。 */
.token-detail {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.token-detail label {
  display: grid;
  font-size: 13px;
  gap: 4px;
}

.token-detail input[readonly] {
  background: var(--panel-soft);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.modal-details {
  color: var(--muted);
  margin: 0;
  max-height: 240px;
  overflow: auto;
  padding-left: 18px;
}

.modal-details li {
  margin: 6px 0;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 36px;
  padding: 8px 9px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible,
.nav a:focus-visible {
  outline: 3px solid rgba(20, 115, 107, 0.22);
  outline-offset: 2px;
}

textarea {
  line-height: 1.45;
  min-height: 68px;
  resize: vertical;
}

.tall {
  min-height: 210px;
}

.normalization {
  background: #f0f8f7;
  border: 1px dashed #bdc7d3;
  border-radius: 8px;
  color: #315f5a;
  font-size: 13px;
  line-height: 1.5;
  min-height: 42px;
  padding: 10px 12px;
}

.coding-board {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.coding-board label {
  margin-bottom: 0;
}

.code-lookup {
  display: grid;
  gap: 6px;
  position: relative;
}

.code-adder {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) auto;
}

.code-adder .code-suggestions {
  top: calc(100% + 4px);
}

.coding-board .primary-code input {
  border-color: #9fbeb9;
  box-shadow: inset 3px 0 0 var(--accent);
}

.code-suggestions {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: none;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  position: absolute;
  top: calc(100% + 4px);
  width: 100%;
  z-index: 10;
}

.code-suggestions.is-open {
  display: grid;
  gap: 3px;
}

.code-suggestions button {
  background: #fff;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 44px;
  padding: 7px 9px;
  text-align: left;
  width: 100%;
}

.code-suggestions button:hover,
.code-suggestions button:focus-visible,
.code-suggestions button.is-active {
  background: var(--accent-soft);
}

.code-suggestions button b {
  font-size: 13px;
}

.code-suggestions button span,
.suggestion-empty {
  color: var(--muted);
  font-size: 12px;
}

.suggestion-empty {
  padding: 9px;
}

.code-review {
  background: #f0f8f7;
  border: 1px solid #bfdbd7;
  border-radius: 8px;
  color: #315f5a;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 10px;
  min-height: 38px;
  padding: 8px 10px;
}

.code-chip-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
  overflow: hidden;
}

.code-chip-board > div {
  align-content: start;
  display: grid;
  gap: 7px;
  min-height: 88px;
  padding: 10px;
}

.code-chip-board > div + div {
  border-left: 1px solid var(--line);
}

.code-chip-board strong {
  font-size: 13px;
}

.code-chips {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.code-chip,
.empty-chip {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
}

.code-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-chip b {
  color: var(--muted);
  font-size: 11px;
}

.code-chip em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.code-chip button {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
  min-height: 20px;
  min-width: 20px;
  padding: 0;
}

.code-chip button:hover {
  color: var(--danger);
}

.code-chip.matched {
  background: #ecfdf3;
  border-color: #abefc6;
}

.code-chip.not-found {
  background: #fff7ed;
  border-color: #fed7aa;
}

.code-chip.format-error {
  background: #fff1f0;
  border-color: #fecdca;
}

.code-chip.pending {
  background: #f5f8fb;
  border-color: #d6e0e8;
}

.empty-chip {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.state-badge {
  background: #eef4ff;
  border: 1px solid #b7cffb;
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 720;
  padding: 5px 9px;
  white-space: nowrap;
}

.state-badge.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.state-badge.success {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--success);
}

.metric-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}

.metric {
  box-shadow: var(--shadow-soft);
  min-height: 64px;
  padding: 10px;
}

.metric strong {
  display: block;
  font-size: 17px;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.result-summary {
  background: #0f3f3a;
  border-radius: 8px;
  color: #effdfa;
  display: grid;
  gap: 1px;
  grid-template-columns: 1.2fr 0.8fr;
  margin-bottom: 10px;
  overflow: hidden;
}

.clinical-narrative {
  background: #f7fbfa;
  border: 1px solid #cddfdb;
  border-radius: 8px;
  color: #253b45;
  line-height: 1.62;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.clinical-narrative p {
  margin: 0;
}

.clinical-narrative p + p {
  margin-top: 6px;
}

.result-summary div {
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 12px;
}

.result-summary span {
  color: #bde5df;
  font-size: 12px;
  font-weight: 720;
}

.result-summary strong {
  font-size: clamp(26px, 2.6vw, 34px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow-wrap: anywhere;
}

.result-panel .metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.section-title {
  font-size: 14px;
  margin: 10px 0 6px;
}

.timeline {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.6;
  max-height: 390px;
  min-height: 210px;
  overflow: auto;
  padding: 11px 13px;
}

.timeline ol {
  margin: 0;
  padding-left: 20px;
}

.timeline li {
  margin: 6px 0;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
}

.job-pane {
  display: grid;
  gap: 14px;
}

.progress-track {
  background: #e7edf3;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

#batch-progress-bar {
  background: var(--accent);
  height: 100%;
  transition: width 180ms ease;
  width: 0%;
}

.details {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.details div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

dd {
  font-weight: 700;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  width: max-content;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

tr:last-child td {
  border-bottom: 0;
}

.filter-row {
  gap: 12px;
  margin-bottom: 14px;
}

.filter-row label {
  margin: 0;
  width: 170px;
}

.report {
  margin-top: 12px;
}

.reports {
  grid-template-columns: 1fr 1fr;
}

.rules-list {
  display: grid;
  gap: 10px;
}

.rule-card {
  align-items: start;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 13px;
}

.rule-card h3 {
  display: grid;
  gap: 3px;
  font-size: 15px;
  margin: 0 0 5px;
}

.rule-card h3 span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.rule-card p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.rule-gap-list {
  margin-top: 12px;
}

.parameter-lookup-block {
  margin-top: 14px;
}

.parameter-filter {
  gap: 10px;
}

.parameter-filter label {
  flex: 1 1 220px;
  margin: 0;
  width: auto;
}

.parameter-lookup-block .table-wrap {
  margin-top: 10px;
}

.rule-gap-card {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  padding: 13px;
}

.rule-gap-card h3 {
  font-size: 15px;
  margin: 3px 0 5px;
}

.rule-gap-card p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.gap-chip-list {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gap-chip-list span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  padding: 6px 8px;
}

.pill {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  padding: 5px 9px;
  white-space: nowrap;
}

.pill.ok {
  background: #ecfdf3;
  color: var(--success);
}

.pill.locked {
  background: #fef3f2;
  color: var(--danger);
}

.error-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

/* 密码弹窗内的表单分组 */
.password-form {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.password-form h3 {
  font-size: 14px;
  margin: 0 0 6px;
}

.password-form:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.password-form[hidden] {
  display: none;
}

.password-form .muted {
  margin: 0 0 6px;
}

.admin-workspace {
  padding-bottom: 52px;
}

.admin-status {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.prototype-note {
  align-items: center;
  background: #fffbeb;
  border: 1px solid #f7d682;
  border-radius: 8px;
  color: #6f4e07;
  display: flex;
  gap: 10px;
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.prototype-note strong {
  white-space: nowrap;
}

.prototype-note.error-note {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.admin-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  padding: 8px;
  position: sticky;
  top: 12px;
}

.admin-nav {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  justify-content: start;
  min-height: 36px;
  text-align: left;
}

.admin-nav.is-active {
  background: #e8f4f2;
  border-color: #b8deda;
  color: var(--accent-dark);
}

/* 「保留」分组：单机构部署下「机构管理」面板仍保留在 DOM 中，但从主流程
   降级——侧栏底部加分隔线和小标题，按钮本身的视觉权重也调低。这样既能让
   管理员看清这不是当前部署形态的功能，又保留了未来多机构扩展时的入口。 */


.admin-nav.admin-nav-legacy {
  color: var(--muted);
  font-size: 13px;
  opacity: 0.7;
}

.admin-nav.admin-nav-legacy:hover,
.admin-nav.admin-nav-legacy:focus {
  opacity: 1;
}

.admin-nav.admin-nav-legacy.is-active {
  background: #f5f1e8;
  border-color: #e6d9b8;
  color: #6f4e07;
  opacity: 1;
}

.admin-main {
  min-width: 0;
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-panel[hidden] {
  display: none;
}

.admin-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-section-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.compact-panel {
  box-shadow: none;
  min-width: 0;
}

.signal-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.signal-list li,
.audit-event,
.dependency-card,
.queue-lane,
.permission-row {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.signal-list li {
  display: grid;
  gap: 5px;
  line-height: 1.45;
  padding: 11px 12px;
}

.signal-list span,
.audit-event p,
.dependency-card p,
.gate-panel p,
.dev-stack-panel p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.dependency-list {
  display: grid;
  gap: 10px;
}

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

.dependency-card {
  min-height: 110px;
  padding: 12px;
}

.dependency-card span,
.queue-lane span,
.audit-event span {
  color: var(--muted);
  font-size: 12px;
}

.dependency-card strong,
.queue-lane strong,
.audit-event strong {
  display: block;
  margin-top: 7px;
}

.dependency-card.success,
.queue-lane.success,
.permission-row.allowed {
  border-color: #abefc6;
}

.dependency-card.error,
.queue-lane.error,
.permission-row.denied {
  border-color: #fecdca;
}

.dependency-card.warning-soft {
  border-color: #fedf89;
}

.admin-split {
  grid-template-columns: minmax(460px, 1.2fr) minmax(280px, 0.8fr);
}

.admin-details {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.admin-details div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.mini-pill {
  background: #eef4ff;
  border: 1px solid #b7cffb;
  border-radius: 999px;
  color: var(--blue);
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
}

.permission-grid {
  display: grid;
  gap: 9px;
}

.permission-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 12px;
}

.permission-row.allowed strong {
  color: var(--success);
}

.permission-row.denied strong {
  color: var(--danger);
}

.gate-panel {
  display: grid;
  gap: 14px;
}

.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-item {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  padding: 6px 9px;
}

.check-item.ok {
  background: #ecfdf3;
  color: var(--success);
}

.check-item.locked {
  background: #fff7ed;
  color: var(--amber);
}

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

.queue-lane {
  min-height: 82px;
  padding: 12px;
}

.queue-lane strong {
  font-size: 24px;
}

.audit-feed {
  display: grid;
  gap: 10px;
}

.audit-event {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.audit-event.error {
  border-color: #fecdca;
}

.audit-event.export {
  border-color: #b7cffb;
}

.audit-empty {
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  padding: 16px;
}

.audit-empty p {
  margin: 0;
}

/* 「加入」无匹配候选时的反馈，之前按钮毫无反应。 */
.lookup-feedback {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
  min-height: 0;
}

.lookup-feedback.has-message {
  color: var(--amber);
  font-weight: 600;
  margin-top: 4px;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented .is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.state-badge.warning-soft {
  background: #fffbeb;
  border-color: #f7d682;
  color: var(--amber);
}

.dev-stack-panel {
  display: grid;
  gap: 12px;
}

@media (min-width: 1500px) {
  .field-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .coding-board {
    align-items: end;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr);
  }

  .coding-board > :nth-child(2),
  .coding-board > :nth-child(5) {
    grid-column: span 2;
  }

  .coding-board textarea {
    min-height: 58px;
  }

  .code-chip-board > div {
    min-height: 74px;
  }
}

@media (max-width: 1320px) {
  .case-header {
    grid-template-columns: minmax(180px, auto) minmax(360px, 1fr);
  }

  .operator-strip {
    grid-column: 1 / -1;
    justify-content: start;
  }

  .panel-grid {
    grid-template-columns: minmax(560px, 1.04fr) minmax(500px, 0.96fr);
  }
}

@media (max-width: 1180px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .result-panel .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1181px) {
  .panel-grid {
    align-items: stretch;
    min-height: calc(100vh - 168px);
  }

  .form-panel,
  .result-panel {
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }

  .code-chip-board,
  .result-panel .timeline {
    flex: 1 1 auto;
  }

  .code-chip-board {
    min-height: 160px;
  }

  .result-panel .timeline {
    max-height: none;
  }
}

@media (max-width: 940px) {
  .topbar,
  .nav,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .tablist {
    width: 100%;
  }

  .nav a,
  .button-link,
  .tab,
  .filter-row label {
    justify-content: center;
    text-align: center;
    width: 100%;
  }

  .auth-panel,
  .case-header,
  .workbench-intro,
  .status-strip,
  .admin-status,
  .panel-grid,
  .split,
  .admin-split,
  .admin-layout,
  .admin-section-grid,
  .dependency-grid,
  .queue-lanes,
  .metric-grid,
  .details,
  .reports,
  .field-grid,
  .coding-board,
  .code-chip-board {
    grid-template-columns: 1fr;
  }

  .case-header {
    position: static;
  }

  .case-meta-row,
  .rule-picker {
    align-items: stretch;
    flex-direction: column;
  }

  .rule-picker select {
    min-width: 0;
  }

  .operator-strip {
    justify-content: start;
  }

  .code-chip-board > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .code-adder {
    grid-template-columns: 1fr;
  }

  .upload-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .rule-gap-card {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 15px;
  }

  .admin-sidebar {
    position: static;
  }

  .admin-nav {
    text-align: center;
  }

  .actions button {
    flex: 1 1 160px;
  }
}

@media (max-width: 520px) {
  .wrap {
    width: min(100vw - 20px, 1280px);
  }

  .workspace {
    padding-top: 14px;
  }

  .tablist {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workbench-intro,
  .case-header {
    padding: 16px;
  }

  .intro-copy h2 {
    font-size: 26px;
  }

  .workflow-steps,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .workflow-steps div,
  .workflow-steps div:nth-child(odd) {
    border-right: 0;
  }

  .workflow-steps div:nth-last-child(2) {
    border-bottom: 1px solid #dce7e5;
  }

  .actions {
    display: grid;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .prototype-note,
  .user-actions,
  .permission-row,
  .segmented {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .user-actions div {
    display: grid;
  }
}

.scheme-validation {
  margin-top: 10px;
}

.scheme-validation-summary {
  background: #fffbeb;
  border: 1px solid #f7d682;
  border-radius: 8px;
  color: #6f4e07;
  line-height: 1.5;
  padding: 9px 11px;
}

.scheme-validation-summary p {
  margin: 0 0 7px;
}

/* 码表不可用：与"发现方案外编码"区分，此处是未作判定而非判定结果 */
.scheme-validation-unavailable {
  margin: 0;
}

.scheme-cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scheme-cat-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  padding: 3px 8px;
  white-space: nowrap;
}

.scheme-cat-chip.warn {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.scheme-cat-chip.expected {
  background: var(--panel-soft);
  color: var(--muted);
}

.scheme-validation-groups {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.scheme-cat-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scheme-cat-unclassified {
  background: #fef3f2;
  border-color: #fecdca;
}

.scheme-cat-unclassified header {
  border-bottom: 1px solid #fecdca;
  display: grid;
  gap: 3px;
  padding: 8px 11px;
}

.scheme-cat-expected {
  background: var(--panel-soft);
}

.scheme-cat-expected[open] {
  background: var(--panel);
}

.scheme-cat-expected > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  list-style: none;
  padding: 8px 11px;
}

.scheme-cat-expected > summary::-webkit-details-marker {
  display: none;
}

.scheme-cat-expected > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
}

.scheme-cat-expected[open] > summary::before {
  content: "▾";
}

.scheme-cat-label {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.scheme-cat-count {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  padding: 1px 6px;
  text-align: center;
}

.scheme-cat-unclassified .scheme-cat-count {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.scheme-cat-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  padding: 1px 7px;
}

.scheme-cat-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  padding: 0 11px 8px;
}

.scheme-cat-unclassified .scheme-cat-desc {
  color: #991b1b;
  padding: 0;
}

.scheme-entry-list {
  list-style: none;
  margin: 0;
  padding: 0 11px 9px;
}

.scheme-cat-unclassified .scheme-entry-list {
  padding: 0 11px 9px;
}

.scheme-entry-list li {
  align-items: baseline;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  padding: 5px 0;
}

.scheme-entry-code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  font-size: 13px;
  font-weight: 700;
}

.scheme-entry-name {
  color: var(--text);
  font-size: 12px;
}

.scheme-entry-kind {
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  padding: 0 5px;
}

.scheme-entry-msg {
  color: var(--danger);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.scheme-cat-unclassified .scheme-entry-msg {
  color: var(--danger);
}

.scheme-cat-expected .scheme-entry-msg {
  color: var(--muted);
}

.rotation-block {
  margin-top: 10px;
}

.rotation-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.rotation-heading .section-title {
  margin: 0;
}

.rotation-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 4px 0 8px;
}

.rotation-result {
  margin-top: 4px;
}

.rotation-loading {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  padding: 8px 0;
}

.rotation-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 7px;
}

.rotation-table td,
.rotation-table th {
  font-size: 13px;
  white-space: normal;
}

.rotation-table td:nth-child(1),
.rotation-table td:nth-child(2) {
  white-space: nowrap;
}

/* DRG 组名可能很长（如"头、颈、耳、鼻、咽、口非恶性增生性疾病，伴合并症或并发症"），
   不约束会把右侧的基准点数与差值列挤出可视区——而点数对比正是本表的目的。
   故组名列截断并用 title 兜住全文，点数与差值列固定不换行。 */
.rotation-table td:nth-child(3),
.rotation-table th:nth-child(3) {
  max-width: 15em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rotation-table td:nth-child(4),
.rotation-table td:nth-child(5),
.rotation-table td:nth-child(6) {
  white-space: nowrap;
  text-align: right;
}

.rotation-table td:nth-child(6) {
  text-align: left;
}

.rotation-row-current {
  background: rgba(37, 99, 235, 0.04);
}

.rotation-row-highest {
  background: rgba(19, 122, 55, 0.06);
  font-weight: 650;
}

.rotation-row-ungrouped {
  background: var(--panel-soft);
  color: var(--muted);
}

.rotation-row-ungrouped td:nth-child(3) {
  color: var(--danger);
  font-weight: 650;
}

.rotation-mark {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.rotation-mark-current {
  background: #eef4ff;
  border: 1px solid #b7cffb;
  color: var(--blue);
}

.rotation-mark-highest {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: var(--success);
}

.rotation-delta-up {
  color: var(--success);
  font-weight: 650;
}

.rotation-delta-down {
  color: var(--danger);
  font-weight: 650;
}

/* 分组依据块复用 rotation 块的视觉风格 */
.evidence-block {
  margin-top: 10px;
}

.evidence-result {
  margin-top: 4px;
}

.evidence-details {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0 0;
}

.evidence-details div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.evidence-details dt {
  font-size: 11px;
}

.evidence-details dd {
  font-size: 13px;
  margin-top: 4px;
}

.exceptions-details {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px;
}

.exceptions-details > summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.exceptions-details > summary::-webkit-details-marker {
  display: none;
}

.exceptions-details > summary::before {
  content: "▾";
  color: var(--muted);
  display: inline-block;
  margin-right: 6px;
}

.exceptions-details:not([open]) > summary::before {
  content: "▸";
}

.exceptions-details .table-wrap {
  margin-top: 10px;
}

.exceptions-details > p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 6px 0 0;
}

@media (max-width: 940px) {
  .evidence-details {
    grid-template-columns: 1fr;
  }
}

/* ---- 管理台列表：分页 + 搜索控件 ----
   四个列表（成员 / 邀请 / 操作记录 / 批量任务）共用同一套样式与状态文案。 */

.list-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.list-toolbar .search-input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  flex: 1 1 240px;
  margin: 0;
  min-width: 200px;
  padding: 8px 10px;
}

.list-toolbar .search-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.list-toolbar .list-range {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
  white-space: nowrap;
}

.list-toolbar .pagination {
  display: flex;
  gap: 6px;
}

.list-status {
  margin: 10px 0 0;
}

.list-status.error-text {
  color: var(--danger);
}

.list-empty,
.list-loading,
.list-no-match,
.list-error {
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  padding: 16px;
}

.list-empty p,
.list-loading p,
.list-no-match p,
.list-error p {
  margin: 0;
}

.list-error {
  border-color: #fecdca;
  color: var(--danger);
}

@media (max-width: 760px) {
  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .list-toolbar .list-range {
    margin-right: 0;
  }

  .list-toolbar .pagination {
    justify-content: space-between;
  }

  .list-toolbar .pagination button {
    flex: 1 1 0;
  }
}
