/* ============================================================
   Essen-Tracker – gleiches Dark-Theme wie die Fitness-App,
   Akzent grün statt rot, Mobile-First
   ============================================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --bg-elevated: #0f3460;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-light: rgba(34, 197, 94, 0.15);
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a8a;
  --border: rgba(255, 255, 255, 0.1);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
  --info: #60a5fa;
  --protein: #60a5fa;
  --carbs: #fbbf24;
  --fat: #f472b6;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 700; line-height: 1.2; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

/* ── Layout ─────────────────────────────────────────────── */
.page-header {
  background: var(--bg-card);
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.page-header h1 { font-size: 1.2rem; flex: 1; text-align: center; }
.page-content {
  padding: 12px 16px;
  padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; width: 100%;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex; z-index: 200;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--text-muted); font-size: 0.7rem; font-weight: 500;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 2; }
.nav-item.active { color: var(--accent); }
.nav-item.nav-add svg {
  width: 44px; height: 44px; padding: 10px; border-radius: 50%;
  background: var(--accent); color: #fff; margin-top: -18px; box-shadow: var(--shadow);
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; border: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.section-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: 16px 0 8px;
}
.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.hint { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--radius-sm); border: none;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; text-decoration: none;
  color: var(--text-primary); background: var(--bg-elevated); font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239,68,68,.35); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-full { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn-icon {
  width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%;
  background: transparent; border: none; color: var(--text-primary); font-size: 1.3rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.form-control {
  width: 100%; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 1rem; padding: 10px 12px; min-height: 44px; outline: none; font-family: inherit;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { appearance: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.seg { display: flex; background: var(--bg-primary); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--text-secondary); padding: 8px 4px;
  border-radius: 6px; font-weight: 600; font-size: 0.85rem; cursor: pointer; font-family: inherit;
}
.seg button.active { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Login ──────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-icon { font-size: 3rem; }
.login-logo p { color: var(--text-secondary); }
.error-message { color: var(--danger); font-size: 0.9rem; margin-bottom: 10px; display: none; }

/* ── Tagesübersicht ─────────────────────────────────────── */
.day-nav { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.day-nav .day-label { font-weight: 700; font-size: 1.05rem; text-align: center; flex: 1; cursor: pointer; }
.day-nav .day-label small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.75rem; }

.summary { display: flex; align-items: center; gap: 14px; }
.ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring-bg { stroke: var(--bg-elevated); }
.ring-fg { stroke: var(--accent); transition: stroke-dashoffset .5s ease; stroke-linecap: round; }
.ring.over .ring-fg { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-text .big { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring-text .lbl { font-size: 0.72rem; color: var(--text-secondary); }
.ring.over .ring-text .big { color: var(--danger); }
.summary-stats { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.summary-stats .row { display: flex; justify-content: space-between; }
.summary-stats .row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.macro .top { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-secondary); }
.macro .val { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; border-radius: 3px; transition: width .4s ease; }
.macro.protein .bar > div { background: var(--protein); }
.macro.carbs .bar > div { background: var(--carbs); }
.macro.fat .bar > div { background: var(--fat); }
.bar.over > div { background: var(--danger) !important; }

.meal-card { padding: 0; overflow: hidden; }
.meal-head { display: flex; align-items: center; padding: 10px 8px 10px 14px; gap: 8px; }
.meal-head .meal-name { font-weight: 700; flex: 1; }
.meal-head .meal-kcal { color: var(--text-secondary); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.meal-add { background: var(--accent-light); color: var(--accent); }
.entry { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.entry:active { background: rgba(255,255,255,.03); }
.entry .info { flex: 1; min-width: 0; }
.entry .name { font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .meta { font-size: 0.75rem; color: var(--text-muted); }
.entry .kcal { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* ── Suche / Liste ──────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; position: sticky; top: 56px; z-index: 50; background: var(--bg-primary); padding: 8px 0; }
.search-bar .form-control { flex: 1; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); white-space: nowrap;
  border-radius: 20px; padding: 6px 14px; font-size: 0.85rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.tab.active { background: var(--accent-light); color: var(--accent); border-color: rgba(34,197,94,.4); }

.food-list { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.food-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); cursor: pointer; }
.food-item:first-child { border-top: none; }
.food-item:active { background: rgba(255,255,255,.03); }
.food-item img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; background: #fff; flex-shrink: 0; }
.food-item .info { flex: 1; min-width: 0; }
.food-item .name { font-size: 0.93rem; line-height: 1.25; }
.food-item .meta { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }
.food-item .kcal { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.food-item .kcal small { display: block; font-weight: 400; font-size: 0.7rem; color: var(--text-muted); }
.badge { display: inline-block; font-size: 0.62rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; vertical-align: 1px; margin-right: 4px; letter-spacing: .03em; }
.badge-bls { background: rgba(96,165,250,.18); color: var(--info); }
.badge-off { background: rgba(251,191,36,.16); color: var(--warning); }
.badge-custom { background: var(--accent-light); color: var(--accent); }
.badge-recipe { background: rgba(244,114,182,.16); color: var(--fat); }
.badge-quick { background: rgba(160,160,176,.16); color: var(--text-secondary); }
.empty-state { text-align: center; color: var(--text-muted); padding: 28px 16px; font-size: 0.9rem; }

/* ── Modal (Bottom Sheet) ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border-radius: 16px 16px 0 0; padding: 18px 16px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 600px; max-height: 92vh; overflow-y: auto;
  transform: translateY(100%); transition: transform .25s ease; border-top: 3px solid var(--accent);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modal-title { font-size: 1.1rem; font-weight: 700; flex: 1; line-height: 1.3; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.6rem; cursor: pointer; line-height: 1; padding: 0 4px; }

.amount-row { display: flex; gap: 8px; align-items: stretch; }
.amount-row input { font-size: 1.4rem; font-weight: 700; text-align: center; }
.amount-row .unit { display: flex; align-items: center; color: var(--text-secondary); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-primary);
  border-radius: 16px; padding: 5px 11px; font-size: 0.8rem; cursor: pointer; font-family: inherit;
}
.chip.active { border-color: var(--accent); color: var(--accent); }
.nutri-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin: 8px 0; }
.nutri-table td { padding: 5px 0; border-bottom: 1px solid var(--border); }
.nutri-table td:last-child, .nutri-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.nutri-table td:nth-child(2) { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nutri-table tr.main td { font-weight: 700; font-size: 1rem; }
.nutri-table .sub td:first-child { padding-left: 12px; color: var(--text-secondary); }

/* ── Verlauf ────────────────────────────────────────────── */
.chart { width: 100%; height: 190px; display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-box { background: var(--bg-primary); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat-box .v { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-box .l { font-size: 0.72rem; color: var(--text-secondary); }
.day-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; }
.day-row:first-child { border-top: none; }
.day-row .d { width: 92px; font-size: 0.85rem; }
.day-row .b { flex: 1; }
.day-row .k { width: 64px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.pos { color: var(--danger); } .neg { color: var(--success); }

/* ── Scanner ────────────────────────────────────────────── */
.scanner { position: fixed; inset: 0; background: #000; z-index: 1100; display: none; flex-direction: column; }
.scanner.show { display: flex; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.scanner .bar-top { position: absolute; top: env(safe-area-inset-top); left: 0; right: 0; padding: 12px; display: flex; justify-content: space-between; align-items: center; }
.scanner .bar-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-size: .9rem; background: linear-gradient(transparent, rgba(0,0,0,.7)); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mb-2 { margin-bottom: 8px; }

/* ── Flüssigkeit (kompakte Leiste in der Tagesansicht) ──── */
.fluid-card { padding: 8px 10px 10px; }
.fluid-info { display: flex; align-items: center; width: 100%; background: none; border: none; color: inherit; text-align: left; font: inherit; cursor: pointer; padding: 2px 2px 6px; }
.fluid-text { flex: 1; font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.fluid-text strong { color: var(--text-primary); }
.fluid-more { color: var(--text-muted); font-size: 1.1rem; line-height: 1; }
.fluid-bar { display: block; margin-top: 8px; }
.fluid-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--info); transition: width .3s ease; }
.fluid-bar.done > span { background: var(--accent); }
.qb-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; transition: grid-template-columns .25s ease; }
.qb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; padding: 5px 4px;
  border-radius: var(--radius-sm); background: rgba(96,165,250,.14); border: 1px solid rgba(96,165,250,.32); color: var(--text-primary);
  font-family: inherit; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; min-width: 0; }
.qb:active { transform: scale(.96); background: rgba(96,165,250,.26); }
.qb-l { font-size: .8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.qb-a { font-size: .95rem; font-weight: 700; color: var(--info); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qbc { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; }
.qbc-head { font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
.qbc-row { display: flex; gap: 8px; align-items: center; }
.qbc-row select { flex: 1; min-width: 0; }
.qbc-icon { width: 56px; flex: 0 0 56px; text-align: center; }
.qbc .chips { margin: 6px 0 4px; }
.snackbar { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-height) + 14px + env(safe-area-inset-bottom)); max-width: 568px; margin: 0 auto;
  background: #0f3460; color: #f0f0f0; border-radius: 10px; padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 900; font-size: .9rem; transition: opacity .25s, transform .25s; }
.snackbar.hide { opacity: 0; transform: translateY(12px); pointer-events: none; }
.snackbar span { flex: 1; }
.snackbar button { background: none; border: none; color: var(--info); font-weight: 700; font-size: .9rem; padding: 8px 10px; cursor: pointer; font-family: inherit; }
.fl-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.fl-row:first-child { border-top: none; }
.fl-row .t { width: 44px; font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fl-row .n { flex: 1; min-width: 0; font-size: .9rem; }
.fl-row .n small { display: block; color: var(--text-muted); font-size: .72rem; }
.fl-row .ml { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fl-row input { width: 76px; min-height: 36px; padding: 4px 8px; text-align: right; }
.qbc-row input[data-f=amount], .qbc-row input[data-f=ml] { width: 96px; flex: 0 0 96px; text-align: right; }

/* Tägliche Buttons: offen (dezent grün), kompakt, erledigt */
.qb-daily { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.35); }
.qb-daily .qb-a { color: var(--accent); }
.qb-a small { font-size: .65rem; font-weight: 600; color: var(--warning); }
.qb-small { padding: 5px 2px; background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.35); }
.qb-small .qb-a { font-size: .75rem; color: var(--accent); }
.qb-i { font-size: 1.05rem; line-height: 1.1; }
.qb-done { padding: 4px 6px; gap: 0; background: rgba(34,197,94,.08); border: 2px solid var(--accent); }
.qb-ok { color: var(--accent); font-weight: 800; font-size: .9rem; line-height: 1; }
.qbc-head { display: flex; align-items: center; gap: 6px; }
.qbc-off-btn { margin-left: auto; background: none; border: none; color: var(--text-muted); font-size: .75rem; cursor: pointer; font-family: inherit; padding: 4px; }
.qbc-daily { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; }
.qbc-daily input { width: 20px; height: 20px; accent-color: var(--accent); }
.c-ok { color: var(--accent); }
