: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(8, minmax(0, 1fr));
}

.license-alert {
  align-items: flex-start;
  background: #fff4e5;
  border: 2px solid #f79009;
  border-radius: 8px;
  color: #7a2e0e;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.license-alert[hidden] {
  display: none;
}

.license-alert.is-blocking {
  background: #fef2f2;
  border-color: #d92d20;
  color: #991b1b;
}

.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 > .code-wide {
    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;
  }
}

/* ==========================================================================
   填写指引层：必填标识、字段说明、页面引导条、说明抽屉、术语解释
   ========================================================================== */

/* --- 字段标签行：标签文字 + 必填/条件徽章 --- */
.label-row {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.3;
}

.tag {
  border-radius: 4px;
  flex: none;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.2px;
  line-height: 1.5;
  padding: 1px 5px;
  white-space: nowrap;
}

/* 必填：不填就分不了组 */
.tag-req {
  background: #fdeceb;
  border: 1px solid #f5c9c5;
  color: var(--danger);
}

/* 条件必填：不填不报错，但会让某些 DRG 组永远判不出来 */
.tag-cond {
  background: #fdf3e4;
  border: 1px solid #f0d9b0;
  color: var(--amber);
}

/* 参考：不参与分组决策，只进统计或回查 */
.tag-ref {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* --- 字段下方的一行说明 --- */
.field-hint {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.45;
  margin-top: -1px;
}

.field-hint strong {
  color: var(--amber);
  font-weight: 650;
}

/* --- 校验失败态：边框 + 就地错误文案 --- */
.is-invalid input,
.is-invalid select,
.is-invalid textarea,
input.is-invalid,
textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.field-error {
  color: var(--danger);
  display: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.is-invalid .field-error,
.field-error.is-shown {
  display: block;
}

/* --- 页面引导条：这个页面做什么 + 三步操作 --- */
.page-guide {
  background: linear-gradient(180deg, #fff 0%, var(--accent-soft) 320%);
  border: 1px solid #cbe3df;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
  overflow: hidden;
}

.page-guide > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  list-style: none;
  min-height: 44px;
  padding: 10px 12px;
  user-select: none;
}

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

.page-guide > summary:hover {
  background: rgba(20, 115, 107, 0.05);
}

.page-guide > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.guide-caret {
  color: var(--accent);
  flex: none;
  transition: transform 180ms ease;
}

.page-guide[open] .guide-caret {
  transform: rotate(90deg);
}

.guide-title {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.guide-lede {
  color: var(--muted);
  flex: 1 1 auto;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-guide[open] .guide-lede {
  display: none;
}

.guide-body {
  border-top: 1px solid #dbeae7;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.guide-body p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

/* 三步操作 */
.guide-steps {
  counter-reset: guide-step;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.guide-steps li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  counter-increment: guide-step;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 9px 10px 9px 34px;
  position: relative;
}

.guide-steps li::before {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 50%;
  color: var(--accent-dark);
  content: counter(guide-step);
  display: flex;
  font-size: 11px;
  font-weight: 700;
  height: 19px;
  justify-content: center;
  left: 9px;
  position: absolute;
  top: 9px;
  width: 19px;
}

.guide-steps li b {
  color: var(--accent-dark);
  font-weight: 650;
}

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

/* 图例：三种必填档位各是什么意思 */
.guide-legend {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px 14px;
  line-height: 1.5;
}

.guide-legend > span {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

/* --- 填写说明抽屉 --- */
.guide-drawer[hidden] {
  display: none;
}

.drawer-panel {
  display: grid;
  gap: 14px;
  max-height: min(86vh, 1300px);
  max-width: 1140px;
  overflow: auto;
  width: 100%;
}

.drawer-section {
  display: grid;
  gap: 8px;
}

.drawer-section > h3 {
  border-left: 3px solid var(--accent);
  font-size: 13px;
  margin: 0;
  padding-left: 8px;
}

.drawer-section > p {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
}

.spec-table {
  border-collapse: collapse;
  font-size: 12.5px;
  width: 100%;
}

.spec-table th,
.spec-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

.spec-table thead th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  position: sticky;
  top: 0;
}

.spec-table td:first-child {
  font-weight: 650;
  white-space: nowrap;
}

/* 「字段」「必填性」「批量列名」不折行，把宽度让给两列说明文字，
   免得整张表溢出到要横向拖。 */
.spec-table th:nth-child(2),
.spec-table td:nth-child(2),
.spec-table th:last-child,
.spec-table td:last-child {
  white-space: nowrap;
}

.spec-table th:nth-child(3) {
  width: 30%;
}

.spec-table th:nth-child(4) {
  width: 28%;
}

.spec-table tbody tr:hover {
  background: rgba(20, 115, 107, 0.035);
}

.spec-table code {
  background: var(--panel-soft);
  border-radius: 3px;
  font-size: 11.5px;
  padding: 1px 4px;
}

/* --- 结果区术语解释 --- */
/* 指标卡很窄，问号内联会把「平均住院日」这类标签拆成两行，
   所以在指标卡里让它脱离文字流、贴右上角。 */
.metric {
  position: relative;
}

.metric .term-tip {
  position: absolute;
  right: 7px;
  top: 7px;
}

/* 结果摘要是深底，浅灰描边在上面几乎看不见，单独给一套配色。 */
.result-summary span {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

.result-summary .term-tip {
  border-color: rgba(189, 229, 223, 0.5);
  color: #bde5df;
}

.result-summary .term-tip:hover,
.result-summary .term-tip:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  border-color: #effdfa;
  color: #effdfa;
}

.term-tip {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  cursor: help;
  display: inline-flex;
  flex: none;
  font-size: 10px;
  font-weight: 700;
  height: 14px;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  width: 14px;
}

.term-tip:hover,
.term-tip:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* --- 编码区分节标题 --- */
.coding-section-title {
  align-items: baseline;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 650;
  gap: 8px;
  grid-column: 1 / -1;
  margin: 2px 0 -2px;
  padding-top: 10px;
}

.coding-section-title:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.coding-section-title em {
  color: var(--muted);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 400;
}

@media (max-width: 940px) {
  .guide-lede {
    display: none;
  }

  .drawer-panel {
    max-height: 88vh;
  }

  .spec-table {
    font-size: 12px;
  }

  .spec-table th,
  .spec-table td {
    padding: 6px 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide-caret {
    transition: none;
  }
}

/* 单病案页是两列网格，引导条要跨满整行 */
.panel-grid > .page-guide {
  grid-column: 1 / -1;
}

/* 窄屏下 button 一律撑满（见 520px 断点），但术语解释的问号图标和弹窗标题栏的
   关闭按钮不是表单动作，撑满会把指标卡和标题行挤坏。 */
@media (max-width: 520px) {
  .term-tip {
    width: 14px;
  }

  .modal-heading > button {
    justify-self: end;
    width: auto;
  }
}

/* --- 术语气泡 --- */
/* title 属性在触屏上不显示、键盘 focus 时也不显示，所以术语解释改成点击气泡；
   同时用伪元素把 14px 的图标撑到 44px 触摸热区，视觉尺寸不变。 */
.term-tip::after {
  content: "";
  inset: -15px;
  position: absolute;
}

.term-tip {
  position: relative;
}

.term-pop {
  background: #17252f;
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.28);
  color: #f2f7f6;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.55;
  max-width: min(300px, calc(100vw - 24px));
  padding: 9px 11px;
  position: fixed;
  z-index: 120;
}

.term-pop::before {
  border: 6px solid transparent;
  border-bottom-color: #17252f;
  content: "";
  left: var(--pop-arrow, 16px);
  position: absolute;
  top: -12px;
}

/* ==========================================================================
   DRG 运营看板（三级）：蓝色基底（对齐国家医保 3.0 视觉主色系的蓝），
   仅作用于 body.dashboard，不影响分组工作台与管理后台的青绿基调。
   组件复用 .wrap/.panel/.nav/.segmented/table/.tag 等既有结构。
   ========================================================================== */

body.dashboard {
  --accent: #1d5fc4;
  --accent-dark: #16499e;
  --accent-soft: #e6eefb;
  background:
    radial-gradient(circle at 18% -12%, rgba(29, 95, 196, 0.12), transparent 28%),
    linear-gradient(180deg, #f6f9fd 0%, #edf3fa 44%, #e5edf7 100%);
}

body.dashboard .app-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid #c9d9ef;
}

body.dashboard .nav a[aria-current="page"] {
  color: var(--accent-dark);
}

.dashboard-workspace {
  display: grid;
  gap: 14px;
}

.dashboard-toolbar {
  box-shadow: var(--shadow);
}

.toolbar-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-controls label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 6px;
}

.toolbar-controls input,
.toolbar-controls select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
}

.dashboard-operator {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.dashboard-message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  margin: 0;
  padding: 10px 14px;
}

.dashboard-message.hidden-message {
  display: none;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 12px 14px;
}

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

.metric-value {
  font-size: 22px;
  font-weight: 740;
  letter-spacing: -0.2px;
}

.metric-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-delta {
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 8px;
}

.metric-delta.up {
  background: #e7f3ea;
  color: var(--success);
}

.metric-delta.down {
  background: #fbeae8;
  color: var(--danger);
}

.metric-delta.flat {
  background: var(--panel-soft);
  color: var(--muted);
}

.metric-delta.delta-null {
  background: var(--panel-soft);
  color: var(--muted);
}

.dashboard-panel {
  box-shadow: var(--shadow);
}

/* 看板壳是 main.wrap（grid）的子项：grid 子项默认 min-width:auto，会被宽表（下钻明细
   16–20 列）撑到比 .wrap 还宽，整页出现横向滚动而不是 .table-wrap 内部滚动。 */
#dashboard-shell {
  min-width: 0;
}

.dist-chart {
  display: grid;
  gap: 6px;
}

.dist-bar-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 10px;
  grid-template-columns: minmax(180px, 260px) 1fr minmax(90px, auto);
  padding: 4px 6px;
  text-align: left;
  width: 100%;
}

.dist-bar-row:hover {
  background: var(--accent-soft);
}

.dist-bar-label {
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dist-bar-track {
  background: #e8eef8;
  border-radius: 999px;
  display: block;
  height: 12px;
  overflow: hidden;
}

.dist-bar-fill {
  background: linear-gradient(90deg, var(--accent) 0%, #4c86e0 100%);
  border-radius: 999px;
  display: block;
  height: 100%;
}

.dist-bar-value {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

tr.drillable {
  cursor: pointer;
}

tr.drillable:hover td {
  background: var(--accent-soft);
}

.drill-pager {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 10px;
}

.bed-day-note {
  margin: 10px 0 0;
}

/* ==========================================================================
   看板 V2：宽屏自适应（1280/1600/1920/2560）、ECharts 图表区、逐级下钻与病例详情。
   设计基调：主色 3B82F6、背景 F8FAFC、正文 1E293B、强调 F97316（文字用 C2410C 保对比度）。
   全部限定在 body.dashboard 作用域内，不影响分组工作台与管理后台。
   ========================================================================== */

body.dashboard {
  --dash-primary: #3b82f6;
  --dash-primary-deep: #1d4ed8;
  --dash-bg: #f8fafc;
  --dash-text: #1e293b;
  --dash-muted: #475569;
  --dash-line: #cbd5e1;
  --dash-accent: #c2410c;
  --dash-accent-soft: #ffedd5;
  --dash-soft: #eff6ff;
  /* 看板页交互色切到蓝系基调（按钮/选中态沿用既有组件样式，仅换变量）。 */
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-soft: #dbeafe;
}

body.dashboard {
  background: var(--dash-bg);
}

body.dashboard .app-header {
  background: rgba(255, 255, 255, 0.94);
}

.kpi-band {
  display: grid;
  gap: 8px;
}

.kpi-band .metric-card {
  border-left-color: var(--dash-primary);
}

.metric-value-null {
  color: var(--dash-muted);
}

.metric-note {
  color: var(--dash-muted);
  font-size: 11px;
  margin: 0;
}

.metric-placeholder {
  align-items: center;
  background: var(--dash-soft);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #1e40af;
  display: inline-flex;
  font-size: 11px;
  gap: 4px;
  padding: 1px 8px;
  width: fit-content;
}

.metric-placeholder:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.cost-detail-strip {
  color: var(--dash-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
}

.cost-chip {
  align-items: baseline;
  display: inline-flex;
  font-size: 12px;
  gap: 8px;
}

.cost-chip strong {
  color: var(--dash-text);
  font-variant-numeric: tabular-nums;
}

/* 面包屑（下钻路径） */
.crumbs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 60%;
}

.crumbs .crumb {
  background: var(--dash-soft);
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: var(--dash-primary-deep);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
}

.crumbs .crumb:hover {
  background: #dbeafe;
}

.crumbs .crumb:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.crumbs .crumb-current {
  background: var(--dash-accent-soft);
  border-color: #fdba74;
  color: var(--dash-accent);
  cursor: default;
}

.crumb-sep {
  color: var(--dash-muted);
  display: inline-flex;
}

/* 图表卡与网格 */
.dash-charts {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 12px;
}

.chart-card {
  background: #ffffff;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  margin: 0;
  min-width: 0;
  padding: 10px 12px 12px;
}

.chart-card figcaption {
  color: var(--dash-text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.chart-box {
  cursor: pointer;
  height: 240px;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.chart-box:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.chart-box-tall {
  height: 340px;
}

#chart-trend {
  cursor: default;
}

#chart-bars.chart-box {
  cursor: pointer;
}

.dash-explore {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.structure-table > summary {
  color: var(--dash-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 2px;
}

.structure-table > summary:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.table-null {
  color: var(--dash-muted);
  cursor: help;
}

.drill-hint {
  align-items: center;
  color: var(--dash-primary-deep);
  display: inline-flex;
  font-size: 12px;
  gap: 3px;
}

/* 病例详情 */
.case-detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.case-detail-block {
  background: #ffffff;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  padding: 10px 12px;
}

.case-detail-block h3 {
  font-size: 13px;
  margin: 0 0 8px;
}

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

.path-chip {
  background: var(--dash-soft);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
}

.path-chip-label {
  color: var(--dash-muted);
  font-size: 11px;
}

.path-chip strong {
  color: var(--dash-text);
  font-size: 12px;
}

.cost-bar-row {
  align-items: center;
  display: grid;
  font-size: 12px;
  gap: 8px;
  grid-template-columns: 64px 1fr 96px;
  margin: 6px 0;
}

.cost-bar-label {
  color: var(--dash-muted);
}

.cost-bar-track {
  background: #e2e8f0;
  border-radius: 999px;
  display: block;
  height: 10px;
  overflow: hidden;
}

.cost-bar-fill {
  border-radius: 999px;
  display: block;
  height: 100%;
}

.cost-bar-fill.tone-primary {
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
}

.cost-bar-fill.tone-muted {
  background: #94a3b8;
}

.cost-bar-value {
  color: var(--dash-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.case-detail-note {
  font-size: 11px;
  margin: 8px 0 0;
}

.payment-line {
  align-items: baseline;
  display: flex;
  font-size: 13px;
  gap: 8px;
  justify-content: space-between;
  margin: 6px 0;
}

/* 详情按钮（表格行内） */
.link-button {
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--dash-primary-deep);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: #1e3a8a;
}

.link-button:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

/* 断点：1280 / 1600 / 1920 / 2560（宽屏提密度，不拉伸单卡） */
@media (min-width: 1280px) {
  .dash-charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-charts #chart-trend-card {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1600px) {
  .dash-explore {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  }
}

@media (min-width: 1920px) {
  .dash-charts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 2560px) {
  body.dashboard .wrap {
    width: min(2320px, calc(100vw - 48px));
  }

  .dash-charts .chart-box {
    height: 280px;
  }

  .dash-explore .chart-box-tall {
    height: 420px;
  }

  .case-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .cost-bar-fill,
  .crumbs .crumb,
  .bedday-entry {
    transition: none;
  }
}

/* 可点表格行的键盘可达性（与图表等价的操作路径） */
tr.drillable {
  cursor: pointer;
}

tr.drillable:focus-visible {
  outline: none;
}

tr.drillable:focus-visible td {
  background: var(--dash-soft);
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: -3px;
}

/* ==========================================================================
   看板 V3：床日组维度（第二条下钻线）。主页只占一个饼图 + 一条指标带；
   组详情字段卡、分段参数表与类型病人入口都在下钻层。沿用 V2 视觉语言。
   ========================================================================== */

.bedday-strip {
  margin-bottom: 12px;
}

.bedday-strip .metric-card {
  min-height: 88px;
}

.bedday-home .structure-table > summary {
  padding: 8px 2px;
}

.bedday-home .table-wrap table {
  margin-top: 4px;
}

/* 组详情：病例构成上下文行 */
.bedday-context {
  align-items: center;
  color: var(--dash-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px 14px;
  margin: 0 0 10px;
}

.bedday-context strong {
  color: var(--dash-text);
  font-variant-numeric: tabular-nums;
}

/* 组详情：8 个主要展示字段 + 预算床日，固定三列三行（第三行是参数依赖的限额/标准/预算），
   宽屏一行九张提密度而不是拉宽单卡 */
.bedday-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.bedday-fields .metric-card {
  gap: 4px;
  min-height: 74px;
  padding: 9px 12px 10px;
}

.bedday-fields .metric-value {
  font-size: 17px;
}

.chart-note {
  font-size: 11px;
  margin: 6px 0 0;
}

/* MDCB 分段参数表 */
#bedday-segments {
  margin-top: 12px;
}

#bedday-segments .table-wrap {
  margin-top: 6px;
}

/* 组详情图表区固定两张图；类型病人入口卡在窄屏时整行排在图下，≥1920 作为第三列竖排 */
.dash-charts.bedday-charts {
  grid-template-columns: minmax(0, 1fr);
}

.bedday-entries-card {
  grid-column: 1 / -1;
  min-width: 0;
}

/* 类型病人明细三个入口 */
.bedday-entries {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.bedday-entry {
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid var(--dash-line);
  border-left: 4px solid var(--dash-primary);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 4px;
  padding: 12px 14px;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bedday-entry:hover {
  border-color: var(--dash-primary);
  box-shadow: 0 2px 10px rgba(29, 78, 216, 0.16);
}

.bedday-entry:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.bedday-entry.tone-over {
  border-left-color: #dc2626;
}

.bedday-entry.tone-under {
  border-left-color: #3b82f6;
}

.bedday-entry.tone-discharged {
  border-left-color: #94a3b8;
}

.bedday-entry-label {
  color: var(--dash-muted);
  font-size: 12px;
}

.bedday-entry-value {
  color: var(--dash-text);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.bedday-entry-sub {
  color: var(--dash-muted);
  font-size: 11px;
}

#bedday-entries-note {
  margin: 8px 0 0;
}

@media (min-width: 1280px) {
  .dash-charts.bedday-charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1920px) {
  .bedday-fields {
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }

  .bedday-fields .metric-card {
    padding-inline: 10px;
  }

  .dash-charts.bedday-charts {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.9fr);
  }

  .bedday-entries-card {
    grid-column: auto;
  }

  .bedday-entries {
    grid-template-columns: minmax(0, 1fr);
  }

  .bedday-entry {
    padding: 10px 14px;
  }
}

/* 超限行视觉区分（床日线病例列表） */
tr.row-over-limit td {
  background: #fef2f2;
}

tr.row-over-limit td:first-child {
  box-shadow: inset 3px 0 0 #dc2626;
}

/* 超限/限额内标签（沿用 tag 家族的变体模式） */
.tag-over {
  background: #fbeae8;
  border: 1px solid #f5c6c0;
  color: var(--danger);
}

.tag-ok {
  background: #e7f3ea;
  border: 1px solid #bfe0c6;
  color: var(--success);
}

/* 预算床日的「测算」角标（口径未确认前的固定标记） */
.bd-est {
  background: var(--dash-soft);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #1e40af;
  font-size: 10px;
  margin-left: 5px;
  padding: 0 5px;
  vertical-align: 1px;
}

/* 下钻明细面板顶部的占位/口径说明 */
.drill-note {
  background: var(--dash-accent-soft);
  border: 1px solid #fdba74;
  border-radius: 6px;
  color: #7c2d12;
  font-size: 12px;
  margin: 0 0 10px;
  padding: 8px 12px;
}

@media (min-width: 2560px) {
  .bedday-fields .metric-value {
    font-size: 19px;
  }
}
