:root {
  --bg: #f6f3ea;
  --panel: #fffaf1;
  --panel-2: #ffffff;
  --ink: #243128;
  --muted: #718073;
  --line: rgba(36, 49, 40, .12);
  --green: #7fa88f;
  --green-dark: #3d6a51;
  --mint: #dfeee3;
  --cream: #fff7e7;
  --orange: #d9995a;
  --red: #ba6c62;
  --shadow: 0 24px 60px rgba(49, 65, 55, .12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(223, 238, 227, .95), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(255, 247, 231, 1), transparent 35%),
    linear-gradient(135deg, #f7f1e6 0%, #eef4ef 100%);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  padding: 22px;
  gap: 20px;
}

.sidebar {
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 241, .72);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  font-size: 28px; font-weight: 800;
  box-shadow: 0 12px 28px rgba(61, 106, 81, .25);
}
.brand h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.nav { display: grid; gap: 8px; margin-top: 10px; }
.nav-item {
  border: 0;
  border-radius: 17px;
  padding: 14px 16px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition: .18s ease;
}
.nav-item:hover { background: rgba(127, 168, 143, .12); color: var(--green-dark); }
.nav-item.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 10px 22px rgba(49, 65, 55, .08);
  font-weight: 700;
}

.sync-card {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  background: rgba(255,255,255,.55);
}
.sync-card strong { display: block; font-size: 14px; }
.sync-card small { color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--orange); box-shadow: 0 0 0 5px rgba(217,153,90,.18); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(127,168,143,.18); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 5px rgba(186,108,98,.18); }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.topbar {
  min-height: 92px;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,.58);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 48px rgba(49,65,55,.08);
}
.eyebrow { margin: 0 0 4px; color: var(--green-dark); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.topbar h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.top-actions { display: flex; gap: 10px; align-items: center; }

.primary, .ghost, .soft, .danger {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  transition: .18s ease;
}
.primary { color: #fff; background: var(--green-dark); box-shadow: 0 14px 26px rgba(61,106,81,.25); }
.primary:hover { transform: translateY(-1px); }
.ghost { color: var(--ink); background: rgba(255,255,255,.74); border: 1px solid var(--line); }
.soft { color: var(--green-dark); background: var(--mint); }
.danger { color: #7d3d38; background: rgba(186,108,98,.12); }
.icon-btn { width: 38px; height: 38px; border: 0; border-radius: 14px; background: rgba(36,49,40,.06); font-size: 22px; }

.view { min-height: calc(100vh - 158px); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px;
  background: rgba(255,250,241,.74);
  box-shadow: 0 18px 50px rgba(49,65,55,.08);
  backdrop-filter: blur(16px);
}
.card.white { background: rgba(255,255,255,.70); }
.card h3 { margin: 0 0 14px; font-size: 19px; letter-spacing: -.02em; }
.card p { color: var(--muted); }

.hero {
  position: relative;
  overflow: hidden;
  min-height: 284px;
  padding: 30px;
  color: #213428;
  background:
    radial-gradient(circle at 78% 22%, rgba(255,255,255,.75), transparent 22%),
    linear-gradient(135deg, #e3f0e5 0%, #fff1d8 100%);
}
.hero::after {
  content: "";
  position: absolute; right: -50px; bottom: -70px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(127,168,143,.18);
}
.hero-content { position: relative; z-index: 1; max-width: 720px; }
.hero .kcal { font-size: clamp(52px, 8vw, 96px); line-height: .95; letter-spacing: -.07em; margin: 8px 0 12px; font-weight: 850; }
.hero .sub { margin: 0; font-size: 16px; color: #516251; }
.metric-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.metric-pill {
  padding: 12px 14px; border-radius: 18px;
  background: rgba(255,255,255,.66); border: 1px solid rgba(255,255,255,.64);
  min-width: 142px;
}
.metric-pill span { display: block; color: var(--muted); font-size: 12px; }
.metric-pill strong { display: block; margin-top: 4px; font-size: 18px; }

.stat {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat label { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 32px; letter-spacing: -.05em; }
.stat small { color: var(--muted); }

.progress { height: 12px; border-radius: 999px; background: rgba(36,49,40,.08); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--green-dark)); transition: width .25s ease; }

.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(36,49,40,.08);
}
.row-main { min-width: 0; }
.row-title { margin: 0; font-weight: 800; }
.row-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.row-value { text-align: right; font-weight: 800; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.tiny { padding: 8px 10px; border-radius: 12px; border: 0; background: rgba(36,49,40,.06); color: var(--ink); font-size: 12px; font-weight: 700; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: rgba(61,106,81,.45); box-shadow: 0 0 0 4px rgba(127,168,143,.13); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; background: rgba(255,255,255,.6); color: var(--muted); font-weight: 800; }
.tab.active { background: var(--green-dark); color: #fff; border-color: transparent; }

.search-results { display: grid; gap: 10px; max-height: 340px; overflow: auto; padding-right: 4px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 10px; background: rgba(127,168,143,.14); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.badge.orange { background: rgba(217,153,90,.16); color: #8b5d2d; }
.badge.red { background: rgba(186,108,98,.14); color: #8d443d; }

.chart { width: 100%; min-height: 220px; }
.chart svg { width: 100%; height: 220px; overflow: visible; }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

.modal {
  border: 0;
  padding: 0;
  border-radius: var(--radius-xl);
  background: transparent;
  width: min(760px, calc(100vw - 28px));
}
.modal::backdrop { background: rgba(25, 35, 27, .34); backdrop-filter: blur(4px); }
.modal-card {
  margin: 0;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: var(--radius-xl);
  background: rgba(255,250,241,.96);
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 22px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(18px);
  opacity: 0; pointer-events: none;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(36,49,40,.92);
  color: #fff;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
  transition: .2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--muted);
  border: 1px dashed rgba(36,49,40,.18);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.45);
}

.note {
  border-left: 4px solid var(--green);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(127,168,143,.12);
  color: #43564a;
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; padding: 12px; padding-bottom: 82px; }
  .sidebar {
    position: fixed; left: 12px; right: 12px; bottom: 10px; top: auto; height: auto; z-index: 10;
    padding: 10px;
    border-radius: 24px;
    flex-direction: row;
    align-items: center;
  }
  .brand, .sync-card { display: none; }
  .nav { display: grid; grid-template-columns: repeat(6, 1fr); width: 100%; gap: 4px; margin: 0; }
  .nav-item { text-align: center; padding: 11px 4px; border-radius: 16px; font-size: 13px; }
  .topbar { padding: 18px; align-items: flex-start; gap: 14px; flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .hero { padding: 22px; min-height: 260px; }
  .hero .kcal { font-size: 58px; }
}

@media (max-width: 520px) {
  .nav { grid-template-columns: repeat(6, 1fr); }
  .nav-item { font-size: 12px; padding: 10px 2px; }
  .topbar h2 { font-size: 25px; }
  .card { padding: 18px; }
  .metric-pill { min-width: calc(50% - 8px); }
}
