.health-view {
  min-width: 0;
}

.health-page-heading {
  margin-bottom: 14px;
}

.health-upload-actions,
.health-share-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.health-upload-actions select {
  width: 190px;
}

.health-sharing-band {
  display: grid;
  grid-template-columns: minmax(150px, 0.3fr) minmax(420px, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  margin-bottom: 9px;
  padding: 12px;
  align-items: center;
}

.health-sharing-band > div:first-child {
  display: grid;
  gap: 3px;
}

#healthShareState {
  font-size: 1.05rem;
}

#healthShareState.enabled {
  color: var(--accent-dark);
}

.health-share-controls input {
  min-width: 0;
  flex: 1 1 300px;
}

.health-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 14px 0;
}

.health-summary > div {
  display: grid;
  min-width: 0;
  gap: 3px;
  border-right: 1px solid var(--line);
  padding: 14px;
}

.health-summary > div:first-child {
  padding-left: 0;
}

.health-summary > div:last-child {
  border-right: 0;
}

.health-summary span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.health-summary strong {
  font-size: 1.3rem;
}

.health-summary .health-period {
  font-size: 0.9rem;
  line-height: 1.35;
}

.health-view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  margin-bottom: 14px;
  padding: 3px;
}

.health-view-tab {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
}

.health-view-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(26, 36, 31, 0.12);
}

.health-lab-panel {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.health-metric-browser {
  position: sticky;
  top: 78px;
  min-width: 0;
}

.health-metric-list {
  display: grid;
  max-height: 650px;
  margin-top: 9px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.health-metric-row {
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 6px;
  text-align: left;
  align-items: center;
}

.health-metric-row:hover,
.health-metric-row.active {
  background: var(--accent-soft);
}

.health-metric-row > span:first-child,
.health-metric-latest {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.health-metric-row strong,
.health-metric-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-metric-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.health-metric-latest {
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 850;
  text-align: right;
}

.health-metric-latest.outside,
.health-value-flag.outside {
  color: var(--danger);
}

.health-trend-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.health-trend-heading {
  display: flex;
  min-height: 55px;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.health-trend-heading h2,
.health-trend-heading h3,
.health-trend-heading p {
  margin: 0;
}

.health-chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(300px, 43vh, 470px);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.health-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.health-history-wrap {
  width: 100%;
  margin-top: 12px;
  overflow-x: auto;
}

.health-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.health-history-table th,
.health-history-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

.health-history-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.health-value-flag {
  font-weight: 850;
}

.health-document-list {
  display: grid;
  gap: 20px;
}

.health-document-group {
  min-width: 0;
}

.health-document-group-heading {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  align-items: baseline;
  justify-content: space-between;
}

.health-document-group-heading h3 {
  margin: 0;
}

.health-document-group-heading span {
  color: var(--muted);
  font-size: 0.8rem;
}

.health-document-row {
  display: grid;
  min-height: 62px;
  grid-template-columns: 34px minmax(0, 1fr) auto auto 42px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 9px 2px;
  align-items: center;
}

.health-document-mark {
  display: grid;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 900;
  place-items: center;
}

.health-document-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.health-document-copy strong,
.health-document-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-document-copy small {
  color: var(--muted);
  font-size: 0.75rem;
}

.health-share-check {
  display: flex;
  gap: 6px;
  align-items: center;
}

.health-share-check input {
  width: 18px;
  min-height: 18px;
}

.health-share-check span {
  margin: 0;
  font-size: 0.8rem;
}

.health-source-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin: 20px 0 0;
  padding-top: 12px;
  font-size: 0.78rem;
}

.health-shared-shell {
  width: min(1260px, calc(100% - 28px));
  margin: 18px auto 40px;
}

.health-shared-heading {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding: 8px 0 18px;
  align-items: center;
  justify-content: space-between;
}

.health-shared-heading h1 {
  margin-top: 3px;
}

.health-shared-shell .health-document-row {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

@media (max-width: 980px) {
  .health-sharing-band,
  .health-lab-panel {
    grid-template-columns: 1fr;
  }

  .health-metric-browser {
    position: static;
  }

  .health-metric-list {
    max-height: 300px;
  }

  .health-trend-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 14px;
    padding-left: 0;
  }
}

@media (max-width: 700px) {
  .health-shared-shell {
    width: calc(100% - 16px);
    margin-top: 8px;
  }

  .health-page-heading,
  .health-upload-actions,
  .health-share-controls {
    display: grid;
  }

  .health-upload-actions select {
    width: 100%;
  }

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

  .health-summary > div,
  .health-summary > div:first-child {
    border-bottom: 1px solid var(--line);
    padding: 11px 8px;
  }

  .health-summary > div:nth-child(2n) {
    border-right: 0;
  }

  .health-view-tabs {
    width: 100%;
  }

  .health-chart-wrap {
    height: 310px;
  }

  .health-document-row,
  .health-shared-shell .health-document-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .health-document-row .health-share-check {
    grid-column: 2;
  }

  .health-document-row .icon-button {
    grid-column: 3;
  }
}
