:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --ink: #142033;
  --muted: #64748b;
  --line: #d8e2ea;
  --brand: #0b5f84;
  --brand-2: #127a96;
  --green: #12814a;
  --yellow: #a66a12;
  --orange: #c4531d;
  --red: #b42318;
  --shadow: 0 18px 42px rgba(15, 23, 42, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.launch-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
  padding: 0;
  overflow: hidden;
  background: #f7f1ec;
}
.launch-bg { display: none; }
.launch-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: saturate(.98);
}
.launch-panel {
  position: absolute;
  right: clamp(18px, 4vw, 56px);
  bottom: clamp(18px, 5vh, 54px);
  width: min(420px, calc(100vw - 36px));
  min-height: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  padding: 20px 22px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(15,79,111,.18);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(23,50,77,.18);
  backdrop-filter: blur(5px);
}
.launch-panel h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
  color: #102a43;
}
.launch-panel p {
  margin: 0;
  color: #0f6d7e;
  font-weight: 700;
}
.launch-button {
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 12px 26px;
  background: #0f4f6f;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(15,79,111,.22);
}
.launch-button:hover { background: #0b405a; }
.launch-panel small {
  max-width: 360px;
  color: var(--muted);
  line-height: 1.65;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #0b415e 0%, #0c6884 48%, #edf4f8 48.2%, #edf4f8 100%);
}
.login-panel {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-panel h1 { margin: 14px 0 10px; font-size: 24px; line-height: 1.35; }
.login-panel p, .login-panel small { color: var(--muted); line-height: 1.7; }

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #0b5f84;
  color: #fff;
  font-weight: 900;
  line-height: 1.05;
  font-size: 17px;
}
.brand-mark.small { width: 48px; height: 48px; font-size: 14px; border-radius: 12px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 18px;
}
.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.department-logo-small {
  width: 54px;
  height: 54px;
  object-fit: contain;
  background: rgba(255,255,255,.96);
  border-radius: 50%;
  padding: 3px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.brand h1 { margin: 0; font-size: 22px; line-height: 1.25; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-badge {
  padding: 8px 11px;
  background: #edf6f8;
  color: #0f516d;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid #cfdee6;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  box-shadow: var(--shadow);
}
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.nav-item span { color: var(--muted); font-size: 12px; font-weight: 600; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.active span { color: rgba(255,255,255,.78); }

.main { min-width: 0; }
.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel.active { display: block; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.actions.left { justify-content: flex-start; margin: 12px 0; align-items: center; }

.primary, .secondary, .ghost, .button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: #074967; }
.secondary { background: #e8f2f6; color: var(--brand); border: 1px solid #cbdfe8; }
.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 13px;
}
.form-grid h3 {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 4px solid var(--brand-2);
  border-radius: 8px;
  font-size: 15px;
}
label { display: block; grid-column: span 2; font-size: 13px; color: #334155; font-weight: 700; }
label.span-2 { grid-column: span 2; }
label.span-3 { grid-column: span 3; }
label.span-4 { grid-column: span 4; }
label.span-12 { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cbd8e3;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; }
textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18, 122, 150, .12); }
.large-text { min-height: 220px; }
.check-row { display: inline-flex; align-items: center; grid-column: auto; margin: 0; }
.form-msg { min-height: 22px; margin-top: 8px; color: var(--red); font-size: 13px; }
.notice {
  border: 1px solid #f0d69a;
  background: #fff8e6;
  color: #6b4e16;
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.7;
  margin-bottom: 14px;
  font-size: 13px;
}
.ocr-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
  align-items: stretch;
}
.file-label { grid-column: auto; margin-bottom: 8px; }
.ocr-preview {
  min-height: 260px;
  background: var(--surface-2);
  border: 1px dashed #adc2ce;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  overflow: hidden;
  text-align: center;
}
.ocr-preview img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, .12);
}
.ocr-status {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.ocr-status.ok { color: #14532d; border-color: #bbdfc7; background: #f0fbf4; }
.ocr-status.bad { color: #8a1f11; border-color: #f3c6be; background: #fff3f1; }

.result-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}
.completeness-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
.check-pass { color: var(--green); font-weight: 800; }
.check-miss { color: var(--red); font-weight: 800; }
.priority-list { display: grid; gap: 8px; }
.priority-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.priority-item b { display: block; margin-bottom: 3px; }
.priority-item span { color: var(--muted); font-size: 13px; }
.score-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.score-label { color: var(--muted); font-weight: 700; }
.score { font-size: 56px; font-weight: 900; color: var(--brand); line-height: 1.1; }
.grade { display: inline-flex; padding: 6px 12px; border-radius: 999px; color: #fff; font-weight: 800; margin: 8px 0; }
.grade.low { background: var(--green); }
.grade.medium { background: var(--yellow); }
.grade.high { background: var(--orange); }
.grade.veryhigh { background: var(--red); }
.score-panel p { color: var(--muted); line-height: 1.7; }
.bar-list { display: grid; gap: 10px; }
.bar-item { border: 1px solid var(--line); border-radius: 12px; padding: 11px; background: #fff; }
.bar-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.bar-track { height: 10px; background: #dce8ee; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 999px; }
.info-columns { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.info-columns article:nth-child(n+4) { grid-column: span 1; }
.info-columns article, .dash-grid article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.info-columns h3, .dash-grid h3 { margin: 0 0 10px; font-size: 16px; color: #0f516d; }
ul { margin: 0; padding-left: 20px; line-height: 1.75; }
.recommendation-item { display: grid; gap: 5px; }
.recommendation-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  line-height: 1.45;
}
.rec-priority, .evidence-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 800;
}
.rec-priority.critical { background: #fee4e2; color: var(--red); }
.rec-priority.high { background: #fff1d6; color: var(--orange); }
.rec-priority.medium { background: #e7f6f8; color: var(--brand); }
.rec-priority.standard { background: #edf6ef; color: var(--green); }
.evidence-tag { background: #eef2f7; color: #475569; font-weight: 700; }
.recommendation-item small { color: var(--muted); line-height: 1.55; }
.empty {
  background: var(--surface-2);
  border: 1px dashed #b9c9d4;
  color: var(--muted);
  border-radius: 12px;
  padding: 18px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef5f8; color: #0f516d; }
.report {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  line-height: 1.8;
}
.report h3 { color: #0f516d; margin: 8px 0 10px; }
.report h4 { margin: 16px 0 8px; }
.report-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fff;
}
.report-section:last-child { margin-bottom: 0; }
.patient-report {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.patient-report h3 {
  color: #17324d;
}

.kpi-grid, .dash-grid { display: grid; gap: 14px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.kpi-grid div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.kpi-grid b { display: block; font-size: 32px; color: var(--brand); }
.kpi-grid span { color: var(--muted); font-size: 13px; }
.dash-grid { grid-template-columns: 1fr 1fr; }
.training-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 14px; margin-bottom: 14px; }
.training-grid.wide { grid-template-columns: 1.15fr .85fr; }
.training-grid article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.training-grid h3 { margin: 0 0 12px; font-size: 16px; color: #0f516d; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric-strip div { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface-2); }
.metric-strip b { display: block; color: var(--brand); font-size: 24px; }
.metric-strip span { color: var(--muted); font-size: 12px; }
.dist-row { display: grid; grid-template-columns: 120px 1fr 56px; gap: 10px; align-items: center; margin: 10px 0; font-size: 13px; }
.dist-track { height: 14px; background: #dce8ee; border-radius: 999px; overflow: hidden; }
.dist-fill { height: 100%; background: var(--brand-2); }

.case-list { display: grid; gap: 10px; }
.case-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: #fff;
}
.case-row b { display: block; margin-bottom: 4px; }
.case-row span { color: var(--muted); font-size: 13px; }
.tag { display: inline-flex; padding: 4px 8px; margin: 5px 5px 0 0; background: #edf6f8; color: #0f516d; border-radius: 999px; font-size: 12px; }
.governance { line-height: 1.8; }
.governance h3 { color: #0f516d; margin-bottom: 6px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #132033;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* Visual refinement: quiet clinical workstation style. */
:root {
  --bg: #f3f6f9;
  --surface-2: #f8fafc;
  --ink: #162033;
  --muted: #667085;
  --line: #d7dee8;
  --brand: #0f4f6f;
  --brand-2: #0e7490;
  --brand-3: #17324d;
  --shadow: 0 14px 34px rgba(20, 32, 51, .08);
  --shadow-soft: 0 8px 18px rgba(20, 32, 51, .06);
}
body { font-size: 14px; background: linear-gradient(180deg, #f7fafc 0, #eef3f7 100%); }
.login-view {
  background:
    linear-gradient(90deg, rgba(23, 50, 77, .98) 0 41%, rgba(243, 246, 249, .98) 41% 100%),
    linear-gradient(180deg, #f7fafc, #e9f1f5);
}
.login-panel, .topbar, .sidebar, .panel, .report, .case-row, .kpi-grid div, .info-columns article, .dash-grid article, .training-grid article {
  border-radius: 10px;
}
.login-panel { padding: 30px; }
.brand-mark { border-radius: 10px; background: linear-gradient(145deg, var(--brand-3), var(--brand)); }
.app { grid-template-columns: 260px 1fr; gap: 16px; padding: 16px; }
.topbar {
  background: linear-gradient(135deg, #172235, #0f4f6f);
  color: #fff;
  border-color: rgba(255,255,255,.10);
  padding: 14px 18px;
}
.brand p { color: rgba(255,255,255,.74); }
.user-badge { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.18); }
.ghost { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }
.sidebar, .panel { box-shadow: var(--shadow-soft); }
.nav-item { border-radius: 8px; padding: 11px 12px; }
.panel-head { border-bottom-color: #e2e8f0; }
.panel-head h2 { font-size: 21px; }
.primary, .secondary, .ghost, .button, input, select, textarea { border-radius: 8px; }
.primary { background: #0f4f6f; }
.primary:hover { background: #0b405a; }
.secondary { background: #eef5f8; border-color: #d0e0e8; }
.form-grid { gap: 12px; }
.form-grid h3 {
  border-left-width: 3px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef6f8, #f8fafc);
}
input, select, textarea { padding: 9px 10px; }
.notice { border-radius: 8px; }
.score-panel, .bar-item, .empty, .ocr-preview, .ocr-status { border-radius: 10px; }
.tag { background: #edf6f8; color: #0f4f6f; }

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; display: grid; grid-template-columns: repeat(2, 1fr); }
  label, label.span-2, label.span-3, label.span-4 { grid-column: span 6; }
  .result-layout, .completeness-layout, .info-columns, .dash-grid { grid-template-columns: 1fr; }
  .training-grid, .training-grid.wide, .metric-strip { grid-template-columns: 1fr; }
  .ocr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .app { padding: 10px; gap: 10px; }
  .launch-view { padding: 0; }
  .launch-poster { object-position: center top; }
  .launch-panel {
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    padding: 14px 16px;
  }
  .launch-panel h1 { font-size: 18px; }
  .topbar, .panel-head { display: block; }
  .top-actions, .actions { justify-content: flex-start; margin-top: 12px; }
  .sidebar { grid-template-columns: 1fr; }
  label, label.span-2, label.span-3, label.span-4 { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .case-row { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .topbar, .sidebar, .panel:not(#reportPanel), .panel-head, .toast { display: none !important; }
  .app { display: block; padding: 0; }
  #reportPanel { display: block !important; box-shadow: none; border: 0; }
  .report { border: 0; }
}
