:root {
  --bg: #f4f0e8;
  --surface: #fffdf8;
  --surface-strong: #fff;
  --text: #2f2a23;
  --muted: #6b645a;
  --brand: #c86b2b;
  --brand-deep: #9a4d17;
  --ok: #1f7a4b;
  --warn: #8f5d00;
  --bad: #a43224;
  --border: #e4d9c6;
  --shadow: 0 14px 36px rgba(107, 81, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 0% 0%, #f7ead6 0%, var(--bg) 45%, #efe9dd 100%);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}

.shape-1 {
  width: 260px;
  height: 260px;
  top: -80px;
  right: -60px;
  background: #f7b66f;
}

.shape-2 {
  width: 340px;
  height: 340px;
  left: -90px;
  bottom: -120px;
  background: #dfd3b9;
}

.container {
  width: min(980px, 94vw);
  margin: 28px auto 42px;
  display: grid;
  gap: 16px;
}

.page-header {
  padding: 10px 4px;
  animation: fade-up 0.45s ease;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.card {
  background: linear-gradient(165deg, var(--surface) 0%, var(--surface-strong) 65%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: fade-up 0.45s ease;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1.08rem;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #d6c9b4;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(200, 107, 43, 0.24);
  border-color: var(--brand);
}

button {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 10px 14px;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary-btn {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
}

.secondary-btn {
  background: #f7eddf;
  border: 1px solid #e6d4bb;
  color: #624022;
}

.full-width {
  grid-column: 1 / -1;
}

.message {
  min-height: 22px;
  margin: 8px 0 0;
  font-size: 0.88rem;
}

.error {
  color: #a43326;
}

.intake-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
}

.intake-left,
.intake-right {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}

.intake-toolbar {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 10px;
}

.category-tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-btn {
  background: #f5ebdd;
  border: 1px solid #e8d8c1;
  color: #6a4728;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
}

.category-btn.active {
  background: linear-gradient(165deg, #dc8a4f 0%, #c5682a 100%);
  border-color: #c5682a;
  color: #fff;
}

.food-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.food-card {
  border: 1px solid #eadbc6;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.food-card.selected {
  border-color: #d3702d;
  box-shadow: 0 0 0 3px rgba(211, 112, 45, 0.12);
}

.food-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.food-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff2df;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.food-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
}

.food-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.food-card button {
  padding: 6px 10px;
  font-size: 0.84rem;
}

.food-grid-empty {
  grid-column: 1 / -1;
  border: 1px dashed #dcc7aa;
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
}

.panel-title {
  margin: 0 0 8px;
  font-size: 1rem;
}

.manual-panel {
  margin-top: 12px;
}

.manual-panel summary {
  cursor: pointer;
  color: #6f4a28;
}

.manual-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.entry-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}

.entry-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.entry-table th,
.entry-table td {
  border-bottom: 1px solid #efe5d4;
  padding: 10px;
  text-align: left;
  font-size: 0.92rem;
}

.entry-table th {
  color: #5e4a34;
  background: #fff7eb;
}

.empty-row {
  text-align: center;
  color: var(--muted);
}

.result-card .result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.value {
  margin: 6px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.status {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.status.neutral {
  color: #5b554b;
  background: #f3eee5;
}

.status.good {
  color: #145030;
  background: #e4f3e8;
}

.status.warn {
  color: #5e4100;
  background: #fff3dc;
}

.status.bad {
  color: #6d2018;
  background: #fde7e4;
}

.disclaimer {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: #7b7268;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .intake-layout {
    grid-template-columns: 1fr;
  }

  .entry-table-wrap {
    max-height: none;
  }
}

@media (max-width: 900px) {
  .food-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .grid-form,
  .manual-grid,
  .result-card .result-grid,
  .intake-toolbar {
    grid-template-columns: 1fr;
  }

  .food-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 420px;
  }

  .value {
    font-size: 1.15rem;
  }

  .container {
    margin-top: 18px;
  }
}
