.week-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.week-picker__label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.week-picker__nav {
  display: flex;
  gap: var(--space-xs);
}

.week-picker__nav .btn {
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.week-picker__nav .btn:hover {
  transform: scale(1.06);
  box-shadow: var(--shadow-sm);
}

@media (prefers-reduced-motion: reduce) {
  .week-picker__nav .btn:hover {
    transform: none;
  }
}

.donut-wrap {
  display: flex;
  justify-content: center;
  padding: var(--space-md) 0;
}

.donut {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--border) 80%, transparent),
    0 12px 40px color-mix(in srgb, var(--accent) 12%, transparent);
  transition: box-shadow var(--transition-slow);
  background: conic-gradient(
    var(--sage) 0deg var(--p-healthy, 0deg),
    var(--amber) var(--p-healthy, 0deg) calc(var(--p-healthy, 0deg) + var(--p-okay, 0deg)),
    var(--coral) calc(var(--p-healthy, 0deg) + var(--p-okay, 0deg)) calc(var(--p-healthy, 0deg) + var(--p-okay, 0deg) + var(--p-unhealthy, 0deg)),
    var(--bg-muted) calc(var(--p-healthy, 0deg) + var(--p-okay, 0deg) + var(--p-unhealthy, 0deg)) 360deg
  );
}

.donut::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--bg-elevated);
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  font-size: 0.8125rem;
}

.donut-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.donut-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-healthy {
  background: var(--sage);
}

.legend-okay {
  background: var(--amber);
}

.legend-unhealthy {
  background: var(--coral);
}

.legend-none {
  background: var(--bg-muted);
}

/* —— Professional dashboard —— */
/* Flex column + gap avoids margin-collapse so blocks never visually merge. */
.dash-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xl);
  align-items: stretch;
  width: 100%;
}

.dash-stack > .dash-hero,
.dash-stack > .dash-add-meal,
.dash-stack > .dash-kpi-grid {
  margin-bottom: 0;
}

.dash-add-meal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: stretch;
  align-items: center;
}

.dash-add-meal__btn {
  width: 100%;
}

@media (min-width: 600px) {
  .dash-add-meal {
    justify-content: flex-start;
  }

  .dash-add-meal__btn {
    width: auto;
    min-width: 11rem;
  }
}

.dash-stack > .dash-compare.card {
  margin-bottom: 0;
}

.dash-stack > .dash-insights {
  margin-top: 0;
}

.dashboard-scope {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  padding: var(--space-xs);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* `display: flex` would override the native [hidden] rule; solo mode must hide the bar. */
.dashboard-scope[hidden] {
  display: none !important;
}

.dashboard-scope__btn {
  flex: 1;
  min-width: 100px;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  transition: transform var(--transition), background var(--transition), color var(--transition);
}

.dashboard-scope__btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.dashboard-scope__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(63, 111, 94, 0.25);
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-scope__btn:hover {
    transform: none;
  }
}

.dash-hero {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.dash-hero--solo {
  background: var(--bg-elevated);
}

.dash-hero__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--space-sm);
}

.dash-hero__title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-sm);
  line-height: 1.2;
}

.dash-hero__partner {
  margin: 0 0 var(--space-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dash-hero__sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 42ch;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.dash-kpi {
  padding: var(--space-lg);
  background: linear-gradient(
    155deg,
    var(--bg-elevated) 0%,
    color-mix(in srgb, var(--bg-elevated) 90%, var(--sage-soft)) 100%
  );
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-slow), transform var(--transition), border-color var(--transition);
}

.dash-kpi:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 15%, var(--border));
}

@media (prefers-reduced-motion: reduce) {
  .dash-kpi:hover {
    transform: none;
  }
}

.dash-kpi__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
}

.dash-kpi__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.dash-kpi__hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.dash-kpi--wellness {
  position: relative;
}

.dash-kpi__info {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  margin: 0;
  z-index: 2;
}

.dash-kpi__info-btn {
  list-style: none;
  cursor: pointer;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.dash-kpi__info-btn::-webkit-details-marker {
  display: none;
}

.dash-kpi__info-btn:hover,
.dash-kpi__info-btn:focus-visible {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-elevated);
  outline: none;
}

.dash-kpi__info[open] .dash-kpi__info-btn {
  color: var(--text-primary);
  border-color: var(--accent, var(--sage));
}

.dash-kpi__info-icon {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.7rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
}

.dash-kpi__info-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(17.5rem, calc(100vw - 2.5rem));
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 5;
}

.dash-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 var(--space-xs);
  letter-spacing: -0.02em;
}

.dash-section-lead {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-md);
  line-height: 1.45;
}

.dash-compare.card {
  padding-bottom: var(--space-xl);
}

.dash-people-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  background: transparent;
}

.dash-people-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.dash-people-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in srgb, var(--bg-muted) 85%, var(--bg-base));
  border-bottom: 1px solid var(--border);
}

.dash-people-table tbody th[scope="row"] {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  padding: var(--space-md);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.dash-people-table td {
  padding: var(--space-md);
  color: var(--text-primary);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.dash-people-table tbody tr:last-child th,
.dash-people-table tbody tr:last-child td {
  border-bottom: none;
}

.dash-people-table__num {
  text-align: right;
  font-weight: 500;
}

.dash-people-table thead .dash-people-table__num {
  text-align: right;
}

.dash-compare__note {
  margin: var(--space-lg) 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.dash-grouped-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.dash-hbar-row {
  display: grid;
  grid-template-columns: 36px 1fr 44px;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
}

.dash-hbar-row__dow {
  color: var(--text-muted);
  font-weight: 600;
}

.dash-hbar-row__track {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  overflow: hidden;
}

.dash-hbar-row__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--sage));
  transition: width 0.45s ease;
}

.dash-hbar-row__val {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-secondary);
}

.donut--lg {
  width: 200px;
  height: 200px;
}

.dash-insights {
  margin-top: 0;
}

/* Two chart cards: explicit gap (stacked + side-by-side). Higher specificity than .grid-2 alone. */
.dash-stack .grid-2.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: var(--space-2xl);
  row-gap: var(--space-2xl);
  column-gap: var(--space-2xl);
  width: 100%;
  min-width: 0;
}

@media (min-width: 900px) {
  .dash-stack .grid-2.dash-charts-row {
    grid-template-columns: 1fr 1fr;
  }
}

.dash-stack .grid-2.dash-charts-row > .card {
  min-width: 0;
}

.app-footer {
  margin-top: auto;
  padding: var(--space-lg);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-muted) 35%, transparent) 0%, var(--surface-glass) 100%);
  font-family: var(--font-brand);
}

.app-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.app-footer__credit {
  margin: 0;
  font-size: 0.7rem;
}

.app-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.app-footer code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  background: var(--bg-muted);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* Light-only theme: no dark overrides. */

