:root {
  color-scheme: light;
  --bg: #f9f9ff;
  --surface: #ffffff;
  --surface-soft: #f0f3ff;
  --surface-mid: #e7eeff;
  --surface-strong: #d8e3fb;
  --ink: #111c2d;
  --muted: #42474f;
  --muted-soft: #727780;
  --line: #c2c7d1;
  --line-strong: #9aa3af;
  --accent: #00355f;
  --accent-dark: #0f4c81;
  --accent-soft: #e7eeff;
  --accent-wash: #f0f3ff;
  --ok: #10b981;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(17, 28, 45, 0.06);
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar-width: 260px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(0, 53, 95, 0.16);
  outline-offset: 1px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.app-shell {
  min-height: 100svh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background: var(--accent-wash);
  border-right: 1px solid var(--line);
}

.app-main {
  min-width: 0;
}

.sidebar-profile {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.sidebar-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--accent);
  border: 1px solid var(--line);
  font-weight: 800;
}

.sidebar-name {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  margin-top: 3px;
}

.sidebar-primary,
.sidebar-link,
.sidebar-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 760;
}

.sidebar-primary {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-link {
  justify-content: flex-start;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid transparent;
}

.sidebar-link:hover {
  background: var(--surface-mid);
}

.sidebar-link.active {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-signout {
  width: 100%;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 160px;
  height: auto;
}

.eyebrow,
.crumb {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.crumb {
  margin-bottom: 12px;
}

.topnav,
.button-row,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topnav form {
  margin: 0;
}

.topnav-link,
.topbar-signout {
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 720;
  min-height: 36px;
  padding: 7px 10px;
  text-decoration: none;
  cursor: pointer;
}

.topnav-link:hover,
.topbar-signout:hover,
.strong-link:hover {
  color: var(--accent-dark);
}

.topnav-link:hover,
.topbar-signout:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.topnav-link.active {
  color: var(--accent);
  background: var(--surface-mid);
  border-color: var(--line);
}

.topnav-link.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.topnav-link.primary:hover,
.topnav-link.primary.active {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.doctor-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: var(--surface-mid);
  color: var(--accent);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 760;
  padding: 4px 10px;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--line);
}

.button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button.compact {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 14px;
}

.button.full {
  width: 100%;
}

.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
}

.flash-wrap {
  max-width: 1180px;
  margin: 18px auto 0;
  padding: 0 24px;
}

.flash {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 680;
}

.flash.notice {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.flash.alert,
.error-box {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.page {
  width: min(1440px, calc(100% - 48px));
  margin: 32px auto 80px;
}

.narrow-page {
  width: min(760px, calc(100% - 40px));
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.page-head p {
  color: var(--muted);
  margin-top: 10px;
  max-width: 720px;
  line-height: 1.45;
}

.auth-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel,
.empty-state,
.table-shell,
.workflow-section,
.summary-panel,
.detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(400px, 100%);
  padding: 24px;
}

.auth-logo {
  display: block;
  width: min(250px, 100%);
  height: auto;
  margin-bottom: 14px;
}

.auth-panel h1 {
  font-size: 30px;
  line-height: 1.1;
}

.auth-panel p,
.empty-state p {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 12px;
}

.seed-hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.form-stack,
.case-form,
.detail-stack {
  display: grid;
  gap: 18px;
}

.form-stack {
  margin-top: 24px;
}

.form-meta {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.case-header {
  align-self: start;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.case-header-main {
  min-width: 0;
}

.case-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  flex-wrap: wrap;
}

.case-title {
  margin-top: 10px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 820;
  line-height: 1.15;
}

.case-identifiers {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.case-identifiers span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcff;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
}

.case-identifiers strong {
  color: var(--ink);
  font-weight: 780;
}

.field {
  display: grid;
  gap: 8px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field > label,
.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
}

.workflow-section {
  padding: 24px;
}

.workflow-shell {
  display: grid;
  grid-template-columns: minmax(220px, 250px) minmax(0, 1fr) minmax(300px, 380px);
  gap: 22px;
  align-items: start;
}

.workflow-nav,
.workflow-context,
.case-reference {
  position: sticky;
  top: 88px;
  max-height: calc(100svh - 112px);
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.case-reference {
  padding: 0;
}

.case-reference details {
  min-width: 0;
}

.case-reference > details > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.case-reference > details > summary::-webkit-details-marker {
  display: none;
}

.case-reference > details > summary::marker {
  content: "";
}

.case-reference > details > summary small {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 680;
}

.case-reference-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.reference-block {
  min-width: 0;
}

.reference-block p {
  color: var(--muted);
  line-height: 1.45;
}

.reference-summary {
  max-height: 280px;
}

.reference-field-list {
  display: grid;
  gap: 8px;
}

.reference-field-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcff;
  overflow: hidden;
}

.reference-field-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.reference-field-group > summary::-webkit-details-marker {
  display: none;
}

.reference-field-group > summary::marker {
  content: "";
}

.reference-field-row {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
}

.reference-field-row strong {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.reference-field-row span {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.workflow-nav-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.workflow-nav-group + .workflow-nav-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.workflow-nav-group-title {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 10px minmax(0, 1fr);
  list-style: none;
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
}

.workflow-nav-group-title:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.workflow-nav-group-title:focus-visible {
  outline: 2px solid rgba(0, 53, 95, 0.16);
  outline-offset: 1px;
}

.workflow-nav-group-title::before {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  content: "";
  height: 6px;
  justify-self: center;
  transform: rotate(-45deg);
  transition: transform 0.14s ease;
  width: 6px;
}

.workflow-nav-group-title::-webkit-details-marker {
  display: none;
}

.workflow-nav-group-title::marker {
  content: "";
}

.workflow-nav-group[open] > .workflow-nav-group-title {
  color: var(--ink);
}

.workflow-nav-group[open] > .workflow-nav-group-title::before {
  transform: rotate(45deg);
}

.workflow-nav-group-title span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.workflow-nav-items {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 3px 0 2px 18px;
}

.workflow-nav-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}

.workflow-nav-item:hover {
  background: var(--surface-soft);
}

.workflow-nav-item.active {
  background: var(--surface-mid);
  border-left-color: var(--accent);
  color: var(--accent);
}

.workflow-nav-item span {
  font-weight: 700;
  line-height: 1.22;
  min-width: 0;
  overflow-wrap: anywhere;
}

.workflow-nav-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.workflow-nav-item.complete small {
  color: #047857;
}

.workflow-editor {
  min-width: 0;
}

.workflow-context p {
  color: var(--muted);
  line-height: 1.4;
}

.guidance-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.guidance-item {
  border-left: 3px solid var(--accent-dark);
  background: var(--surface-soft);
  padding: 12px 14px;
}

.guidance-item strong,
.missing-list strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.guidance-item p {
  color: var(--muted);
  line-height: 1.4;
}

.missing-list {
  margin-top: 14px;
}

.missing-list ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.completion-note {
  margin-top: 12px;
}

.workflow-actions {
  justify-content: flex-end;
}

.section-intro {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.section-intro p {
  color: var(--muted);
  margin-top: 7px;
}

.section-signals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.signal-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  padding: 4px 9px;
  white-space: nowrap;
}

.signal-pill.complete {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.field-group {
  min-width: 0;
  margin: 0 0 18px;
  border: 0;
  padding: 0;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group legend {
  width: 100%;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  padding: 0 0 12px;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.workflow-section > .fields-grid {
  margin-bottom: 18px;
}

.workflow-section > .fields-grid:last-child {
  margin-bottom: 0;
}

.choice-field {
  gap: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
  gap: 8px;
  align-items: stretch;
}

.choice-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 96px), 1fr));
}

.choice-option {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(17, 28, 45, 0.03);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.choice-option:hover {
  border-color: var(--line-strong);
  background: #fbfcff;
  box-shadow: 0 2px 6px rgba(17, 28, 45, 0.06);
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 7px rgba(0, 53, 95, 0.18);
}

.choice-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-marker {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}

.choice-option input:checked + .choice-marker {
  border-color: #ffffff;
  background: #ffffff;
  box-shadow: inset 0 0 0 4px var(--accent);
}

.choice-option input:focus-visible + .choice-marker {
  outline: 2px solid rgba(0, 53, 95, 0.22);
  outline-offset: 3px;
}

.choice-label {
  position: relative;
  min-width: 0;
  color: inherit;
  font-size: 13px;
  font-weight: 730;
  line-height: 1.25;
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.checkbox-option {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.checkbox-option:hover {
  border-color: var(--line-strong);
  background: #fbfcff;
  box-shadow: 0 2px 6px rgba(17, 28, 45, 0.05);
}

.checkbox-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.checkbox-box {
  position: relative;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}

.checkbox-option input:checked + .checkbox-box {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox-option input:checked + .checkbox-box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-option input:focus-visible + .checkbox-box {
  outline: 2px solid rgba(0, 53, 95, 0.22);
  outline-offset: 3px;
}

.table-shell {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--surface-soft);
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  width: 1%;
  white-space: nowrap;
}

.strong-link {
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
}

.muted {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

.empty-state {
  padding: 36px;
  text-align: center;
}

.empty-state .button {
  margin-top: 20px;
}

.split-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 20px;
}

.full-span {
  grid-column: 1 / -1;
}

.detail-section {
  padding: 20px;
}

.review-stack {
  display: grid;
  gap: 18px;
  min-width: 0;
  align-content: start;
}

.summary-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.summary-block pre {
  max-height: none;
}

.reference-panel {
  align-self: start;
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1fr);
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.detail-label {
  color: var(--muted);
  font-weight: 760;
}

.detail-value {
  line-height: 1.45;
}

.detail-value p {
  margin-bottom: 8px;
}

.summary-panel {
  align-self: start;
  position: sticky;
  top: 88px;
  padding: 0;
  overflow: hidden;
}

.summary-actions,
.ai-summary,
.case-chat-panel {
  margin-top: 14px;
}

.summary-actions form {
  margin: 0;
}

.summary-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin: -4px 0 10px;
}

.panel-title {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.summary-panel > .panel-title {
  color: #ffffff;
  background: var(--accent);
  margin: 0;
  padding: 14px 16px;
}

.summary-panel > pre,
.summary-panel > .summary-actions,
.summary-panel > .ai-summary,
.summary-panel > .case-chat-panel {
  margin: 16px;
}

.case-chat-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.chat-thread {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.chat-message {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
}

.chat-message.assistant {
  background: var(--surface-soft);
}

.chat-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.chat-message-body {
  color: var(--ink);
}

.chat-message-body > * + * {
  margin-top: 8px;
}

.chat-message-body p {
  line-height: 1.45;
}

.chat-message-body h3,
.chat-message-body h4,
.chat-message-body h5 {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  margin: 0;
}

.chat-message-body ul,
.chat-message-body ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.chat-message-body li {
  line-height: 1.4;
}

.chat-message-body strong {
  font-weight: 800;
}

.case-chat-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.case-chat-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

pre {
  max-height: 620px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  line-height: 1.45;
  font-size: 13px;
}

.error-box {
  border-radius: var(--radius);
  padding: 14px;
}

.error-box ul {
  margin-bottom: 0;
}

/* Compact clinical workspace pass. Keep the form primary and the reference panel quiet. */
body {
  background: #f7f8fb;
}

.topbar {
  min-height: 56px;
  padding: 8px 18px;
}

.brand img {
  width: 132px;
}

.topnav {
  gap: 6px;
  font-size: 14px;
}

.topnav-link,
.topbar-signout {
  min-height: 32px;
  padding: 6px 9px;
  font-weight: 700;
}

.doctor-chip,
.status-pill {
  min-height: 24px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 730;
}

.page {
  width: min(1520px, calc(100% - 40px));
  margin: 22px auto 56px;
}

.workflow-page .page-head {
  margin-bottom: 12px;
}

.workflow-page h1 {
  font-size: 28px;
  line-height: 1.1;
}

.crumb {
  margin-bottom: 7px;
  font-size: 10px;
}

.workflow-shell {
  grid-template-columns: 218px minmax(620px, 1fr) 330px;
  gap: 16px;
}

.workflow-nav,
.workflow-context,
.case-reference {
  top: 72px;
  max-height: calc(100svh - 88px);
  border-color: #d2d7e1;
  box-shadow: none;
}

.workflow-nav {
  padding: 10px;
}

.workflow-nav-title {
  margin-bottom: 7px;
  font-size: 10px;
}

.workflow-nav-group + .workflow-nav-group {
  margin-top: 7px;
  padding-top: 7px;
}

.workflow-nav-group-title {
  padding: 5px 6px;
  font-size: 11px;
  gap: 6px;
}

.workflow-nav-items {
  gap: 1px;
  padding: 2px 0 1px 12px;
}

.workflow-nav-item {
  padding: 7px 8px;
  font-size: 12px;
}

.workflow-nav-item.active {
  background: #edf3ff;
}

.workflow-nav-item span {
  font-weight: 730;
}

.workflow-nav-item small {
  font-size: 10.5px;
}

.case-header,
.workflow-section,
.summary-block,
.detail-section,
.table-shell {
  border-color: #d2d7e1;
  box-shadow: none;
}

.case-header {
  padding: 11px 14px;
}

.case-status-line {
  font-size: 12px;
}

.case-title {
  margin-top: 7px;
  font-size: 18px;
}

.case-identifiers {
  margin-top: 8px;
  gap: 6px;
}

.case-identifiers span {
  min-height: 24px;
  padding: 3px 8px;
  font-size: 11px;
}

.workflow-section {
  padding: 18px 22px;
}

.section-intro {
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.section-intro h2 {
  font-size: 19px;
}

.section-intro p {
  margin-top: 4px;
  font-size: 14px;
}

.signal-pill {
  min-height: 24px;
  padding: 3px 8px;
  font-size: 11px;
}

.field-group {
  margin-bottom: 14px;
}

.field-group legend {
  font-size: 14px;
  padding-bottom: 8px;
}

.fields-grid {
  gap: 14px 16px;
}

input,
select,
textarea {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 14px;
}

select {
  height: 38px;
}

textarea {
  min-height: 88px;
}

.field {
  gap: 6px;
}

.field > label,
.field-label {
  font-size: 12px;
}

.field-hint {
  font-size: 12px;
  line-height: 1.3;
}

.choice-option,
.checkbox-option {
  min-height: 38px;
  padding: 9px 10px;
}

.choice-label {
  font-size: 12.5px;
}

.case-reference > details > summary {
  gap: 2px;
  padding: 11px 13px;
  background: #ffffff;
  color: var(--ink);
  border-bottom: 1px solid #d2d7e1;
}

.case-reference > details > summary small {
  color: var(--muted);
}

.case-reference-body {
  gap: 12px;
  padding: 13px;
}

.reference-block + .reference-block {
  border-top: 1px solid #e1e5ee;
  padding-top: 12px;
}

.panel-title {
  margin-bottom: 7px;
  font-size: 10px;
}

.reference-block p {
  font-size: 13px;
}

.reference-summary,
pre {
  background: #fbfcff;
  font-size: 11.5px;
  line-height: 1.35;
  padding: 10px;
}

.reference-summary {
  max-height: 220px;
}

.reference-field-group > summary {
  padding: 8px 10px;
  font-size: 12px;
}

.reference-field-row {
  padding: 8px 10px;
}

.workflow-actions {
  margin-top: 2px;
}

@media (max-width: 1180px) {
  .workflow-shell {
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  }

  .case-reference {
    grid-column: 2;
    position: static;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .topbar,
  .page-head,
  .impersonation-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .page,
  .narrow-page {
    width: min(100% - 28px, 1180px);
    margin-top: 24px;
  }

  .form-meta,
  .fields-grid,
  .split-page,
  .workflow-shell,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .summary-panel,
  .reference-panel,
  .workflow-nav,
  .workflow-context,
  .case-reference {
    position: static;
    max-height: none;
  }

  .section-intro,
  .case-header {
    flex-direction: column;
  }

  .section-signals {
    justify-content: flex-start;
  }
}
