:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #e4eaf2;
  --sidebar: #10243d;
  --sidebar-2: #173450;
  --primary: #246bfd;
  --primary-soft: #eaf1ff;
  --teal: #0f9f8f;
  --teal-soft: #e6f7f4;
  --green: #1f9d61;
  --green-soft: #e8f7ef;
  --amber: #b7791f;
  --amber-soft: #fff6e5;
  --danger: #c84b4b;
  --danger-soft: #fdeeee;
  --shadow: 0 10px 30px rgba(23, 32, 51, .06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(135deg, #4f8cff, #18c2b1);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: white;
  box-shadow: 0 8px 20px rgba(36, 107, 253, .35);
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.brand-title.dark { color: var(--ink); }
.brand-sub { font-size: 10px; color: rgba(255,255,255,.55); letter-spacing: .8px; text-transform: uppercase; }
.brand-sub.dark { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 11px;
  color: rgba(255,255,255,.72); font-weight: 500;
  transition: .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; box-shadow: inset 3px 0 0 #55d6c2; }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.nav-group {
  margin: 20px 14px 6px; font-size: 10px; letter-spacing: 1.4px;
  color: rgba(255,255,255,.35); text-transform: uppercase;
}
.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; gap: 10px; align-items: center; padding: 8px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.15); display: grid; place-items: center;
  font-weight: 700; color: #fff;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-meta { font-size: 11px; color: rgba(255,255,255,.55); }
.logout { display: block; margin: 10px 8px 0; font-size: 12px; color: rgba(255,255,255,.55); }
.logout:hover { color: #fff; }

.main { margin-left: 244px; padding: 26px 34px 60px; min-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.eyebrow { font-size: 10px; letter-spacing: 1.7px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.topbar h1 { margin: 3px 0 0; font-size: 28px; letter-spacing: -.5px; line-height: 1.2; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar-actions form { display: inline-flex; margin: 0; }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash-stack.compact { margin: 14px 0 4px; }
.flash { padding: 11px 14px; border-radius: 11px; font-size: 13px; border: 1px solid transparent; }
.flash-success { background: var(--green-soft); color: #176c45; border-color: #c9ebd9; }
.flash-error { background: var(--danger-soft); color: #9d3434; border-color: #f3cfcf; }
.flash-warning { background: var(--amber-soft); color: #8e5e12; border-color: #f4dfb3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 15px; font-size: 13px; font-weight: 600;
  transition: .16s ease; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(36,107,253,.2); }
.btn-primary:hover { background: #1858d8; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #0b8579; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #177c4c; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93c3c; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-block { width: 100%; }
.btn-small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.2px; }
.panel-wide { min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 650; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.ellipsis { max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-link { color: var(--primary); font-size: 12px; font-weight: 600; }
.text-link:hover { text-decoration: underline; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.slot-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  background: linear-gradient(135deg, #10243d, #17466a); color: #fff;
  border-radius: 14px; padding: 15px 20px; margin-bottom: 18px;
}
.slot-banner > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.slot-banner .eyebrow { color: #79bfe8; }
.slot-banner strong { font-size: 14px; }
.slot-remaining { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 700; }
.slot-remaining.full { background: #ffe6e6; color: #9d3434; border-color: #ffc4c4; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--primary-soft); opacity: .7; }
.stat-card.accent-blue::after { background: #e3edff; }
.stat-card.accent-green::after { background: #e2f6ec; }
.stat-card.accent-amber::after { background: #fff0d0; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 750; line-height: 1.2; margin: 6px 0 2px; letter-spacing: -1px; }
.stat-foot { font-size: 11px; color: var(--muted); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .8fr); gap: 20px; align-items: start; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #fbfcfe; white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table tbody tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 9px; font-size: 11px; font-weight: 650; white-space: nowrap;
}
.status-draft { background: #eef2f7; color: #526173; }
.status-submitted { background: #e7efff; color: #2459c7; }
.status-approved { background: #e4f6ec; color: #18764a; }
.status-returned { background: #fff0dd; color: #9b6414; }

.empty-state { text-align: center; padding: 42px 20px; }
.empty-state.compact { padding: 24px; }
.empty-icon { font-size: 28px; color: #9aa8ba; margin-bottom: 6px; }
.empty-state h3 { margin: 0 0 4px; font-size: 16px; }
.empty-state p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.progress-list { display: flex; flex-direction: column; gap: 14px; }
.progress-row > div:first-child { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.progress-track { height: 7px; border-radius: 99px; background: #eef2f7; overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: 99px; background: #94a3b8; }
.progress-track i.blue { background: var(--primary); }
.progress-track i.green { background: var(--green); }
.progress-track i.amber { background: #d79a35; }
.callout { background: #f7f9fd; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 20px; }
.callout-title { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.callout p { margin: 0; font-size: 12px; color: var(--muted); }

.office-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.office-card { border: 1px solid var(--line); border-radius: 13px; padding: 15px; background: #fcfdff; }
.office-name { font-size: 12px; font-weight: 700; color: var(--muted); }
.office-total { font-size: 28px; font-weight: 750; margin: 3px 0 6px; }
.office-total span { font-size: 11px; color: var(--muted); font-weight: 500; }
.office-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); }
.mini-bars { display: flex; height: 5px; border-radius: 99px; overflow: hidden; background: #eef2f7; margin-top: 12px; }
.mini-bars i { display: block; height: 100%; }
.mini-bars i.green { background: var(--green); }
.mini-bars i.blue { background: var(--primary); }
.mini-bars i.amber { background: #d79a35; }
.inline-bar { display: inline-block; width: 90px; height: 6px; border-radius: 99px; background: #eef2f7; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.inline-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.inline-bar i.green { background: var(--green); }

.btn-row, .form-actions, .action-buttons { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.narrow { max-width: 720px; }
.readonly-field { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--line); }
.readonly-field span { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label, .form-stack label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 650; color: #46556a; }
.form-grid input, .form-grid select, .form-grid textarea,
.form-stack input, .form-stack select, .form-stack textarea,
.inline-lab-form input, .inline-lab-form select {
  width: 100%; border: 1px solid #dbe3ee; border-radius: 9px;
  padding: 10px 11px; background: #fff; color: var(--ink); outline: none;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus,
.inline-lab-form input:focus, .inline-lab-form select:focus {
  border-color: #82a9ff; box-shadow: 0 0 0 3px rgba(36,107,253,.09);
}
.form-grid textarea, .form-stack textarea { resize: vertical; min-height: 110px; width: 100%; }
.span-2 { grid-column: span 2; }
.check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #46556a; }
.switch-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--line); font-weight: 600; }
.switch-row input { width: 16px; height: 16px; }

.login-body { background: #edf3fb; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; }
.login-hero {
  background: radial-gradient(circle at 20% 15%, rgba(75, 141, 255, .4), transparent 35%),
              radial-gradient(circle at 80% 80%, rgba(15, 159, 143, .25), transparent 30%),
              linear-gradient(135deg, #0f2239, #143c5f);
  color: #fff; padding: 70px 8vw; display: flex; flex-direction: column; justify-content: center;
}
.hero-badge { font-size: 11px; letter-spacing: 2.4px; color: #8cc9ff; font-weight: 700; }
.login-hero h1 { font-size: clamp(34px, 4vw, 56px); line-height: 1.15; letter-spacing: -1.4px; margin: 18px 0 20px; max-width: 620px; }
.login-hero.hero-minimal { justify-content: center; }
.login-hero.hero-minimal h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(40px, 5.4vw, 72px);
  line-height: 1.12;
  letter-spacing: -2px;
}
.hero-copy { max-width: 560px; color: rgba(255,255,255,.72); font-size: 15px; line-height: 1.9; }
.hero-grid { display: flex; gap: 48px; margin-top: 38px; }
.hero-grid div { display: flex; flex-direction: column; }
.hero-grid strong { font-size: 28px; line-height: 1.1; }
.hero-grid span { font-size: 11px; color: rgba(255,255,255,.55); letter-spacing: .5px; }
.hero-note { margin-top: 42px; font-size: 11px; color: rgba(255,255,255,.45); }
.login-card-wrap { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; }
.login-card { width: min(440px, 100%); background: #fff; border-radius: 22px; box-shadow: 0 30px 80px rgba(15,34,57,.14); padding: 32px; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-tabs { display: flex; flex-wrap: wrap; gap: 2px; background: #f1f5fa; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.login-tab { flex: 1 1 30%; border: none; background: transparent; padding: 8px; border-radius: 8px; font-size: 12px; font-weight: 650; color: var(--muted); }
.login-tab.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(15,34,57,.08); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 650; color: #46556a; }
.login-form input, .login-form select { border: 1px solid #dbe3ee; border-radius: 10px; padding: 11px 12px; outline: none; }
.login-form input:focus, .login-form select:focus { border-color: #82a9ff; box-shadow: 0 0 0 3px rgba(36,107,253,.09); }
.form-hint { font-size: 11px; color: var(--muted); margin: 0; }
.hidden { display: none !important; }
.login-foot { margin-top: 20px; font-size: 11px; color: #8a97a8; }

.case-hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.case-hero-title { font-size: 22px; font-weight: 750; display: flex; align-items: center; gap: 10px; }
.case-hero-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 5px; }
.case-hero-stats { display: flex; gap: 28px; }
.case-hero-stats div { display: flex; flex-direction: column; align-items: flex-end; }
.case-hero-stats strong { font-size: 24px; line-height: 1.1; }
.case-hero-stats span { font-size: 10px; color: var(--muted); }
.review-panel { border-color: #d7e6ff; background: linear-gradient(180deg, #fbfdff, #ffffff); }
.review-actions { margin-top: 12px; }
.review-quick { padding: 16px 20px; margin-bottom: 16px; }
.notice { border: 1px solid var(--line); background: #f8fafc; border-radius: 12px; padding: 13px 15px; font-size: 13px; color: #4c5b6e; margin-bottom: 18px; }
.notice-amber { background: var(--amber-soft); border-color: #f0d8a4; color: #805610; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.upload-panel { margin-bottom: 20px; }
.step-pill { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 750; font-size: 12px; }
.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 150px; border: 1.5px dashed #c9d6e8; border-radius: 13px;
  background: #fbfdff; color: #4c5b6e; text-align: center; cursor: pointer; margin: 14px 0 10px;
  transition: .18s ease;
}
.file-drop:hover { border-color: #82a9ff; background: #f7faff; }
.file-drop input { display: none; }
.file-drop-icon { font-size: 26px; color: var(--primary); line-height: 1; }
.file-drop small { font-size: 10px; color: var(--muted); }
.doc-strip { display: flex; gap: 8px; overflow-x: auto; padding-top: 12px; }
.doc-thumb { width: 74px; flex: 0 0 74px; display: flex; flex-direction: column; gap: 4px; font-size: 9px; color: var(--muted); }
.doc-thumb img { width: 74px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.doc-thumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.case-form > .panel { scroll-margin-top: 20px; }
.sticky-actions {
  position: sticky; bottom: 16px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(15,34,57,.12); margin: 8px 0 20px;
}
.sticky-note { font-size: 11px; color: var(--muted); }
.action-buttons { justify-content: flex-end; }
.lab-table td { vertical-align: middle; }
.crop-thumb { padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; width: 96px; height: 34px; }
.crop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.confidence { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; color: var(--muted); }
.inline-lab-form {
  display: grid; grid-template-columns: 1.4fr 1fr .7fr .8fr .7fr .7fr auto;
  gap: 8px; align-items: end; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.inline-lab-form label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--muted); font-weight: 650; }
.inline-lab-form input, .inline-lab-form select { padding: 8px; font-size: 12px; }

.summary-highlight { background: linear-gradient(135deg, #f2f7ff, #effbf8); border: 1px solid #dceafa; border-radius: 14px; padding: 16px; }
.summary-label { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--primary); font-weight: 750; margin-bottom: 10px; }
.summary-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-item { background: #fff; border: 1px solid #e1ebf7; border-radius: 11px; padding: 12px; }
.summary-item-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.summary-values { font-size: 17px; font-weight: 750; margin: 4px 0 1px; }
.summary-list { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.summary-line { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 6px 2px; border-bottom: 1px dashed #edf1f6; }
.summary-line:last-child { border-bottom: none; }
.summary-line > span:first-child { min-width: 72px; font-weight: 650; }

.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.filter-bar input, .filter-bar select { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; min-width: 130px; }
.search-field input { min-width: 240px; }

.table-input { border: 1px solid transparent; border-radius: 7px; padding: 6px 8px; background: transparent; width: 100%; min-width: 80px; }
.table-input:hover, .table-input:focus { border-color: var(--line); background: #fff; outline: none; }
.user-table td { padding: 8px 10px; }

.case-report { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.report-head { padding: 34px 38px 28px; background: linear-gradient(135deg, #f6f9ff, #f4fbf9); border-bottom: 1px solid var(--line); }
.report-kicker { font-size: 10px; letter-spacing: 2px; color: var(--primary); font-weight: 750; }
.report-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 8px; }
.report-title-row h1 { margin: 0; font-size: 30px; letter-spacing: -.7px; }
.report-dept { font-size: 16px; color: #46556a; margin-top: 2px; }
.report-id { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; }
.report-patient { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.report-patient div { display: flex; flex-direction: column; gap: 2px; }
.report-patient span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.report-patient strong { font-size: 13px; }
.report-section { padding: 26px 38px; border-bottom: 1px solid #eef2f7; }
.report-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.report-section-head span { font-size: 10px; font-weight: 750; color: var(--primary); letter-spacing: 1px; }
.report-section-head h2 { margin: 0; font-size: 17px; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.report-field label { display: block; font-size: 10px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 4px; }
.report-field div { font-size: 13px; }
.prewrap { white-space: pre-wrap; }
.report-foot { padding: 18px 38px; display: flex; justify-content: space-between; gap: 16px; font-size: 11px; color: var(--muted); background: #fbfcfe; }
.summary-print { background: #fbfdff; }

.modal {
  position: fixed; inset: 0; background: rgba(10, 20, 35, .78); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 30px;
}
.modal.open { display: flex; }
.modal img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.4); background: #fff; }
.modal-close { position: absolute; top: 18px; right: 22px; border: none; background: rgba(255,255,255,.16); color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 24px; }
.loading-overlay {
  position: fixed; inset: 0; background: rgba(248, 250, 253, .88); backdrop-filter: blur(5px);
  display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 120;
}
.loading-overlay.open { display: flex; }
.spinner { width: 40px; height: 40px; border: 3px solid #d9e4f5; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-title { margin-top: 14px; font-weight: 700; }
.loading-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-body { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.error-card { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 50px; box-shadow: var(--shadow); }
.error-code { font-size: 64px; font-weight: 800; color: var(--primary); line-height: 1; }
.error-card h1 { font-size: 20px; margin: 12px 0 22px; }

@media (max-width: 1100px) {
  .stat-grid, .office-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .summary-items { grid-template-columns: 1fr; }
  .report-patient { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar { position: static; width: auto; padding: 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 0 12px 0 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group, .sidebar-foot { display: none; }
  .main { margin-left: 0; padding: 20px 16px 50px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 48px 28px; }
  .hero-grid { gap: 28px; }
  .upload-grid, .form-grid, .report-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .inline-lab-form { grid-template-columns: 1fr 1fr; }
  .case-hero { flex-direction: column; align-items: flex-start; }
  .case-hero-stats { align-self: stretch; justify-content: flex-start; }
  .sticky-actions { position: static; flex-direction: column; align-items: flex-start; }
  .action-buttons { justify-content: flex-start; }
  .report-head, .report-section { padding-left: 22px; padding-right: 22px; }
  .report-title-row { flex-direction: column; }
  .report-id { align-items: flex-start; }
  .report-patient { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-foot { flex-direction: column; padding-left: 22px; padding-right: 22px; }
}

@media print {
  .sidebar, .topbar, .topbar-actions, .flash-stack, .sticky-actions, .btn, .modal {
    display: none !important;
  }
  .main { margin: 0; padding: 0; }
  .case-report { border: none; box-shadow: none; border-radius: 0; }
  .report-head, .report-section { padding-left: 18px; padding-right: 18px; }
  .report-section { break-inside: avoid; }
  .crop-thumb { width: 110px; height: 36px; }
  body { background: #fff; }
}
