main.dash {
  display: block;
  width: 100%;
  max-width: var(--app-width);
  margin: 0 auto;
  padding: 0;
  padding-bottom: calc(68px + var(--space-4) + env(safe-area-inset-bottom, 0px));
  background: var(--gray-900);
}

body:has(main.dash) {
  background: var(--gray-900);
}

body.has-tab-bar main.dash {
  padding-top: 0;
}

.dash-head,
.dash-section:not(.dash-section--grey) {
  background: var(--bg);
}

.dash-head {
  position: static;
  display: flex;
  justify-content: flex-end;
  padding: var(--space-6) var(--space-4) 0;
}


.dash-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gray-900);
  color: var(--text);
}

.dash-section {
  padding: var(--space-3) var(--space-4) var(--space-5);
}

.dash-section--grey {
  background: var(--gray-900);
  padding-top: var(--space-5);
}

.dash-section--grey + .dash-section--grey {
  padding-top: 0;
}

.dash-section--last {
  padding-bottom: var(--space-6);
}

.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.dash-section-title {
  margin: 0 0 var(--space-3);
  font-size: var(--type-heading);
  font-weight: 700;
  color: var(--text);
}

.dash-section-link {
  font-size: var(--type-body);
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
}

.dash-ring-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.dash-ring-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.dash-ring-side strong {
  font-size: var(--type-heading);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-ring-side span,
.dash-ring-center span {
  font-size: var(--type-label);
  color: var(--gray-500);
}

.dash-ring {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

.dash-ring svg {
  width: 100%;
  height: 100%;
}

.dash-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.dash-ring-track {
  stroke: var(--gray-800);
}

.dash-ring-fill {
  stroke: var(--text);
  transition: stroke-dasharray 0.4s ease;
  animation: dash-ring-grow 1s cubic-bezier(0.25, 1, 0.5, 1) both;
}

@keyframes dash-ring-grow {
  from { stroke-dasharray: 0 1000; }
}

html[data-turbo-preview] .dash-ring-fill {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .dash-ring-fill {
    animation: none;
  }
}

.dash-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dash-ring-center strong {
  font-size: var(--type-title);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-macros {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.dash-macro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.dash-macro-label {
  width: 100%;
  padding-bottom: var(--space-1);
  border-bottom: 2px solid var(--gray-800);
  text-align: center;
  font-size: var(--type-label);
  color: var(--gray-500);
}

.dash-macro--protein .dash-macro-label { border-color: var(--macro-protein); }
.dash-macro--fat .dash-macro-label { border-color: var(--macro-fat); }
.dash-macro--carbs .dash-macro-label { border-color: var(--macro-carbs); }

.dash-macro-value {
  font-size: var(--type-body);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.dash-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-4);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.dash-card:hover {
  color: var(--text);
}

.dash-card-title {
  font-size: var(--type-body);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-card-sub {
  font-size: var(--type-label);
  color: var(--gray-500);
}

.dash-habit-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin: var(--space-3) 0;
}

.dash-habit-grid i {
  display: block;
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--gray-800);
}

.dash-habit-grid i.is-on {
  background: var(--green-500);
}

.dash-habit-grid i.is-rest {
  background: var(--gray-700);
}

.dash-streak {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--text);
}

.dash-streak svg {
  color: #f97316;
}

.dash-streak--off {
  font-weight: 500;
  color: var(--gray-500);
}

.dash-streak--off svg {
  color: var(--gray-600);
}

.dash-habit--risk {
  border: 1px solid color-mix(in srgb, var(--amber-500) 45%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--amber-500) 14%, var(--bg)), var(--bg) 70%);
}

.dash-risk {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--amber-500);
}

.dash-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--gray-800);
  color: var(--gray-500);
  font-size: var(--type-label);
}

.dash-card-foot strong {
  font-size: var(--type-body);
  font-weight: 700;
  color: var(--text);
}

.dash-sparkline {
  width: 100%;
  height: 56px;
  margin: var(--space-3) 0;
}

.dash-sparkline polyline {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.dash-sparkline circle {
  fill: var(--bg);
  stroke-width: 2;
}

.dash-sparkline--trend polyline,
.dash-sparkline--trend circle { stroke: var(--purple-500); }

.dash-sparkline--scale polyline,
.dash-sparkline--scale circle { stroke: var(--green-500); }

.dash-sparkline--volume polyline,
.dash-sparkline--volume circle { stroke: var(--macro-protein); }

.dash-habit:nth-child(3):last-child {
  grid-column: 1 / -1;
}

.dash-bars {
  width: 100%;
  height: 56px;
  margin: var(--space-3) 0;
}

.dash-bars rect {
  fill: var(--gray-700);
}

.dash-bars rect.is-current {
  fill: var(--blue-500);
}

.dash-chart-empty {
  display: flex;
  align-items: center;
  min-height: 56px;
  margin: var(--space-3) 0;
  font-size: var(--type-label);
  color: var(--gray-500);
}

@media (min-width: 480px) {
  .dash-ring {
    width: 180px;
    height: 180px;
  }
}
