:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #68747f;
  --line: #d9e1dc;
  --blue: #286a8d;
  --blue-dark: #184d68;
  --green: #3d7a61;
  --red: #b94b4b;
  --amber: #b97625;
  --violet: #6e5aa6;
  --shadow: 0 18px 45px rgba(32, 48, 59, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(61, 122, 97, 0.18), transparent 28rem),
    linear-gradient(145deg, #f7f8f4 0%, #eef4f5 52%, #f9f6ee 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.4rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 0.18rem;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1.08;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

h3 {
  font-size: 0.96rem;
  line-height: 1.3;
}

.header-actions,
.import-actions,
.panel-heading,
.segmented-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.primary-button,
.ghost-button,
.icon-button,
.segmented-control button {
  min-height: 2.35rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.primary-button {
  padding: 0.55rem 0.9rem;
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 720;
}

.primary-button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.ghost-button,
.segmented-control button {
  padding: 0.5rem 0.75rem;
  background: #f4f7f6;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover,
.segmented-control button:hover {
  border-color: #adc1bc;
}

.icon-button {
  width: 2.35rem;
  background: #edf3f4;
  border-color: var(--line);
  color: var(--blue-dark);
  font-size: 1.05rem;
  font-weight: 780;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 2rem;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-panel,
.filter-panel,
.daily-trends-panel,
.medication-timeline-panel,
.metric-history-panel,
.priority-panel,
.records-panel,
.summary-strip article {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 225, 220, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.import-panel,
.filter-panel,
.daily-trends-panel,
.medication-timeline-panel,
.metric-history-panel,
.priority-panel,
.records-panel {
  padding: 1rem;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  margin-top: 0.22rem;
}

.status-pill,
.record-flag,
#priorityMeta,
#medicationTimelineMeta,
#metricHistoryMeta {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 730;
}

.status-pill {
  color: var(--green);
  background: #e7f2ed;
}

.import-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

textarea {
  width: 100%;
  min-height: 13rem;
  resize: vertical;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  line-height: 1.45;
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(40, 106, 141, 0.18);
  border-color: var(--blue);
}

.filter-panel {
  display: grid;
  gap: 0.55rem;
}

label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

input,
select {
  width: 100%;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 0 0.7rem;
}

.dashboard {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.source-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: #fff7e8;
  border: 1px solid #e7c58f;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.source-banner div {
  display: grid;
  gap: 0.18rem;
}

.source-banner strong {
  color: #7c4c12;
  font-size: 0.95rem;
}

.source-banner span {
  color: #705a3b;
  font-size: 0.86rem;
  line-height: 1.35;
}

.source-banner a {
  flex: 0 0 auto;
  color: var(--blue-dark);
  font-size: 0.86rem;
  font-weight: 760;
  text-decoration: none;
}

.source-banner a:hover {
  text-decoration: underline;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.summary-strip article {
  min-height: 6rem;
  padding: 1rem;
  display: grid;
  align-content: center;
}

.summary-strip span {
  color: var(--blue-dark);
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 820;
  line-height: 1;
}

.summary-strip p {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.86rem;
}

.insights-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.range-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f6f5;
}

.range-toggle button {
  min-width: 3rem;
  min-height: 2rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 780;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.range-toggle button.active {
  color: var(--blue-dark);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(31, 41, 51, 0.12);
}

.daily-trend-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  gap: 0.72rem;
}

.daily-trend-card {
  --card-accent: var(--blue);
  position: relative;
  overflow: hidden;
  min-height: 13.6rem;
  display: grid;
  gap: 0.65rem;
  padding: 0.9rem;
  border: 1px solid rgba(217, 225, 220, 0.95);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 252, 251, 0.94)),
    linear-gradient(135deg, color-mix(in srgb, var(--card-accent) 15%, transparent), transparent 55%);
  box-shadow: 0 12px 28px rgba(32, 48, 59, 0.08);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.daily-trend-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 0.22rem;
  background: var(--card-accent);
}

.daily-trend-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--card-accent) 42%, var(--line));
  box-shadow: 0 16px 34px rgba(32, 48, 59, 0.13);
}

.daily-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.daily-card-head h3 {
  color: var(--ink);
  font-size: 0.95rem;
}

.daily-card-head p,
.daily-card-foot {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.daily-pill {
  flex: 0 0 auto;
  align-self: start;
  border-radius: 999px;
  padding: 0.17rem 0.45rem;
  color: color-mix(in srgb, var(--card-accent) 78%, #1f2933);
  background: color-mix(in srgb, var(--card-accent) 12%, #ffffff);
  font-size: 0.72rem;
  font-weight: 800;
}

.daily-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
}

.daily-value-row strong {
  color: var(--ink);
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  line-height: 1;
}

.daily-delta {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: #eef3f1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.daily-delta.up {
  color: #8f3030;
  background: #fff0f0;
}

.daily-delta.down {
  color: #245f49;
  background: #e9f5ef;
}

.daily-sparkline {
  width: 100%;
  height: 6.5rem;
  display: block;
}

.daily-sparkline .daily-line {
  fill: none;
  stroke: var(--spark-color);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 720;
  animation: drawLine 700ms ease both;
}

.daily-sparkline circle {
  fill: var(--spark-color);
  stroke: #ffffff;
  stroke-width: 2;
}

.daily-sparkline text {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.daily-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.medication-timeline-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.65rem;
}

.medication-timeline-item {
  display: grid;
  grid-template-columns: 6.9rem minmax(0, 1fr);
  gap: 0.7rem;
  min-height: 7.2rem;
  padding: 0.82rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: #fffdf8;
}

.medication-timeline-item.current {
  border-left-color: var(--green);
  background: #fbfffc;
}

.medication-timeline-item.stop {
  border-left-color: var(--red);
  background: #fffafa;
}

.medication-date {
  display: grid;
  align-content: start;
  gap: 0.25rem;
}

.medication-date strong {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.2;
}

.medication-date span,
.medication-body p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.medication-body {
  min-width: 0;
  display: grid;
  gap: 0.42rem;
}

.medication-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.medication-title-row h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.medication-badge {
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--amber);
  font-size: 0.78rem;
  font-weight: 860;
}

.medication-badge.current {
  background: var(--green);
}

.medication-badge.stop {
  background: var(--red);
}

.medication-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.medication-targets span {
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  background: #eef4f5;
  color: var(--blue-dark);
  font-size: 0.71rem;
  font-weight: 760;
}

@keyframes drawLine {
  from {
    stroke-dashoffset: 720;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.history-legend {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
  margin: -0.2rem 0 0.85rem;
}

.history-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot,
.source-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.normal {
  background: var(--green);
}

.legend-dot.attention {
  background: var(--red);
}

.source-ucla {
  background: var(--blue);
}

.source-advanced {
  background: #9a4f72;
}

.source-apple {
  background: #4b6f8f;
}

.source-whoop {
  background: #2e7d58;
}

.source-med {
  background: var(--amber);
}

.source-mixed {
  background: #596774;
}

.metric-history-list {
  display: grid;
  gap: 0.7rem;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric-info {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(14rem, auto);
  gap: 0.25rem 0.8rem;
  align-items: start;
}

.metric-info h3 {
  color: var(--ink);
  font-size: 0.98rem;
}

.metric-info h3,
.metric-zh,
.metric-meta,
.metric-med-summary {
  grid-column: 1;
}

.metric-zh,
.metric-meta,
.metric-range,
.metric-med-summary {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.metric-med-summary {
  color: #875b18;
  font-weight: 760;
}

.metric-latest {
  grid-column: 2;
  grid-row: 1 / span 4;
  justify-self: end;
  text-align: right;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
  color: var(--blue-dark);
  font-weight: 780;
}

.metric-latest strong {
  font-size: 1.35rem;
  line-height: 1;
}

.metric-latest.attention strong {
  color: var(--red);
}

.metric-spark {
  min-width: 0;
  width: 100%;
}

.sparkline {
  width: 100%;
  height: 15.2rem;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(31, 41, 51, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 41, 51, 0.035) 1px, transparent 1px),
    #ffffff;
  background-size: 100% 33.333%, 20% 100%, auto;
}

.sparkline path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline .point {
  stroke: #ffffff;
  stroke-width: 2;
}

.sparkline .point.attention {
  fill: var(--red);
}

.sparkline text {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.sparkline .year-label {
  text-anchor: middle;
  fill: #7a858e;
  font-size: 9px;
  font-weight: 720;
}

.sparkline .event-line {
  stroke: var(--amber);
  stroke-width: 2.4;
  stroke-dasharray: 5 5;
  opacity: 0.9;
}

.sparkline .event-line.stop {
  stroke: var(--red);
}

.sparkline .event-badge {
  fill: #fff7e8;
  stroke: #d79533;
  stroke-width: 1.2;
  opacity: 0.96;
}

.sparkline .event-badge.stop {
  fill: #fff4f4;
  stroke: var(--red);
}

.sparkline .event-label {
  fill: #7c4c12;
  font-size: 9px;
  font-weight: 820;
  text-anchor: middle;
}

.sparkline .event-hit {
  fill: transparent;
  stroke: transparent;
}

.metric-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.9rem, 1fr));
  gap: 0.32rem;
  margin-top: 0.55rem;
}

.metric-point-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-height: 1.5rem;
  padding: 0.16rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 690;
  white-space: nowrap;
}

.metric-point-chip.attention {
  border-color: #efb7b7;
  background: #fff4f4;
  color: #8f3030;
}

.med-event-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.med-event-list.chart-events {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0.45rem 0.1rem 0.1rem;
  margin-top: 0.35rem;
  scrollbar-width: thin;
}

.med-event-chip {
  display: inline-flex;
  flex: 0 0 auto;
  max-width: min(34rem, 90vw);
  min-height: 1.45rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.48rem;
  background: #fff7e8;
  border: 1px solid #e7c58f;
  color: #7c4c12;
  font-size: 0.74rem;
  font-weight: 720;
  white-space: nowrap;
}

.med-event-chip strong {
  margin-right: 0.25rem;
}

.med-event-chip small {
  margin-left: 0.35rem;
  color: rgba(124, 76, 18, 0.72);
  font-size: 0.7rem;
  font-weight: 650;
}

.med-event-chip.stop {
  background: #fff4f4;
  border-color: #efb7b7;
  color: #8f3030;
}

.med-event-chip.stop small {
  color: rgba(143, 48, 48, 0.72);
}

.priority-list,
.records-list {
  display: grid;
  gap: 0.65rem;
}

.priority-item {
  border-left: 4px solid var(--amber);
  background: #fffaf1;
  padding: 0.75rem;
  border-radius: 8px;
}

.priority-item strong {
  display: block;
  font-size: 0.92rem;
}

.priority-item span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.segmented-control {
  padding: 0.18rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f6;
}

.segmented-control button {
  min-height: 2rem;
  border: 0;
  background: transparent;
}

.segmented-control button.active {
  background: #ffffff;
  box-shadow: 0 3px 9px rgba(31, 41, 51, 0.12);
}

.record-group {
  display: grid;
  gap: 0.55rem;
}

.record-group h3 {
  color: var(--blue-dark);
  margin-top: 0.2rem;
  font-size: 0.88rem;
}

.record-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 4.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.record-main {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
}

.record-icon {
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 840;
}

.record-detail {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  margin-top: 0.18rem;
  overflow-wrap: anywhere;
}

.record-translation {
  color: var(--blue-dark);
  font-size: 0.84rem;
  font-weight: 730;
  line-height: 1.35;
  margin-top: 0.16rem;
  overflow-wrap: anywhere;
}

.record-meta {
  display: grid;
  justify-items: end;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.record-date {
  color: var(--muted);
  font-size: 0.8rem;
}

.record-flag.normal {
  color: var(--green);
  background: #e7f2ed;
}

.record-flag.attention {
  color: var(--red);
  background: #fdecec;
}

.record-flag.info {
  color: var(--violet);
  background: #efedf8;
}

.empty-state {
  min-height: 12rem;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #b9c7c4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 1rem;
}

@media (max-width: 980px) {
  .app-shell,
  .insights-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 0.72fr);
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .import-actions {
    width: 100%;
  }

  .primary-button,
  .ghost-button {
    flex: 1;
  }

  .side-panel,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .record-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .metric-info {
    grid-template-columns: 1fr;
  }

  .metric-latest {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    text-align: left;
    justify-content: flex-start;
  }

  .sparkline {
    height: 10.5rem;
  }

  .record-meta {
    width: 100%;
    justify-items: start;
  }

  .source-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .daily-trends-panel .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .medication-timeline-item {
    grid-template-columns: 1fr;
  }

  .range-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .range-toggle button {
    flex: 1;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .daily-sparkline .daily-line {
    animation: none;
  }

  .daily-trend-card,
  .primary-button,
  .ghost-button,
  .icon-button,
  .segmented-control button {
    transition: none;
  }
}

/* 2026 health cockpit redesign */
:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --ink: #17252a;
  --muted: #65757a;
  --line: #dce7e3;
  --blue: #176b72;
  --blue-dark: #0e4f57;
  --green: #278267;
  --red: #c64a5b;
  --amber: #c07a2c;
  --violet: #7357b4;
  --shadow: 0 10px 35px rgba(25, 65, 63, 0.07);
  --shadow-raised: 0 18px 55px rgba(25, 65, 63, 0.11);
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 8% -4%, rgba(39, 130, 103, 0.13), transparent 28rem),
    radial-gradient(circle at 92% 4%, rgba(115, 87, 180, 0.08), transparent 26rem),
    #f3f7f6;
}

.app-header {
  min-height: 5.4rem;
  padding: 1rem max(1.25rem, calc((100vw - 1440px) / 2));
  border-bottom-color: rgba(23, 107, 114, 0.1);
  background: rgba(248, 251, 250, 0.9);
  box-shadow: 0 1px 0 rgba(255,255,255,.8);
}

.app-header > div:first-child {
  position: relative;
  padding-left: 3.35rem;
}

.app-header > div:first-child::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 13px;
  transform: translateY(-50%);
  background:
    linear-gradient(90deg, transparent 18%, #fff 18% 40%, transparent 40%) 50% 50% / 60% 22% no-repeat,
    linear-gradient(transparent 18%, #fff 18% 40%, transparent 40%) 50% 50% / 22% 60% no-repeat,
    linear-gradient(145deg, #16757a, #2b9275);
  box-shadow: 0 8px 20px rgba(23,107,114,.24);
}

.eyebrow {
  color: var(--green);
  font-size: .7rem;
  letter-spacing: .11em;
}

h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
  letter-spacing: -.035em;
}

.app-shell {
  display: block;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.15rem 1.25rem 4rem;
}

.dashboard {
  gap: .9rem;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

.source-banner {
  padding: .8rem 1rem;
  border-color: #d7e8e3;
  border-radius: 14px;
  background: linear-gradient(110deg, #edf8f4, #f8fbfa 62%, #f4f1fb);
  box-shadow: none;
}

.source-banner strong {
  color: #185b52;
  font-size: .9rem;
}

.source-banner span {
  color: #60716d;
  font-size: .8rem;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .42rem;
}

.source-links a {
  padding: .42rem .65rem;
  border: 1px solid rgba(23,107,114,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  font-size: .74rem;
}

.summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
}

.summary-strip article {
  position: relative;
  min-height: 6.6rem;
  padding: 1rem 1.1rem;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(145deg, #fff, #f8fbfa);
  box-shadow: var(--shadow);
}

.summary-strip article::after {
  content: "";
  position: absolute;
  width: 4.8rem;
  height: 4.8rem;
  right: -1.8rem;
  bottom: -2.4rem;
  border-radius: 999px;
  background: rgba(23,107,114,.08);
}

.summary-strip article.attention-summary {
  background: linear-gradient(145deg, #fff, #fff3f4);
}

.summary-strip article.attention-summary::after {
  background: rgba(198,74,91,.12);
}

.summary-strip p {
  order: -1;
  margin: 0 0 .5rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 760;
  letter-spacing: .02em;
}

.summary-strip span {
  color: var(--blue-dark);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -.04em;
}

.attention-summary span {
  color: var(--red);
}

.side-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: .7rem;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(9rem, .65fr) minmax(10rem, 1fr) minmax(9rem, .8fr) minmax(15rem, 1.6fr);
  align-items: end;
  gap: .65rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.88);
  box-shadow: none;
}

.filter-title {
  align-self: center;
  display: grid;
  gap: .16rem;
  padding-left: .25rem;
}

.filter-title span {
  font-size: .88rem;
  font-weight: 820;
}

.filter-title small,
.import-panel summary small {
  color: var(--muted);
  font-size: .7rem;
}

.filter-field {
  display: grid;
  gap: .32rem;
}

.filter-field input,
.filter-field select {
  height: 2.35rem;
  border-color: #d8e4e0;
  border-radius: 10px;
  background: #f8fbfa;
  font-size: .82rem;
}

.import-panel {
  width: 13.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.88);
  box-shadow: none;
}

.import-panel summary {
  display: grid;
  gap: .12rem;
  padding: .78rem 2.2rem .78rem .9rem;
  cursor: pointer;
  list-style: none;
  position: relative;
}

.import-panel summary::-webkit-details-marker { display: none; }
.import-panel summary::after {
  content: "+";
  position: absolute;
  right: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  font-size: 1.15rem;
  font-weight: 500;
}

.import-panel[open] {
  width: min(40rem, 100%);
}

.import-panel[open] summary::after { content: "−"; }
.import-panel summary span { font-size: .82rem; font-weight: 800; }
.import-content { padding: 0 .8rem .8rem; }
.import-content textarea { min-height: 8rem; font-size: .8rem; border-radius: 10px; }
.import-actions { align-items: stretch; flex-wrap: wrap; margin-top: .55rem; }
.import-actions button { flex: 1 1 8.5rem; font-size: .76rem; }

.insights-layout {
  gap: .9rem;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

.priority-panel { order: 1; }
.metric-history-panel { order: 2; }
.medication-timeline-panel { order: 3; }
.daily-trends-panel { order: 4; }

[hidden] {
  display: none !important;
}

.daily-trends-panel,
.medication-timeline-panel,
.metric-history-panel,
.priority-panel,
.records-panel {
  min-width: 0;
  padding: 1rem;
  border: 0;
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: rgba(255,255,255,.94);
}

.panel-heading {
  margin-bottom: .8rem;
}

.panel-heading h2 {
  font-size: 1.05rem;
  letter-spacing: -.015em;
}

.panel-subtitle {
  font-size: .76rem;
}

.priority-panel {
  background: linear-gradient(145deg, #fff, #fff9f2);
}

.priority-list {
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: .55rem;
}

.priority-item {
  min-height: 5rem;
  padding: .75rem .85rem;
  border: 1px solid #f1dfc6;
  border-left: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.76);
}

.priority-item strong { font-size: .86rem; }
.priority-item span { font-size: .75rem; line-height: 1.4; }

.daily-trend-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(17rem, 23rem);
  grid-template-columns: none;
  gap: .65rem;
  overflow-x: auto;
  padding: .08rem .08rem .65rem;
  scroll-snap-type: x proximity;
  scrollbar-color: #b7cbc5 transparent;
  width: 100%;
  max-width: 100%;
}

.daily-trend-card {
  min-height: 12.2rem;
  padding: .82rem;
  border: 1px solid #e1eae7;
  border-radius: 14px;
  box-shadow: none;
  scroll-snap-align: start;
}

.daily-trend-card::before {
  inset: 0 auto 0 0;
  width: .22rem;
  height: auto;
}

.daily-trend-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(25,65,63,.09);
}

.daily-value-row strong { font-size: 1.75rem; }
.daily-sparkline { height: 5.6rem; }
.daily-sparkline .daily-line { stroke-width: 2.6; }

.range-toggle {
  border: 0;
  border-radius: 10px;
  background: #edf4f2;
}

.range-toggle button { min-height: 1.85rem; font-size: .74rem; }

.medication-timeline-list {
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
}

.medication-timeline-item {
  min-height: 6.5rem;
  border-width: 1px;
  border-left-width: 3px;
  border-radius: 12px;
  background: #fffdf8;
}

.metric-row {
  border-color: #e1eae7;
  border-radius: 14px;
  background: var(--surface-soft);
}

.sparkline {
  height: 13rem;
  border: 0;
  border-radius: 12px;
  background:
    linear-gradient(rgba(23,107,114,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,107,114,.04) 1px, transparent 1px),
    #fff;
  background-size: 100% 33.333%, 20% 100%, auto;
}

.sparkline path { stroke-width: 2.6; }

.source-cityofhope { background: var(--violet); }

.records-panel {
  margin-top: 0;
}

.record-card {
  min-height: 4.2rem;
  border-color: #e1eae7;
  border-radius: 12px;
  background: #fafcfb;
}

.record-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23,107,114,.22);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-title { grid-column: 1 / -1; }
  .side-panel { grid-template-columns: 1fr; }
  .import-panel { width: 100%; }
}

@media (max-width: 640px) {
  .app-header { min-height: 4.6rem; padding: .8rem 1rem; }
  .app-header > div:first-child { padding-left: 2.85rem; }
  .app-header > div:first-child::before { width: 2.15rem; height: 2.15rem; border-radius: 11px; }
  .eyebrow { font-size: .58rem; }
  h1 { font-size: 1.42rem; }
  .header-actions .primary-button { display: none; }
  .app-shell { padding: .75rem .7rem 3rem; }
  .source-banner { align-items: stretch; }
  .source-links { justify-content: flex-start; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip article { min-height: 5.5rem; padding: .8rem; border-radius: 14px; }
  .summary-strip span { font-size: 1.55rem; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .daily-trends-panel,
  .medication-timeline-panel,
  .metric-history-panel,
  .priority-panel,
  .records-panel { padding: .8rem; border-radius: 15px; }
  .daily-trend-list { grid-auto-columns: minmax(15.8rem, 87vw); }
  .panel-heading { align-items: flex-start; }
  .metric-info { grid-template-columns: 1fr; }
  .metric-latest { grid-column: 1; grid-row: auto; justify-self: start; text-align: left; }
}

/* Daily focus: weight, WHOOP and actionable alerts stay above the rest of the dashboard. */
.top-health-stack {
  order: -2;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(21rem, .72fr);
  align-items: start;
  gap: .9rem;
  min-width: 0;
}

.source-banner {
  order: -1;
}

.top-focus-panel,
.top-alert-panel {
  order: initial;
  min-width: 0;
}

.top-focus-panel {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 92% -8%, rgba(45, 146, 117, .14), transparent 29%),
    linear-gradient(145deg, #ffffff, #f3faf7);
}

.top-focus-panel::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: .22rem;
  background: linear-gradient(90deg, #176b72, #2e926f 62%, #6b58a8);
}

.top-alert-panel {
  background:
    radial-gradient(circle at 105% -10%, rgba(198, 74, 91, .12), transparent 34%),
    linear-gradient(145deg, #ffffff, #fff9f5);
}

.panel-kicker {
  margin: 0 0 .24rem;
  color: var(--green);
  font-size: .66rem;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.alert-kicker {
  color: #a34739;
}

.top-focus-heading {
  align-items: flex-start;
  gap: 1rem;
}

.focus-controls {
  display: grid;
  justify-items: end;
  gap: .48rem;
}

.focus-meta {
  display: inline-flex;
  min-height: 1.45rem;
  align-items: center;
  padding: .16rem .52rem;
  border-radius: 999px;
  color: #266452;
  background: #e8f4ee;
  font-size: .72rem;
  font-weight: 780;
  white-space: nowrap;
}

.top-focus-panel .daily-trend-list {
  grid-auto-columns: minmax(15.8rem, 19rem);
}

.top-focus-panel .daily-trend-card {
  min-height: 12rem;
  background: rgba(255, 255, 255, .86);
}

.daily-trend-card.attention {
  border-color: rgba(198, 74, 91, .48);
  background: linear-gradient(155deg, #ffffff, #fff4f5);
}

.daily-trend-card.attention::before {
  background: var(--red);
}

.daily-pill.attention {
  color: #9c3342;
  background: #fde8eb;
}

.top-alert-panel .panel-heading {
  align-items: flex-start;
}

.top-alert-panel .priority-list {
  grid-template-columns: 1fr;
  align-content: start;
  max-height: 25rem;
  overflow-y: auto;
  padding-right: .2rem;
  overscroll-behavior: contain;
  scrollbar-color: #c7d7d2 transparent;
}

.priority-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: start;
  gap: .65rem;
  min-height: 0;
  border: 1px solid #eadfcf;
  border-left-width: 1px;
  padding: .72rem;
}

.priority-item.attention {
  border-color: #efc7cc;
  background: #fff5f6;
}

.priority-item.whoop {
  border-color: #cce4d8;
  background: #f4faf7;
}

.priority-item.info {
  border-color: #cbdde7;
  background: #f4f8fb;
}

.priority-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  color: #9c3342;
  background: #f9dfe3;
  font-size: .72rem;
  font-weight: 900;
}

.priority-item.whoop .priority-icon {
  color: #24634b;
  background: #dcefe5;
}

.priority-item.info .priority-icon {
  color: #285d7b;
  background: #dfeef6;
  font-size: 1rem;
}

.priority-copy {
  min-width: 0;
}

.priority-copy strong {
  line-height: 1.3;
}

.priority-copy span {
  line-height: 1.45;
}

.priority-clear {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  align-items: center;
  gap: .75rem;
  min-height: 5.5rem;
  padding: .8rem;
  border: 1px solid #cce4d8;
  border-radius: 12px;
  background: #f4faf7;
}

.priority-clear > span {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  color: #fff;
  background: #2e8a67;
  font-weight: 900;
}

.priority-clear strong {
  font-size: .88rem;
}

.priority-clear p {
  margin-top: .2rem;
  color: var(--muted);
  font-size: .76rem;
}

.compact-empty {
  min-height: 8rem;
}

@media (max-width: 1040px) {
  .top-health-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .top-alert-panel .priority-list {
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  }
}

@media (max-width: 640px) {
  .top-health-stack {
    gap: .7rem;
  }

  .top-focus-heading {
    display: grid;
  }

  .focus-controls {
    width: 100%;
    justify-items: start;
  }

  .top-focus-panel .range-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .top-focus-panel .range-toggle button {
    min-width: 0;
  }

  .top-focus-panel .daily-trend-list {
    grid-auto-columns: minmax(15.5rem, 86vw);
  }

  .top-alert-panel .priority-list {
    grid-template-columns: 1fr;
  }
}
