:root {
  --ink: #17232c;
  --muted: #687781;
  --line: #dce4e7;
  --paper: #ffffff;
  --canvas: #f2f6f6;
  --teal: #087f83;
  --teal-dark: #056269;
  --teal-soft: #e5f4f3;
  --navy: #122734;
  --red: #c43e3e;
  --amber: #b57215;
  --shadow: 0 12px 32px rgba(21, 48, 58, .08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif; }
body.locked > .topbar, body.locked > .layout, body.locked > .detail-drawer, body.locked > .drawer-backdrop { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

.topbar { height: 76px; padding: 0 28px; display: flex; align-items: center; gap: 14px; background: var(--navy); color: white; position: sticky; top: 0; z-index: 20; }
.brand-mark { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; padding: 4px; border: 1px solid rgba(255,255,255,.35); border-radius: 9px; background: #eefcfc; overflow: hidden; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: .02em; }
.topbar p { margin: 4px 0 0; color: #aabac2; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.system-badges { margin-left: auto; display: flex; gap: 8px; }
.topbar-action { min-height: 34px; padding: 0 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; color: #e6f0f2; background: transparent; }
.topbar-action:hover { background: rgba(255,255,255,.1); }
.badge { padding: 7px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 4px; color: #dbe8eb; font-size: 12px; }
.badge.good::before { content: "●"; margin-right: 6px; color: #50d5b7; }

.layout { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 236px 1fr; }
.sidebar { padding: 22px 16px; background: #e7eeee; border-right: 1px solid #d3dedf; display: flex; flex-direction: column; min-height: calc(100vh - 76px); }
.nav-button { width: 100%; padding: 12px 14px; border: 0; border-radius: 5px; text-align: left; color: var(--ink); background: transparent; font-weight: 600; }
.nav-button.active { color: white; background: var(--teal); }
.side-heading { margin: 28px 10px 10px; color: #73838b; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.case-list { display: flex; flex-direction: column; gap: 5px; overflow: auto; }
.case-item { padding: 10px; border: 0; border-radius: 4px; text-align: left; background: transparent; color: var(--ink); }
.case-item:hover { background: rgba(255,255,255,.65); }
.case-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.case-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.disclaimer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #ccd8da; color: #7a888f; font-size: 11px; line-height: 1.65; }

.main { padding: 34px clamp(24px, 4vw, 56px) 70px; overflow: hidden; }
.view-section { max-width: 1320px; margin: 0 auto; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-title h2 { margin: 4px 0 6px; font: 600 30px/1.2 Georgia, "Microsoft YaHei", serif; }
.page-title p { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .18em; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.form-panel { padding: 28px; }
.form-section { padding: 0 0 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.field-label { display: block; margin-bottom: 8px; color: #31444e; font-size: 13px; font-weight: 700; }
.field-help { margin-top: 7px; color: var(--muted); font-size: 12px; }
.file-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.text-input, .select-input, textarea { width: 100%; border: 1px solid #cbd7da; border-radius: 4px; background: white; color: var(--ink); outline: none; }
.text-input, .select-input { height: 42px; padding: 0 12px; }
textarea { padding: 10px 12px; resize: vertical; }
.text-input:focus, .select-input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,131,.11); }
.button { min-height: 40px; padding: 0 17px; border: 1px solid transparent; border-radius: 4px; font-weight: 700; }
.button.primary { color: white; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--teal-dark); background: white; border-color: #a9c4c5; }
.button.ghost { margin-top: 16px; color: var(--muted); background: transparent; border-color: var(--line); }
.button.large { min-width: 210px; height: 48px; }
.section-row { display: flex; justify-content: space-between; gap: 20px; }
.small-actions { display: flex; gap: 12px; }
.text-button { padding: 0; border: 0; color: var(--teal); background: none; font-size: 12px; font-weight: 700; }
.model-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.model-card { display: block; position: relative; padding: 15px 14px 13px 40px; border: 1px solid var(--line); border-radius: 5px; background: #fbfdfd; min-height: 84px; }
.model-card:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.model-card input { position: absolute; left: 14px; top: 17px; accent-color: var(--teal); }
.model-card strong { display: block; font-size: 13px; }
.model-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.recommended-pill { display: inline-block !important; width: fit-content; margin-top: 7px !important; padding: 2px 6px; color: var(--teal-dark) !important; background: #ccebea; border-radius: 3px; font-size: 10px !important; font-weight: 700; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.advanced { margin: 0 0 24px; padding: 15px; border: 1px solid var(--line); border-radius: 5px; background: #f9fbfb; }
.advanced summary { color: #3a505a; font-size: 13px; font-weight: 700; cursor: pointer; }
.advanced-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.check-line { margin-top: 16px; display: flex; gap: 9px; align-items: flex-start; color: var(--muted); font-size: 12px; line-height: 1.5; }
.check-line input { margin-top: 3px; accent-color: var(--teal); }
.error-box { margin-bottom: 16px; padding: 12px 14px; border-left: 3px solid var(--red); background: #fff0f0; color: #8e2d2d; font-size: 13px; }
.auth-screen { min-height: 100vh; padding: 30px 16px; display: grid; place-items: center; background: radial-gradient(circle at 50% 12%, #effbfa 0, #edf3f4 46%, #e2eaec 100%); }
.auth-card { width: min(440px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 24px 70px rgba(17,45,57,.16); }
.auth-card > img { width: 78px; height: 78px; display: block; margin: 0 auto 20px; object-fit: contain; }
.auth-card .eyebrow { display: block; text-align: center; }
.auth-card h2 { margin: 8px 0 12px; text-align: center; font: 600 25px/1.3 Georgia, "Microsoft YaHei", serif; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.7; }
.auth-card .button { width: 100%; margin-top: 4px; }
.auth-card small { display: block; margin-top: 16px; color: #849198; text-align: center; }
.upload-status { margin-top: 14px; }
.upload-status .progress-track { margin-top: 0; }
.upload-status span { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.retention-note { color: var(--muted); font-size: 12px; }

.progress-panel { margin-top: 18px; padding: 24px; }
.progress-heading { display: flex; justify-content: space-between; align-items: center; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--teal); }
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.progress-track { height: 8px; margin-top: 17px; overflow: hidden; background: #e5ecee; border-radius: 20px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #33b9aa); transition: width .35s ease; }
.progress-details { margin-top: 12px; color: var(--muted); font-size: 12px; }

.metric-grid { margin-bottom: 18px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metric-card { padding: 17px; background: white; border: 1px solid var(--line); border-radius: 5px; }
.metric-card span { color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin-top: 6px; font: 600 24px Georgia, serif; }
.results-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, .8fr); gap: 18px; }
.panel-heading { padding: 18px 20px 14px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.overview-panel { overflow: hidden; }
.viewer-shell { position: relative; overflow: hidden; background: #07151c; }
.wsi-viewer { width: 100%; height: 650px; background: #07151c; }
.viewer-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #b8c9cf; font-size: 13px; letter-spacing: .04em; }
.viewer-toolbar, .viewer-presets, .viewer-layers, .viewer-legend, .scale-widget, .viewer-status { position: absolute; z-index: 8; color: white; background: rgba(7, 21, 28, .82); border: 1px solid rgba(255, 255, 255, .17); box-shadow: 0 4px 16px rgba(0, 0, 0, .2); backdrop-filter: blur(5px); }
.viewer-toolbar { top: 13px; left: 13px; display: flex; overflow: hidden; border-radius: 5px; }
.viewer-toolbar button { width: 39px; height: 38px; padding: 0; border: 0; border-right: 1px solid rgba(255,255,255,.14); color: white; background: transparent; font-size: 20px; font-weight: 700; }
.viewer-toolbar button:last-child { border-right: 0; }
.viewer-toolbar button:hover { background: rgba(42, 185, 178, .45); }
.viewer-presets { top: 60px; left: 13px; display: flex; overflow: hidden; border-radius: 5px; }
.viewer-presets button { min-height: 34px; padding: 0 10px; border: 0; border-right: 1px solid rgba(255,255,255,.14); color: #e8f1f3; background: transparent; font-size: 10px; font-weight: 700; }
.viewer-presets button:last-child { border-right: 0; }
.viewer-presets button:hover, .viewer-presets button.active { color: #08252a; background: #6ff4ed; }
.viewer-layers { top: 13px; right: 13px; display: flex; gap: 13px; padding: 10px 12px; border-radius: 5px; font-size: 11px; }
.viewer-layers label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.viewer-layers input { accent-color: #25c9c6; }
.viewer-legend { left: 13px; bottom: 47px; display: flex; gap: 14px; padding: 8px 10px; border-radius: 4px; font-size: 10px; }
.viewer-legend span { display: flex; gap: 6px; align-items: center; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot.candidate { background: #ef4141; border: 2px solid white; }
.legend-dot.hotspot { background: rgba(0, 215, 209, .25); border: 2px solid #00d7d1; }
.scale-widget { left: 13px; bottom: 13px; min-width: 80px; padding: 6px 9px 5px; border-radius: 3px; font-size: 9px; }
.scale-bar { width: 80px; height: 5px; margin-bottom: 3px; border: solid white; border-width: 0 2px 2px; transition: width .12s linear; }
.viewer-status { right: 13px; bottom: 13px; padding: 7px 10px; border-radius: 3px; color: #d5e2e5; font-size: 9px; pointer-events: none; }
.wsi-viewer .navigator { border: 1px solid rgba(255,255,255,.72) !important; background: #10232c !important; box-shadow: 0 5px 18px rgba(0,0,0,.35); }
.osd-candidate-marker { width: 15px; height: 15px; padding: 0; border: 2px solid white; border-radius: 50%; background: rgba(239, 56, 56, var(--candidate-opacity, .9)); box-shadow: 0 0 0 2px rgba(119, 3, 3, .65), 0 2px 8px rgba(0,0,0,.8); transform: scale(1); transition: transform .14s ease, box-shadow .14s ease; cursor: pointer; }
.osd-candidate-marker:hover, .osd-candidate-marker.selected { z-index: 5; transform: scale(1.65); box-shadow: 0 0 0 3px #ffe34f, 0 2px 12px rgba(0,0,0,.9); }
.osd-hotspot-marker { width: 100%; height: 100%; min-width: 18px; min-height: 18px; padding: 0; border: 3px solid #00d7d1; border-radius: 50%; background: rgba(0, 215, 209, .13); box-shadow: inset 0 0 18px rgba(0, 215, 209, .15), 0 0 7px rgba(0,0,0,.5); cursor: pointer; }
.osd-hotspot-marker:hover, .osd-hotspot-marker.selected { border-color: #fff064; background: rgba(255, 240, 100, .15); box-shadow: 0 0 0 2px #fff064, inset 0 0 22px rgba(255,240,100,.18); }
.info-list { margin: 0; padding: 12px 20px 20px; }
.info-list div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #edf1f2; }
.info-list dt { color: var(--muted); font-size: 12px; }
.info-list dd { margin: 0; text-align: right; font-size: 12px; font-weight: 700; }
.tabbar { margin-top: 28px; display: flex; gap: 26px; border-bottom: 1px solid #cbd7da; }
.tab { padding: 12px 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.tab.active { color: var(--teal-dark); border-color: var(--teal); }
.tab-content { padding-top: 18px; }
.hotspot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hotspot-card, .candidate-card { overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: white; box-shadow: 0 5px 16px rgba(19,46,57,.05); }
.hotspot-card { cursor: pointer; }
.hotspot-card img, .candidate-card img { width: 100%; display: block; background: #e9eeee; object-fit: cover; }
.hotspot-card img { aspect-ratio: 1; }
.card-body { padding: 12px 13px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title-row strong { font-size: 13px; }
.score { font: 700 16px Georgia, serif; color: var(--teal-dark); }
.card-meta { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.candidate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.candidate-card { cursor: pointer; }
.candidate-card:hover, .hotspot-card:hover { border-color: #86abad; transform: translateY(-1px); transition: .15s ease; }
.review-chip { display: inline-block; margin-top: 8px; padding: 3px 7px; border-radius: 3px; font-size: 10px; font-weight: 800; }
.review-chip.TP { color: #076d58; background: #d9f3e9; }
.review-chip.FP { color: #982e2e; background: #f9dddd; }
.review-chip.uncertain { color: #8a5b12; background: #f7ead0; }

.detail-drawer { position: fixed; z-index: 60; top: 0; right: 0; width: min(670px, 94vw); height: 100vh; padding: 24px; overflow-y: auto; background: white; box-shadow: -20px 0 60px rgba(12,34,44,.22); transform: translateX(105%); transition: transform .25s ease; }
.detail-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(8,24,33,.38); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-header h3 { margin: 4px 0 0; font-size: 23px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 24px; line-height: 1; }
.zoom-row { margin: 22px 0 10px; display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; }
.zoom-row span { margin-right: auto; }
.zoom-button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; background: white; color: var(--muted); font-size: 11px; }
.zoom-button.active { color: white; background: var(--teal); border-color: var(--teal); }
.detail-image-frame { min-height: 420px; display: grid; place-items: center; background: #e9eeee; }
.detail-image-frame img { width: 100%; display: block; }
.candidate-meta { padding: 14px 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.review-section { padding-top: 18px; border-top: 1px solid var(--line); }
.review-actions { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.review-button { min-height: 38px; border: 1px solid var(--line); border-radius: 4px; background: white; font-weight: 700; font-size: 12px; }
.review-button.tp:hover, .review-button.tp.selected { color: #076d58; border-color: #62bda6; background: #e2f5ef; }
.review-button.fp:hover, .review-button.fp.selected { color: #982e2e; border-color: #d98d8d; background: #fce8e8; }
.review-button.uncertain:hover, .review-button.uncertain.selected { color: #8a5b12; border-color: #d5b36d; background: #fbf0dc; }
.saved-message { min-height: 20px; margin-top: 8px; color: var(--teal); font-size: 11px; }

@media (max-width: 1050px) {
  .model-grid, .candidate-grid { grid-template-columns: repeat(2, 1fr); }
  .hotspot-grid { grid-template-columns: repeat(2, 1fr); }
  .advanced-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 24px 14px 50px; }
  .system-badges { display: none; }
  .file-row, .split-fields, .results-grid { grid-template-columns: 1fr; }
  .model-grid, .candidate-grid, .hotspot-grid, .advanced-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .review-actions { grid-template-columns: repeat(2, 1fr); }
  .wsi-viewer { height: 520px; }
  .viewer-presets { right: 13px; overflow-x: auto; }
  .viewer-presets button { padding: 0 7px; }
  .viewer-layers { top: 105px; left: 13px; right: auto; }
  .viewer-status { display: none; }
}
