:root {
  --bg: #f5efe2;
  --surface: #fffdf8;
  --surface-strong: #f0e5cf;
  --text: #2f2418;
  --muted: #766757;
  --line: #d7c7af;
  --accent: #7b9e3d;
  --accent-dark: #29311b;
  --danger: #a44833;
  --shadow: 0 20px 60px rgba(76, 57, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(123, 158, 61, 0.18), transparent 28%),
    linear-gradient(180deg, #f7f2e8 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.version-badge {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  padding: 8px 12px;
  border: 1px solid rgba(41, 49, 27, 0.12);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(76, 57, 26, 0.08);
  backdrop-filter: blur(8px);
}

.hero,
.workspace {
  display: grid;
  gap: 20px;
}

.hero {
  grid-template-columns: 1.6fr auto;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: var(--accent-dark);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.96;
}

.hero-copy,
.table-copy,
.status,
.upload-note {
  color: var(--muted);
}

.hero-copy {
  margin-top: 14px;
  max-width: 58ch;
  font-size: 1rem;
  line-height: 1.55;
}

.workspace {
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.05fr);
  margin-bottom: 24px;
}

.card {
  border: 1px solid rgba(122, 102, 74, 0.12);
  border-radius: 26px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.scanner-card,
.entry-card,
.table-card {
  padding: 24px;
}

.upload-zone {
  display: block;
  margin-top: 18px;
  padding: 22px;
  border: 1.5px dashed var(--line);
  border-radius: 22px;
  background: var(--surface);
  cursor: pointer;
}

.camera-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.upload-zone input {
  display: none;
}

.upload-title {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.preview-wrap {
  margin-top: 18px;
  border-radius: 22px;
  overflow: hidden;
  background: #ede3d2;
  min-height: 280px;
}

#previewImage {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: cover;
}

#cameraPreview {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: cover;
}

.preview-placeholder {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.ocr-actions,
.form-actions,
.table-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.ocr-actions {
  margin-top: 16px;
  flex-wrap: wrap;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

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

.button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-dark {
  color: #fff;
  background: linear-gradient(135deg, #334020 0%, #171d0f 100%);
}

.button-light {
  color: var(--text);
  background: var(--surface-strong);
}

.entry-form {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.entry-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.entry-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}

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

.table-head {
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid rgba(122, 102, 74, 0.16);
}

th {
  font-size: 0.9rem;
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 30px 12px;
}

.table-input {
  width: 88px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.meal-cell {
  font-weight: 700;
}

.action-link {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
}

@media (max-width: 860px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .card,
  .hero {
    box-shadow: none;
    border: 0;
  }
}
