:root {
  --ink: #173f35;
  --ink-strong: #102d27;
  --muted: #6e7e77;
  --line: #e4e7e1;
  --surface: #ffffff;
  --surface-soft: #f7f8f4;
  --canvas: #f2f4ef;
  --mint: #dfeee4;
  --mint-strong: #b9dec7;
  --lime: #c8e86a;
  --yellow: #f2cf58;
  --orange: #ec9b63;
  --red: #c96a5a;
  --shadow: 0 12px 34px rgba(25, 48, 38, 0.07);
  --radius: 14px;
  --radius-small: 9px;
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink-strong);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 244px;
  min-height: 100vh;
  padding: 28px 18px 18px;
  color: #eef6ef;
  background: var(--ink);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 38px;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 3px;
  width: 29px;
  height: 26px;
}

.brand-mark span {
  display: block;
  width: 7px;
  border-radius: 5px 5px 2px 2px;
  background: var(--lime);
}

.brand-mark span:nth-child(1) { height: 14px; opacity: 0.66; }
.brand-mark span:nth-child(2) { height: 23px; }
.brand-mark span:nth-child(3) { height: 18px; opacity: 0.82; }

.brand-name {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-caption {
  margin-top: 5px;
  color: #a9c3b4;
  font-size: 11px;
}

.nav-label {
  margin: 0 10px 9px;
  color: #86a496;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav { display: grid; gap: 5px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 43px;
  padding: 0 11px;
  color: #bad0c4;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.nav-item:hover, .nav-item:focus-visible { color: #ffffff; background: rgba(255, 255, 255, 0.08); outline: none; }
.nav-item.is-active { color: var(--ink); background: var(--lime); font-weight: 700; }
.nav-icon { width: 18px; font-size: 17px; line-height: 1; text-align: center; }

.sidebar-note {
  margin-top: auto;
  padding: 17px 13px;
  color: #b9cdc2;
  border: 1px solid rgba(212, 235, 219, 0.16);
  border-radius: 11px;
}

.sidebar-note-title { margin: 0 0 7px; color: #eef6ef; font-size: 12px; font-weight: 700; }
.sidebar-note p:not(.sidebar-note-title) { margin: 0 0 11px; font-size: 11px; line-height: 1.5; }
.sidebar-note strong { color: #f3f8ef; font-weight: 600; }
.text-button { padding: 0; color: inherit; background: transparent; border: 0; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover, .text-button:focus-visible { color: var(--ink); outline: 2px solid var(--lime); outline-offset: 3px; }
.sidebar-note .text-button { color: var(--lime); }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 20px 10px 0;
  color: #8faa9c;
  font-size: 11px;
}

.status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #8acb87; }

.main-content { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 94px;
  padding: 20px clamp(22px, 4vw, 62px);
  background: rgba(242, 244, 239, 0.92);
  border-bottom: 1px solid rgba(227, 231, 224, 0.85);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "Playfair Display", Georgia, serif; font-size: clamp(25px, 3vw, 34px); line-height: 1.1; letter-spacing: -0.03em; }
h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -0.02em; }
h3 { margin-bottom: 5px; font-size: 15px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.source-chip { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.secondary-button, .primary-button, .icon-button { border: 0; }
.secondary-button {
  padding: 9px 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.secondary-button:hover, .secondary-button:focus-visible { border-color: var(--ink); outline: none; }
.primary-button { padding: 11px 16px; color: var(--ink); background: var(--lime); border-radius: 8px; font-size: 13px; font-weight: 700; }
.primary-button:hover, .primary-button:focus-visible { background: #d4f27e; outline: 3px solid rgba(200, 232, 106, 0.34); outline-offset: 2px; }
.mobile-menu { display: none; }

.content-wrap { max-width: 1440px; margin: 0 auto; padding: 32px clamp(22px, 4vw, 62px) 28px; }
.view-stack { display: grid; gap: 24px; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.page-intro p { max-width: 580px; margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.view-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: end; }

.day-tabs { display: flex; gap: 7px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: thin; }
.day-tab { min-width: 76px; padding: 9px 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.day-tab:hover, .day-tab:focus-visible { color: var(--ink); border-color: var(--ink); outline: none; }
.day-tab.is-active { color: var(--surface); background: var(--ink); border-color: var(--ink); }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric-card { min-height: 123px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card.highlight { color: var(--ink); background: var(--lime); border-color: transparent; }
.metric-label { margin: 0 0 16px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.metric-card.highlight .metric-label { color: rgba(23, 63, 53, 0.72); }
.metric-value { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 30px; line-height: 1; letter-spacing: -0.04em; }
.metric-unit { margin-left: 4px; font-family: "DM Sans", sans-serif; font-size: 12px; font-weight: 600; letter-spacing: 0; }
.metric-foot { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.metric-card.highlight .metric-foot { color: rgba(23, 63, 53, 0.72); }

.dashboard-grid { display: grid; grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr); gap: 18px; align-items: start; }
.panel { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-title { margin-bottom: 3px; font-size: 17px; }
.panel-subtitle { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.source-label { color: var(--muted); font-size: 11px; }

.profile-form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 11px; font-weight: 700; }
.field input, .field select, .search-input {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  color: var(--ink-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.field input:focus, .field select:focus, .search-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23, 63, 53, 0.1); }
.field-hint { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 2px; }
.form-status { min-height: 17px; margin: 0; color: var(--muted); font-size: 11px; }

.summary-panel { display: grid; gap: 20px; }
.summary-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.summary-day-label { margin: 0; color: var(--muted); font-size: 12px; }
.calorie-overview { display: grid; grid-template-columns: 146px 1fr; gap: 20px; align-items: center; }
.calorie-ring { position: relative; display: grid; width: 146px; height: 146px; place-items: center; border-radius: 50%; background: conic-gradient(var(--ink) var(--ring-progress), var(--mint) 0); }
.calorie-ring::after { position: absolute; inset: 10px; content: ""; background: var(--surface); border-radius: 50%; }
.ring-copy { position: relative; z-index: 1; text-align: center; }
.ring-number { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 28px; line-height: 1; }
.ring-unit { color: var(--muted); font-size: 10px; }
.calorie-copy h3 { margin-bottom: 7px; }
.calorie-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.calorie-copy strong { color: var(--ink-strong); }

.macro-list { display: grid; gap: 13px; }
.macro-row { display: grid; gap: 6px; }
.macro-row-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.macro-row-top strong { color: var(--ink-strong); font-weight: 700; }
.progress-track { height: 8px; overflow: hidden; background: var(--mint); border-radius: 20px; }
.progress-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--ink); transition: width 250ms ease; }
.progress-fill.warn { background: var(--orange); }
.progress-fill.over { background: var(--red); }

.warning-panel { display: flex; align-items: start; gap: 12px; padding: 15px 17px; color: #6c4b24; background: #fff6dc; border: 1px solid #eddba1; border-radius: var(--radius-small); }
.warning-icon { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; color: #8c641e; background: #f7dc8c; border-radius: 50%; font-weight: 800; }
.warning-panel p { margin: 0; font-size: 12px; line-height: 1.5; }
.warning-panel strong { color: #5d411f; }

.meal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.meal-card { padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; }
.meal-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.meal-card h3 { margin: 0; font-size: 14px; }
.meal-kcal { color: var(--ink); font-size: 11px; font-weight: 700; }
.meal-items { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.meal-item { display: flex; align-items: start; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.meal-item-name { color: var(--ink-strong); }
.meal-item-meta { flex: 0 0 auto; text-align: right; white-space: nowrap; }
.missing-tag { display: inline-block; margin-left: 4px; padding: 2px 4px; color: #8e5a16; background: #f9dfa0; border-radius: 4px; font-size: 9px; font-weight: 700; }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 3px; }
.week-card { display: grid; gap: 12px; min-height: 188px; padding: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.week-card.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(23, 63, 53, 0.12); }
.week-card-head { display: flex; justify-content: space-between; gap: 8px; }
.week-day { margin: 0; font-size: 13px; font-weight: 700; }
.week-meals { margin: 0; color: var(--muted); font-size: 11px; }
.week-kcal { display: flex; align-items: baseline; gap: 3px; margin-top: auto; font-family: "Playfair Display", Georgia, serif; font-size: 28px; line-height: 1; }
.week-kcal small { font-family: "DM Sans", sans-serif; color: var(--muted); font-size: 10px; }
.week-macro-line { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.week-status { color: var(--ink); font-size: 10px; font-weight: 700; }
.week-status.warn { color: #a56032; }
.week-status.missing { color: #8e5a16; }
.week-card .secondary-button { width: 100%; padding: 7px 9px; font-size: 11px; }

.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.search-wrap { width: min(360px, 100%); }
.search-wrap label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.search-input { background: var(--surface-soft); }
.table-scroll { overflow-x: auto; }
.food-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.food-table th, .food-table td { padding: 13px 21px; border-bottom: 1px solid var(--line); text-align: left; }
.food-table th { color: var(--muted); background: var(--surface-soft); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; }
.food-table td { color: var(--ink-strong); font-size: 12px; }
.food-table td:not(:first-child), .food-table th:not(:first-child) { text-align: right; }
.food-table tbody tr:hover { background: #fbfcfa; }
.food-name { font-weight: 600; }
.food-note { padding: 15px 21px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.empty-state { padding: 40px 21px; color: var(--muted); text-align: center; }

.info-view { gap: 20px; }
.info-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 26px; color: #eef6ef; background: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.info-hero h2 { margin-bottom: 8px; color: #ffffff; font-size: clamp(23px, 3vw, 31px); }
.info-hero p:not(.eyebrow) { max-width: 690px; margin: 0; color: #bad0c4; font-size: 13px; line-height: 1.55; }
.info-hero .eyebrow { color: var(--lime); }
.info-hero-value { display: grid; grid-template-columns: 1fr; min-width: 144px; padding: 16px 18px; color: var(--ink); background: var(--lime); border-radius: 11px; text-align: center; }
.info-hero-value span { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.info-hero-value strong { display: block; margin: 3px 0; font-family: "Playfair Display", Georgia, serif; font-size: 31px; line-height: 1; }
.info-hero-value small { display: block; color: rgba(23, 63, 53, 0.7); font-size: 10px; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.info-card { min-height: 190px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.info-number { display: inline-grid; width: 27px; height: 27px; margin-bottom: 17px; place-items: center; color: var(--ink); background: var(--mint); border-radius: 50%; font-size: 10px; font-weight: 800; }
.info-card h3 { margin-bottom: 9px; font-size: 16px; }
.info-card p, .info-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.info-section { display: grid; gap: 15px; }
.formula-list { display: grid; gap: 9px; }
.formula-list > div { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 14px; padding: 13px 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; }
.formula-list strong { color: var(--ink); font-size: 12px; }
.formula-list span { color: var(--muted); font-size: 12px; }
.formula-list b { color: var(--ink); font-size: 13px; white-space: nowrap; }
.goal-explanation { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.goal-explanation > div { display: grid; gap: 5px; padding: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; }
.goal-explanation strong { color: var(--ink); font-size: 12px; }
.goal-explanation span { color: var(--muted); font-size: 11px; }
.info-list { display: grid; gap: 10px; margin: 0; padding-left: 19px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.info-list strong { color: var(--ink-strong); }
.info-warning { margin-top: 0; }

.source-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.source-stat { padding: 15px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.source-stat-label { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.source-stat-value { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 24px; }
.source-list { display: grid; gap: 10px; margin: 18px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.app-footer { display: flex; justify-content: space-between; gap: 18px; max-width: 1440px; margin: 0 auto; padding: 0 clamp(22px, 4vw, 62px) 25px; color: var(--muted); font-size: 11px; }
.app-footer .text-button { color: var(--ink); }

.toast { position: fixed; right: 23px; bottom: 22px; z-index: 10; max-width: 330px; padding: 12px 15px; color: #f5fbf3; background: var(--ink); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(9px); transition: opacity 150ms ease, transform 150ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(13, 36, 29, 0.45); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px, 100%); max-height: min(680px, 90vh); overflow: auto; padding: 24px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 30px 80px rgba(11, 32, 24, 0.24); }
.modal-header { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.icon-button { display: grid; width: 32px; height: 32px; place-items: center; color: var(--muted); background: var(--surface-soft); border-radius: 50%; font-size: 23px; line-height: 1; }
.icon-button:hover, .icon-button:focus-visible { color: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 840px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 15; width: min(280px, 86vw); transform: translateX(-100%); transition: transform 180ms ease; box-shadow: 18px 0 45px rgba(8, 28, 20, 0.18); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; width: 35px; height: 35px; margin-right: 12px; place-items: center; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 17px; }
  .topbar { justify-content: start; }
  .topbar-actions { margin-left: auto; }
  .source-chip { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .calorie-overview { grid-template-columns: 132px 1fr; }
  .calorie-ring { width: 132px; height: 132px; }
  .info-hero { align-items: start; flex-direction: column; }
  .info-hero-value { width: 100%; }
}

@media (max-width: 610px) {
  .topbar { min-height: 78px; padding: 15px 18px; }
  .topbar .secondary-button { display: none; }
  .content-wrap { padding: 25px 17px 24px; }
  .app-footer { display: block; padding: 0 17px 22px; line-height: 1.5; }
  .app-footer .text-button { display: block; margin-top: 7px; }
  .page-intro { display: block; }
  .view-actions { justify-content: start; margin-top: 14px; }
  .metrics-grid { gap: 9px; }
  .metric-card { min-height: 112px; padding: 14px; }
  .metric-label { margin-bottom: 13px; font-size: 10px; }
  .metric-value { font-size: 25px; }
  .panel { padding: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .calorie-overview { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .calorie-copy { max-width: 300px; }
  .meal-grid { grid-template-columns: 1fr; }
  .table-toolbar { display: block; padding: 17px; }
  .search-wrap { width: 100%; margin-top: 14px; }
  .food-table th, .food-table td { padding: 12px 14px; }
  .source-summary { grid-template-columns: 1fr; }
  .formula-list > div { grid-template-columns: 1fr; gap: 5px; }
  .formula-list b { white-space: normal; }
  .goal-explanation { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 96px; }
  .metric-label { margin-bottom: 8px; }
}
