:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f1f5f9;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-pale: #eff6ff;
  --green: #047857;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #c2410c;
  --amber-soft: #ffedd5;
  --tag-surgery-bg: #fff1f2;
  --tag-surgery-text: #be123c;
  --tag-surgery-border: #fecdd3;
  --tag-exam-bg: #eff6ff;
  --tag-exam-text: #2563eb;
  --tag-exam-border: #bfdbfe;
  --tag-diagnosis-bg: #f5f3ff;
  --tag-diagnosis-text: #6d28d9;
  --tag-diagnosis-border: #ddd6fe;
  --tag-milestone-bg: #fff7ed;
  --tag-milestone-text: #c2410c;
  --tag-milestone-border: #fdba74;
  --tag-finding-bg: #fef9c3;
  --tag-finding-text: #854d0e;
  --tag-finding-border: #fde047;
  --tag-biologic-bg: #ecfeff;
  --tag-biologic-text: #0e7490;
  --tag-biologic-border: #67e8f9;
  --tag-normal-bg: #ecfdf5;
  --tag-normal-text: #047857;
  --tag-normal-border: #a7f3d0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lifted: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.app-header__inner,
.app-shell {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding-inline: clamp(16px, 3vw, 32px);
}

.app-header__inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.header-meta span + span {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.app-shell {
  padding-block: 32px 44px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.history-section {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.section-heading h2,
.list-heading h2,
.viewer__header h2,
.filters h2 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ghost-button:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.ghost-button span {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.history-panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface-soft);
}

.history-grid .history-panel {
  grid-column: span 4;
  padding: 20px;
}

.history-panel--timeline {
  padding: 0;
  background: #ffffff;
  border-color: transparent;
}

.history-panel h3,
.timeline-head h3 {
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-transform: uppercase;
}

.history-panel h3 span {
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  text-transform: none;
}

.info-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 12px 16px;
  margin: 0;
  font-size: 14px;
}

.info-list dt {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.info-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.info-list dd.is-alert {
  color: var(--red);
}

.info-list dt.info-list__wide,
.info-list dd.info-list__wide {
  grid-column: 1 / -1;
}

.info-list dd.info-list__wide {
  text-align: left;
  line-height: 1.65;
}

.medicine-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.medicine-item {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  background: #ecfdf5;
  color: var(--green);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

#pastMeds .medicine-item {
  border-color: var(--line);
  background: var(--surface-muted);
  color: #475569;
}

.medicine-item span {
  color: inherit;
  opacity: 0.76;
  font-weight: 900;
  white-space: nowrap;
}

.medicine-item strong {
  min-width: 0;
  color: inherit;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.medicine-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.timeline-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.timeline-head h3 {
  margin: 0;
  font-size: 18px;
  text-transform: none;
}

.sort-actions {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.sort-toggle {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.sort-toggle.is-active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.clinical-timeline {
  position: relative;
  display: grid;
  gap: 24px;
  margin-left: 12px;
  padding-left: 24px;
  border-left: 2px solid var(--line);
}

.history-event {
  position: relative;
  min-width: 0;
}

.history-event::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.history-event time {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.history-event__place {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.history-event__body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.history-event__body h4 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}

.history-event__body p {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.text-tag,
.chip {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.text-tag--surgery,
.chip--red {
  background: var(--tag-surgery-bg);
  color: var(--tag-surgery-text);
  box-shadow: inset 0 0 0 1px var(--tag-surgery-border);
}

.text-tag--exam {
  background: var(--tag-exam-bg);
  color: var(--tag-exam-text);
  box-shadow: inset 0 0 0 1px var(--tag-exam-border);
}

.text-tag--diagnosis {
  background: var(--tag-diagnosis-bg);
  color: var(--tag-diagnosis-text);
  box-shadow: inset 0 0 0 1px var(--tag-diagnosis-border);
}

.text-tag--milestone {
  background: var(--tag-milestone-bg);
  color: var(--tag-milestone-text);
  box-shadow: inset 0 0 0 1px var(--tag-milestone-border);
}

.text-tag--finding {
  background: var(--tag-finding-bg);
  color: var(--tag-finding-text);
  box-shadow: inset 0 0 0 1px var(--tag-finding-border);
}

.text-tag--normal {
  background: var(--tag-normal-bg);
  color: var(--tag-normal-text);
  box-shadow: inset 0 0 0 1px var(--tag-normal-border);
}

.text-tag--biologic {
  background: var(--tag-biologic-bg);
  color: var(--tag-biologic-text);
  box-shadow: inset 0 0 0 1px var(--tag-biologic-border);
}

.text-tag--treatment,
.chip--green {
  background: #ecfdf5;
  color: var(--green);
}

.chip--amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.event-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.event-link {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.event-link:hover {
  background: var(--primary-pale);
  border-color: var(--primary-soft);
}

.event-link--missing {
  color: var(--muted);
  background: var(--surface-muted);
  cursor: default;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 3fr) minmax(320px, 4fr) minmax(360px, 5fr);
  gap: 24px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  min-width: 0;
}

.side-card,
.report-list__inner,
.viewer-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.side-card {
  padding: 20px;
}

.side-card h2 {
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

label {
  color: #475569;
  font-size: 14px;
  font-weight: 700;
}

.search-box {
  position: relative;
}

.search-box span {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--faint);
  border-radius: 50%;
  transform: translateY(-55%);
  pointer-events: none;
}

.search-box span::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 2px;
  border-radius: 999px;
  background: var(--faint);
  transform: rotate(45deg);
}

input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 12px 0 38px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="search"]::placeholder {
  color: #94a3b8;
}

input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

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

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  font-size: 14px;
  font-weight: 800;
  transition: background 0.18s ease, color 0.18s ease;
}

.tab:hover {
  background: var(--surface-muted);
}

.tab.is-active {
  background: var(--primary-pale);
  color: #1d4ed8;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 0 0 0 8px;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--line);
  list-style: none;
}

.timeline li {
  position: relative;
  min-width: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 1px solid #ffffff;
}

.timeline time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline strong {
  display: block;
  overflow: hidden;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline span {
  display: block;
  color: var(--faint);
  font-size: 12px;
}

.report-list,
.viewer {
  min-width: 0;
}

.report-list__inner,
.viewer-card {
  height: 800px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

.list-heading,
.viewer__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.list-heading p,
.viewer__header p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.list-heading h2 {
  font-size: 20px;
  font-weight: 900;
}

.viewer__header h2 {
  font-size: 18px;
  font-weight: 900;
}

#resultCount {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.cards {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding-right: 8px;
}

.card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-lifted);
  transform: translateY(-1px);
}

.card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow);
}

.card__kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card__meta {
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
}

.card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
  transition: color 0.18s ease;
}

.card:hover h3 {
  color: var(--primary);
}

.card p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.highlights,
.card__footer,
.card__image {
  display: none;
}

.viewer__header .ghost-button {
  min-height: 32px;
  padding-inline: 11px;
  border-color: transparent;
  background: var(--surface-muted);
  font-size: 13px;
}

.viewer__body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

#previewImage {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.empty {
  padding: 40px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

@media (max-width: 1180px) {
  .history-grid .history-panel {
    grid-column: span 6;
  }

  .workspace {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }

  .viewer {
    grid-column: 1 / -1;
  }

  .viewer-card {
    height: 760px;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
  }

  .app-header__inner {
    min-height: auto;
    align-items: start;
    flex-direction: column;
    padding-block: 16px;
  }

  .header-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .app-shell {
    padding-block: 20px 32px;
    gap: 24px;
  }

  .history-section {
    padding: 16px;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .print-button {
    width: 100%;
  }

  .history-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .history-grid .history-panel {
    grid-column: 1 / -1;
  }

  .timeline-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sort-actions {
    width: 100%;
  }

  .sort-toggle {
    flex: 1;
  }

  .filters {
    position: static;
  }

  .side-card--timeline {
    display: none;
  }

  .report-list__inner,
  .viewer-card {
    height: auto;
    min-height: 520px;
  }

  .viewer-card {
    min-height: 620px;
  }

  .viewer__body {
    min-height: 520px;
  }
}

@media (max-width: 470px) {
  .app-header__inner,
  .app-shell {
    padding-inline: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .history-section,
  .side-card,
  .report-list__inner,
  .viewer-card {
    border-radius: 14px;
  }

  .info-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .info-list dd {
    text-align: left;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-header,
  .filters,
  .viewer,
  .report-list,
  .ghost-button,
  .sort-actions {
    display: none !important;
  }

  .app-shell {
    width: auto;
    padding: 0;
  }

  .history-section,
  .history-panel {
    box-shadow: none;
  }

  .history-section {
    border: 0;
    padding: 0;
  }

  .workspace {
    display: none;
  }
}

/* Three-column clinical workstation refactor */
html.h-full,
html.h-full .workbench-body {
  height: 100%;
}

.workbench-body {
  overflow: hidden;
  background: #f1f5f9;
  color: #1e293b;
}

.workstation-header {
  height: 64px;
  display: flex;
  flex: 0 0 64px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(16px, 2.5vw, 28px);
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.workstation-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.workstation-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.workstation-title h1 {
  margin: 0;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.workstation-title p {
  margin: 2px 0 0;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.workstation-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workstation-meta span + span {
  padding-left: 12px;
  border-left: 1px solid rgba(203, 213, 225, 0.22);
}

.workstation-layout {
  height: 100vh;
  display: flex;
  min-height: 0;
  overflow: hidden;
  background: #f1f5f9;
}

.col-scroll {
  min-height: 0;
  overflow-y: auto;
}

.patient-sidebar {
  width: 22%;
  min-width: 300px;
  display: flex;
  flex: 0 0 22%;
  align-self: flex-start;
  flex-direction: column;
  gap: 14px;
  position: relative;
  max-height: 100vh;
  padding: 16px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  border-bottom-right-radius: 18px;
  background: #ffffff;
  box-shadow: 5px 0 18px rgba(15, 23, 42, 0.05);
  z-index: 10;
}

.sidebar-rail:hover {
  border-color: #93c5fd;
  color: #2563eb;
}

.sidebar-rail:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: -3px;
}

.sidebar-rail {
  width: 30px;
  min-width: 30px;
  display: flex;
  flex: 0 0 30px;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  border: 0;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  box-shadow: 5px 0 18px rgba(15, 23, 42, 0.05);
  cursor: pointer;
}

.sidebar-rail__collapse,
.sidebar-rail__expand {
  width: 24px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  font-size: 0;
  font-weight: 900;
  line-height: 1;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.sidebar-rail:hover .sidebar-rail__collapse,
.sidebar-rail:hover .sidebar-rail__expand,
.sidebar-rail:focus-visible .sidebar-rail__collapse,
.sidebar-rail:focus-visible .sidebar-rail__expand {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #2563eb;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.13);
}

.sidebar-rail__collapse::before,
.sidebar-rail__expand::before {
  content: "";
  width: 7px;
  height: 7px;
  display: block;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
}

.sidebar-rail__collapse::before {
  transform: rotate(135deg) translate(-1px, -1px);
}

.sidebar-rail__expand::before {
  transform: rotate(-45deg) translate(-1px, -1px);
}

.sidebar-rail__expand {
  display: none;
}

.is-sidebar-collapsed .patient-sidebar {
  display: none;
}

.is-sidebar-collapsed .sidebar-rail {
  width: 44px;
  min-width: 44px;
  display: flex;
  flex: 0 0 44px;
  justify-content: center;
  padding: 0;
}

.is-sidebar-collapsed .sidebar-rail__collapse {
  display: none;
}

.is-sidebar-collapsed .sidebar-rail__expand {
  display: inline-flex;
}

.patient-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.patient-avatar {
  width: 56px;
  height: 56px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #f8fafc;
  color: #475569;
  font-size: 22px;
  font-weight: 900;
}

.patient-profile h2 {
  margin: 0;
  color: #0f172a;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.patient-profile p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.risk-alert {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
}

.risk-alert__icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #dc2626;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.risk-alert strong,
.patient-section h3 {
  margin: 0;
}

.risk-alert strong {
  color: #991b1b;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.patient-section h3 {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.risk-alert span:last-child {
  min-width: 0;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.patient-section {
  min-width: 0;
}

.patient-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

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

.metric-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.metric-card--wide {
  grid-column: 1 / -1;
  padding-block: 11px;
}

.metric-card span,
.chief-complaint span,
.medicine-card span {
  display: block;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
}

.metric-card strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chief-complaint {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.chief-complaint p {
  margin: 6px 0 0;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.medicine-stack {
  display: grid;
  gap: 9px;
  margin-top: 8px;
}

.medication-section .patient-section__head {
  align-items: center;
}

.medication-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: #e2e8f0;
}

.medication-tab {
  min-height: 26px;
  min-width: 68px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.medication-tab.is-active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.medication-panel {
  min-width: 0;
}

.medicine-card {
  padding: 8px 9px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
}

.medicine-card strong {
  display: block;
  margin-top: 0;
  color: #047857;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.medicine-card span {
  margin-top: 4px;
  color: #059669;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  opacity: 0.82;
  overflow-wrap: anywhere;
}

.anemia-trend {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff7ed;
}

.anemia-trend__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.anemia-trend__head span {
  color: #9f1239;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.anemia-trend__head strong {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #ffffff;
  color: #be123c;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.anemia-trend__tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.anemia-trend__zoom {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(190, 18, 60, 0.2);
  border-radius: 7px;
  background:
    linear-gradient(#9f1239, #9f1239) left 7px top 7px / 7px 2px no-repeat,
    linear-gradient(#9f1239, #9f1239) left 7px top 7px / 2px 7px no-repeat,
    linear-gradient(#9f1239, #9f1239) right 7px top 7px / 7px 2px no-repeat,
    linear-gradient(#9f1239, #9f1239) right 7px top 7px / 2px 7px no-repeat,
    linear-gradient(#9f1239, #9f1239) left 7px bottom 7px / 7px 2px no-repeat,
    linear-gradient(#9f1239, #9f1239) left 7px bottom 7px / 2px 7px no-repeat,
    linear-gradient(#9f1239, #9f1239) right 7px bottom 7px / 7px 2px no-repeat,
    linear-gradient(#9f1239, #9f1239) right 7px bottom 7px / 2px 7px no-repeat,
    #ffffff;
  box-shadow: 0 1px 2px rgba(190, 18, 60, 0.08);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.anemia-trend__zoom:hover,
.anemia-trend__zoom:focus-visible {
  border-color: rgba(190, 18, 60, 0.5);
  box-shadow: 0 8px 18px rgba(190, 18, 60, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.anemia-trend__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.anemia-trend__stats div {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
}

.anemia-trend__stats span,
.anemia-trend__stats small {
  display: block;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.anemia-trend__stats strong {
  display: block;
  margin-top: 3px;
  color: #111827;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.anemia-trend__stats small {
  margin-top: 3px;
  color: #64748b;
}

.anemia-chart {
  margin-top: 8px;
  padding: 8px 8px 6px;
  border: 1px solid rgba(251, 113, 133, 0.22);
  border-radius: 8px;
  background: #ffffff;
}

.anemia-chart svg {
  width: 100%;
  height: 112px;
  display: block;
  overflow: visible;
}

.anemia-chart__reference {
  stroke: #cbd5e1;
  stroke-dasharray: 4 5;
  stroke-width: 1.5;
}

.anemia-chart__reference-label {
  fill: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  text-anchor: end;
}

.anemia-chart__line {
  fill: none;
  stroke: #e11d48;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.anemia-chart__dot {
  stroke: #ffffff;
  stroke-width: 1.8;
}

.anemia-chart__dot.is-severe {
  fill: #dc2626;
}

.anemia-chart__dot.is-low {
  fill: #f59e0b;
}

.anemia-chart__dot.is-recovered {
  fill: #059669;
}

.anemia-chart__axis {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.anemia-trend__markers {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.anemia-trend__markers span {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(251, 113, 133, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
  color: #9f1239;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

body.has-anemia-modal {
  overflow: hidden;
}

.anemia-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.anemia-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.anemia-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
}

.anemia-modal__panel {
  position: relative;
  width: min(980px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 12px;
  background: #fff7ed;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
  outline: none;
}

.anemia-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.anemia-modal__head p {
  margin: 0 0 4px;
  color: #be123c;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.anemia-modal__close {
  width: 34px;
  height: 34px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #ffffff;
  color: #9f1239;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.anemia-modal__close:hover,
.anemia-modal__close:focus-visible {
  border-color: #fb7185;
  outline: none;
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.18);
}

.anemia-large {
  display: grid;
  gap: 12px;
}

.anemia-large__chart {
  overflow-x: auto;
  padding: 12px 12px 8px;
  border: 1px solid rgba(251, 113, 133, 0.24);
  border-radius: 8px;
  background: #ffffff;
}

.anemia-large__chart svg {
  width: 100%;
  min-width: 820px;
  height: auto;
  display: block;
  overflow: visible;
}

.anemia-large-chart__band {
  fill: rgba(16, 185, 129, 0.1);
}

.anemia-large-chart__grid {
  stroke: #e2e8f0;
  stroke-width: 1;
}

.anemia-large-chart__grid.is-reference {
  stroke: #10b981;
  stroke-dasharray: 6 5;
  stroke-width: 1.4;
}

.anemia-large-chart__y-label,
.anemia-large-chart__range-label {
  fill: #64748b;
  font-size: 12px;
  font-weight: 900;
  text-anchor: end;
}

.anemia-large-chart__range-label {
  fill: #047857;
}

.anemia-large-chart__line {
  fill: none;
  stroke: #e11d48;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.anemia-large-chart__point circle {
  stroke: #ffffff;
  stroke-width: 2.2;
}

.anemia-large-chart__point.is-below circle {
  fill: #dc2626;
}

.anemia-large-chart__point.is-normal circle {
  fill: #059669;
}

.anemia-large-chart__point.is-above circle {
  fill: #2563eb;
}

.anemia-large-chart__value {
  fill: #111827;
  font-size: 12px;
  font-weight: 900;
  text-anchor: middle;
}

.anemia-large-chart__x-label {
  fill: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-anchor: end;
}

.anemia-large__table {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.anemia-large__table div {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(251, 113, 133, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.anemia-large__table time,
.anemia-large__table strong,
.anemia-large__table span {
  display: block;
  overflow-wrap: anywhere;
}

.anemia-large__table time {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.anemia-large__table strong {
  margin-top: 5px;
  color: #111827;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
}

.anemia-large__table span {
  margin-top: 5px;
  color: #9f1239;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.past-medicine-timeline {
  position: relative;
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding-left: 14px;
}

.past-medicine-timeline::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: #e2e8f0;
}

.past-med-card {
  position: relative;
  max-width: 100%;
  padding: 8px 9px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
}

.past-med-card::before {
  content: "";
  position: absolute;
  top: 12px;
  left: -15px;
  width: 10px;
  height: 10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 1px #cbd5e1;
}

.past-med-card time {
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 6px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.past-med-card strong {
  display: block;
  color: #0f172a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.past-med-card p {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.journey-column {
  width: 35%;
  min-width: 400px;
  display: flex;
  flex: 0 0 35%;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
}

.journey-controls {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(12px);
}

.search-box--workbench {
  margin-bottom: 0;
}

.timeline-filters {
  grid-column: 1 / -1;
  display: flex;
  min-width: 0;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.timeline-filters::-webkit-scrollbar {
  display: none;
}

.timeline-filter {
  min-height: 28px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.timeline-filter:hover {
  border-color: #94a3b8;
  color: #334155;
}

.timeline-filter.is-active {
  border-color: #0f172a;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.search-box--workbench span {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  transform: translateY(-55%);
  pointer-events: none;
}

.search-box--workbench span::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: #94a3b8;
  transform: rotate(45deg);
}

.search-box--workbench input {
  width: 100%;
  min-height: 42px;
  padding: 0 14px 0 40px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.search-box--workbench input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.journey-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.journey-toolbar .sort-actions {
  margin: 0;
  background: #e2e8f0;
}

.journey-toolbar .sort-toggle {
  min-height: 32px;
  padding: 0 10px;
}

.mobile-output-actions {
  display: none;
}

.journey-scroll {
  position: relative;
  flex: 1;
  padding: 10px 16px 22px;
}

.feed-group {
  position: relative;
  z-index: 1;
  padding: 14px 0 14px 42px;
}

.feed-group::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 15px;
  width: 2px;
  background: #e2e8f0;
  transform: translateX(-50%);
}

.feed-group:first-child::before {
  top: 28px;
}

.feed-group:last-child::before {
  bottom: calc(100% - 28px);
}

.feed-group:first-child:last-child::before {
  display: none;
}

.feed-node {
  position: absolute;
  left: 6px;
  top: 19px;
  width: 18px;
  height: 18px;
  border: 4px solid #cbd5e1;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  z-index: 1;
}

.feed-group:has(.feed-card.is-selected) .feed-node {
  border-color: #2563eb;
}

.feed-date {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 10px;
  padding: 0 10px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.feed-cards {
  display: grid;
  gap: 10px;
}

.feed-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.feed-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.feed-card--history {
  padding-top: 10px;
}

.feed-card--compact {
  padding-block: 9px 10px;
}

.feed-card--compact .feed-card__top {
  margin-bottom: 4px;
}

.feed-card--compact h3 {
  line-height: 1.25;
}

.feed-card.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb, 0 12px 26px rgba(37, 99, 235, 0.12);
}

.feed-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 22px;
  margin-bottom: 7px;
}

.feed-card__top--plain {
  justify-content: flex-end;
  margin-bottom: 5px;
}

.feed-card__top--title {
  align-items: flex-start;
  margin-bottom: 6px;
}

.feed-card__top--title h3 {
  min-width: 0;
  margin: 0;
  flex: 1;
}

.feed-card__top .tag-row {
  flex: 1;
  align-items: center;
  margin: 0;
}

.feed-card__top .chip,
.feed-card__top .text-tag {
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
}

.feed-card__meta {
  min-height: 22px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.feed-card h3 {
  margin: 0;
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.feed-card p {
  margin: 6px 0 0;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.feed-card__cue {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px -14px -14px;
  padding: 0 14px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.feed-card__cue strong {
  color: #2563eb;
  font-weight: 900;
}

.mobile-card-detail {
  display: none;
}

.chip--blue {
  background: #eff6ff;
  color: #2563eb;
}

.feed-card > .tag-row {
  margin-top: 10px;
}

.empty-state {
  margin: 36px 0 0 42px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 700;
}

.viewer-column {
  min-width: 420px;
  flex: 1 1 43%;
  background: var(--surface-muted);
}

.viewer-frame {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--surface-muted);
}

.viewer-topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  color: var(--ink);
}

.viewer-topbar p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.viewer-topbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.viewer-topbar span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.viewer-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.print-mode {
  min-height: 36px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #e2e8f0;
}

.print-mode__button {
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.print-mode__button.is-active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.viewer-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.viewer-button:hover {
  border-color: #bfdbfe;
  background: var(--primary-pale);
  color: var(--primary);
}

.viewer-button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.viewer-stage {
  min-height: 0;
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.viewer-empty {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  color: #94a3b8;
  text-align: center;
}

.viewer-empty strong {
  color: #64748b;
  font-size: 18px;
  font-weight: 900;
}

.viewer-empty span {
  max-width: 320px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.6;
}

.viewer-content {
  min-height: 100%;
  background: #ffffff;
}

#previewImage {
  display: block;
  width: 100%;
  height: auto;
  background: #f8fafc;
}

.viewer-text {
  display: block;
  padding: 26px;
  color: #1e293b;
}

.report-brief {
  display: grid;
  gap: 14px;
  padding-bottom: 4px;
}

.report-brief p,
.history-detail p {
  margin: 0;
  color: #334155;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.report-brief ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 19px;
  color: #475569;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
}

.history-detail {
  display: grid;
  gap: 13px;
}

.history-detail__item {
  display: grid;
  gap: 8px;
}

.history-detail__item--linked {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.history-detail__item--linked:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.therapy-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: #ffffff;
}

.therapy-table table {
  width: 100%;
  min-width: 520px;
  border-collapse: separate;
  border-spacing: 0;
  color: #334155;
  font-size: 14px;
}

.therapy-table th,
.therapy-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  text-align: left;
  vertical-align: top;
}

.therapy-table th {
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.therapy-table td {
  font-weight: 650;
  line-height: 1.6;
}

.therapy-table td:first-child {
  width: 88px;
  color: #0f172a;
  font-weight: 900;
  white-space: nowrap;
}

.therapy-table td:nth-child(2) {
  width: 128px;
  color: #334155;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.therapy-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-detail .tag-row {
  margin-bottom: 2px;
}

.history-detail .muted-note {
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.is-hidden {
  display: none !important;
}

.print-document {
  display: none;
}

.clinical-viewer:fullscreen {
  width: 100vw;
  min-width: 0;
  background: var(--surface-muted);
}

.clinical-viewer:fullscreen .viewer-frame {
  height: 100vh;
}

@media (max-width: 1180px) {
  .workbench-body {
    overflow: auto;
  }

  .workstation-layout {
    height: auto;
    min-height: 100vh;
    display: block;
    overflow: visible;
  }

  .patient-sidebar,
  .journey-column,
  .viewer-column {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }

  .patient-sidebar,
  .journey-column {
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
  }

  .patient-sidebar {
    border-bottom-right-radius: 0;
  }

  .sidebar-rail,
  .is-sidebar-collapsed .sidebar-rail {
    width: 100%;
    min-width: 0;
    height: 40px;
    display: flex;
    flex: 0 0 40px;
    align-self: auto;
    flex-direction: row;
    gap: 8px;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 5px 18px rgba(15, 23, 42, 0.04);
  }

  .sidebar-rail__collapse,
  .sidebar-rail__expand {
    width: 32px;
    height: 24px;
  }

  .sidebar-rail__collapse::before {
    transform: rotate(-135deg) translate(-1px, -1px);
  }

  .sidebar-rail__expand::before {
    transform: rotate(45deg) translate(-1px, -1px);
  }

  .col-scroll,
  .journey-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .viewer-column {
    display: none;
    min-height: 0;
  }

  .viewer-frame {
    height: auto;
  }

  .mobile-output-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 1px;
  }

  .mobile-output-actions__button {
    min-width: 88px;
  }

  .mobile-card-detail {
    display: block;
    margin: 13px -14px -14px;
    padding: 13px 14px 14px;
    border-top: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 0 0 11px 11px;
    background: rgba(255, 255, 255, 0.72);
    cursor: default;
  }

  .feed-card.is-selected .feed-card__cue {
    margin-bottom: 0;
  }

  .mobile-card-detail .history-detail {
    gap: 11px;
  }

  .mobile-card-detail .history-detail p,
  .mobile-card-detail .report-brief p {
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.7;
  }

  .mobile-card-detail .report-brief ul {
    gap: 7px;
    font-size: 13px;
    line-height: 1.65;
  }

  .mobile-card-detail .history-detail__item--linked {
    padding-bottom: 11px;
    border-bottom-color: rgba(148, 163, 184, 0.32);
  }

  .mobile-card-detail .event-links {
    gap: 7px;
    margin-top: 2px;
  }

  .mobile-card-detail .event-link {
    min-height: 32px;
    border-radius: 8px;
    background: #ffffff;
    font-size: 12px;
  }

  .mobile-card-detail .therapy-table table {
    min-width: 480px;
    font-size: 13px;
  }
}

@media (max-width: 760px) {
  .workstation-layout {
    min-height: 100vh;
  }

  .workstation-title h1 {
    font-size: 16px;
  }

  .workstation-meta {
    align-self: stretch;
    justify-content: space-between;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journey-controls {
    grid-template-columns: 1fr;
  }

  .journey-toolbar {
    justify-content: stretch;
  }

  .journey-toolbar .sort-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-output-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mobile-output-actions .print-mode {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-output-actions .print-mode__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .viewer-frame {
    height: 660px;
    padding: 16px;
  }

  .viewer-topbar {
    flex-direction: column;
  }

  .viewer-actions {
    width: 100%;
  }

  .viewer-button {
    flex: 1;
  }

  .anemia-modal {
    align-items: stretch;
    padding: 10px;
  }

  .anemia-modal__panel {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: 10px;
  }

  .anemia-large__table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .patient-sidebar,
  .journey-controls,
  .journey-scroll {
    padding-inline: 12px;
  }

  .feed-group {
    padding-left: 34px;
  }

  .feed-node {
    left: 4px;
  }

  .feed-group::before {
    left: 13px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .mobile-output-actions {
    grid-template-columns: 1fr;
  }

  .mobile-output-actions__button {
    width: 100%;
  }

  .mobile-card-detail .event-link {
    flex: 1 1 calc(50% - 7px);
    justify-content: center;
    text-align: center;
  }

  .anemia-large__table {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  .workbench-body {
    height: auto;
    overflow: visible;
    background: #ffffff;
  }

  body.is-printing .workstation-layout,
  body.is-printing .anemia-modal {
    display: none !important;
  }

  body.is-printing .print-document {
    display: block !important;
  }

  .print-document {
    color: #111827;
    font-size: 10.5pt;
    line-height: 1.58;
  }

  .print-document * {
    box-shadow: none !important;
  }

  .print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14mm;
    padding-bottom: 5mm;
    border-bottom: 1.5pt solid #0f172a;
    break-after: avoid;
  }

  .print-header h1 {
    margin: 0;
    color: #0f172a;
    font-size: 20pt;
    font-weight: 900;
    line-height: 1.15;
  }

  .print-header span {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 9pt;
    font-weight: 800;
  }

  .print-section {
    margin-top: 6mm;
  }

  .print-section h2 {
    margin: 0 0 3mm;
    color: #0f172a;
    font-size: 14pt;
    font-weight: 900;
    line-height: 1.2;
    break-after: avoid-page;
  }

  .print-summary {
    padding-bottom: 4mm;
    border-bottom: 1pt solid #e2e8f0;
    break-inside: avoid-page;
  }

  .print-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2mm;
    margin: 0 0 4mm;
  }

  .print-metrics div {
    padding: 2.2mm 2.6mm;
    border: 1pt solid #e2e8f0;
    border-radius: 2mm;
    background: #f8fafc;
  }

  .print-metrics dt,
  .print-metrics dd {
    margin: 0;
  }

  .print-metrics dt {
    color: #64748b;
    font-size: 8.5pt;
    font-weight: 900;
  }

  .print-metrics dd {
    margin-top: 1mm;
    color: #0f172a;
    font-size: 10.5pt;
    font-weight: 900;
  }

  .print-medicine-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4mm;
  }

  .print-medicine-grid h3 {
    margin: 0 0 1.5mm;
    color: #334155;
    font-size: 10.5pt;
    font-weight: 900;
  }

  .print-medicine-grid ul {
    margin: 0;
    padding-left: 4.5mm;
  }

  .print-medicine-grid li {
    margin: 0 0 1mm;
  }

  .print-anemia-summary {
    margin-top: 4mm;
    padding: 2.5mm 3mm;
    border: 1pt solid #fecdd3;
    border-radius: 2mm;
    background: #fff7ed;
    break-inside: avoid-page;
  }

  .print-anemia-summary__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4mm;
    margin-bottom: 2mm;
  }

  .print-anemia-summary__head h3 {
    margin: 0;
    color: #334155;
    font-size: 10.5pt;
    font-weight: 900;
  }

  .print-anemia-summary__head span {
    flex: 0 0 auto;
    color: #047857;
    font-size: 8.5pt;
    font-weight: 900;
  }

  .print-anemia-chart {
    margin-bottom: 2mm;
    padding: 1.5mm 2mm 0;
    border: 0.75pt solid #fecdd3;
    border-radius: 1.8mm;
    background: #ffffff;
  }

  .print-anemia-chart svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
  }

  .print-anemia-chart__band {
    fill: rgba(16, 185, 129, 0.1);
  }

  .print-anemia-chart__grid {
    stroke: #e2e8f0;
    stroke-width: 1;
  }

  .print-anemia-chart__grid.is-reference {
    stroke: #10b981;
    stroke-dasharray: 6 5;
    stroke-width: 1.4;
  }

  .print-anemia-chart__y-label {
    fill: #64748b;
    font-size: 12px;
    font-weight: 900;
    text-anchor: end;
  }

  .print-anemia-chart__line {
    fill: none;
    stroke: #e11d48;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
  }

  .print-anemia-chart__point circle {
    stroke: #ffffff;
    stroke-width: 2;
  }

  .print-anemia-chart__point.is-below circle {
    fill: #dc2626;
  }

  .print-anemia-chart__point.is-normal circle {
    fill: #059669;
  }

  .print-anemia-chart__point.is-above circle {
    fill: #2563eb;
  }

  .print-anemia-chart__value {
    fill: #111827;
    font-size: 11px;
    font-weight: 900;
    text-anchor: middle;
  }

  .print-anemia-chart__x-label {
    fill: #64748b;
    font-size: 10px;
    font-weight: 800;
    text-anchor: end;
  }

  .print-anemia-summary p {
    margin: 0 0 1mm;
  }

  .print-timeline {
    display: grid;
    gap: 4mm;
  }

  .print-event {
    padding: 4mm 0 0 5mm;
    border-top: 1pt solid #e2e8f0;
    break-inside: auto;
  }

  .print-event:first-child {
    border-top: 0;
  }

  .print-event__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 5mm;
    margin-bottom: 2.5mm;
    break-after: avoid;
  }

  .print-event__head time {
    display: block;
    margin-bottom: 1mm;
    color: #be123c;
    font-size: 9.5pt;
    font-weight: 900;
  }

  .print-event__head h3 {
    margin: 0;
    color: #0f172a;
    font-size: 12pt;
    font-weight: 900;
    line-height: 1.25;
  }

  .print-event__head p {
    margin: 1mm 0 0;
    color: #64748b;
    font-size: 9pt;
    font-weight: 800;
  }

  .print-tags {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 1.3mm;
    max-width: 55mm;
  }

  .print-tags span {
    min-height: 5mm;
    display: inline-flex;
    align-items: center;
    padding: 0 2mm;
    border: 0.75pt solid #cbd5e1;
    border-radius: 1.5mm;
    color: #475569;
    font-size: 8pt;
    font-weight: 900;
    line-height: 1;
  }

  .print-detail {
    margin-top: 2mm;
  }

  .print-detail p {
    margin: 0 0 1.8mm;
  }

  .print-table {
    width: 100%;
    margin: 2mm 0;
    border-collapse: collapse;
    break-inside: avoid;
  }

  .print-table th,
  .print-table td {
    padding: 1.5mm 2mm;
    border: 0.75pt solid #cbd5e1;
    text-align: left;
    vertical-align: top;
  }

  .print-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 8.5pt;
    font-weight: 900;
  }

  .print-links {
    margin: 2mm 0 1mm;
  }

  .print-links--pdf {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5mm;
  }

  .print-links--pdf a {
    display: inline-flex;
    align-items: center;
    min-height: 6mm;
    padding: 0 2.2mm;
    border: 0.75pt solid #bfdbfe;
    border-radius: 1.5mm;
    color: #1d4ed8;
    font-size: 8.5pt;
    font-weight: 900;
    text-decoration: none;
  }

  .print-qr-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3mm;
  }

  .print-qr-card {
    width: 30mm;
    margin: 0;
    padding: 2mm;
    border: 0.75pt solid #cbd5e1;
    border-radius: 2mm;
    background: #ffffff;
    text-align: center;
    break-inside: avoid;
  }

  .print-qr-card svg {
    width: 23mm;
    height: 23mm;
    display: block;
    margin: 0 auto 1mm;
  }

  .print-qr-card figcaption strong,
  .print-qr-card figcaption span {
    display: block;
  }

  .print-qr-card figcaption strong {
    color: #0f172a;
    font-size: 8pt;
    font-weight: 900;
    line-height: 1.2;
  }

  .print-qr-card figcaption span {
    margin-top: 0.6mm;
    color: #64748b;
    font-size: 7.2pt;
    font-weight: 800;
    line-height: 1.15;
  }

  .print-qr__fallback {
    width: 23mm;
    height: 23mm;
    display: grid;
    place-items: center;
    margin: 0 auto 1mm;
    border: 0;
    background: #f1f5f9;
    color: #64748b;
    font-size: 7pt;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
  }
}
