:root {
  color: #192120;
  background: #f9f8f6;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --canvas-base: #f9f8f6;
  --canvas-header: #e9f3f0;
  --surface-primary: #fffefc;
  --surface-subtle: #f2f4f1;
  --ink-primary: #192120;
  --ink-secondary: #59615f;
  --ink-tertiary: #68736f;
  --border-subtle: #d9deda;
  --accent-coral: #ef5d3b;
  --accent-coral-text: #c74731;
  --accent-mint: #41a08d;
  --accent-mint-text: #147a64;
  --accent-mint-tint: #e7f3ef;
  --state-danger: #b6424a;
  --action-primary: #192122;
  --action-pressed: #0f1716;
  --focus-ring: rgba(20, 122, 100, 0.24);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--canvas-base);
  color-scheme: light;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas-base);
  color: var(--ink-primary);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--action-primary);
  color: var(--surface-primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.viewer-header {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--canvas-header);
}

.viewer-header__inner {
  display: flex;
  width: min(calc(100% - 48px), 1120px);
  min-height: 76px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.viewer-header__security {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 20px;
}

.security-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mint);
}

.header-expiry::before {
  content: "·";
  margin-right: 8px;
  color: var(--ink-tertiary);
}

.viewer-main {
  display: block;
  width: 100%;
  outline: none;
}

.state-view {
  display: grid;
  min-height: calc(100dvh - 132px);
  padding: 56px 20px;
  place-items: center;
}

.state-panel {
  width: min(100%, 520px);
  padding: clamp(32px, 6vw, 52px);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  background: var(--surface-primary);
  box-shadow: 0 18px 54px rgba(25, 33, 32, 0.06);
}

.accent-rule {
  display: block;
  width: 32px;
  height: 3px;
  margin-bottom: 24px;
  border-radius: 999px;
  background: var(--accent-coral);
}

.accent-rule--mint {
  background: var(--accent-mint);
}

.accent-rule--danger {
  background: var(--state-danger);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--ink-tertiary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 18px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

.state-panel h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(34px, 7vw, 46px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.state-summary {
  max-width: 42ch;
  margin: 20px 0 0;
  color: var(--ink-secondary);
  font-size: 17px;
  line-height: 1.55;
}

.access-form {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.access-form label {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}

.field-hint {
  margin: -4px 0 2px;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 20px;
}

.access-form input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  outline: 0;
  background: var(--surface-primary);
  color: var(--ink-primary);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.18em;
}

.access-form input::placeholder {
  color: #7a8581;
  letter-spacing: 0.05em;
}

.access-form input:hover {
  border-color: #b9c3be;
}

.access-form input:focus-visible {
  border-color: var(--accent-mint-text);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.access-form input[aria-invalid="true"] {
  border-color: var(--state-danger);
}

.access-form button,
.secondary-button {
  min-height: 52px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.access-form button {
  margin-top: 4px;
  border: 1px solid var(--action-primary);
  background: var(--action-primary);
  color: var(--surface-primary);
}

.access-form button:hover {
  background: var(--action-pressed);
}

.access-form button:active {
  transform: translateY(1px);
}

.access-form button:focus-visible,
.secondary-button:focus-visible,
.show-more:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.access-form button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.inline-message {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--state-danger);
  background: #f8ebec;
  color: #86313a;
  font-size: 14px;
  line-height: 20px;
}

.privacy-copy {
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 19px;
}

.loading-lines {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.loading-lines span {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-subtle);
}

.loading-lines span:nth-child(1) {
  width: 76%;
}

.loading-lines span:nth-child(2) {
  width: 100%;
}

.loading-lines span:nth-child(3) {
  width: 54%;
}

.secondary-button {
  margin-top: 28px;
  padding: 0 20px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--ink-primary);
}

.secondary-button:hover {
  border-color: var(--ink-secondary);
  background: var(--surface-subtle);
}

.report-paper {
  width: min(calc(100% - 48px), 1120px);
  margin: 32px auto 48px;
  padding: clamp(36px, 5vw, 64px);
  border: 1px solid var(--border-subtle);
  border-radius: 28px;
  background: var(--surface-primary);
  box-shadow: 0 20px 64px rgba(25, 33, 32, 0.045);
}

.report-identity {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 48px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.report-identity h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(38px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.report-identity__meta {
  align-self: end;
}

.report-identity__meta p {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 15px;
  line-height: 22px;
}

.report-identity__meta p:first-child {
  margin-bottom: 8px;
  color: var(--ink-primary);
  font-size: 17px;
  font-weight: 600;
}

.summary-section,
.trends-section,
.records-section {
  padding-top: 48px;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading--split {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 30px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.summary-grid.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.metric-summary {
  position: relative;
  min-width: 0;
  padding: 28px 32px;
}

.metric-summary + .metric-summary {
  border-left: 1px solid var(--border-subtle);
}

.metric-summary::before {
  position: absolute;
  top: 28px;
  bottom: 28px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  content: "";
}

.metric-summary--bp::before {
  background: var(--accent-coral);
}

.metric-summary--glucose::before {
  background: var(--accent-mint);
}

.metric-name,
.metric-count,
.metric-reading {
  margin: 0;
}

.metric-name {
  font-size: 17px;
  font-weight: 500;
  line-height: 24px;
}

.metric-reading {
  display: flex;
  min-width: 0;
  margin-top: 12px;
  align-items: baseline;
  gap: 10px;
}

.metric-value {
  min-width: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: clamp(38px, 5vw, 52px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1;
}

.metric-unit {
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 20px;
}

.metric-count {
  margin-top: 14px;
  color: var(--ink-tertiary);
  font-size: 14px;
  line-height: 20px;
}

.chart-disclaimer,
.records-progress {
  max-width: 38ch;
  margin: 0;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 19px;
  text-align: right;
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr);
  gap: 20px;
}

.chart-grid.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.chart-panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--surface-primary);
}

.chart-heading {
  display: flex;
  min-height: 48px;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.chart-heading h3,
.chart-heading p {
  margin: 0;
}

.chart-heading h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 24px;
}

.chart-heading p {
  margin-top: 3px;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 18px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-line {
  display: inline-block;
  width: 16px;
  border-top: 2px solid var(--accent-coral);
}

.legend-line--dashed {
  border-top-style: dashed;
}

.legend-line--mint {
  border-top-color: var(--accent-mint);
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 240px;
  margin-top: 16px;
}

#glucose-chart-panel canvas {
  height: 220px;
}

.records-table-wrap {
  width: 100%;
  overflow: hidden;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.records-table th,
.records-table td {
  padding: 16px 12px;
  text-align: left;
  vertical-align: top;
}

.records-table th {
  color: var(--ink-tertiary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 17px;
  text-transform: uppercase;
}

.records-table td {
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 20px;
}

.records-table th:nth-child(1) {
  width: 21%;
}

.records-table th:nth-child(2) {
  width: 18%;
}

.records-table th:nth-child(3) {
  width: 22%;
}

.records-table th:nth-child(4) {
  width: 22%;
}

.records-table th:nth-child(5) {
  width: 17%;
}

.record-type {
  display: inline-block;
  color: var(--ink-primary);
  font-weight: 500;
}

.record-type--bp {
  text-decoration-color: var(--accent-coral);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.record-type--glucose {
  text-decoration-color: var(--accent-mint);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.record-reading {
  color: var(--ink-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.record-note {
  display: block;
  margin-top: 5px;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 18px;
}

.record-cards {
  display: none;
}

.show-more {
  display: block;
  min-width: 210px;
  margin: 24px auto 0;
}

.report-notice {
  margin-top: 48px;
  padding: 20px 24px;
  border-left: 3px solid var(--accent-mint);
  background: var(--accent-mint-tint);
}

.report-notice p {
  margin: 0;
  color: #28544a;
  font-size: 15px;
  font-weight: 500;
  line-height: 22px;
}

.report-footer {
  display: flex;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  justify-content: space-between;
  gap: 24px;
}

.report-footer p {
  margin: 0;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 19px;
}

.site-footer {
  padding: 0 20px 28px;
  color: var(--ink-tertiary);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 820px) {
  .report-identity {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .report-identity__meta {
    align-self: auto;
  }

  .chart-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-panel canvas,
  #glucose-chart-panel canvas {
    height: 230px;
  }
}

@media (max-width: 640px) {
  .viewer-header__inner {
    width: 100%;
    min-height: 68px;
    padding: 0 16px;
  }

  .viewer-header__security {
    font-size: 12px;
  }

  .header-expiry {
    display: none;
  }

  .state-view {
    min-height: calc(100dvh - 116px);
    padding: 24px 14px;
    place-items: start stretch;
  }

  .state-panel {
    width: 100%;
    padding: 30px 24px;
    border-radius: 20px;
  }

  .state-panel h1 {
    font-size: 36px;
  }

  .report-paper {
    width: 100%;
    margin: 0;
    padding: 36px 20px 40px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .report-identity {
    padding-bottom: 32px;
  }

  .report-identity h1 {
    font-size: 40px;
  }

  .summary-section,
  .trends-section,
  .records-section {
    padding-top: 40px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .metric-summary {
    padding: 24px 20px;
  }

  .metric-summary + .metric-summary {
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
  }

  .metric-summary::before {
    top: 24px;
    bottom: 24px;
  }

  .metric-value {
    font-size: 44px;
  }

  .section-heading--split {
    display: block;
  }

  .chart-disclaimer,
  .records-progress {
    margin-top: 10px;
    text-align: left;
  }

  .chart-panel {
    padding: 20px 16px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .chart-heading {
    display: block;
  }

  .chart-legend {
    margin-top: 10px;
    justify-content: start;
  }

  .chart-panel canvas,
  #glucose-chart-panel canvas {
    height: 210px;
  }

  .records-table-wrap {
    display: none;
  }

  .record-cards {
    display: grid;
    border-top: 1px solid var(--border-subtle);
  }

  .record-card {
    padding: 22px 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .record-card__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
  }

  .record-card__header p,
  .record-card__header time {
    margin: 0;
  }

  .record-card__header time {
    color: var(--ink-tertiary);
    font-size: 13px;
    line-height: 18px;
    text-align: right;
  }

  .record-card__reading {
    margin: 16px 0 0;
    color: var(--ink-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    font-size: 28px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    line-height: 34px;
  }

  .record-card__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
    margin: 18px 0 0;
  }

  .record-card__details div {
    min-width: 0;
  }

  .record-card__details dt {
    color: var(--ink-tertiary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    line-height: 16px;
    text-transform: uppercase;
  }

  .record-card__details dd {
    margin: 3px 0 0;
    color: var(--ink-secondary);
    font-size: 14px;
    line-height: 20px;
  }

  .record-card__note {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    color: var(--ink-secondary);
    font-size: 14px;
    line-height: 21px;
  }

  .report-notice {
    margin-top: 40px;
    padding: 18px 18px;
  }

  .report-footer {
    display: block;
  }

  .report-footer p + p {
    margin-top: 8px;
  }

  .site-footer {
    padding-top: 24px;
  }
}

@media (max-width: 390px) {
  .wordmark {
    font-size: 14px;
  }

  .viewer-header__security {
    max-width: 144px;
    justify-content: end;
    text-align: right;
  }

  .state-panel {
    padding: 28px 20px;
  }

  .report-identity h1 {
    font-size: 38px;
  }

  .metric-reading {
    flex-wrap: wrap;
  }

  .record-card__details {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .security-status,
  .accent-rule,
  .metric-summary::before {
    forced-color-adjust: none;
  }
}

@media print {
  body {
    background: #fff;
  }

  .viewer-header,
  .site-footer,
  .show-more {
    display: none !important;
  }

  .report-paper {
    width: 100%;
    margin: 0;
    padding: 24px;
    border: 0;
    box-shadow: none;
  }

  .chart-panel {
    break-inside: avoid;
  }

  .records-table-wrap {
    overflow: visible;
  }
}
