:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --bg-soft: #eef4eb;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --ink: #162014;
  --muted: #657160;
  --soft: #dfe8dc;
  --line: rgba(22, 32, 20, 0.1);
  --brand: #237c3a;
  --brand-2: #78b84f;
  --brand-dark: #145625;
  --amber: #f4b63f;
  --danger: #b94848;
  --shadow: 0 24px 60px rgba(34, 77, 37, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(120, 184, 79, 0.28), transparent 34rem),
    radial-gradient(circle at top right, rgba(244, 182, 63, 0.22), transparent 28rem),
    linear-gradient(160deg, #fbfcf8 0%, var(--bg) 52%, #edf5e8 100%);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img {
  max-width: 100%;
  display: block;
}

.screen {
  min-height: 100dvh;
  padding: 18px;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 26px rgba(35, 124, 58, 0.28);
}

.brand-copy strong {
  display: block;
  font-size: 1.18rem;
  letter-spacing: -0.03em;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-title {
  margin: 0 0 8px;
  font-size: clamp(2.1rem, 11vw, 4rem);
  line-height: 0.96;
  letter-spacing: -0.07em;
}

.hero-title span {
  color: var(--brand);
}

.lede {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border-radius: 999px;
  background: var(--bg-soft);
  margin-bottom: 18px;
}

.tabs button {
  padding: 11px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tabs button.active {
  color: #fff;
  background: var(--brand);
}

.form {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(35, 124, 58, 0.45);
  box-shadow: 0 0 0 4px rgba(35, 124, 58, 0.12);
  background: #fff;
}

.button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 16px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(35, 124, 58, 0.24);
}

.button.secondary {
  color: var(--ink);
  background: var(--bg-soft);
  box-shadow: none;
}

.button.ghost {
  color: var(--brand-dark);
  background: transparent;
  box-shadow: none;
}

.button.danger {
  background: var(--danger);
  box-shadow: none;
}

.alert {
  padding: 12px 14px;
  border-radius: 15px;
  color: var(--danger);
  background: rgba(185, 72, 72, 0.1);
  border: 1px solid rgba(185, 72, 72, 0.16);
  font-size: 0.92rem;
}

.app-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding-bottom: 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 14px;
  background: linear-gradient(180deg, rgba(246, 248, 245, 0.96), rgba(246, 248, 245, 0.72) 78%, transparent);
  backdrop-filter: blur(16px);
}

.topbar .brand-lockup {
  margin: 0;
  min-width: 0;
}

.topbar .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 15px;
}

.topbar .brand-copy span {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-button {
  position: relative;
  min-width: 74px;
  height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  background: #172114;
  box-shadow: 0 18px 34px rgba(22, 32, 20, 0.22);
  font-weight: 800;
}

.cart-button small {
  display: block;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.62rem;
  line-height: 1;
}

.page-head {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.08em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.search-panel {
  position: relative;
  margin-bottom: 16px;
}

.search-panel input {
  min-height: 58px;
  padding-left: 48px;
  border-radius: 22px;
  font-weight: 700;
}

.search-panel::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-58%);
  opacity: 0.72;
}

.search-panel::after {
  content: "";
  position: absolute;
  left: 31px;
  top: 36px;
  width: 8px;
  height: 2px;
  border-radius: 99px;
  background: var(--muted);
  transform: rotate(45deg);
  opacity: 0.72;
}

.quick-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 16px;
  scrollbar-width: none;
}

.quick-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.chip.active {
  color: #fff;
  border-color: transparent;
  background: var(--brand);
}

.grid {
  display: grid;
  gap: 14px;
}

.food-card, .category-card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(34, 77, 37, 0.08);
  overflow: hidden;
}

.food-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  min-height: 148px;
}

.thumb {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(35, 124, 58, 0.16), rgba(244, 182, 63, 0.18)),
    var(--bg-soft);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 900;
  font-size: 1.6rem;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.food-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.food-title-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.food-title-row h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

.food-title-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.carb-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 13px;
  color: var(--brand-dark);
  background: rgba(120, 184, 79, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
}

.meta-line {
  color: var(--muted);
  font-size: 0.8rem;
}

.calc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  align-items: end;
}

.segmented {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.segmented button {
  flex: 1;
  padding: 8px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--brand);
}

.mini-input {
  min-height: 42px;
  border-radius: 14px;
  padding: 9px 12px;
}

.add-button {
  min-width: 58px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  letter-spacing: -0.04em;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

.category-card {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-card strong {
  display: block;
  letter-spacing: -0.02em;
}

.category-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty {
  padding: 24px;
  border: 1px dashed rgba(22, 32, 20, 0.18);
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 22;
  width: min(calc(100% - 28px), 520px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(20px);
}

.bottom-nav button {
  min-height: 46px;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-nav button.active {
  color: #fff;
  background: var(--ink);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 20, 10, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 41;
  width: min(100%, 560px);
  max-height: 82dvh;
  padding: 18px;
  border-radius: 28px 28px 0 0;
  background: var(--panel-solid);
  box-shadow: 0 -26px 70px rgba(22, 32, 20, 0.26);
  transform: translate(-50%, 105%);
  transition: transform 220ms cubic-bezier(.2,.7,.2,1);
  overflow: auto;
}

.drawer.open {
  transform: translate(-50%, 0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.drawer-head h2 {
  margin: 0;
  letter-spacing: -0.05em;
}

.total-card {
  padding: 18px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  margin-bottom: 14px;
}

.total-card span {
  color: rgba(255,255,255,0.7);
  font-weight: 700;
}

.total-card strong {
  display: block;
  margin-top: 4px;
  font-size: 2.4rem;
  letter-spacing: -0.08em;
}

.calc-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.calc-item strong {
  display: block;
}

.calc-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.small-link {
  color: var(--brand-dark);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.photo-preview {
  width: 100%;
  max-height: 180px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.hidden { display: none !important; }

@media (min-width: 720px) {
  .screen { padding: 24px; }
  .app-shell { padding-bottom: 34px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .food-card { grid-template-columns: 116px 1fr; }
  .bottom-nav { position: sticky; top: 72px; bottom: auto; margin: 4px auto 22px; transform: none; left: auto; }
  .page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
  .side-panel { position: sticky; top: 88px; }
}
