/* Палитра Catppuccin Mocha — https://catppuccin.com/palette */
:root {
  --rosewater: #f5e0dc;
  --flamingo: #f2cdcd;
  --pink: #f5c2e7;
  --mauve: #cba6f7;
  --red: #f38ba8;
  --maroon: #eba0ac;
  --peach: #fab387;
  --yellow: #f9e2af;
  --green: #a6e3a1;
  --teal: #94e2d5;
  --sky: #89dceb;
  --sapphire: #74c7ec;
  --blue: #89b4fa;
  --lavender: #b4befe;
  --text: #cdd6f4;
  --subtext1: #bac2de;
  --subtext0: #a6adc8;
  --overlay2: #9399b2;
  --overlay1: #7f849c;
  --overlay0: #6c7086;
  --surface2: #585b70;
  --surface1: #45475a;
  --surface0: #313244;
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;

  --radius: 16px;
  --bar-h: 120px; /* высота панели отчётов, уточняется из app.js */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--base); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--base);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view { max-width: 560px; margin: 0 auto; }

/* ---------- Шапка ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 12px;
}

.topbar-text { flex: 1; min-width: 0; }

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.sub { margin: 4px 0 0; font-size: 13px; color: var(--subtext0); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 14px;
  background: var(--surface0);
  color: var(--text);
  transition: transform .12s ease;
}

.icon-btn:active { transform: scale(.94); }
.icon-btn.accent { background: var(--mauve); color: var(--crust); }
.icon-btn.accent svg { stroke-width: 2.4; }

/* ---------- Поиск ---------- */
.search { padding: 0 16px 12px; }

.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--surface0);
  border-radius: 12px;
  background: var(--mantle) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f849c' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center / 18px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease;
}

.search input::placeholder { color: var(--overlay0); }
.search input:focus { border-color: var(--lavender); }

/* ---------- Карточки ---------- */
.cards {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 16px calc(var(--bar-h) + 20px);
  list-style: none;
}

.card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface0);
  cursor: pointer;
  outline: none;
  transition: transform .12s ease, background-color .12s ease, opacity .2s ease;
}

.card:active { transform: scale(.985); background: #3a3b50; }
.card:focus-visible { box-shadow: 0 0 0 2px var(--lavender); }
.card.off { opacity: .5; }

.card-head { display: flex; align-items: flex-start; gap: 12px; }

.card-name {
  flex: 1;
  min-width: 0;
  margin: 3px 0 0;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip.batch { color: var(--peach); background: rgba(250, 179, 135, .14); }
.chip.batch.none { color: var(--overlay1); background: transparent; box-shadow: inset 0 0 0 1px var(--surface2); }
.chip.shelf { color: var(--blue); background: rgba(137, 180, 250, .14); }

.qty { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.q { padding: 8px 11px; border-radius: 12px; background: var(--mantle); }
.q-label { display: block; font-size: 12px; color: var(--subtext0); }

.q-value {
  display: block;
  margin-top: 1px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.q.showcase .q-value { color: var(--green); }
.q.fridge .q-value { color: var(--sky); }
.q.none .q-value { color: var(--overlay0); }

.card.skeleton {
  height: 128px;
  cursor: default;
  background: linear-gradient(100deg, var(--surface0) 40%, #3a3b50 50%, var(--surface0) 60%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.empty { margin: 36px 24px; text-align: center; color: var(--subtext0); }

/* ---------- Переключатель ---------- */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface1);
  transition: background-color .18s ease;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--overlay2);
  transition: transform .18s ease, background-color .18s ease;
}

.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"] span { transform: translateX(20px); background: var(--base); }
.switch:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; }

/* ---------- Панель отчётов ---------- */
.reportbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--surface0);
  background: rgba(24, 24, 37, .94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.reportbar-inner { max-width: 528px; margin: 0 auto; }

/* Переключатель «Холодильник | Витрина» */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 12px;
  background: var(--crust);
}

.seg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--overlay1);
  font-size: 14px;
  font-weight: 650;
  transition: background-color .15s ease, color .15s ease;
}

.seg-btn svg { width: 16px; height: 16px; }
.seg-btn[aria-checked="true"] { background: var(--surface0); }
.seg-btn[data-place="fridge"][aria-checked="true"] { color: var(--sky); }
.seg-btn[data-place="showcase"][aria-checked="true"] { color: var(--green); }
.seg-btn:focus-visible { outline: 2px solid var(--lavender); outline-offset: 1px; }

.report-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.report-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  text-align: left;
  transition: transform .12s ease, opacity .2s ease;
}

.report-btn:active { transform: scale(.97); }
.report-btn:disabled { opacity: .6; }
.report-btn.primary { background: var(--mauve); color: var(--crust); }
.report-btn.secondary { background: var(--surface0); box-shadow: inset 0 0 0 1px var(--surface1); }
.report-btn.secondary svg { color: var(--sky); }
.reportbar[data-place="showcase"] .report-btn.secondary svg { color: var(--green); }
.report-btn.busy svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.rb-text { display: flex; flex-direction: column; min-width: 0; }
.rb-main { font-size: 16px; font-weight: 750; line-height: 1.2; }
.rb-sub { font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Форма ---------- */
.form { display: grid; gap: 16px; padding: 4px 16px calc(32px + var(--safe-bottom)); }

.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }

.label { padding: 0; font-size: 13px; font-weight: 600; color: var(--subtext1); }

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--surface1);
  border-radius: 12px;
  background: var(--mantle);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input::placeholder { color: var(--overlay0); }
.input:focus { border-color: var(--lavender); box-shadow: 0 0 0 3px rgba(180, 190, 254, .16); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(243, 139, 168, .14); }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 120px; }

.suffix {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}

.hint { font-size: 12.5px; color: var(--overlay1); }
.err { font-size: 12.5px; font-style: normal; color: var(--red); }
.err:empty { display: none; }

.range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.dash { color: var(--overlay1); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface0);
}

.switch-row .hint { display: block; }
.label-strong { display: block; font-weight: 600; }

.actions { display: grid; gap: 10px; margin-top: 4px; }

.btn {
  height: 52px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  transition: transform .12s ease, opacity .2s ease;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn.primary { background: var(--mauve); color: var(--crust); }
.btn.danger { background: rgba(243, 139, 168, .12); color: var(--red); }

/* ---------- Уведомления и заглушка ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(var(--bar-h), var(--safe-bottom)) + 12px);
  z-index: 30;
  max-width: 528px;
  margin: 0 auto;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  border-radius: 14px;
  background: var(--surface1);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(17, 17, 27, .55);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show { opacity: 1; transform: none; }
.toast.warn { border-left-color: var(--yellow); }
.toast.error { border-left-color: var(--red); }

.blocker {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--base);
}

.blocker-card { max-width: 340px; text-align: center; }
.blocker-icon { font-size: 44px; }
.blocker h2 { margin: 12px 0 6px; font-size: 20px; }
.blocker p { margin: 0; color: var(--subtext0); }
