:root {
  --ink: #17202a;
  --muted: #64717d;
  --line: #d9e1e7;
  --paper: #f7f9fa;
  --surface: #ffffff;
  --blue: #245c86;
  --blue-dark: #173d5a;
  --warning: #805d18;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  line-height: 1.55;
}

a {
  color: var(--blue);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid #9bc7e7;
  outline-offset: 3px;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 250, 0.92);
}

.site-header__inner,
.hero,
.section,
.site-footer,
.auth-shell,
.portal-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
}

.site-header nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.brand {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: clamp(48px, 8vw, 112px);
  align-items: center;
  padding-top: clamp(72px, 12vw, 144px);
  padding-bottom: clamp(72px, 12vw, 144px);
}

.hero h1,
.portal-header h1,
.auth-panel h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.8rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.lede {
  max-width: 600px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--blue);
  border-radius: 4px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.button--quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--blue-dark);
}

.button--quiet:hover {
  background: var(--surface);
  border-color: var(--blue);
}

.trust-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.signal-panel,
.auth-panel,
.portal-placeholder {
  border: 1px solid var(--line);
  background: var(--surface);
}

.signal-panel {
  padding: 28px;
}

.signal-panel__header,
.portal-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.signal-panel__header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.signal-panel__header strong {
  color: var(--blue);
}

.signal-list {
  margin: 0;
}

.signal-list > div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.signal-list dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.signal-list dd {
  margin: 0;
  font-weight: 600;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 24px;
}

.pipeline span {
  padding: 10px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.section {
  padding-bottom: 112px;
}

.section--narrow {
  max-width: 760px;
}

.section h2,
.portal-placeholder h2 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.section p:last-child {
  max-width: 680px;
  margin-top: 24px;
  color: var(--muted);
}

.site-footer {
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.site-footer strong {
  color: var(--ink);
}

.auth-shell,
.portal-shell {
  padding-top: clamp(64px, 10vw, 112px);
  padding-bottom: 112px;
}

.auth-panel {
  width: min(560px, 100%);
  padding: clamp(28px, 6vw, 56px);
}

.auth-panel h1 {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
}

.auth-panel > p:not(.eyebrow):not(.notice) {
  color: var(--muted);
}

.auth-panel form {
  display: grid;
  gap: 20px;
  margin-top: 32px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  font-size: 0.9rem;
  font-weight: 700;
}

.form-field input,
.form-field select {
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--blue);
  outline: 3px solid #9bc7e7;
  outline-offset: 1px;
}

.auth-panel form .button {
  justify-self: start;
}

.notice {
  width: fit-content;
  margin: 16px auto;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.notice--warning {
  margin: 24px 0;
  border-color: #e4d3a7;
  color: var(--warning);
}

.portal-header {
  align-items: flex-start;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.portal-header h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
}

.portal-header p:last-child {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
}

.portal-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-actions form,
.settings-section form {
  margin: 0;
}

.portal-actions .button,
.settings-section .button {
  font: inherit;
  cursor: pointer;
}

.settings-section {
  margin-top: 48px;
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--line);
  background: var(--surface);
}

.settings-section__header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.settings-section__header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.settings-section__header > p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
}

.settings-section > form {
  display: grid;
  max-width: 560px;
  gap: 20px;
  margin-top: 28px;
}

.session-table-wrap {
  margin-top: 28px;
  overflow-x: auto;
}

.session-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.session-table th,
.session-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.session-table thead th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-table tbody th {
  min-width: 180px;
  font-weight: 700;
}

.session-table tbody td {
  white-space: nowrap;
}

.session-table .button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.session-type {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.session-table .status-label {
  display: inline-block;
  margin-top: 10px;
}

.empty-state {
  margin: 28px 0 0;
  color: var(--muted);
}

.settings-section > .button {
  margin-top: 24px;
}

.settings-section--danger {
  border-color: #dfb7b7;
}

.button--danger {
  border-color: #a43f3f;
  background: #a43f3f;
}

.button--danger:hover {
  border-color: #7f2f2f;
  background: #7f2f2f;
}

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

.status-label {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #a8c4d8;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.portal-placeholder {
  max-width: 760px;
  margin-top: 48px;
  padding: clamp(28px, 6vw, 56px);
}

.portal-placeholder > p:not(.eyebrow) {
  color: var(--muted);
}

.portal-placeholder ul {
  margin: 28px 0 0;
  padding-left: 20px;
}

.portal-placeholder li + li {
  margin-top: 12px;
}

.portal-placeholder .button {
  margin-top: 28px;
}

.measurement-history,
.measurement-form-panel,
.measurement-empty,
.measurement-preview {
  margin-top: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.measurement-history,
.measurement-form-panel,
.measurement-empty,
.measurement-preview {
  padding: clamp(24px, 5vw, 40px);
}

.measurement-table-wrap {
  overflow-x: auto;
}

.measurement-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.measurement-table th,
.measurement-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.measurement-table thead th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.measurement-table tbody th {
  min-width: 190px;
}

.measurement-table time {
  white-space: nowrap;
}

.measurement-unit,
.measurement-preview small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.source-label {
  color: var(--blue-dark);
  font-weight: 700;
}

.table-action {
  display: inline-block;
  margin-right: 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.table-action--danger {
  color: #a43f3f;
}

.measurement-read-only {
  color: var(--muted);
  font-size: 0.86rem;
}

.measurement-empty h2 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.measurement-empty p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
}

.measurement-empty .button {
  margin-top: 12px;
}

.measurement-form-panel form {
  display: grid;
  max-width: 560px;
  gap: 20px;
}

.measurement-form-panel small {
  color: var(--muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.measurement-preview__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.measurement-preview h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.measurement-preview__list {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.measurement-preview__list li {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.sleep-history,
.sleep-empty,
.sleep-form-panel,
.sleep-summary,
.sleep-timeline-panel {
  margin-top: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: clamp(24px, 5vw, 40px);
}

.sleep-table-wrap,
.sleep-segment-table-wrap {
  overflow-x: auto;
}

.sleep-table,
.sleep-segment-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.sleep-table th,
.sleep-table td,
.sleep-segment-table th,
.sleep-segment-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.sleep-table thead th,
.sleep-segment-table thead th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sleep-table time,
.sleep-segment-table time {
  white-space: nowrap;
}

.activity-history,
.activity-empty {
  margin-top: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: clamp(24px, 5vw, 40px);
}

.activity-table-wrap {
  overflow-x: auto;
}

.activity-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.activity-table th,
.activity-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.activity-table thead th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.activity-table time {
  white-space: nowrap;
}

.activity-empty h2 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.activity-empty p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
}

.sleep-empty h2 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.sleep-empty p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
}

.sleep-empty .button {
  margin-top: 12px;
}

.sleep-summary__header,
.sleep-timeline-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.sleep-summary__header h2,
.sleep-timeline-panel__header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.sleep-summary__header > p {
  margin: 0;
}

.sleep-session-interval {
  margin: 28px 0 0;
  color: var(--muted);
}

.sleep-session-interval time {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.sleep-summary__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  margin: 28px 0 0;
  padding: 0;
  background: var(--line);
  border: 1px solid var(--line);
  list-style: none;
}

.sleep-summary__stat {
  margin: 0;
  padding: 18px;
  background: var(--surface);
}

.sleep-summary__stat dt {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sleep-summary__stat dd {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.sleep-coverage {
  display: inline-block;
  margin: 24px 0 0;
  padding: 7px 10px;
  border: 1px solid #a8c4d8;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sleep-coverage[data-coverage="partial"] {
  border-color: #e2c67a;
  color: var(--warning);
}

.sleep-coverage[data-coverage="none"] {
  border-color: var(--line);
  color: var(--muted);
}

.sleep-derived-note {
  margin: 16px 0 0;
  color: var(--muted);
}

.sleep-timeline-panel__header > p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
}

.sleep-timeline {
  position: relative;
  height: 64px;
  margin-top: 32px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(25% - 1px),
      #edf2f5 calc(25% - 1px),
      #edf2f5 25%
    );
}

.sleep-timeline__segment {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 2px;
  min-width: 2px;
}

.sleep-timeline__axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.sleep-timeline__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.sleep-timeline__legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sleep-timeline__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.sleep-timeline__segment--in_bed,
.sleep-timeline__swatch--in_bed {
  background: #3d5a73;
}

.sleep-timeline__segment--awake,
.sleep-timeline__swatch--awake {
  background: #c9a227;
}

.sleep-timeline__segment--asleep,
.sleep-timeline__swatch--asleep {
  background: #245c86;
}

.sleep-timeline__segment--asleep_unspecified,
.sleep-timeline__swatch--asleep_unspecified {
  background: #8b99a5;
}

.sleep-timeline__segment--asleep_core,
.sleep-timeline__swatch--asleep_core {
  background: #2f6f9f;
}

.sleep-timeline__segment--asleep_deep,
.sleep-timeline__swatch--asleep_deep {
  background: #173d5a;
}

.sleep-timeline__segment--asleep_rem,
.sleep-timeline__swatch--asleep_rem {
  background: #5b7db1;
}

.sleep-segment-table-wrap {
  margin-top: 32px;
}

.sleep-segments {
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.sleep-segments legend {
  padding: 0;
  font-weight: 700;
}

.fieldset-note {
  color: var(--muted);
  font-weight: 400;
}

.fieldset-hint {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
}

.sleep-segment-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.sleep-segment-row:last-child {
  border-bottom: 0;
}

.sleep-segment-row.is-removed {
  display: none;
}

@media (max-width: 720px) {
  .site-header__inner,
  .hero,
  .section,
  .site-footer,
  .auth-shell,
  .portal-shell {
    width: min(100% - 32px, 1120px);
  }

  .site-header__inner {
    min-height: 64px;
  }

  .site-header nav {
    gap: 12px;
    font-size: 0.9rem;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 72px;
  }

  .signal-panel__header,
  .portal-header,
  .settings-section__header,
  .measurement-preview__header,
  .sleep-summary__header,
  .sleep-timeline-panel__header {
    flex-direction: column;
  }

  .sleep-segment-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
  }

  .portal-actions {
    width: 100%;
  }

  .portal-actions .button {
    width: 100%;
  }

  .settings-section {
    margin-top: 32px;
  }

  .site-footer p {
    flex-direction: column;
  }
}

/* Authenticated portal shell */
.portal-frame {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.portal-nav {
  display: flex;
  position: sticky;
  top: 0;
  flex-direction: column;
  gap: 32px;
  align-self: start;
  height: 100vh;
  padding: 28px 18px 22px;
  background: #eef3f6;
  border-right: 1px solid var(--line);
}

.portal-nav__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-nav__brand .brand {
  font-size: 1.2rem;
}

.portal-nav__links {
  display: grid;
  gap: 5px;
}

.portal-nav__menu > .portal-nav__links {
  display: grid;
}

.portal-nav__links--mobile,
.portal-nav__menu {
  display: none;
}

.portal-nav__menu > summary {
  list-style: none;
}

.portal-nav__menu > summary::-webkit-details-marker {
  display: none;
}

.portal-nav__link {
  display: block;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.portal-nav__link:hover,
.portal-nav__link.is-active {
  border-color: #c9dbe8;
  background: var(--surface);
  color: var(--blue-dark);
}

.portal-nav__link.is-active::before {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 9px 2px 0;
  border-radius: 50%;
  background: var(--blue);
  content: "";
}

.portal-nav__footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.portal-nav__account {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-nav__signout {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}

.portal-nav__toggle {
  display: none;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--blue-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.portal-content {
  min-width: 0;
}

.portal-content > .portal-shell {
  width: min(1280px, calc(100% - 80px));
  margin: 0 auto;
  padding-top: 54px;
}

.portal-loading {
  position: fixed;
  z-index: 5;
  top: 16px;
  right: 20px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

.dashboard-shell .portal-header {
  padding-bottom: 38px;
}

.dashboard-shell .portal-header h1 {
  max-width: 720px;
}

.section-heading,
.dashboard-panel__header,
.sync-summary-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.section-heading h2,
.dashboard-panel h2,
.sync-summary-panel h2,
.sync-results-panel h2,
.sync-metadata-panel h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.section-heading > p,
.dashboard-panel__header > p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.signal-grid {
  margin-top: 42px;
}

.signal-grid__cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.signal-card {
  min-height: 164px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.signal-card__label,
.signal-card__meta,
.signal-card time,
.sleep-preview__stats span,
.source-list small,
.dashboard-record-list small,
.action-list span,
.sync-table small {
  color: var(--muted);
  font-size: 0.78rem;
}

.signal-card__label {
  margin: 0;
  font-weight: 700;
}

.signal-card__value {
  margin: 26px 0 4px;
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 750;
  letter-spacing: -0.06em;
  line-height: 1;
}

.signal-card__value--empty {
  color: var(--muted);
  font-size: 1.55rem;
}

.signal-card__meta,
.signal-card time {
  display: block;
  margin: 0;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  margin-top: 20px;
}

.dashboard-columns--lower {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
}

.dashboard-panel,
.sync-history,
.sync-summary-panel,
.sync-results-panel,
.sync-metadata-panel {
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.dashboard-panel__header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.dashboard-panel__header .eyebrow,
.sync-summary-panel__header .eyebrow {
  margin-bottom: 8px;
}

.dashboard-record-list,
.source-list,
.action-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-record-list li,
.source-list li,
.action-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.dashboard-record-list li:last-child,
.source-list li:last-child,
.action-list li:last-child {
  border-bottom: 0;
}

.dashboard-record-list li > span,
.source-list li > span {
  min-width: 0;
}

.dashboard-record-list strong,
.source-list strong {
  display: block;
}

.dashboard-record-list small,
.source-list small,
.action-list span {
  display: block;
  margin-top: 3px;
}

.dashboard-state {
  padding: 26px 0 8px;
}

.dashboard-state p {
  margin: 5px 0 16px;
  color: var(--muted);
}

.sleep-preview {
  padding-top: 20px;
}

.sleep-preview__date {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.sleep-preview__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0;
}

.sleep-preview__stats div {
  padding: 12px;
  background: #f3f6f8;
}

.sleep-preview__stats span,
.sleep-preview__stats strong {
  display: block;
}

.sleep-preview__stats strong {
  margin-top: 4px;
  font-size: 1.1rem;
}

.muted-copy {
  color: var(--muted);
  font-size: 0.88rem;
}

.action-list a {
  color: var(--blue-dark);
  font-weight: 700;
}

.sync-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-top: 20px;
  padding: 22px 24px;
  border: 1px solid #c4d9e7;
  background: #edf6fb;
}

.sync-strip .eyebrow {
  margin-bottom: 7px;
}

.sync-strip h2 {
  margin: 0;
  font-size: 1.35rem;
}

.sync-strip p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
}

.sync-history,
.sync-summary-panel,
.sync-results-panel,
.sync-metadata-panel,
.sync-empty {
  margin-top: 34px;
}

.sync-table-wrap {
  overflow-x: auto;
  margin-top: 24px;
}

.sync-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.sync-table th,
.sync-table td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.sync-table thead th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sync-table td small,
.sync-table th small {
  display: block;
  margin-top: 4px;
}

.sync-id,
.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
}

.sync-status,
.sync-outcome,
.sync-retryability {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 700;
}

.sync-status--successful,
.sync-result:not([data-outcome="rejected"]) .sync-outcome,
.sync-callout--success {
  border-color: #a9d0bf;
  color: #216048;
}

.sync-status--processing {
  border-color: #b7c9d8;
  color: var(--blue-dark);
}

.sync-status--partial,
.sync-callout--attention {
  border-color: #dfc98f;
  color: var(--warning);
}

.sync-status--failed,
.sync-result[data-outcome="rejected"] .sync-outcome,
.sync-error-detail {
  border-color: #dfb7b7;
  color: #8a3636;
}

.sync-summary-panel__header > .sync-status {
  margin-top: 8px;
}

.sync-counts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  margin: 26px 0 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.sync-counts div {
  padding: 14px;
  background: var(--surface);
}

.sync-counts dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.sync-counts dd {
  margin: 5px 0 0;
  font-size: 1.6rem;
  font-weight: 750;
}

.sync-callout,
.sync-error-detail {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid;
  font-size: 0.88rem;
}

.sync-results-panel .section-heading {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.sync-results {
  display: grid;
}

.sync-result {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.sync-result__index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

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

.sync-result h3 {
  margin: 0;
  font-size: 1rem;
}

.sync-result__meta,
.sync-result__next {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.sync-error-detail {
  margin-top: 12px;
}

.sync-retryability {
  width: fit-content;
  margin-top: 4px;
}

.metadata-list {
  margin: 22px 0 0;
}

.metadata-list div {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.metadata-list dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.metadata-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.sync-empty {
  padding: 42px 28px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.sync-empty h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: -0.05em;
}

.sync-empty p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .portal-frame {
    grid-template-columns: 196px minmax(0, 1fr);
  }

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

@media (max-width: 720px) {
  .portal-frame {
    display: block;
  }

  .portal-nav {
    position: static;
    height: auto;
    min-height: 0;
    gap: 14px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .portal-nav__toggle {
    display: block;
  }

  .portal-nav__links--desktop {
    display: none;
  }

  .portal-nav__menu {
    display: block;
    width: 100%;
  }

  .portal-nav__menu:not([open]) > .portal-nav__links {
    display: none;
  }

  .portal-nav__menu[open] > .portal-nav__links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-nav__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
    padding-top: 12px;
  }

  .portal-content > .portal-shell {
    width: min(100% - 32px, 1280px);
    padding-top: 32px;
  }

  .portal-header,
  .section-heading,
  .dashboard-panel__header,
  .sync-summary-panel__header,
  .sync-strip {
    flex-direction: column;
  }

  .signal-grid {
    margin-top: 30px;
  }

  .signal-grid__cards,
  .dashboard-columns,
  .dashboard-columns--lower {
    grid-template-columns: 1fr;
  }

  .dashboard-panel,
  .sync-history,
  .sync-summary-panel,
  .sync-results-panel,
  .sync-metadata-panel {
    padding: 18px;
  }

  .sync-counts {
    grid-template-columns: repeat(2, 1fr);
  }

  .sync-counts div:last-child {
    grid-column: span 2;
  }

  .metadata-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .sync-result__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .sync-table {
    min-width: 0;
  }

  .sync-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .sync-table,
  .sync-table tbody,
  .sync-table tr,
  .sync-table th,
  .sync-table td {
    display: block;
    width: 100%;
  }

  .sync-table tr {
    padding: 12px 0;
  }

  .sync-table th,
  .sync-table td {
    padding: 8px 0 8px 96px;
    position: relative;
  }

  .sync-table td::before {
    position: absolute;
    left: 0;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .measurement-table,
  .sleep-table,
  .sleep-segment-table,
  .activity-table,
  .session-table {
    min-width: 0;
  }

  .measurement-table thead,
  .sleep-table thead,
  .sleep-segment-table thead,
  .activity-table thead,
  .session-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .measurement-table,
  .measurement-table tbody,
  .measurement-table tr,
  .measurement-table th,
  .measurement-table td,
  .sleep-table,
  .sleep-table tbody,
  .sleep-table tr,
  .sleep-table th,
  .sleep-table td,
  .sleep-segment-table,
  .sleep-segment-table tbody,
  .sleep-segment-table tr,
  .sleep-segment-table th,
  .sleep-segment-table td,
  .activity-table,
  .activity-table tbody,
  .activity-table tr,
  .activity-table th,
  .activity-table td,
  .session-table,
  .session-table tbody,
  .session-table tr,
  .session-table th,
  .session-table td {
    display: block;
    width: 100%;
  }

  .measurement-table tr,
  .sleep-table tr,
  .sleep-segment-table tr,
  .activity-table tr,
  .session-table tr {
    padding: 12px 0;
  }

  .measurement-table th,
  .measurement-table td,
  .sleep-table th,
  .sleep-table td,
  .sleep-segment-table th,
  .sleep-segment-table td,
  .activity-table th,
  .activity-table td,
  .session-table th,
  .session-table td {
    min-width: 0;
    padding: 8px 0 8px 96px;
    position: relative;
  }

  .measurement-table td::before,
  .sleep-table td::before,
  .sleep-segment-table td::before,
  .activity-table td::before,
  .session-table td::before {
    position: absolute;
    left: 0;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}
