:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: #f0fdfa;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --neutral: #475569;
  --neutral-soft: #f1f5f9;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: #ccfbf1; color: #134e4a; }

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

/* 与 ELISA Curve Tool 一致的 YDchenTools 品牌页眉 */
.site-header {
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.yd-brand { flex: 0 0 auto; line-height: 1; white-space: nowrap; }
.yd-brand-name {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #0f172a;
}
.yd-brand-tools {
  margin-left: 6px;
  font-size: 18px;
  font-weight: 300;
  color: #94a3b8;
}
.site-header-divider { width: 1px; height: 32px; flex: 0 0 auto; background: rgba(203, 213, 225, 0.8); }
.tool-heading { min-width: 0; }
.tool-heading h1 { margin: 0; font-size: 16px; line-height: 1.25; font-weight: 600; color: #1e293b; }
.tool-heading p { margin: 2px 0 0; font-size: 12px; line-height: 1.25; color: #64748b; }

.tool-nav-wrap { padding: 16px 0 0; }
.tool-nav-inner {
  width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.tool-nav {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%; overflow-x: auto;
  padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.86);
  scrollbar-width: none;
}
.tool-nav::-webkit-scrollbar { display: none; }
.tool-nav-link {
  min-height: 34px; padding: 7px 12px; border-radius: 7px; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  color: #64748b; font-size: 13px; font-weight: 600; transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.tool-nav-link:hover { color: #0f172a; background: #f8fafc; }
.tool-nav-link.active { color: #0f172a; background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,.1); }
.workspace-context {
  min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  color: #94a3b8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.workspace-context span { overflow: hidden; text-overflow: ellipsis; }
.workspace-name { color: #475569; font-weight: 600; }
.workspace-separator { flex: 0 0 auto; color: #cbd5e1; }

.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px 8px 48px; }
.page-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.page-title { margin: 0; font-size: clamp(22px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.025em; font-weight: 700; color: #1e293b; }
.page-desc { color: var(--muted); margin: 6px 0 0; line-height: 1.6; max-width: 780px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn {
  border: 1px solid transparent; border-radius: 8px; min-height: 38px; padding: 8px 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 600; font-size: 13px; line-height: 1; background: var(--surface); color: var(--text);
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:hover { box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.btn:focus-visible, .tool-nav-link:focus-visible, .tab:focus-visible { outline: 2px solid #14b8a6; outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { border-color: var(--line-strong); background: var(--surface); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: #0f172a; background: #f1f5f9; box-shadow: none; }
.btn-small { min-height: 32px; padding: 6px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.025); }
.card-body { padding: 18px; }
.card-header { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.card-title { margin: 0; font-size: 16px; color: #1e293b; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.stat-card { padding: 17px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { margin-top: 8px; font-size: 24px; font-weight: 700; letter-spacing: -.025em; color: #1e293b; }
.stat-note { margin-top: 5px; color: #94a3b8; font-size: 12px; }

.patient-list { display: grid; gap: 12px; }
.patient-card { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; transition: border-color .15s ease, box-shadow .15s ease; }
.patient-card:hover { border-color: #cbd5e1; box-shadow: 0 7px 20px rgba(15,23,42,.05); }
.patient-code { font-size: 17px; font-weight: 700; color: #1e293b; }
.patient-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.patient-result { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-width: 165px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 600; background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.badge-primary { background: #ccfbf1; color: #0f766e; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-success { background: #dcfce7; color: #166534; }
.response-chip { display: inline-flex; border-radius: 7px; padding: 6px 9px; font-weight: 700; font-size: 12px; }
.response-success { color: var(--success); background: var(--success-soft); }
.response-warning { color: var(--warning); background: var(--warning-soft); }
.response-danger { color: var(--danger); background: var(--danger-soft); }
.response-neutral { color: var(--neutral); background: var(--neutral-soft); }
.response-muted { color: var(--muted); background: #f1f5f9; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 10px 12px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: #334155; }
.tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

.info-list { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 11px 18px; margin: 0; }
.info-list dt { color: var(--muted); font-size: 13px; }
.info-list dd { margin: 0; font-weight: 600; color: #334155; }

.lesion-list { display: grid; gap: 10px; }
.lesion-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; }
.lesion-name { font-weight: 650; color: #334155; }
.lesion-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }

.timeline { display: grid; gap: 14px; }
.timeline-item { position: relative; padding: 18px; }
.timeline-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.timeline-title { font-weight: 700; font-size: 16px; color: #1e293b; }
.timeline-date { color: var(--muted); font-size: 13px; margin-top: 4px; }
.timeline-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-top: 15px; }
.metric { border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; background: var(--surface-soft); }
.metric-label { font-size: 11px; color: var(--muted); }
.metric-value { font-size: 15px; font-weight: 700; margin-top: 4px; color: #334155; }
.reason { margin-top: 13px; padding: 11px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 8px 8px 0; font-size: 13px; line-height: 1.65; color: #134e4a; }

.issue-list { display: grid; gap: 8px; }
.issue { display: flex; align-items: flex-start; gap: 9px; padding: 10px 11px; border-radius: 8px; font-size: 13px; line-height: 1.55; border: 1px solid transparent; }
.issue-warning { background: var(--warning-soft); color: #854d0e; border-color: #fde68a; }
.issue-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.issue-info { background: var(--neutral-soft); color: #475569; border-color: #e2e8f0; }

.empty { text-align: center; padding: 48px 22px; color: var(--muted); }
.empty-title { font-size: 18px; color: #1e293b; font-weight: 700; margin-bottom: 7px; }
.empty p { max-width: 520px; margin: 0 auto 18px; line-height: 1.65; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field-full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: #334155; }
.help { font-size: 12px; color: var(--muted); line-height: 1.5; }
.input, select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--text);
  min-height: 40px; padding: 8px 10px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { min-height: 92px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.11); }
.checkbox { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; }
.checkbox input { margin-top: 3px; accent-color: var(--primary); }
.measurement-grid { display: grid; gap: 9px; }
.measurement-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.measurement-row:last-child { border-bottom: 0; }
.section-label { font-size: 13px; font-weight: 700; margin: 18px 0 8px; color: var(--primary-strong); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.48); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 70px rgba(15,23,42,.22); }
.modal-small { width: min(520px, 100%); }
.modal-header { padding: 17px 20px; display: flex; justify-content: space-between; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-title { margin: 0; font-size: 18px; color: #1e293b; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; position: sticky; bottom: 0; background: var(--surface); }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: 7px; font-size: 20px; }
.icon-btn:hover { background: var(--surface-soft); color: var(--text); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; background: #0f172a; color: #fff; padding: 12px 15px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; max-width: 360px; }

.audit-list { display: grid; gap: 9px; }
.audit-row { display: grid; grid-template-columns: 170px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.audit-time { font-size: 12px; color: var(--muted); }
.audit-summary { font-size: 13px; font-weight: 600; color: #334155; }
.audit-actor { font-size: 12px; color: var(--muted); margin-top: 3px; }
.code-block { white-space: pre-wrap; word-break: break-word; background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 13px; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 300px; overflow: auto; }

.callout { padding: 14px 15px; border-radius: 8px; background: var(--primary-soft); border: 1px solid #99f6e4; line-height: 1.65; font-size: 13px; color: #134e4a; }
.callout-warning { background: var(--warning-soft); border-color: #fde68a; color: #854d0e; }
.danger-zone { border-color: #fecaca; }
.danger-zone .card-header { color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: var(--surface-soft); }
tr:last-child td { border-bottom: 0; }

@media (min-width: 640px) {
  .site-header-inner { padding: 16px; gap: 16px; }
  .yd-brand-name, .yd-brand-tools { font-size: 20px; }
  .site-header-divider { height: 36px; }
  .tool-heading h1 { font-size: 18px; }
  .tool-heading p { font-size: 14px; }
  .tool-nav-inner { padding-left: 16px; padding-right: 16px; }
  .content { padding: 24px 16px 56px; }
}

@media (max-width: 760px) {
  .workspace-context { display: none; }
  .tool-nav-inner { display: block; }
  .tool-nav { width: 100%; }
  .tool-nav-link { flex: 1 0 auto; }
  .page-header { flex-direction: column; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .patient-card { grid-template-columns: 1fr; }
  .patient-result { align-items: flex-start; min-width: 0; }
  .timeline-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .info-list { grid-template-columns: 1fr; gap: 4px; }
  .info-list dd { margin-bottom: 8px; }
  .measurement-row { grid-template-columns: 1fr; gap: 7px; }
  .audit-row { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .site-header-inner { gap: 10px; }
  .yd-brand-tools { margin-left: 5px; }
  .tool-heading h1 { font-size: 15px; }
  .tool-heading p { font-size: 11px; }
  .content { padding-left: 8px; padding-right: 8px; }
  .card-body, .patient-card, .timeline-item { padding: 14px; }
  .card-header { padding: 14px; }
  .timeline-metrics { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); border-radius: 10px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
