:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: #243247;
  background: #f3f6fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #172b4d;
  --muted: #5c6b7d;
  --line: #dbe3ec;
  --surface: #fff;
  --accent: #176b78;
  --shadow: 0 3px 12px rgb(23 43 77 / 5%);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: #243247;
}

.report-header {
  padding: 1.6rem max(1.5rem, calc((100% - 1180px) / 2));
  border-bottom: 4px solid #2d8390;
  background: var(--ink);
  color: #fff;
}

.report-header h1 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: #9fcbd0;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.report-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
}

.note {
  margin: 0 0 1.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid #d6e2e9;
  border-left: 4px solid #6d8997;
  border-radius: 0.35rem;
  background: #eaf1f5;
  color: #435466;
  font-size: 0.82rem;
  line-height: 1.55;
}

.patient {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 0.8rem;
}

.report-nav a {
  color: #d0f0f3;
}

.demo-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  color: #536371;
  font-size: 12px;
}

.demo-tools a {
  padding: 8px 0;
  color: inherit;
}

.demo-tools a:focus-visible {
  outline: 3px solid #80b6bd;
  outline-offset: 3px;
}

.clinical-card {
  margin-bottom: 1rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0.55rem;
  background: var(--surface);
}

.clinical-card small {
  color: var(--muted);
  font-weight: 400;
}

.clinical-summary {
  font-weight: 650;
  line-height: 1.5;
}

.handoff-demo {
  color: var(--muted);
  font-size: 0.85rem;
}

.patient-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.patient-header .eyebrow {
  color: var(--accent);
}

.patient-header h2 {
  margin: 0.25rem 0 0;
  color: var(--ink);
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.patient-record {
  color: var(--muted);
  font-size: 0.83rem;
}

.report-section {
  padding: 1.25rem 1.5rem;
}

.report-section + .report-section {
  border-top: 1px solid #edf1f5;
}

h3 {
  margin: 0 0 0.9rem;
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

h4 {
  color: var(--ink);
  line-height: 1.35;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.section-heading h3 {
  margin-bottom: 0;
}

.question {
  margin: 0.75rem 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: #fff;
  box-shadow: 0 1px 3px rgb(23 43 77 / 4%);
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 0.8rem;
}

.measurement-card {
  min-width: 0;
  margin: 0;
  padding: 0.8rem;
  border-top: 3px solid #7aa7ad;
}

.measurement-card h4 {
  margin: 0.1rem 0 0.75rem;
  font-size: 0.94rem;
}

.measurement-card .statistics {
  grid-template-columns: minmax(6.2rem, auto) 1fr;
  gap: 0.35rem 0.65rem;
  font-size: 0.79rem;
}

.statistics {
  display: grid;
  grid-template-columns: minmax(12rem, 0.4fr) 1fr;
  gap: 0.55rem 1rem;
}

dt {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 600;
}

dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: #26384e;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 0.65rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e5eaf0;
  text-align: left;
}

th {
  background: #f4f7fa;
  color: #46576b;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: #fafbfd;
}

.severity-badge {
  display: inline-block;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}

.severity-green {
  background: #dcfce7;
  color: #14532d;
}

.severity-yellow {
  background: #fef3c7;
  color: #713f12;
}

.severity-orange {
  background: #ffedd5;
  color: #7c2d12;
}

.severity-red {
  background: #fee2e2;
  color: #7f1d1d;
}

.severity-unknown {
  background: #edf0f3;
  color: #445264;
}

.severity-cell {
  font-weight: 650;
}

.severity-cell.severity-green {
  background: #f0fdf4;
}

.severity-cell.severity-yellow {
  background: #fffbeb;
}

.severity-cell.severity-orange {
  background: #fff7ed;
}

.severity-cell.severity-red {
  background: #fef2f2;
}

.severity-cell.severity-unknown {
  background: #f3f5f7;
}

.severity-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.severity-legend strong {
  color: var(--muted);
  font-size: 0.78rem;
}

.chart {
  margin: 0.55rem 0 0;
}

.chart .plotly-graph-div {
  min-height: 310px;
}

.chart .modebar {
  top: 0.25rem !important;
  right: 0.25rem !important;
}

.empty-state {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px dashed #cbd5df;
  border-radius: 0.4rem;
  background: #f7f9fb;
  color: var(--muted);
}

details {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid #e9edf2;
}

summary {
  color: #3d596f;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 650;
}

summary:focus-visible {
  border-radius: 0.2rem;
  outline: 3px solid #80b6bd;
  outline-offset: 3px;
}

@media (max-width: 920px) {
  .measurement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .report-header {
    padding: 1.2rem 1rem;
  }

  .report-shell {
    padding: 1rem 0.75rem;
  }

  .patient-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 1rem;
  }

  .report-section {
    padding: 1rem;
  }

  .statistics {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  dd {
    margin-bottom: 0.45rem;
  }

  .measurement-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  :root {
    background: #fff;
  }

  .report-header {
    padding: 0 0 1rem;
    border-bottom: 2px solid #243247;
    background: #fff;
    color: #172b4d;
  }

  .eyebrow,
  .patient-header .eyebrow {
    color: #40566d;
  }

  .report-shell {
    max-width: none;
    padding: 1rem 0;
  }

  .patient {
    border: 0;
    box-shadow: none;
  }

  .patient-header,
  .report-section {
    padding-right: 0;
    padding-left: 0;
  }

  .question,
  details {
    break-inside: avoid;
  }

  .question {
    box-shadow: none;
  }

  details > .table-scroll {
    display: block;
  }

  table {
    font-size: 8pt;
  }

  th,
  td {
    padding: 0.35rem 0.45rem;
  }

  .chart {
    break-inside: avoid;
  }
}

.patient-email {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.patient-email label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.patient-email-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.patient-email input[type="email"] {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.patient-email button {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.patient-email button:hover {
  filter: brightness(0.9);
}

.patient-email button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.patient-email input:focus-visible,
.patient-email button:focus-visible {
  outline: 3px solid #80b6bd;
  outline-offset: 3px;
}

.patient-email-hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.email-feedback {
  padding: 1rem;
  border-radius: 0.5rem;
  background: #edf2f7;
}

.patient-email-error {
  background: #fff0ee;
  color: #992b24;
}

.patient-email-success {
  background: #eaf6ef;
  color: #1b6941;
}
