:root {
  --bg: #f2efe7;
  --ink: #132026;
  --muted: #5c6662;
  --panel: #fffaf1;
  --panel-2: #f7f1e6;
  --accent: #1c6f63;
  --accent-2: #d07a4a;
  --danger: #b44737;
  --warning: #c48a2a;
  --ok: #3f7b4a;
  --shadow: 0 12px 30px rgba(19, 32, 38, 0.12);
  --radius: 9px;
  --space: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #f7e4d6 0%, transparent 35%),
    radial-gradient(circle at 80% 0%, #e2efe9 0%, transparent 40%),
    linear-gradient(180deg, #f2eee6 0%, #f0e9df 100%);
  min-height: 100vh;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
      120deg,
      rgba(19, 32, 38, 0.04) 0%,
      transparent 30%,
      rgba(19, 32, 38, 0.03) 60%,
      transparent 100%
    ),
    repeating-linear-gradient(
      90deg,
      rgba(19, 32, 38, 0.02),
      rgba(19, 32, 38, 0.02) 1px,
      transparent 1px,
      transparent 12px
    );
  pointer-events: none;
  z-index: -1;
}

h1,
h2,
h3 {
  font-family: "Spectral", serif;
  margin: 0 0 0.2rem 0;
}

p {
  margin: 0.15rem 0;
}

.app {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: var(--space);
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space);
  margin-bottom: 0;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: var(--space);
  flex-wrap: wrap;
}

.tab {
  border: 1px solid rgba(19, 32, 38, 0.12);
  background: #fffdf7;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.tab-primary {
  font-size: 1rem;
  font-weight: 700;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 16px rgba(28, 111, 99, 0.2);
}

.tab-secondary {
  font-size: 0.85rem;
  font-weight: 500;
}

.tab-secondary:not(.active) {
  color: var(--ink);
  background: rgba(28, 111, 99, 0.08);
  border-color: rgba(28, 111, 99, 0.2);
  opacity: 1;
}

@media (hover: hover) {
  .tab:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(28, 111, 99, 0.25);
  }

  .tab:not(.active):hover {
    color: var(--accent);
  }
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tab-panel > main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.assess-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space);
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.assess-input {
  display: grid;
  gap: var(--space);
  min-height: 0;
}

.assess-report {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.assess-report-header {
  align-items: flex-start;
}

.assess-report-meta {
  display: grid;
  gap: 2px;
}

.report-line {
  margin: 0;
  font-size: 0.85rem;
}

.assess-report-meta .report-line:first-child {
  font-size: 1rem;
  font-weight: 600;
}

.assess-textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(19, 32, 38, 0.12);
  background: var(--panel-2);
  padding: var(--space);
  resize: vertical;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
}

.verbosity {
  display: flex;
  align-items: center;
  gap: var(--space);
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.assess-controls select {
  border-radius: 6px;
  border: 1px solid rgba(19, 32, 38, 0.12);
  padding: 6px 8px;
  font-size: 0.8rem;
  background: #fffdf7;
  color: var(--ink);
}

.assess-actions {
  display: flex;
  gap: var(--space);
  justify-content: flex-end;
}

#assessGenerate {
  font-size: 1.2rem;
  padding: 18px 36px;
}

.assess-output {
  background: var(--panel-2);
  border-radius: 8px;
  padding: var(--space);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.assess-chart-block {
  margin: 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: #fffdf7;
  border: 1px solid rgba(19, 32, 38, 0.1);
}

.assess-chart-block figcaption {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.assess-chart-frame {
  position: relative;
  height: 220px;
}

.assess-chart,
.assess-output canvas[data-chart] {
  width: 100%;
  height: 100%;
}

.assess-output .assess-plain {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  white-space: pre-wrap;
}

.assess-output h3,
.assess-output h4 {
  margin: 0.6rem 0 0.3rem;
  font-size: 1.05rem;
}

.assess-output h3:not(:first-of-type),
.assess-output h4:not(:first-of-type) {
  margin-top: 1.2rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(19, 32, 38, 0.08);
}

.assess-output p {
  margin: 0.3rem 0;
}

.assess-output ul,
.assess-output ol {
  margin: 0.2rem 0 0.8rem 1.1rem;
  padding: 0;
}

.assess-output li {
  margin: 0.15rem 0;
}

.assess-output hr {
  border: 0;
  border-top: 1px solid rgba(19, 32, 38, 0.08);
  margin: 0.6rem 0;
}

.assess-footer {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: var(--space);
  flex-wrap: wrap;
  row-gap: 4px;
  margin-top: 4px;
}

.assess-tokens {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  margin-left: auto;
  flex: 0 0 auto;
}

.assess-disclaimer {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.subtitle {
  color: var(--muted);
  max-width: 28rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}

.header-meta {
  display: flex;
  gap: var(--space);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip,
.pill {
  background: var(--panel);
  border: 1px solid rgba(19, 32, 38, 0.1);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  box-shadow: var(--shadow);
}

.pill[data-tone="warn"] {
  color: var(--warning);
  border-color: rgba(196, 138, 42, 0.35);
}

.pill[data-tone="ok"] {
  color: var(--ok);
  border-color: rgba(63, 123, 74, 0.35);
}

.pill[data-tone="error"] {
  color: var(--danger);
  border-color: rgba(180, 71, 55, 0.35);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space);
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow);
  border: 1px solid rgba(19, 32, 38, 0.08);
  animation: rise 0.6s ease both;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-patients {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.panel-list {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  min-height: 0;
}

.panel-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  min-height: 0;
}

.panel-trends {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  min-height: 0;
}

.panel-overview {
  min-height: 0;
  overflow: hidden;
}

.trend-stack {
  display: grid;
  gap: var(--space);
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: #132026;
  color: #f7f1e6;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 10px 18px rgba(19, 32, 38, 0.2);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

.tooltip:hover::after,
.tooltip:focus::after,
.tab:focus-visible .tooltip::after {
  opacity: 1;
  transform: translateY(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

.search span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.search input {
  width: 100%;
  padding: var(--space);
  border-radius: 6px;
  border: 1px solid rgba(19, 32, 38, 0.12);
  background: var(--panel-2);
  margin-top: 6px;
  font-size: 0.9rem;
}

.filters {
  display: flex;
  gap: var(--space);
}

.filter {
  border: 1px solid rgba(19, 32, 38, 0.12);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: var(--space);
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.sort-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink);
}

.sort-option input {
  accent-color: var(--accent);
}

.filter.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.patient-list {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  max-height: 420px;
  overflow: auto;
  padding-right: 0.3rem;
}

.panel-patients .patient-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.patient-card {
  padding: var(--space);
  background: #f3eadf;
  border-radius: 7px;
  border: 1px solid rgba(19, 32, 38, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.patient-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(19, 32, 38, 0.12);
}

.patient-card.active {
  border-color: var(--accent);
  box-shadow: none;
}

.patient-card.active:hover {
  transform: none;
  box-shadow: none;
}

.patient-card h4 {
  margin: 0;
}

.patient-card .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(28, 111, 99, 0.12);
  color: var(--accent);
}

.badge.high {
  background: rgba(180, 71, 55, 0.12);
  color: var(--danger);
}

.badge.warn {
  background: rgba(196, 138, 42, 0.12);
  color: var(--warning);
}

.panel-section h3 {
  margin-bottom: 0.6rem;
}

.schedule {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.schedule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fffdf7;
  border: 1px solid rgba(19, 32, 38, 0.06);
  font-size: 0.8rem;
}

.appointment-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space);
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space);
}

.week-day {
  text-align: center;
  padding: 8px 0;
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.week-day.today {
  background: rgba(28, 111, 99, 0.15);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 6px 12px rgba(28, 111, 99, 0.18);
}

.ingest-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space);
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.ingest-drop {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.drop-zone {
  border: 2px dashed rgba(19, 32, 38, 0.2);
  border-radius: 8px;
  padding: var(--space);
  text-align: center;
  color: var(--muted);
  background: var(--panel-2);
  position: relative;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone.dragover,
.drop-zone:focus-within {
  border-color: var(--accent);
  background: rgba(28, 111, 99, 0.08);
  color: var(--ink);
}

.drop-content {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.ingest-queue {
  margin-top: var(--space);
  display: grid;
  gap: 6px;
  max-height: none;
  flex: 1;
  overflow: auto;
}

.ingest-controls {
  margin-top: var(--space);
  display: grid;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  flex: 0 0 auto;
}

.ingest-controls .control {
  display: grid;
  gap: 4px;
}

.ingest-controls .mode {
  gap: 6px;
}

.ingest-controls .radio {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.78rem;
}

.ingest-controls .radio input {
  accent-color: var(--accent);
}

.ingest-controls select {
  border-radius: 6px;
  border: 1px solid rgba(19, 32, 38, 0.12);
  padding: 6px 8px;
  font-size: 0.8rem;
  background: #fffdf7;
}

.ingest-controls input[type="range"] {
  width: 100%;
}

.ingest-controls .range {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.ingest-controls .range-value {
  min-width: 32px;
  text-align: right;
  font-weight: 600;
}

.ingest-controls .toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ingest-controls .toggle input {
  accent-color: var(--accent);
}

.ingest-merge-actions {
  display: flex;
  gap: 6px;
  margin: 6px 0 var(--space);
}

.hidden-input {
  display: none;
}

.patient-card.ingest-selectable {
  position: relative;
  padding-right: 36px;
}

.patient-card .ingest-select {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.patient-card .ingest-select input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.ingest-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: 6px 8px;
  border-radius: 6px;
  background: #fffdf7;
  border: 1px solid rgba(19, 32, 38, 0.08);
  font-size: 0.78rem;
}

.ingest-file .meta {
  display: grid;
  gap: 2px;
}

.ingest-file .name {
  font-weight: 600;
}

.ingest-file .patient {
  font-size: 0.7rem;
  color: var(--muted);
}

.ingest-file .status {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.ingest-file .status.ok {
  color: var(--ok);
}

.ingest-file .status.warn {
  color: var(--warning);
}

.ingest-file .status.error {
  color: var(--danger);
}

.ingest-json {
  background: var(--panel-2);
  border-radius: 8px;
  padding: var(--space);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: none;
  overflow: auto;
  margin: 0;
  flex: 1;
  min-height: 0;
}

.overview-header {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1.2fr);
  gap: var(--space);
  margin-bottom: var(--space);
}

#patientMeta {
  white-space: pre-line;
}

.identity-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.risk-pill {
  background: rgba(28, 111, 99, 0.15);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

.risk-pill.high {
  background: rgba(180, 71, 55, 0.15);
  color: var(--danger);
}

.risk-pill.warn {
  background: rgba(196, 138, 42, 0.15);
  color: var(--warning);
}

.contact-card {
  background: var(--panel-2);
  padding: var(--space);
  border-radius: 7px;
}

.muted {
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space);
  margin-bottom: var(--space);
}

.metric-card {
  background: #fffdf7;
  border-radius: 8px;
  padding: var(--space);
  border: 1px solid rgba(19, 32, 38, 0.06);
}

.metric-card h3 {
  margin-top: 0.2rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space);
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.card {
  background: #fffdf7;
  border-radius: 8px;
  padding: var(--space);
  border: 1px solid rgba(19, 32, 38, 0.06);
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space);
  font-size: 0.9rem;
}

#problemList li,
#medList li,
#allergyList li {
  padding: 6px 8px;
  border-radius: 6px;
}

#problemList {
  counter-reset: problem;
}

#problemList li {
  position: relative;
  padding: 6px 8px 6px 30px;
}

#problemList li::before {
  counter-increment: problem;
  content: counter(problem) ".";
  position: absolute;
  left: 10px;
  top: 6px;
  font-weight: 600;
  color: var(--muted);
}

#problemList li:nth-child(odd),
#medList li:nth-child(odd),
#allergyList li:nth-child(odd) {
  background: rgba(19, 32, 38, 0.04);
}

.list li span {
  color: var(--muted);
  font-size: 0.78rem;
}

.trend {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 6px;
  height: 70px;
  padding: 8px;
  background: var(--panel-2);
  border-radius: 6px;
}

.trend span {
  width: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, #9cd1c7 100%);
  border-radius: 5px 5px 2px 2px;
  height: calc(var(--value) * 100%);
  min-height: 12px;
  position: relative;
}

.trend span.warn {
  background: linear-gradient(180deg, var(--warning) 0%, #f0d2a0 100%);
}

.trend span.high {
  background: linear-gradient(180deg, var(--danger) 0%, #f3b3a9 100%);
}

.notes {
  display: grid;
  gap: var(--space);
}

.note {
  padding: var(--space);
  background: var(--panel-2);
  border-radius: 6px;
}

.panel-summary .summary-output {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--space);
  align-items: start;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.summary-stack {
  display: grid;
  gap: var(--space);
}

.summary-block {
  background: #fffdf7;
  border-radius: 8px;
  padding: var(--space);
  border: 1px solid rgba(19, 32, 38, 0.08);
}

.summary-block ul {
  margin: 6px 0 0 0;
  padding-left: 16px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.summary-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

.footer-actions {
  display: flex;
  gap: var(--space);
}

.ghost {
  border: 1px solid rgba(19, 32, 38, 0.12);
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.ghost.danger {
  color: var(--danger);
  border-color: rgba(180, 71, 55, 0.35);
}

.raw-record {
  display: none;
  background: var(--panel-2);
  border-radius: 7px;
  padding: var(--space);
  font-size: 0.85rem;
  line-height: 1.4;
}

.raw-record.show {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media print {
  body.print-assess-only .app-header,
  body.print-assess-only .tab-bar,
  body.print-assess-only .tab-panel:not(.active) {
    display: none !important;
  }

  body.print-assess-only .app,
  body.print-assess-only .tab-panel,
  body.print-assess-only .tab-panel.active {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  body.print-assess-only .assess-grid {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body.print-assess-only .assess-grid > :not(.assess-report) {
    display: none !important;
  }

  body.print-assess-only .assess-report {
    width: 100%;
    height: auto;
    box-shadow: none;
    border: none;
    background: #fff;
    margin: 0;
  }

  body.print-assess-only #assessExportPdf,
  body.print-assess-only #assessExportDoc {
    display: none;
  }

  body.print-assess-only .assess-tokens {
    display: none;
  }

  body.print-assess-only .assess-output {
    overflow: visible;
    max-height: none;
  }
}

@media (max-width: 1200px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .panel-list {
    order: 1;
  }

  .panel-overview {
    order: 2;
  }

  .panel-trends {
    order: 3;
  }

  .panel-summary {
    order: 4;
  }

  .appointment-grid,
  .ingest-grid,
  .assess-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow: visible;
  }

  .tab-panel.active,
  .tab-panel > main {
    overflow: visible;
  }

  .app-grid,
  .assess-grid,
  .appointment-grid,
  .ingest-grid {
    height: auto;
  }

  .panel {
    overflow: visible;
  }

  .trend-stack,
  .detail-grid,
  .panel-summary .summary-output,
  .assess-output {
    max-height: none;
    overflow: visible;
  }

  .app-header {
    flex-direction: column;
  }

  .header-meta {
    display: none;
  }

  .search span {
    display: none;
  }

  .search input {
    margin-top: 0;
  }

  .filters {
    display: none;
  }

  .panel-patients .patient-list {
    max-height: calc(4 * 4.6rem + 3 * var(--space));
    overflow-y: auto;
  }

  .overview-header {
    grid-template-columns: 1fr;
  }

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

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

  .panel-summary .summary-output {
    grid-template-columns: 1fr;
  }

  .summary-stack {
    gap: var(--space);
  }
}

@media (max-width: 600px) {
  .app {
    padding: var(--space);
  }

}

@media (min-width: 901px) {
  .tooltip::after {
    top: auto;
    bottom: calc(100% + 0.5rem);
    transform: translateY(4px);
  }
}
