:root {
  color-scheme: light;
  --ink: #1d2522;
  --muted: #68736e;
  --line: #dce2d7;
  --paper: #fffdf7;
  --surface: #ffffff;
  --olive: #6d8b38;
  --olive-dark: #3f5d22;
  --tomato: #c64e38;
  --sea: #2f7c8c;
  --wheat: #c59345;
  --plum: #6d5577;
  --shadow: 0 18px 50px rgba(35, 45, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(198, 78, 56, 0.12), transparent 28%),
    linear-gradient(135deg, #f8f3e8 0%, #edf4ee 52%, #f7f0e2 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 20;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 10px 12px;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(63, 93, 34, 0.18);
  background: rgba(255, 253, 247, 0.82);
  backdrop-filter: blur(18px);
  padding: 24px 18px;
}

.brand,
.nav-item,
.metric-card,
.panel-header,
.meal-item,
.shopping-item,
.day-card {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-height: 54px;
}

.brand-mark,
.metric-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--olive-dark);
  color: #f9f5e8;
}

.brand-mark svg,
.nav-item svg,
.icon-button svg,
.metric-icon svg {
  width: 22px;
  height: 22px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.subcopy,
.metric-card span,
.progress-row span,
.score-note,
.meal-time,
.shopping-item span,
.day-card small {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-item {
  gap: 10px;
  min-height: 46px;
  border-radius: 8px;
  color: var(--muted);
  padding: 0 12px;
  text-decoration: none;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  background: #e8efd8;
  color: var(--olive-dark);
  outline: none;
}

.dashboard {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--tomato);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
}

.subcopy {
  max-width: 720px;
  margin-bottom: 0;
}

.profile-panel,
.panel,
.metric-card {
  border: 1px solid rgba(63, 93, 34, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.profile-panel {
  padding: 18px;
  text-align: right;
}

.score-label,
.score-note {
  display: block;
}

.profile-panel strong {
  display: block;
  color: var(--olive-dark);
  font-size: 2rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card {
  gap: 14px;
  min-height: 112px;
  padding: 18px;
}

.metric-card p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.metric-card strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1.05;
}

.metric-icon {
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.metric-icon.oil {
  background: #eef4df;
  color: var(--olive-dark);
}

.metric-icon.fish {
  background: #e0f0f2;
  color: var(--sea);
}

.metric-icon.veg {
  background: #e6f3e6;
  color: #2f7b42;
}

.metric-icon.grain {
  background: #f7edda;
  color: var(--wheat);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--olive-dark);
}

.icon-button:hover,
.icon-button:focus-visible,
.action-button:hover,
.action-button:focus-visible,
.segment:hover,
.segment:focus-visible {
  border-color: var(--olive);
  outline: 3px solid rgba(109, 139, 56, 0.2);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--olive-dark);
  padding: 0 10px;
  font-size: 0.88rem;
  font-weight: 800;
}

.action-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.export-status {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.meal-list,
.progress-list,
.shopping-list,
.shopping-group-items {
  display: grid;
  gap: 10px;
}

.meal-item {
  gap: 14px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
}

.meal-art {
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), transparent),
    var(--meal-color);
  color: rgba(29, 37, 34, 0.76);
}

.meal-art svg {
  width: 38px;
  height: 38px;
}

.meal-item strong,
.meal-item span {
  display: block;
}

.meal-time {
  font-size: 0.86rem;
}

.progress-row {
  display: grid;
  gap: 8px;
}

.progress-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #edf0e8;
}

progress::-webkit-progress-bar {
  background: #edf0e8;
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--olive), var(--sea));
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--olive), var(--sea));
}

.chart-panel {
  min-height: 250px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.donut {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--wheat) 0 45%, var(--olive) 45% 80%, var(--sea) 80% 100%);
  position: relative;
}

.donut::after {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

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

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.dot.carbs {
  background: var(--wheat);
}

.dot.fats {
  background: var(--olive);
}

.dot.protein {
  background: var(--sea);
}

.shopping-item {
  gap: 10px;
  min-height: 44px;
}

.shopping-group {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.shopping-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.shopping-group h3 {
  margin: 0;
  color: var(--olive-dark);
  font-size: 0.9rem;
}

.shopping-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--olive-dark);
}

.shopping-item label {
  display: grid;
  cursor: pointer;
}

.shopping-item:has(input:checked) label {
  color: var(--muted);
  text-decoration: line-through;
}

.pill {
  border-radius: 999px;
  background: #edf4ee;
  color: var(--olive-dark);
  padding: 6px 10px;
  font-size: 0.86rem;
  font-weight: 800;
}

.weekly-panel {
  margin-top: 14px;
}

.tracking-panel {
  margin-top: 14px;
}

.tracker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 14px;
}

.tracker-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tracker-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.tracker-form input,
.tracker-form select,
.participant-add input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.tracker-form input:focus,
.tracker-form select:focus,
.participant-add input:focus {
  border-color: var(--olive);
  outline: 3px solid rgba(109, 139, 56, 0.2);
}

.primary-button {
  align-self: end;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--olive-dark);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #31491b;
  outline: 3px solid rgba(109, 139, 56, 0.24);
}

.tracker-summary {
  display: grid;
  gap: 10px;
  align-content: start;
}

.summary-number {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 14px;
}

.summary-number span,
.log-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-number strong {
  display: block;
  color: var(--olive-dark);
  font-size: 1.7rem;
}

.participant-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.log-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.log-item strong {
  display: block;
}

.delete-log {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--tomato);
}

.segmented {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f6f1;
  padding: 4px;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.segment.active {
  background: #fff;
  color: var(--olive-dark);
  box-shadow: 0 6px 18px rgba(29, 37, 34, 0.08);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(170px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.day-card {
  align-items: stretch;
  flex-direction: column;
  min-height: 230px;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
}

.day-card strong {
  margin-bottom: 8px;
}

.day-card p {
  margin-bottom: 10px;
  font-weight: 700;
}

.day-card small,
.day-card p {
  overflow-wrap: anywhere;
}

.day-card small {
  margin-top: auto;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px 20px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    overflow-x: auto;
  }

  .nav-item {
    flex: 0 0 auto;
  }

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

@media (max-width: 760px) {
  .dashboard {
    padding: 18px;
  }

  .topbar,
  .content-grid,
  .donut-wrap,
  .tracker-grid,
  .tracker-form {
    grid-template-columns: 1fr;
  }

  .profile-panel {
    text-align: left;
  }

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

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .participant-add,
  .log-item {
    grid-template-columns: 1fr;
  }

  .segment {
    flex: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .nav-item,
  .icon-button,
  .action-button,
  .segment,
  .meal-item,
  .shopping-item {
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease;
  }

  .meal-item:hover {
    transform: translateY(-2px);
  }
}


/* ── Online/Offline badge ──────────────────────────────── */
.online-badge {
  display: block;
  margin: auto 1rem 1.2rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: .25rem .6rem;
  border-radius: 99px;
}
.online-badge.is-online  { background: #d4f0db; color: #1a6b2f; }
.online-badge.is-offline { background: #f0f0f0; color: #888; }

/* ── Day type badge ─────────────────────────────────────── */
.day-type-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 99px;
  background: var(--meal-color, #eee);
  margin-left: .5rem;
  vertical-align: middle;
}

/* ── Dot nav ────────────────────────────────────────────── */
.dot-nav {
  display: flex;
  gap: .45rem;
  margin: .8rem 0 1.2rem;
}
.day-dot {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  border: 2px solid #ccc;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.day-dot.active,
.day-dot:hover { background: #2d6a4f; border-color: #2d6a4f; }

/* ── Meal detail rows ───────────────────────────────────── */
.meal-details  { display: flex; flex-direction: column; gap: .6rem; }
.meal-row      { display: flex; gap: .7rem; align-items: baseline; }
.meal-label    { font-size: .75rem; font-weight: 700; color: #888; min-width: 6.5rem; text-transform: uppercase; letter-spacing: .04em; }
.meal-value    { font-size: .95rem; color: #1a1a1a; line-height: 1.4; }

.recipe-details { margin-top: .4rem; }
.recipe-details summary { font-size: .8rem; cursor: pointer; color: #2d6a4f; font-weight: 600; }
.recipe-details p { font-size: .87rem; color: #555; margin-top: .4rem; line-height: 1.5; }
.prep-hint { color: #888 !important; font-style: italic; }

/* ── Goal list ──────────────────────────────────────────── */
.goal-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.goal-list li { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.goal-dot { width: .65rem; height: .65rem; border-radius: 50%; flex-shrink: 0; }
.goal-dot.fleisch { background: #e07050; }
.goal-dot.fisch   { background: #50a0e0; }
.goal-dot.veggie  { background: #50c070; }
.goal-dot.kcal    { background: #f0b030; }
.goal-dot.olive   { background: #a0b840; }

/* ── Shopping grid ──────────────────────────────────────── */
.shopping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1.2rem; margin-top: .5rem; }
.shop-section  { }
.shop-cat      { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #888; margin: 0 0 .5rem; }
.shop-item     { display: flex; align-items: center; gap: .5rem; font-size: .9rem; padding: .2rem 0; cursor: pointer; }
.shop-item input[type=checkbox] { width: 1rem; height: 1rem; cursor: pointer; accent-color: #2d6a4f; }
.shop-item:has(input:checked) span { text-decoration: line-through; color: #bbb; }

/* ── Full-panel layout ──────────────────────────────────── */
.full-panel { grid-column: 1 / -1; }

/* ── Participant tabs ───────────────────────────────────── */
.participant-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.participant-tab {
  padding: .4rem 1rem;
  border: 2px solid #ddd;
  border-radius: 99px;
  background: transparent;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  color: #555;
}
.participant-tab:hover   { border-color: #2d6a4f; color: #2d6a4f; }
.participant-tab.active  { background: #2d6a4f; border-color: #2d6a4f; color: #fff; }
.participant-tab.add-tab { border-style: dashed; color: #999; }
.participant-tab.add-tab:hover { border-color: #2d6a4f; color: #2d6a4f; }

/* ── Calorie summary ────────────────────────────────────── */
.kcal-summary {
  background: #f8faf8;
  border: 1px solid #e4ede6;
  border-radius: .8rem;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.kcal-numbers {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .7rem;
}
.kcal-stat { text-align: center; }
.kcal-stat--mid { }
.kcal-val  { display: block; font-size: 1.6rem; font-weight: 800; color: #1a1a1a; line-height: 1.1; }
.kcal-lbl  { display: block; font-size: .72rem; color: #888; text-transform: uppercase; letter-spacing: .04em; }
.kcal-pct  { display: block; font-size: 1.1rem; font-weight: 700; color: #2d6a4f; }
.kcal-goal-line { font-size: .82rem; color: #888; margin: .5rem 0 0; text-align: right; }

.kcal-bar-track {
  width: 100%;
  height: .55rem;
  background: #e0e8e2;
  border-radius: 99px;
  overflow: hidden;
}
.kcal-bar-fill {
  height: 100%;
  background: #2d6a4f;
  border-radius: 99px;
  transition: width .4s ease;
}
.kcal-bar-fill.near-limit  { background: #e08030; }
.kcal-bar-fill.over-limit  { background: #d04040; }

/* ── Log form ───────────────────────────────────────────── */
.log-form { margin-bottom: 1rem; }
.log-form-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: stretch;
}
.log-select,
.log-input {
  padding: .55rem .75rem;
  border: 1.5px solid #ddd;
  border-radius: .5rem;
  font-size: .9rem;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color .15s;
}
.log-select:focus,
.log-input:focus { border-color: #2d6a4f; }
.log-select { min-width: 9rem; }
.log-input  { flex: 1; min-width: 12rem; }
.log-input--sm { flex: 0 0 10rem; }
.log-submit {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: .5rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.log-submit:hover { background: #235a40; }
.log-submit svg { width: 1rem; height: 1rem; stroke: currentColor; stroke-width: 2; fill: none; }
.log-hint { font-size: .78rem; color: #aaa; margin: .4rem 0 0; }

/* ── Log list ───────────────────────────────────────────── */
.log-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .2rem; }
.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem .85rem;
  background: #f8faf8;
  border: 1px solid #e4ede6;
  border-radius: .55rem;
  gap: .5rem;
}
.log-info    { display: flex; flex-direction: column; gap: .15rem; }
.log-meal-type { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #2d6a4f; }
.log-desc    { font-size: .9rem; color: #1a1a1a; }
.log-right   { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.log-kcal    { font-size: .9rem; font-weight: 700; color: #555; white-space: nowrap; }
.log-delete  {
  background: none; border: none; cursor: pointer; color: #bbb;
  font-size: .85rem; padding: .15rem .3rem; border-radius: .3rem;
  transition: color .15s, background .15s;
  line-height: 1;
}
.log-delete:hover { color: #d04040; background: #fde8e8; }
.log-empty,
.log-offline { font-size: .88rem; color: #aaa; padding: .5rem 0; }

/* ── Add-person dialog ──────────────────────────────────── */
.add-person-dialog {
  border: none;
  border-radius: .9rem;
  padding: 1.8rem;
  width: min(28rem, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.add-person-dialog::backdrop { background: rgba(0,0,0,.4); }
.add-person-dialog h2 { margin: 0 0 1.2rem; font-size: 1.1rem; }
.add-person-dialog label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: .8rem;
}
.add-person-dialog input {
  padding: .55rem .75rem;
  border: 1.5px solid #ddd;
  border-radius: .5rem;
  font-size: .95rem;
  outline: none;
}
.add-person-dialog input:focus { border-color: #2d6a4f; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.btn-primary {
  padding: .55rem 1.2rem; background: #2d6a4f; color: #fff;
  border: none; border-radius: .5rem; font-size: .9rem; font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #235a40; }
.btn-secondary {
  padding: .55rem 1.2rem; background: #f0f0f0; color: #555;
  border: 1px solid #ddd; border-radius: .5rem; font-size: .9rem; font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: #e5e5e5; }
