/* Светлый минимализм: тонкие линии, много воздуха, цветом — только тревога.
   Экран читается при магазинном освещении, поэтому фон почти белый, а
   контраст текста высокий. Тёмной темы намеренно нет. */
:root {
  --bg: #faf9f7;
  --paper: #ffffff;
  --ink: #1b1a18;
  --ink-soft: #6f6b66;
  --ink-faint: #a5a09a;
  --line: #e2ded8;
  --line-strong: #c9c3bb;
  --warn: #c8850c;
  --warn-bg: #fdf5e6;
  --bad: #c0392b;
  --bad-bg: #fbeceb;
  --ok: #4a7c59;
  --radius: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.app { max-width: 560px; margin: 0 auto; padding: 20px 16px 96px; }

/* ── шапка ─────────────────────────────────────────────────────────────── */
.head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.head h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.head .who { margin-left: auto; font-size: 13px; color: var(--ink-faint); }
.back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
  color: var(--ink-soft); text-decoration: none; font-size: 15px;
  min-height: var(--tap);
}

/* ── главный экран: холодильник и шкаф ─────────────────────────────────── */
.home { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; align-items: start; }

.fridge { width: 100%; display: block; }
.fridge .body { fill: var(--paper); stroke: var(--line-strong); stroke-width: 1.5; }
.fridge .divider { stroke: var(--line-strong); stroke-width: 1.5; }
.fridge .handle { stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; }
.fridge .zone { fill: transparent; cursor: pointer; }
.fridge .zone:active + .zonefill, .fridge .zone:hover + .zonefill { fill: #f2efea; }
.fridge .zonefill { fill: transparent; pointer-events: none; transition: fill .12s; }
.fridge .label { font-size: 11px; fill: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
.fridge .count { font-size: 17px; fill: var(--ink); font-weight: 600; pointer-events: none; }
.fridge .alarm { font-size: 12px; pointer-events: none; }
.fridge .alarm.warn { fill: var(--warn); }
.fridge .alarm.bad { fill: var(--bad); }

.pantry {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer;
}
.pantry h2 { margin: 0 0 10px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.pantry .row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.pantry .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pantry .empty { color: var(--ink-faint); font-size: 13px; }

/* точки уровня запаса */
.dots { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--line-strong); }
.dot.on { background: var(--ink-soft); border-color: var(--ink-soft); }
.lvl0 .dot.on { background: var(--bad); border-color: var(--bad); }
.lvl1 .dot.on { background: var(--warn); border-color: var(--warn); }

/* ── карточки-ссылки под холодильником ─────────────────────────────────── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 13px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); min-height: var(--tap);
}
.tile .t { font-size: 14px; font-weight: 500; }
.tile .s { font-size: 12px; color: var(--ink-faint); }
.tile.accent { border-color: var(--line-strong); }

/* ── списки ────────────────────────────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden; position: relative;
}
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.item .nm { flex: 1; min-width: 0; }
.item .nm b { display: block; font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .nm span { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.item.warn { border-left: 3px solid var(--warn); }
.item.bad { border-left: 3px solid var(--bad); }
.item .nm span.warn { color: var(--warn); }
.item .nm span.bad { color: var(--bad); font-weight: 500; }

.acts { display: flex; gap: 6px; flex: 0 0 auto; }
.act {
  min-width: var(--tap); min-height: 36px; padding: 0 10px;
  border: 1px solid var(--line-strong); background: var(--paper); border-radius: 9px;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.act:active { background: #f2efea; }
.act.eat { border-color: #b7cdbe; color: var(--ok); }
.act.trash { border-color: #e6c3bf; color: var(--bad); }

/* ── список покупок ────────────────────────────────────────────────────── */
.buy { display: flex; align-items: center; gap: 12px; padding: 13px 14px; cursor: pointer; }
.box {
  width: 21px; height: 21px; flex: 0 0 auto; border: 1.5px solid var(--line-strong);
  border-radius: 6px; display: grid; place-items: center; font-size: 13px; color: transparent;
}
.buy.done .box { background: var(--ink-soft); border-color: var(--ink-soft); color: #fff; }
.buy.done .txt { text-decoration: line-through; color: var(--ink-faint); }
.buy .txt { flex: 1; font-size: 15px; }
.buy .src { font-size: 11px; color: var(--ink-faint); letter-spacing: .03em; }

/* ── формы ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=number], select {
  width: 100%; padding: 12px 13px; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 11px;
  font-family: inherit; min-height: var(--tap);
}
input:focus, select:focus { outline: 2px solid var(--ink-faint); outline-offset: -1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 13px 16px; font-size: 15px; font-weight: 500;
  background: var(--ink); color: #fff; border: 0; border-radius: 11px; cursor: pointer;
  font-family: inherit;
}
.btn:active { opacity: .85; }
.btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--paper); color: var(--bad); border: 1px solid #e6c3bf; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.addbar { display: flex; gap: 8px; margin-bottom: 14px; }
.addbar input { flex: 1; }
.addbar .btn { width: auto; padding: 0 18px; }

/* ── сканер ────────────────────────────────────────────────────────────── */
.scan { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; margin-bottom: 14px; }
.scan video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan .frame {
  position: absolute; inset: 18% 10%; border: 2px solid rgba(255,255,255,.85); border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.28);
}
.scan .hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* ── прочее ────────────────────────────────────────────────────────────── */
.empty-note { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 32px 12px; }
.sect { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; margin: 22px 0 10px; }
.stat { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat .n { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 14px; z-index: 50; max-width: 90vw; text-align: center;
}

.login { max-width: 320px; margin: 18vh auto 0; }
.login h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.login p { color: var(--ink-faint); font-size: 14px; margin: 0 0 24px; }
.err { color: var(--bad); font-size: 13.5px; margin-bottom: 12px; }

.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--ink); color: #fff;
  border: 0; font-size: 26px; line-height: 1; cursor: pointer; z-index: 20;
  box-shadow: 0 4px 14px rgba(0,0,0,.16);
}
