html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(66, 133, 244, 0.08), transparent 28%),
    linear-gradient(180deg, #f7faff 0%, #eef4fb 100%);
  color: #163253;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

canvas {
  width: 100% !important;
}

.dashboard-shell {
  min-height: 100vh;
  display: block;
}

.main-panel {
  max-width: 1480px;
  margin: 0 auto;
  padding: 42px 44px 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #88a1c2;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(2.4rem, 3vw, 3.2rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #163253;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.range-picker {
  position: relative;
  max-width: 100%;
}

.range-display {
  min-height: 60px;
  min-width: 330px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d6e2f1;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(136, 165, 201, 0.08);
  color: #29486d;
  font-size: 1.08rem;
  font-weight: 500;
}

.range-display:after {
  content: "▾";
  color: #7f98ba;
}

.range-popover {
  position: fixed;
  left: 16px;
  top: 96px;
  z-index: 30;
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #d6e2f1;
  border-radius: 20px;
  box-shadow: 0 24px 50px rgba(78, 110, 150, 0.18);
}

.range-popover.hidden {
  display: none;
}

.range-popover-head,
.range-popover-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.range-popover-title {
  color: #17375d;
  font-weight: 700;
}

.range-popover-subtitle {
  margin-top: 4px;
  color: #7f98ba;
  font-size: 0.92rem;
}

.range-mode-copy {
  margin-bottom: 10px;
}

.range-mode-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.range-mode-chip {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #d6e2f1;
  border-radius: 999px;
  background: #fff;
  color: #476789;
  font-size: 0.9rem;
  font-weight: 600;
}

.range-mode-chip.active {
  border-color: #4285f4;
  background: rgba(66, 133, 244, 0.12);
  color: #1b4f9a;
}

.range-nav {
  display: flex;
  gap: 8px;
}

.range-nav-btn {
  width: 40px;
  height: 40px;
  padding: 0;
}

.range-calendars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 18px 0;
}

.range-calendar {
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fd);
  border: 1px solid #e0ebf7;
}

.range-calendar-title {
  margin-bottom: 12px;
  text-align: center;
  color: #17375d;
  font-weight: 700;
}

.range-weekday-row,
.range-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.range-weekday-row {
  margin-bottom: 8px;
  color: #8aa1bf;
  font-size: 0.82rem;
  text-align: center;
}

.range-day {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #29486d;
  font-weight: 500;
}

.range-day.muted {
  color: #b0bfd3;
}

.range-day.in-range {
  background: rgba(66, 133, 244, 0.12);
}

.range-day.edge {
  background: linear-gradient(135deg, #4285f4, #2f70db);
  color: #fff;
}

.range-day:hover {
  background: rgba(66, 133, 244, 0.08);
}

.range-day.edge:hover {
  background: linear-gradient(135deg, #4285f4, #2f70db);
}

.primary-button {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.month-chip input[type="month"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #4285f4, #2f70db);
  color: #fff;
  box-shadow: 0 16px 28px rgba(66, 133, 244, 0.22);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.tab-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 34px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(194, 210, 230, 0.72);
  overflow-x: auto;
}

.top-tab {
  border: 0;
  background: transparent;
  color: #8ca4c4;
  padding: 10px 2px 14px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.top-tab.active {
  color: #21456f;
  border-bottom-color: #4285f4;
  font-weight: 600;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-block + .section-block {
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid rgba(194, 210, 230, 0.72);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #18375c;
}

.section-meta {
  color: #7f98ba;
  font-size: 0.94rem;
}

.panel-grid {
  display: grid;
  gap: 22px;
}

.panel-grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(208, 221, 238, 0.9);
  border-radius: 24px;
  padding: 22px 22px 20px;
  box-shadow: 0 20px 46px rgba(122, 150, 188, 0.12);
  overflow: hidden;
}

.chart-card.full,
.chart-card.wide {
  grid-column: span 1;
}

#moreDataGrid .chart-card {
  min-height: 340px;
}

.chart-card h3,
.chart-card-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #17375d;
}

.chart-card-head {
  margin-bottom: 14px;
}

.chart-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 18px;
  align-items: stretch;
}

.chart-wrap,
.solo-chart {
  position: relative;
  min-height: 240px;
}

.chart-stack {
  display: flex;
  flex-direction: column;
}

.chart-wrap.compact {
  min-height: 210px;
}

.solo-chart {
  min-height: 300px;
  margin-top: 8px;
}

.metric-rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding-left: 6px;
}

.metric-big {
  font-size: clamp(2rem, 3vw, 2.7rem);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: #17375d;
}

.metric-label {
  color: #8aa1bf;
  font-size: 0.95rem;
}

.metric-subtle {
  color: #4d7bd4;
  font-size: 0.92rem;
}

.chart-note {
  margin-top: 10px;
  color: #86a0c1;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.today-grid-secondary {
  margin-top: 18px;
}

.day-view-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.day-picker-wrap {
  position: relative;
}

.day-picker {
  min-height: 48px;
  min-width: 190px;
  padding: 0 14px;
  border: 1px solid #d6e2f1;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #29486d;
  font-size: 1.02rem;
  font-weight: 500;
  box-shadow: 0 10px 24px rgba(136, 165, 201, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.day-picker:after {
  content: "▾";
  color: #7f98ba;
}

.day-popover {
  position: fixed;
  left: 16px;
  top: 96px;
  z-index: 30;
  width: min(380px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #d6e2f1;
  border-radius: 20px;
  box-shadow: 0 24px 50px rgba(78, 110, 150, 0.18);
}

.day-popover.hidden {
  display: none;
}

.day-calendar-shell {
  display: block;
  margin: 18px 0;
}

.day-calendar {
  max-width: 100%;
}

.today-stat {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f9fbff, #f1f6fd);
  border: 1px solid #e0ebf7;
}

.today-stat.wide {
  grid-column: span 2;
}

.today-kpi {
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  color: #17375d;
  letter-spacing: -0.05em;
}

.today-caption {
  margin-top: 8px;
  color: #88a1c2;
  font-size: 0.92rem;
}

.today-detail {
  color: #4a678b;
  line-height: 1.5;
}

.day-heart-panel {
  margin-top: 10px;
}

.dashboard-heart-panel {
  display: grid;
  gap: 16px;
}

.day-heart-meta {
  margin-bottom: 14px;
}

.day-heart-label {
  color: #8aa1bf;
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.day-heart-range {
  margin-top: 4px;
  color: #17375d;
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.day-heart-unit {
  font-size: 0.44em;
  letter-spacing: 0;
  color: #6f89ac;
}

.day-heart-subtitle {
  margin-top: 10px;
  color: #7f98ba;
  font-size: 0.95rem;
}

.day-heart-chart-wrap {
  position: relative;
  min-height: 260px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fd);
  border: 1px solid #e0ebf7;
  padding: 12px 14px 10px;
}

.day-heart-chart {
  display: block;
  width: 100%;
  height: 260px;
}

.day-heart-tooltip {
  position: absolute;
  transform: translateY(-100%);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(23, 38, 60, 0.94);
  color: #fff;
  font-size: 0.82rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 10px 22px rgba(10, 20, 38, 0.22);
}

.day-heart-tooltip.hidden {
  display: none;
}

.day-view-grid {
  align-items: start;
}

.dashboard-heart-chart-wrap {
  min-height: 280px;
}

.dashboard-heart-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#recentWorkouts {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

#recentWorkouts table {
  width: 100%;
  border-collapse: collapse;
}

#recentWorkouts th,
#recentWorkouts td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(220, 230, 242, 0.9);
  text-align: left;
  color: #456384;
}

#recentWorkouts th {
  color: #7f98ba;
  font-size: 0.88rem;
  font-weight: 600;
}

.diagnostics-table {
  width: 100%;
  border-collapse: collapse;
}

.diagnostics-table th,
.diagnostics-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(220, 230, 242, 0.9);
  text-align: left;
  vertical-align: top;
  color: #456384;
}

.diagnostics-table th {
  color: #7f98ba;
  font-size: 0.88rem;
  font-weight: 600;
}

.diagnostic-list {
  display: grid;
  gap: 8px;
  color: #4a678b;
  line-height: 1.55;
}

.calendar-controls {
  display: flex;
  gap: 8px;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.9);
  color: #5d7ba2;
  border: 1px solid #d6e2f1;
  box-shadow: 0 10px 24px rgba(136, 165, 201, 0.08);
}

#calendarGrid table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 10px;
}

#calendarGrid th {
  padding: 8px 0 6px;
  color: #8aa1bf;
  font-weight: 600;
  text-align: left;
}

.cal-day {
  min-height: 128px;
  vertical-align: top;
  padding: 12px 12px 10px;
  background: linear-gradient(180deg, #fefeff, #f7fbff);
  border: 1px solid #e0ebf7;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.cal-day.out-period {
  opacity: 0.55;
}

.day-label {
  font-weight: 700;
  color: #1f426c;
  margin-bottom: 8px;
}

.cell-stat {
  margin-top: 5px;
  font-size: 0.85rem;
  color: #6481a6;
}

.good {
  color: #2a9d67;
}

.watch {
  color: #ff9b3f;
}

.partial {
  color: #dd5d50;
}

#insightMomentum,
#recoveryText,
#insightBestDay {
  color: #4a678b;
  line-height: 1.65;
  font-size: 0.98rem;
}

.empty-state {
  padding: 24px;
  color: #86a0c1;
  text-align: center;
}

@media (max-width: 1220px) {
  .main-panel {
    padding: 34px 28px 44px;
  }

  .chart-card-body {
    grid-template-columns: 1fr;
  }

  .metric-rail {
    padding-left: 0;
    border-top: 1px solid rgba(220, 230, 242, 0.9);
    padding-top: 12px;
  }
}

@media (max-width: 980px) {
  .panel-grid.two-up {
    grid-template-columns: 1fr;
  }

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

  .today-stat.wide {
    grid-column: span 1;
  }

  .section-head,
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .day-view-controls {
    flex-wrap: wrap;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .range-calendars {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-panel {
    padding: 26px 16px 34px;
  }

  .range-display {
    width: 100%;
  }

  .range-popover {
    min-width: 0;
    width: min(100vw - 32px, 700px);
    max-width: calc(100vw - 32px);
  }

  .primary-button {
    width: 100%;
    justify-content: center;
  }

  #calendarGrid table {
    border-spacing: 6px;
  }

  .cal-day {
    min-height: 104px;
    padding: 10px;
  }
}
