.sh-history-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
}

.sh-history-strip h2 {
  flex: none;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.3;
}

.sh-history-strip-title {
  padding: 5px 2px;
  font-weight: 650;
}

.sh-history-strip-title:hover { color: var(--brand); }

.sh-history-all {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 22px;
  background: #24334a;
  color: white;
  font-size: 12px;
  white-space: nowrap;
}

.sh-history-all:hover { background: #344a6d; }

.sh-history-strip-items {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.sh-history-strip-entry {
  display: grid;
  flex: 1 0 116px;
  gap: 2px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 7px;
  text-align: left;
}

.sh-history-strip-entry:hover { background: #f2f5fc; }

.sh-history-strip-entry > span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sh-history-strip-entry > span .ico { color: #647fbc; }

.sh-history-strip-entry strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.sh-history-strip-empty {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sh-history { min-width: 0; }

.sh-history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 18px 20px 12px;
}

.sh-history-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
}

.sh-history-header h2 .ico { color: var(--brand); }

.sh-history-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.sh-history-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 4px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.sh-history-controls label {
  display: grid;
  gap: 4px;
  min-width: 132px;
  color: var(--muted);
  font-size: 12px;
}

.sh-history-controls select {
  width: 100%;
  min-height: 36px;
  padding: 4px 9px;
  border: 1px solid #dce4ef;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

.sh-history-results { padding: 15px 20px 22px; }

.sh-history-year + .sh-history-year { margin-top: 22px; }

.sh-history-year h3 {
  margin-bottom: 8px;
  color: #344660;
  font-size: 15px;
  font-weight: 650;
}

.sh-history-year ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sh-history-item {
  --history-color: #4565aa;
  --history-tint: #eaf0fd;
  display: grid;
  position: relative;
  grid-template-columns: minmax(74px, 102px) 30px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
}

.sh-history-item[data-history-kind="focus"] { --history-color: #7c5627; --history-tint: #fff1d9; }
.sh-history-item[data-history-kind="care"],
.sh-history-item[data-history-kind="observation"] { --history-color: #277d65; --history-tint: #e8f6ef; }
.sh-history-item[data-history-kind="visit"] { --history-color: #7250a7; --history-tint: #f2ecfc; }
.sh-history-item[data-history-kind="followup"] { --history-color: #a34c5c; --history-tint: #fff0f3; }
.sh-history-item[data-history-kind="measurement"],
.sh-history-item[data-history-kind="vitals"] { --history-color: #257e89; --history-tint: #e5f6f8; }

.sh-history-item:last-child { padding-bottom: 0; }

.sh-history-date {
  align-self: start;
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sh-history-marker {
  position: relative;
  align-self: stretch;
  display: flex;
  justify-content: center;
  margin-top: 8px;
  color: var(--history-color);
}

.sh-history-item:not(:last-child) .sh-history-marker::before {
  content: '';
  position: absolute;
  top: 30px;
  bottom: -18px;
  left: 50%;
  width: 1px;
  background: #e4e9f0;
}

.sh-history-marker .ico {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 7px;
  border-radius: 50%;
  background: var(--history-tint);
}

.sh-history-card {
  min-width: 0;
  border: 1px solid #e5ebf3;
  border-radius: 9px;
  background: #fafbfd;
}

.sh-history-target { border-color: var(--brand); box-shadow: 0 0 0 2px #e1e9ff; }

.sh-history-card summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
}

.sh-history-card summary::-webkit-details-marker { display: none; }
.sh-history-card summary:hover { background: #f1f5fc; }
.sh-history-card summary:focus-visible { outline: 2px solid #577cf5; outline-offset: 2px; }

.sh-history-card-copy { display: grid; gap: 1px; min-width: 0; }

.sh-history-card-copy strong {
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.sh-history-entry-type {
  color: var(--history-color);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.sh-history-expand {
  display: inline-flex;
  flex: none;
  color: var(--muted);
}

.sh-history-card[open] .sh-history-expand { transform: rotate(180deg); }

.sh-history-card-body {
  display: grid;
  justify-items: start;
  gap: 9px;
  padding: 8px 13px 12px;
  border-top: 1px solid #e8edf4;
}

.sh-history-card-body dl { display: grid; gap: 5px; width: 100%; margin: 0; }

.sh-history-card-body dl div {
  display: grid;
  grid-template-columns: minmax(44px, 80px) minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
  line-height: 1.55;
}

.sh-history-card-body dt { color: var(--muted); }
.sh-history-card-body dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.sh-history-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 2px 7px;
  border: 1px solid #dae4f6;
  border-radius: 6px;
  background: #fff;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 600;
}

.sh-history-source:hover { background: #edf3ff; }

.sh-history-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 34px 8px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 580px) {
  .sh-history-strip { gap: 7px; padding: 6px 8px; }
  .sh-history-strip h2 { font-size: 13px; }
  .sh-history-all { padding-inline: 8px; }
  .sh-history-strip-entry { flex-basis: 110px; padding-inline: 5px; }
  .sh-history-header { padding: 13px 12px 9px; }
  .sh-history-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 3px 12px 12px; }
  .sh-history-controls label { min-width: 0; }
  .sh-history-controls select { padding-inline: 4px; font-size: 12px; }
  .sh-history-results { padding: 11px 12px 14px; }
  .sh-history-item { grid-template-columns: 24px minmax(0, 1fr); column-gap: 8px; row-gap: 4px; }
  .sh-history-date { grid-column: 2; padding-top: 1px; }
  .sh-history-marker { grid-row: 1 / 3; margin-top: 0; }
  .sh-history-marker .ico { width: 24px; height: 24px; padding: 5px; }
  .sh-history-item:not(:last-child) .sh-history-marker::before { top: 24px; bottom: -10px; }
  .sh-history-card { grid-column: 2; }
}
