/* Screen layout for the patient handout. Print has its own A4 sizing below. */
#patientReport {
  max-width: 1120px;
}

#patientReportBody {
  min-width: 0;
  padding: 20px;
  background: #edf4f7;
}

#patientReport .report-print-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.patient-report {
  --report-ink: #173247;
  --report-muted: #40586a;
  --report-navy: #12374f;
  --report-line: #cbdce4;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 1080px;
  margin: 0 auto;
  color: var(--report-ink);
  background: #fff;
  border: 1px solid #cbdbe3;
  border-radius: 17px;
  box-shadow: 0 14px 44px #183b5112;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

.patient-report .summary-front,
.patient-report .report-appendix,
.patient-report .report-history-continuation,
.patient-report .report-extra-actions {
  padding: 28px 34px;
}

.patient-report .summary-heading {
  display: block;
  margin: 0;
  padding: 18px 22px;
  border: 1px solid #b9ded6;
  border-radius: 14px;
  background: #e4f4f1;
}

.summary-title {
  text-align: center;
}

.summary-title h1 {
  margin: 0;
  color: #315b59;
  font-size: 16px;
  line-height: 1.35;
}

.summary-person-name {
  display: block;
  margin-top: 4px;
  color: #184e4a;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.summary-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(50%);
  align-items: center;
  gap: 8px 18px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #b9d8d2;
  color: #365b5c;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.summary-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.summary-brand > div {
  min-width: 0;
}

.summary-app-brand {
  display: block;
  margin-bottom: 2px;
  color: #164d70;
  font-size: 13px;
  font-weight: 750;
}

.summary-facility,
.summary-patient {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  min-width: 0;
}

.summary-patient {
  font-variant-numeric: tabular-nums;
}

.summary-patient > span {
  min-width: 0;
}

.patient-report .care-scope-logo {
  flex: none;
  width: 24px;
  height: 24px;
}

.summary-demo {
  margin: 7px 2px 19px;
  color: #405d6f;
  font-size: 12px;
  text-align: right;
}

.summary-band {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin: 20px 0 12px;
  padding: 8px 12px;
  color: var(--report-navy);
  background: linear-gradient(100deg, #d5eaf6, #f0f8fb);
  border: 1px solid #c2dce9;
  border-radius: 9px;
}

.summary-band > span {
  display: grid;
  flex: none;
  place-items: center;
  width: 27px;
  height: 27px;
  color: #fff;
  background: #286c91;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
}

.summary-band h2 {
  min-width: 0;
  margin: 0;
  color: inherit;
  font-size: 18px;
  line-height: 1.35;
}

.summary-band > p {
  margin: 0 0 0 auto;
  color: #36566c;
  font-size: 13px;
}

/* These colors identify status across the diagram, results and history. */
.patient-report .risk-recorded {
  --report-risk-fill: #f1f7fb;
  --report-risk-accent: #5f8ca3;
  --report-risk-pill: #e6f1f8;
  --report-risk-ink: #234d65;
}

.patient-report .risk-check {
  --report-risk-fill: #fff4d6;
  --report-risk-accent: #a97014;
  --report-risk-pill: #faedca;
  --report-risk-ink: #694708;
}

.patient-report .risk-high {
  --report-risk-fill: #fbe7e5;
  --report-risk-accent: #ae5149;
  --report-risk-pill: #fae3df;
  --report-risk-ink: #7b332c;
}

/* Markers end at approximate areas of the illustration. */
.summary-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
}

.summary-person {
  --figure-height: 200px;
  --figure-width: calc(var(--figure-height) * .6667);
  --figure-gap: 8px;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--figure-width) minmax(0, 1fr);
  align-items: center;
  gap: var(--figure-gap);
  min-width: 0;
  padding: 8px 14px;
  background: radial-gradient(ellipse at 50% 55%, #d8eee9, transparent 62%), #f5fafb;
  border: 1px solid #d1e7e7;
  border-radius: 12px;
}

.summary-person > img {
  grid-column: 2;
  grid-row: 1;
  display: block;
  width: var(--figure-width);
  max-width: 100%;
  height: var(--figure-height);
  object-fit: contain;
}

.person-labels {
  position: relative;
  grid-row: 1;
  align-self: center;
  min-width: 0;
  height: var(--figure-height);
}

.person-left {
  grid-column: 1;
}

.person-right {
  grid-column: 3;
}

.patient-report .person-label {
  --marker-run: calc(var(--figure-width) * var(--marker-reach, .4) + var(--figure-gap));
  position: absolute;
  z-index: 1;
  top: var(--marker-y, 50%);
  transform: translateY(-50%);
  display: block;
  width: max-content;
  max-width: 100%;
  padding: 5px 9px;
  color: var(--report-risk-ink, #254356);
  background: var(--report-risk-pill, #fff);
  border: 1px solid var(--report-risk-accent, #90b2c0);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.person-label::before,
.person-label::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--report-risk-accent, #5f8ca3);
  pointer-events: none;
}

.person-label::before {
  width: var(--marker-run);
  height: 2px;
}

.person-label::after {
  width: 8px;
  height: 8px;
  border: 1px solid #fff;
  border-radius: 50%;
}

.person-left .person-label {
  right: 0;
}

.person-left .person-label::before {
  left: 100%;
}

.person-left .person-label::after {
  left: calc(100% + var(--marker-run) - 4px);
}

.person-right .person-label {
  left: 0;
}

.person-right .person-label::before {
  right: 100%;
}

.person-right .person-label::after {
  right: calc(100% + var(--marker-run) - 4px);
}

.person-label:focus-visible,
.history-scroll:focus-visible {
  outline: 2px solid #216c91;
  outline-offset: 3px;
}

.person-label:hover {
  text-decoration: underline;
}

.person-warning {
  display: inline-grid;
  place-items: center;
  width: 1.2em;
  height: 1.2em;
  margin-inline-end: 4px;
  color: #fff;
  background: var(--report-risk-ink);
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
  vertical-align: baseline;
}

.label-mind {
  --marker-y: 12%;
  --marker-reach: .43;
}

.label-vital {
  --marker-y: 31%;
  --marker-reach: .4;
}

.label-nutrition {
  --marker-y: 54%;
  --marker-reach: .44;
}

.label-swallow {
  --marker-y: 18%;
  --marker-reach: .46;
}

.label-comfort {
  --marker-y: 52%;
  --marker-reach: .33;
}

.label-mobility {
  --marker-y: 78%;
  --marker-reach: .39;
}

.domain-column {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-width: 0;
}

.domain-column:empty {
  display: none;
}

.summary-body:has(> .domain-column:empty) > .domain-column:not(:empty) {
  grid-column: 1 / -1;
}

.domain-card {
  min-width: 0;
  border: 1px solid var(--report-line);
  border-radius: 11px;
  overflow: hidden;
  scroll-margin-top: 105px;
}

.domain-card:target {
  outline: 2px solid var(--domain, #5f8ca3);
  outline-offset: 3px;
}

.domain-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  color: #173b4f;
  background: color-mix(in srgb, var(--domain) 12%, white);
  border-bottom: 1px solid var(--report-line);
  font-size: 15px;
  line-height: 1.3;
}

.domain-category-icon {
  flex: none;
  width: 23px;
  height: 23px;
}

.domain-card .report-risk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 10px;
  row-gap: 2px;
  padding: 9px 11px 9px 12px;
  background: var(--report-risk-fill, #f8fbfd);
  border-left: 3px solid var(--report-risk-accent, #8fb8cc);
}

.domain-card .report-risk + .report-risk {
  border-top: 1px solid #dce7eb;
}

.result-assessment-name {
  grid-column: 1;
  grid-row: 1;
  font-size: 14px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.report-risk-label {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
  max-width: 11em;
  padding: 1px 7px;
  color: var(--report-risk-ink, #234d65);
  background: var(--report-risk-pill, #e6f1f8);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}

.result-measured-at {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  margin: 0;
  color: #40566a;
  font-size: 12px;
  text-align: right;
}

.domain-score {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  color: var(--report-navy);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.domain-description,
.domain-card .report-risk > p:last-child:not(.domain-score, .result-measured-at) {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: #29465b;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.summary-legend,
.history-scope,
.summary-caution {
  margin: 9px 0 0;
  color: var(--report-muted);
  font-size: 13px;
  line-height: 1.55;
}

.history-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  background: #fff;
  border: 1px solid #bdced9;
  border-radius: 10px;
}

.summary-history {
  width: 100%;
  min-width: 650px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.summary-history thead th {
  padding: 10px 8px;
  color: #17384e;
  background: #eaf3f8;
  border-bottom: 1px solid #bdced9;
  font-size: 13px;
}

.summary-history thead th:first-child {
  width: 23%;
  padding-left: 13px;
  text-align: left;
}

.summary-history th[scope="row"] {
  padding: 8px 10px 8px 13px;
  color: #203e51;
  background: #fff;
  font-size: 13px;
  text-align: left;
}

.summary-history td {
  padding: 8px 7px;
  color: var(--report-risk-ink, #203e51);
  background: var(--report-risk-fill, #f8fbfd);
  line-height: 1.35;
  text-align: center;
}

.summary-history td,
.summary-history th[scope="row"] {
  border-bottom: 1px solid #e0e8ee;
  overflow-wrap: anywhere;
}

.summary-history td:not(:last-child),
.summary-history thead th:not(:last-child) {
  border-right: 1px solid #dde8ee;
}

.summary-history td.current-column,
.summary-history th.current-head {
  border-inline: 2px solid #8cbbb9;
  font-weight: 800;
}

.summary-history thead th.current-head {
  color: #184d4a;
  background: #ddf0eb;
}

.summary-history thead b {
  display: block;
  font-size: 12px;
}

.summary-history small {
  display: block;
  margin-top: 3px;
  color: var(--report-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.summary-history .history-group th {
  padding: 4px 13px;
  color: #25485c;
  background: #eef5f8;
  border-bottom: 1px solid #d3e1e8;
  font-size: 13px;
  text-align: left;
}

.measurement-unit {
  white-space: nowrap;
}

.summary-history .measurement-part {
  display: block;
}

.domain-score .measurement-part {
  display: inline-block;
  max-width: 100%;
}

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

.point-card,
.report-comment {
  min-width: 0;
  padding: 12px;
  color: #2b485b;
  background: var(--report-risk-fill, #f5f9fb);
  border: 1px solid #cadce4;
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.point-card h3,
.report-comment h3 {
  margin: 0 0 3px;
  color: #183f55;
  font-size: 15px;
}

.point-card p,
.report-comment p {
  margin: 0;
  font-size: 14px;
}

.point-card p:empty {
  display: none;
}

.report-comment {
  margin-top: 10px;
  background: #f3f9f7;
}

.report-comment p {
  white-space: pre-wrap;
}

.patient-report .summary-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: 19px 0 0;
  padding: 12px 0 0;
  color: #335365;
  border-top: 1px solid #dce7ed;
}

.summary-caution {
  margin-top: 0;
}

.patient-report .report-extra-actions {
  padding-block: 16px;
  background: #f3f8fa;
  border-top: 1px solid #d9e7ec;
  border-radius: 0 0 17px 17px;
}

.report-extra-actions p {
  margin: 6px 0 0;
  color: var(--report-muted);
  font-size: 13px;
}

.report-appendix,
.report-history-continuation {
  display: none;
}

.show-report-details .report-appendix,
.show-report-details .report-history-continuation {
  display: block;
}

.summary-detail {
  padding: 12px 0;
  border-bottom: 1px solid #dbe6ed;
  overflow-wrap: anywhere;
}

.summary-detail h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.summary-detail h3 small,
.detail-version,
.detail-source {
  color: var(--report-muted);
  font-size: 13px;
  font-weight: 400;
}

.summary-detail dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 3px 8px;
}

.summary-detail dd {
  margin: 0;
}

.report-history-continuation .history-scroll {
  margin-top: 10px;
}

.report-asset-preloader {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.report-image-error {
  padding: 10px;
  color: #a4433a;
  font-size: 12px;
}

/* The assessment form and guide share this stylesheet. */
#recordComment {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

@media screen {
  #assessmentGuide { width: min(840px, calc(100% - 28px)); max-height: 90dvh; }
  #guideSearch { font-size: 16px; }
  .evaluation-guide-entry { border: 1px solid #d6e0e5; border-radius: 10px; margin-top: 12px; padding: 14px 16px; }
  .evaluation-guide-entry > summary { font-weight: 700; color: #155e75; cursor: pointer; min-height: 32px; }
  .evaluation-guide-entry h3 { font-size: 15px; margin: 18px 0 6px; }
  .evaluation-guide-entry p, .evaluation-guide-entry li { font-size: 14px; line-height: 1.8; }
  .guide-sources { overflow-wrap: anywhere; }
  .footer-links { flex-wrap: wrap; gap: 14px 24px; }
  .guide-sources a { color: #155e75; }
}

@media screen and (max-width: 750px) {
  .summary-history th[scope="row"],
  .summary-history thead th:first-child {
    position: sticky;
    z-index: 2;
    left: 0;
    box-shadow: 1px 0 0 #d4e0e6;
  }
}

@media screen and (max-width: 650px) {
  #patientReportBody {
    padding: 0;
  }

  .patient-report {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .patient-report .summary-front,
  .patient-report .report-appendix,
  .patient-report .report-history-continuation,
  .patient-report .report-extra-actions {
    padding: 15px 13px;
  }

  .patient-report .summary-heading {
    padding: 14px 13px 12px;
  }

  .summary-meta {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .summary-patient {
    padding-inline-start: 32px;
  }

  .summary-person-name {
    font-size: 27px;
  }

  .summary-band {
    flex-wrap: wrap;
    gap: 7px;
  }

  .summary-band h2 {
    flex: 1;
    font-size: 16px;
  }

  .summary-band > p {
    width: 100%;
    margin-left: 34px;
  }

  .summary-body,
  .summary-points {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }

  .summary-person {
    --figure-height: 156px;
    --figure-gap: 4px;
    padding-inline: 6px;
  }

  .patient-report .person-label {
    padding: 4px 5px;
    font-size: 11px;
  }

  .domain-card .report-risk {
    padding-block: 11px;
  }

  .domain-description {
    font-size: 14px;
  }

  .domain-card {
    scroll-margin-top: 135px;
  }
}

@media screen and (max-width: 380px) {
  .summary-person {
    --figure-height: 196px;
    --figure-width: 98px;
  }

  .label-vital {
    --marker-y: 33%;
  }

  .label-nutrition {
    --marker-y: 56%;
  }

  .result-measured-at {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: start;
    text-align: left;
  }

  .domain-score {
    grid-column: 1 / -1;
  }
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html,
  body {
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }

  body > *:not(#patientReport),
  #patientReport::backdrop,
  #patientReport > .dialog-heading {
    display: none !important;
  }

  #patientReport {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  #patientReportBody {
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }

  .patient-report {
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: 10.5pt;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .patient-report .summary-front,
  .patient-report .report-history-continuation {
    padding: 0;
  }

  .patient-report .summary-heading {
    padding: 12px 16px;
    break-inside: avoid;
  }

  .summary-person {
    --figure-height: 48mm;
    margin-bottom: 11px;
    column-span: all;
    break-inside: avoid;
  }

  .summary-band,
  .domain-card h3,
  .summary-history .history-group,
  .report-history-continuation h2 {
    break-after: avoid;
  }

  /* Keep each measurement together, while allowing a long group to continue. */
  .summary-body {
    display: block;
    columns: 2;
    column-gap: 4mm;
  }

  .domain-column {
    display: contents;
  }

  .domain-card {
    margin-bottom: 10px;
    overflow: visible;
  }

  .domain-card .report-risk,
  .point-card,
  .summary-history tr {
    break-inside: avoid;
  }

  .domain-card .report-risk {
    padding-block: 6px;
  }

  .history-scroll {
    overflow: visible;
  }

  .summary-history {
    min-width: 0;
    font-size: 10pt;
  }

  .summary-history thead {
    display: table-header-group;
  }

  .summary-history td,
  .summary-history th[scope="row"] {
    padding-block: 5px;
  }

  .patient-report .report-extra-actions,
  .patient-report .report-appendix {
    display: none !important;
  }

  .patient-report .report-history-continuation {
    display: block !important;
  }

  a[href]::after {
    content: none;
  }

  .patient-report .person-label::after {
    content: "";
  }
}
