:root {
  --bg: #f2f5f7; --card: #fff; --ink: #1b2c37; --muted: #516674; --line: #d5dfe5;
  --accent: #095789; --accent-soft: #e9f3f9; --warn: #b42318; --ok: #176d50;
  --t-high: #1d4ed8; --t-mid: #6d28d9; --t-low: #9ca3af;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid #0874b5; outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--warn); }
button { font: inherit; padding: 4px 10px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 7px 22px; }
button.small { padding: 1px 8px; font-size: 12px; }
input, textarea { font: inherit; }

.institution {
  display: flex; align-items: center; flex: none; gap: 20px; height: 70px; padding: 0 24px;
  background: #fff; border-bottom: 2px solid #095789;
}
.hospital-signature { width: clamp(192px, 15.5vw, 218px); height: auto; display: block; flex: none; }
.platform-name { border-left: 1px solid #b5c8d4; padding: 5px 0 5px 20px; display: flex; align-items: baseline; gap: 16px; color: #084b76; }
.platform-name strong { font: 700 clamp(21px, 1.75vw, 27px)/1.1 "Inter", "Segoe UI", Arial, sans-serif; letter-spacing: -.55px; }
.platform-name strong span { font-weight: 500; }
.platform-zh { font-size: clamp(16px, 1.24vw, 20px); letter-spacing: .025em; font-weight: 600; }
#topbar { display: flex; align-items: center; min-height: 39px; flex: none; gap: 18px; padding: 4px 24px; background: #fff; border-bottom: 1px solid var(--line); }
#topbar .brand { color: #1d3849; white-space: nowrap; font-size: 15px; font-weight: 650; }
#topbar #progress { font-variant-numeric: tabular-nums; font-size: 13px; }
#topbar #progress:not(:empty) { border-left: 1px solid var(--line); padding-left: 14px; }
#topbar #user { margin-left: auto; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; }
#topbar a { display: inline-flex; align-items: center; min-height: 28px; font-size: 13px; text-decoration: none; font-weight: 550; }
#topbar a:hover { text-decoration: underline; }
#topbar button { color: var(--muted); background: transparent; min-height: 26px; }
.test-badge { background: #fff3cd; color: #7a5a00; border: 1px solid #e6c65c; border-radius: 10px;
              padding: 1px 8px; font-size: 12px; cursor: help; }
.workbench, .registration { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.workbench > main, .registration > main { min-height: 0; flex: 1 1 0; }
.workbench:has(#login-view:not(.hidden)) #topbar, .registration #topbar { display: none; }
.data-page > main { min-height: calc(100% - 109px); }
.data-page :is(h2, h3) { color: #203c4b; }
.data-page :is(.panel, .card) { border-color: var(--line); }
.data-page .grid th { background: #eaf1f5; color: #294756; }
.data-page table { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .institution { height: 57px; gap: 12px; padding-inline: 14px; }
  .hospital-signature { width: 145px; }
  .platform-name { display: grid; gap: 1px; padding: 0 0 0 12px; }
  .platform-name strong { font-size: 16px; letter-spacing: -.3px; }
  .platform-zh { font-size: 11px; letter-spacing: 0; }
  #topbar { gap: 4px 10px; padding: 4px 12px; flex-wrap: wrap; }
  #topbar #user { gap: 3px 9px; }
  #topbar #progress:not(:empty) { padding-left: 9px; }
  .data-page > main { max-width: 100%; overflow-x: auto; }
  .data-page main.hist .detail, .data-page main.case .right { min-width: min(100%, 280px); }
}
@media (max-width: 360px) {
  .institution { gap: 8px; padding-inline: 9px; }
  .hospital-signature { width: 125px; }
  .platform-name { padding-left: 8px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; }
.card.narrow { max-width: 360px; margin: 60px auto; display: flex; flex-direction: column; gap: 12px; }
.card label { display: flex; flex-direction: column; gap: 4px; }
.card input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }

#task-view { display: flex; height: 100%; }
#viewer-pane { flex: 1.35; display: flex; flex-direction: column; min-width: 0; background: #111; }
#viewer-toolbar { display: flex; gap: 8px; align-items: center; padding: 6px 10px; background: #1b1f27; color: #d6dae3; flex-wrap: wrap; }
#viewer-toolbar button { background: #2b313c; color: #e5e7eb; border-color: #3a414e; }
#viewer-toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
#viewer-toolbar input[type=range] { width: 110px; }
#viewer { position: relative; flex: 1; min-height: 0; }
#canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#canvas.pointing { cursor: crosshair; }
#point-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(31,111,235,.9); color: #fff; padding: 3px 12px; border-radius: 12px; font-size: 13px; }
#image-meta { padding: 6px 12px; color: #cfd5df; background: #1b1f27; font-size: 13px; display: flex; gap: 18px; }
#image-meta b { color: #fff; }

#form-pane { flex: 1; min-width: 420px; max-width: 640px; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #fff; }
#form { flex: 1; overflow-y: auto; padding: 4px 16px 24px; }
.actions { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
#form-errors { padding: 0 16px; }

#step-banner { margin: 10px 16px 0; padding: 8px 12px; border-radius: 8px; background: #fff7e6; border: 1px solid #f5d48a; }
#ai-panel { margin: 10px 16px 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); border: 1px solid #c7d7fb; }
#ai-panel h3 { margin: 0 0 6px; font-size: 14px; }
#ai-panel ul { margin: 0; padding-left: 18px; }
#ai-panel .tier { display: inline-block; min-width: 2.2em; text-align: center; margin-left: 8px; padding: 0 6px; border-radius: 10px; color: #fff; font-size: 12px; }
#ai-panel .tier-高 { background: var(--t-high); } #ai-panel .tier-中 { background: var(--t-mid); } #ai-panel .tier-低 { background: var(--t-low); }
#ai-panel .note { margin-top: 6px; font-size: 12px; color: var(--muted); }

#review-panel { margin: 10px 16px 0; padding: 8px 12px; border-radius: 8px; background: #fffaf0; border: 1px solid #f0d9a8; max-height: 40vh; overflow-y: auto; }
#review-panel summary { cursor: pointer; font-weight: 600; }
#review-panel .reasons { margin: 6px 0 2px; color: #8a5a00; font-size: 13px; }
#review-panel .opinion { border-top: 1px dashed #ecd9b0; padding: 6px 0 4px; margin-top: 4px; }
#review-panel .ohead { display: flex; align-items: center; gap: 10px; }
#review-panel .ohead b { color: #b26a00; }
#review-panel ul { margin: 3px 0 0; padding-left: 18px; font-size: 13px; }

fieldset.section { border: none; border-top: 1px solid var(--line); margin: 12px 0 0; padding: 10px 0 0; }
fieldset.section > legend { font-weight: 600; padding: 0 6px 0 0; }
.help { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.q { margin: 8px 0; padding: 4px 6px; border-radius: 6px; }
.q.missing { background: #fdecea; outline: 1px solid #f3b4ad; }
.q > .qlabel { font-weight: 500; margin-bottom: 3px; }
.q > .qlabel .req { color: var(--warn); margin-left: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.eye-tag { margin-left: 8px; padding: 0 8px; border-radius: 10px; background: #fff3cd; color: #7a4b00; font-size: 12px; font-weight: 600; }
.chip.first > span { outline: 2px dashed var(--accent); outline-offset: 1px; }
/* options as cards (display: cards): 收治入院建议 */
.chips.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 340px) { .chips.cards { grid-template-columns: 1fr; } }
.card-opt { --tone: #344054; --tone-soft: #f2f4f7; --tone-line: var(--line); display: block; }
.card-opt[data-opt="urgent"] { --tone: #d92d20; --tone-soft: #fef3f2; --tone-line: #f5b5ae; }
.card-opt[data-opt="routine"] { --tone: #1f6feb; --tone-soft: #eef4ff; --tone-line: #c7d7fb; }
.card-opt > span.card-body { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 9px 11px; border: 1px solid var(--tone-line);
  border-radius: 10px; background: #fff; color: inherit; cursor: pointer; user-select: none; }
.card-opt[data-opt="urgent"] > span.card-body { background: #fffafa; }
.card-opt > input:checked + span.card-body { background: var(--tone-soft); border-color: var(--tone); color: inherit; box-shadow: 0 0 0 1px var(--tone); }
.card-opt:hover > span.card-body { border-color: var(--tone); }
.card-head { display: flex; align-items: center; gap: 7px; }
.card-radio { flex: none; width: 16px; height: 16px; border: 2px solid var(--tone-line); border-radius: 50%; background: #fff; }
.card-opt[data-opt="urgent"] .card-radio, .card-opt[data-opt="routine"] .card-radio { border-color: var(--tone); }
.card-opt > input:checked + span .card-radio { border-color: var(--tone); background: radial-gradient(var(--tone) 0 4px, #fff 4.5px); }
.card-icon { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--tone); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-title { color: var(--tone); font-size: 14.5px; }
.card-desc { color: var(--muted); font-size: 12.5px; line-height: 1.5; padding-left: 23px; }
/* questions asked under the cards: one block below them, coloured like the chosen card */
.q.sub { --tone: #344054; --tone-soft: #f8f9fb; --tone-line: #d0d5dd; margin: 0 0 0 4px; padding: 7px 10px;
  border-left: 3px solid var(--tone-line); border-radius: 0; background: var(--tone-soft); }
.q.sub[data-tone="urgent"] { --tone-soft: #fff7f6; --tone-line: #f04438; }
.q.sub[data-tone="routine"] { --tone-soft: #f5f8ff; --tone-line: #1f6feb; }
.q.sub[data-tone="none"], .q.sub[data-tone="na"] { --tone-soft: #f8f9fb; --tone-line: #98a2b3; }
.chips.cards + .count { display: none; }
.q:not(.sub) + .q.sub:not(.hidden) { margin-top: 6px; }
textarea.counted + .count { text-align: right; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dx-search { margin: 2px 0 6px; }
.dx-search input { width: 100%; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; }
.dx-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dx-hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; resize: vertical; }
input.other { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; margin-top: 4px; }

.region { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.region .rhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.region .rname { font-weight: 500; min-width: 7.5em; }
.region .rbody { margin-top: 6px; }
.disease-detail { margin: 6px 0 6px 10px; padding: 6px 10px; border-left: 3px solid var(--accent); background: #fafbff; border-radius: 4px; }
.disease-detail .dtitle { font-weight: 500; }
.disease-detail .std { color: var(--muted); font-size: 12px; margin-left: 6px; }
.point-ctrl { display: flex; gap: 8px; align-items: center; }
.outline-ctrl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.outline-ctrl select { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 100%; }
.outline-list { display: flex; flex-direction: column; gap: 3px; margin: 4px 0; }
.outline-row { display: flex; gap: 8px; align-items: center; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.outline-row:hover, .outline-row.sel { background: var(--accent-soft); }
.outline-row button { margin-left: auto; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.outline-pick { margin: 6px 0; padding: 6px 8px; border: 1px dashed #e0a030; border-radius: 6px; background: #fffaf0; }
.outline-pick .muted { font-size: 13px; margin-bottom: 4px; }
.outline-pick-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 2px 0; }
.info-btn { margin-left: 8px; font-size: 12px; padding: 1px 8px; color: var(--accent); border-color: var(--accent); vertical-align: 1px; }
.info-text { white-space: pre-wrap; font-size: 13px; line-height: 1.6; background: #f6f8fc; border: 1px solid var(--line);
             border-radius: 6px; padding: 8px 10px; margin: 4px 0 6px; }
fieldset.suspect { border-left: 3px solid #d500f9; }
.suspect-note { flex: 1; min-width: 120px; font: inherit; font-size: 13px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; }
.suspect-box { margin-top: 6px; padding: 6px 8px; border: 1px dashed #d500f9; border-radius: 6px; background: #fdf4ff; }
.suspect-head { font-size: 13px; margin-bottom: 4px; }
.suspect-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.suspect-row select { font: inherit; font-size: 13px; padding: 2px 4px; max-width: 100%; }
details.missing { background: #fdecea; outline: 1px solid #f3b4ad; border-radius: 6px; }
#feedback-box { margin-top: 14px; text-align: left; }
#feedback-box summary { cursor: pointer; font-weight: 600; }
.fb-item { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin: 12px 0; }
.fb-fig { position: relative; width: 320px; max-width: 100%; }
.fb-fig img { width: 100%; display: block; border-radius: 6px; }
.fb-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.fb-fig polygon { fill: rgba(213, 0, 249, .15); stroke: #d500f9; stroke-width: 2; vector-effect: non-scaling-stroke; }
.fb-tag { position: absolute; transform: translate(-50%, -120%); background: #d500f9; color: #fff; font-size: 12px; padding: 0 4px; border-radius: 4px; }
.fb-info { flex: 1; min-width: 200px; }
.fb-region { margin: 6px 0; }
.fb-answer { margin-top: 2px; }
.outline-warn { color: var(--warn); font-size: 13px; }
.outline-warn:empty { display: none; }
fieldset.outline.missing { background: #fdecea; outline: 1px solid #f3b4ad; border-radius: 6px; }

.reg { margin-top: 30px !important; }
.profile { display: flex; flex-direction: column; gap: 12px; }
.profile:empty { display: none; }
.card select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.checklist { margin: 4px 0 8px; padding-left: 0; list-style: none; }
.checklist li { margin: 2px 0; }
.checklist .ok { color: var(--ok); font-weight: 600; }
.checklist .no { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; margin: -6px 0 0; }
.hint.error { color: var(--warn); }
.hint:empty, .notice:empty { display: none; }
.notice { font-size: 12px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 0; }
.inv-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0; }
.inv-form input, .inv-form select { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; }
.inv-form input[type=number] { width: 5em; }
.link-wrap { display: flex; gap: 4px; align-items: center; }
.link-box { flex: 1; min-width: 200px; font: 12px/1.4 Consolas, monospace; padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: #f6f8fb; }
.link-wrap button { flex: none; }
.code { font: 600 14px Consolas, monospace; letter-spacing: 1px; }
.off { color: var(--muted); }
.flash { padding: 8px 12px; border-radius: 8px; background: #edf7ee; border: 1px solid #b7dfbd; margin: 6px 0; }
.acts { white-space: nowrap; }
.acts button { margin-right: 4px; }
.flash.bad { background: #fdecea; border-color: #f3b4ad; }

/* Personal edits in expert review. Retired choices have a dashed edge even when
   clinical urgency, keyboard focus or a missing required field also uses colour. */
.chip.review-added > input:checked + span { background: #b42318; border-color: #961e15; color: white; }
.card-opt.review-added > input:checked + .card-body { background: #fff1ef; border-color: #b42318; color: #7a231c; box-shadow: inset 0 0 0 1px #b42318; }
.card-opt.review-added > input:checked + .card-body .card-title { color: #96251d; text-decoration: underline; text-underline-offset: 3px; }
.chip.review-removed > span { border: 1px dashed #b42318; color: #90251d; }
.chip.review-removed:not(.card-opt) > span, .card-opt.review-removed .card-title { text-decoration: line-through; }
textarea.review-added, input.review-added, select.review-added, .point-ctrl.review-added,
.outline-row.review-added { outline: 2px solid #b42318; outline-offset: 1px; }
textarea.review-removed, input.review-removed, select.review-removed, .point-ctrl.review-removed {
  outline: 1px dashed #b42318; outline-offset: 1px;
}
.review-change-hint { color: #84281f; font-size: 13px; line-height: 1.5; }
.review-change-list { margin: 4px 0 8px; padding-inline-start: 22px; color: #96251d; font-size: 14px; overflow-wrap: anywhere; }
.review-change-list li { margin: 3px 0; }
#review-change-key { padding: 6px 10px; border-inline-start: 3px solid #c3382b; background: #fff8f6; }
#review-change-key summary { cursor: pointer; }
table.grid { border-collapse: collapse; width: 100%; margin: 8px 0 18px; background: #fff; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
table.grid th { background: #f0f2f6; }
