:root {
  --ink: #17343a;
  --muted: #6d7f83;
  --line: #dce5e3;
  --line-strong: #b9cbc6;
  --paper: #f6f8f6;
  --panel: #ffffff;
  --teal: #176e6b;
  --teal-dark: #145954;
  --date-count: 69;
  --label-width: 244px;
  --cell-width: 66px;
  --timeline-width: 4554px;
  --header-height: 92px;
  --chart-height: 220px;
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #f2f6f4 0%, #f8faf8 230px, var(--paper) 100%);
}

body {
  font-size: 14px;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

.app-shell {
  width: min(100%, 1740px);
  margin: 0 auto;
  padding: 42px 34px 26px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 720;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.header-meta #dateRange {
  color: var(--ink);
  font-weight: 700;
}

.meta-divider {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.control-group label {
  white-space: nowrap;
}

select {
  min-width: 132px;
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.check-control {
  gap: 16px;
}

.check-control label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input[type="checkbox"] {
  accent-color: var(--teal);
}

.control-spacer {
  flex: 1;
}

.data-summary {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sheet-viewport {
  overflow: auto;
  margin-top: 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(27, 68, 62, 0.06);
  scrollbar-color: #a9c3bd #edf2f0;
}

.sheet-grid {
  width: calc(var(--label-width) + var(--timeline-width));
  min-width: 100%;
}

.sheet-corner {
  position: sticky;
  left: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: var(--label-width);
  height: var(--header-height);
  padding: 0 20px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: #eff5f2;
}

.corner-kicker {
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sheet-corner strong {
  font-size: 16px;
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 7;
  width: var(--timeline-width);
  height: var(--header-height);
  border-bottom: 1px solid var(--line-strong);
  background: #fff;
}

.phase-track,
.date-track {
  display: grid;
  grid-template-columns: repeat(var(--date-count), var(--cell-width));
  width: calc(var(--timeline-width) - var(--axis-offset) - var(--timeline-right-offset));
  margin-left: var(--axis-offset);
}

.phase-track {
  height: 39px;
  border-bottom: 1px solid var(--line);
}

.phase-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.54);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.phase-cell span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-track {
  height: 53px;
}

.date-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding-left: 9px;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.date-cell.is-today {
  background: #e7f4ee;
  box-shadow: inset 0 -3px 0 var(--teal);
}

.date-label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.weekday-label {
  color: var(--muted);
  font-size: 10px;
}

.sheet-body {
  width: calc(var(--label-width) + var(--timeline-width));
}

.section-row {
  display: grid;
  grid-template-columns: var(--label-width) var(--timeline-width);
  min-height: var(--chart-height);
  border-bottom: 1px solid var(--line-strong);
}

.label-panel {
  position: sticky;
  left: 0;
  z-index: 5;
  width: var(--label-width);
  padding: 18px 16px 14px 20px;
  border-right: 1px solid var(--line-strong);
  background: #fbfdfc;
}

.section-row:nth-child(odd) .label-panel {
  background: #f5f9f7;
}

.label-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.label-title strong {
  font-size: 16px;
}

.unit-chip {
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.series-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.series-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #4e6265;
  font-size: 11px;
}

.series-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.series-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-panel {
  position: relative;
  width: var(--timeline-width);
  height: var(--chart-height);
  overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(to right, rgba(214, 226, 222, 0.74) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(225, 234, 231, 0.75) 1px, transparent 1px);
  background-size: var(--cell-width) 100%, 100% 44px;
}

.section-row:nth-child(odd) .chart-panel {
  background-color: #fcfefd;
}

.chart-panel svg {
  display: block;
  width: var(--timeline-width);
  height: var(--chart-height);
  overflow: visible;
}

.text-chart-panel {
  min-height: 132px;
}

.text-chart-panel svg {
  height: 132px;
}

.text-timeline-baseline {
  stroke: rgba(76, 111, 104, 0.42);
  stroke-width: 1.1;
}

.text-timeline-value {
  fill: #8b3f5d;
  font-size: 13px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #f9fbfa;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.text-timeline-hit-area {
  fill: transparent;
  cursor: crosshair;
}

.sleep-section-row {
  min-height: 330px;
}

.sleep-chart-panel {
  height: 330px !important;
  background-size: var(--cell-width) 100%, 100% 50px;
}

.sleep-chart-panel svg {
  height: 330px;
}

.axis-label {
  fill: #829492;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.sleep-chart-title {
  fill: #17343a;
  font-size: 20px;
  font-weight: 720;
}

.sleep-chart-subtitle {
  fill: #6d7f83;
  font-size: 13px;
  font-weight: 600;
}

.sleep-chart-count {
  fill: #829492;
  font-size: 11px;
}

.sleep-axis-label {
  fill: #829492;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sleep-band {
  cursor: crosshair;
}

.sleep-band:hover {
  fill: #285fc8;
}

.sleep-value-label {
  fill: #3974e6;
  font-size: 10px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.training-section-row {
  min-height: 300px;
}

.training-chart-panel {
  height: 300px !important;
  background-size: var(--cell-width) 100%, 100% 48px;
}

.training-chart-panel svg {
  height: 300px;
}

.training-chart-title {
  fill: #17343a;
  font-size: 13px;
  font-weight: 720;
}

.training-chart-subtitle {
  fill: #829492;
  font-size: 10px;
}

.training-axis-label {
  fill: #829492;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.training-lane-label {
  fill: #829492;
  font-size: 10px;
  font-weight: 700;
}

.training-cell-value {
  fill: #4e6265;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.training-formal-value {
  fill: #829492;
  font-size: 8px;
}

.axis-line {
  stroke: rgba(132, 159, 152, 0.45);
  stroke-width: 1;
}

.phase-divider {
  stroke: rgba(45, 90, 80, 0.5);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
}

.series-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.series-point {
  stroke: #fff;
  stroke-width: 1.4;
}

.hover-line {
  stroke: #17343a;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0;
  pointer-events: none;
}

.chart-hit-area {
  fill: transparent;
  cursor: crosshair;
}

.tooltip {
  position: fixed;
  z-index: 30;
  display: none;
  min-width: 154px;
  padding: 10px 12px;
  border: 1px solid #b9cbc6;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 12px 26px rgba(23, 52, 58, 0.14);
  pointer-events: none;
}

.tooltip-date {
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.tooltip-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  color: #4e6265;
  font-size: 11px;
}

.tooltip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tooltip-value {
  margin-left: auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 800px) {
  :root {
    --date-count: 69;
    --label-width: 178px;
    --cell-width: 60px;
    --timeline-width: 4140px;
  }

  .app-shell {
    padding: 24px 14px 18px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .header-meta {
    white-space: normal;
  }

  .control-bar {
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 14px 0;
  }

  .control-spacer {
    display: none;
  }

  .data-summary {
    width: 100%;
  }

  .page-footer {
    flex-direction: column;
    gap: 5px;
  }
}

/* Full-screen workbench treatment */
:root {
  --ink: #17333a;
  --muted: #718280;
  --line: rgba(38, 79, 75, 0.14);
  --line-strong: rgba(38, 79, 75, 0.24);
  --paper: #eef3f1;
  --panel: #f9fbfa;
  --teal: #15766e;
  --label-width: 220px;
  --cell-width: 72px;
  --axis-offset: 68px;
  --timeline-right-offset: 0px;
  --header-height: 76px;
  --focus-row-height: 640px;
}

html,
body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #eef3f1;
}

body {
  font-size: 13px;
}

.app-shell {
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 100%;
  margin: 0;
  padding: 18px 0 0;
  display: flex;
  flex-direction: column;
}

.page-header {
  align-items: center;
  gap: 22px;
  padding: 0 28px 14px;
  border-bottom: 1px solid var(--line);
}

.page-header > .brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.header-meta {
  padding: 0;
  color: var(--muted);
  font-size: 12px;
}

.control-bar {
  min-height: 52px;
  padding: 8px 28px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 251, 250, 0.72);
}

.control-group {
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.range-control {
  gap: 0;
}

.control-label {
  white-space: nowrap;
}

.range-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: none;
}

.range-button {
  min-width: 34px;
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.range-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.3);
}

.range-button.is-active {
  background: rgba(255, 255, 255, 0.56);
  color: var(--teal);
  box-shadow: 0 1px 5px rgba(34, 54, 51, 0.12);
}

.zoom-control {
  min-width: 126px;
  gap: 7px;
}

.zoom-control input[type="range"] {
  width: 86px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}

.zoom-control output {
  min-width: 34px;
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

select {
  min-width: 148px;
  height: 30px;
  padding: 0 22px 0 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background-color: transparent;
  color: var(--ink);
  font-weight: 650;
}

.check-control {
  gap: 10px;
}

.check-control label {
  gap: 0;
  color: var(--muted);
}

input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 28px;
  height: 16px;
  margin: 0;
  border: 1px solid rgba(64, 76, 74, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 52, 50, 0.2);
  transition: transform 160ms ease;
}

input[type="checkbox"]:checked {
  border-color: var(--teal);
  background: var(--teal);
}

input[type="checkbox"]:checked::after {
  transform: translateX(12px);
}

.data-summary {
  color: var(--muted);
  font-size: 11px;
  margin-left: 2px;
}

.date-range-button {
  display: inline-flex;
  align-items: center;
  height: 32px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.22);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.date-range-button:hover,
.date-range-button:focus-visible {
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 3px 10px rgba(34, 54, 51, 0.1);
  outline: none;
}

/* Single-row control header: keep the brand, controls, and date range aligned. */
.page-header {
  gap: 18px;
  padding: 6px 16px;
  align-items: center;
  min-height: 56px;
}

.brand-block {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 0;
}

.brand-block h1 {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: clamp(160px, 18vw, 220px);
  margin-left: -8px;
  height: auto;
  line-height: 0;
  white-space: nowrap;
}

.brand-block h1 img {
  display: block;
  width: 100%;
  height: auto;
}

.brand-block .data-summary {
  flex: 0 0 auto;
  align-self: flex-end;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.topbar-controls {
  flex: 0 0 auto;
  margin-left: auto;
  min-width: 0;
  min-height: 34px;
  padding: 0;
  gap: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.header-meta {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.header-meta {
  margin-left: 2px;
  align-self: center;
}

.topbar-controls .range-switch,
.topbar-controls .zoom-control,
.topbar-controls .check-control,
.date-range-button {
  height: 38px;
  min-height: 38px;
  border: 1px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(35, 52, 49, 0.08);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.topbar-controls .range-switch {
  gap: 1px;
  padding: 3px;
  border-radius: 999px;
}

.topbar-controls .zoom-control {
  min-width: 146px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
}

.topbar-controls .check-control {
  gap: 0;
  padding: 2px;
  border-radius: 999px;
  overflow: visible;
}

.topbar-controls .check-control label {
  width: 34px;
  min-width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.topbar-controls .control-spacer {
  min-width: 8px;
}

.topbar-controls .data-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-controls .check-control {
  gap: 0;
}

.topbar-controls .check-control label {
  position: relative;
  flex: 0 0 34px;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  color: var(--muted);
  cursor: pointer;
}

.topbar-controls .check-control label + label {
  margin-left: -4px;
}

.topbar-controls .check-control label:hover,
.topbar-controls .check-control label:has(input:checked) {
  z-index: 1;
}

.topbar-controls .check-control input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}

.topbar-controls .check-control label:has(input:focus-visible) {
  outline: 2px solid rgba(21, 118, 110, 0.42);
  outline-offset: 3px;
}

.topbar-controls .check-control label:has(input:checked) {
  color: var(--muted);
  box-shadow: inset 0 0 0 999px rgba(29, 29, 31, 0.09);
}

.topbar-controls .check-control label:hover,
.topbar-controls .range-button:hover,
.date-range-button:hover,
.date-range-button:focus-visible {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 999px rgba(29, 29, 31, 0.07);
}

.topbar-controls .check-control label span {
  line-height: 1;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.topbar-controls .check-control label:has(input:checked) span {
  font-weight: 650;
}

.page-header,
.timeline-header {
  -webkit-user-select: none;
  user-select: none;
}

.topbar-controls .range-button {
  position: relative;
  height: 30px;
  border-radius: 999px;
}

.topbar-controls .range-button:not(.is-active) + .range-button:not(.is-active)::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 50%;
  width: 1px;
  height: 14px;
  border-radius: 1px;
  background: rgba(74, 84, 86, 0.18);
  transform: translateY(-50%);
  pointer-events: none;
}

.topbar-controls .range-button:hover {
  background: transparent;
}

.topbar-controls .range-button.is-active {
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 999px rgba(29, 29, 31, 0.1);
}

.topbar-controls .range-button.is-active:hover {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 999px rgba(29, 29, 31, 0.1);
}

.date-range-button {
  width: auto;
  min-width: 0;
  height: 38px;
  min-height: 38px;
  border-radius: 999px;
  padding-inline: 14px;
  justify-content: center;
}

.source-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.source-button em {
  margin-left: 9px;
  color: var(--teal);
  font-style: normal;
}

.source-button.tab {
  min-width: 112px;
  justify-content: space-between;
  padding: 0 12px;
  border: 0;
  border-radius: 21px;
  background: #e4efec;
  color: var(--teal);
  font-size: 14px;
  font-weight: 800;
}

.kept-button {
  width: 140px;
}

.source-button:hover,
.source-button:focus-visible {
  background: #d9e9e4;
  color: var(--teal-dark);
  outline: none;
}

.brand-block .source-button {
  align-self: flex-end;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.topbar-controls .range-button.is-active,
.topbar-controls .check-control label:has(input:checked) {
  background: transparent;
}

.sheet-viewport {
  flex: 1;
  min-height: 0;
  margin-top: 0;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: var(--header-height);
  scroll-snap-type: none;
  border: 0;
  background: var(--panel);
  box-shadow: none;
  scrollbar-color: #a5bbb4 #e7efec;
}

.sheet-grid {
  width: calc(var(--label-width) + var(--timeline-width));
  display: grid;
  grid-template-columns: var(--label-width) var(--timeline-width);
  grid-template-rows: var(--header-height) auto;
}

.sheet-corner {
  grid-column: 1;
  grid-row: 1;
  width: var(--label-width);
  height: var(--header-height);
  padding: 0 20px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: #e5efec;
}

.sheet-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 20;
}

.corner-kicker {
  display: none;
}

.sheet-corner strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.timeline-header {
  grid-column: 2;
  grid-row: 1;
  width: var(--timeline-width);
  height: var(--header-height);
  border-bottom: 1px solid var(--line-strong);
  background: #f5f8f6;
}

.frozen-y-axis {
  transform: translateX(var(--y-axis-scroll, 0px));
  transform-origin: 0 0;
  transform-box: fill-box;
}

.timeline-header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--axis-offset);
  background: linear-gradient(180deg, #e8f1ee 0%, #f1f6f4 100%);
  border-right: 1px solid rgba(38, 79, 75, 0.2);
  pointer-events: none;
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 8;
}

.phase-track {
  height: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.48);
}

.week-track {
  display: grid;
  grid-template-columns: repeat(var(--date-count), var(--cell-width));
  width: calc(var(--timeline-width) - var(--axis-offset) - var(--timeline-right-offset));
  margin-left: var(--axis-offset);
  height: 18px;
  border-bottom: 1px solid var(--line);
  background: #edf4f1;
}

.week-track[hidden] {
  display: none;
}

.week-cell {
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  color: var(--teal);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.phase-cell {
  padding: 0 10px;
  border-right: 0;
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.date-track {
  height: 42px;
}

.compact-date {
  display: none;
}

.date-track[data-density="small"] .weekday-label {
  display: none;
}

.date-track[data-density="small"] .date-cell {
  align-items: center;
  justify-content: center;
  padding-left: 0;
}

.date-track[data-density="small"] .date-label {
  font-size: 9px;
}

.date-track[data-density="compact"] .full-date,
.date-track[data-density="compact"] .weekday-label {
  display: none;
}

.date-track[data-density="compact"] .compact-date {
  display: block;
}

.date-track[data-density="compact"] .date-cell {
  align-items: center;
  justify-content: center;
  gap: 0;
  padding-left: 0;
}

.date-track[data-density="compact"] .date-label {
  font-size: 9px;
}

.date-track[data-density="tiny"] .date-label,
.date-track[data-density="tiny"] .weekday-label {
  display: none;
}

.date-track[data-density="tiny"] .date-cell {
  padding-left: 0;
}

.date-cell {
  min-width: 0;
  overflow: hidden;
  gap: 3px;
  padding-left: 10px;
  border-right: 1px solid var(--line);
  background: transparent;
}

.date-cell.is-today {
  background: rgba(21, 118, 110, 0.12);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.date-label {
  font-size: 11px;
}

.weekday-label {
  font-size: 10px;
}

.sheet-body {
  grid-column: 1 / -1;
  grid-row: 2;
  width: calc(var(--label-width) + var(--timeline-width));
}

.section-row {
  min-height: var(--chart-height);
  border-bottom: 1px solid var(--line);
}

.label-panel {
  position: sticky;
  left: 0;
  z-index: 12;
  width: var(--label-width);
  padding: 16px 18px 12px;
  border-right: 1px solid var(--line-strong);
  box-shadow: inset 4px 0 0 var(--group-accent, var(--teal)), inset 0 3px 0 var(--group-accent, var(--teal));
  background: #e5efec;
}

.section-row:nth-child(odd) .label-panel {
  background: #eff5f2;
}

.section-row {
  border-bottom: 1px solid var(--line-strong);
}

.label-title {
  gap: 6px;
  margin-bottom: 10px;
}

.label-title strong {
  font-size: 15px;
}

.series-list {
  gap: 0;
  border-top: 1px solid rgba(47, 88, 81, 0.16);
}

.series-item {
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 29px;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(47, 88, 81, 0.16);
  color: #617370;
  font-size: 11px;
}

.series-change {
  margin-left: 0;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.series-change.is-positive { color: #c43f3f; }
.series-change.is-negative { color: #2f8b70; }
.series-change.is-neutral { color: var(--muted); }

.chart-panel {
  overflow: visible;
  background-color: #f9fbfa;
  background-image:
    linear-gradient(to right, rgba(69, 106, 99, 0.11) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(69, 106, 99, 0.1) 1px, transparent 1px);
  background-position: var(--axis-offset) 0, 0 0;
  background-size: var(--cell-width) 100%, 100% 44px;
}

.section-row:nth-child(odd) .chart-panel {
  background-color: #fbfcfb;
}

.sleep-chart-panel {
  background-size: var(--cell-width) 100%, 100% 50px;
}

.training-chart-panel {
  background-size: var(--cell-width) 100%, 100% 48px;
}

.training-combined-row {
  min-height: var(--focus-row-height);
  scroll-snap-align: none;
}

.training-combined-panel {
  height: var(--focus-row-height) !important;
  background-size: var(--cell-width) 100%, 100% 48px;
}

.training-combined-panel svg {
  height: var(--focus-row-height);
}

.expanded-chart-row {
  min-height: var(--focus-row-height);
  scroll-snap-align: none;
}

.expanded-chart-panel {
  height: var(--focus-row-height) !important;
  background-size: var(--cell-width) 100%, 100% 52px;
}

.expanded-chart-panel svg {
  height: var(--focus-row-height);
}

.training-action-list {
  gap: 9px;
}

.training-action-list .series-item {
  grid-template-columns: 8px minmax(0, 1fr) auto;
}

.line-value-label,
.training-value-label,
.bar-value-label {
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: #f9fbfa;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.data-bar {
  opacity: 0.88;
}

.data-bar:hover {
  opacity: 1;
  filter: brightness(0.92);
}

.tooltip-training-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.axis-line {
  stroke: rgba(76, 111, 104, 0.42);
  stroke-width: 1.1;
}

.axis-gutter {
  fill: #eaf3f0;
  pointer-events: none;
}

.axis-spine {
  stroke: rgba(36, 80, 73, 0.52);
  stroke-width: 1.25;
  pointer-events: none;
}

.axis-label,
.sleep-axis-label,
.training-axis-label {
  fill: #4d6864;
  font-weight: 650;
}

.phase-divider {
  stroke: rgba(45, 90, 80, 0.34);
}

.tooltip {
  padding: 10px 12px;
  border: 1px solid rgba(53, 94, 87, 0.18);
  border-radius: 8px;
  background: rgba(250, 252, 251, 0.94);
  box-shadow: 0 14px 34px rgba(23, 52, 58, 0.16);
  backdrop-filter: blur(12px);
}

@media (max-width: 800px) {
  .app-shell {
    padding-top: 12px;
  }

  .page-header,
  .control-bar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-header {
    align-items: center;
    flex-direction: row;
  }

  .header-meta {
    margin-left: auto;
    font-size: 11px;
  }

  .brand-block {
    gap: 8px;
  }

  .brand-block .data-summary {
    margin-bottom: 3px;
    font-size: 16px;
  }

  .control-bar {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .data-summary {
    width: auto;
    margin-left: auto;
  }

  .zoom-control {
    min-width: 148px;
  }

  :root {
    --label-width: 178px;
    --cell-width: 60px;
  }

  .training-combined-row {
    min-height: var(--focus-row-height);
  }

  .expanded-chart-row {
    min-height: var(--focus-row-height);
  }

  .expanded-chart-panel,
  .expanded-chart-panel svg,
  .training-combined-panel,
  .training-combined-panel svg {
    height: var(--focus-row-height) !important;
  }
}
