/* ── Домашний склад — стили ─────────────────────────────────────────────── */
:root {
  --bg: oklch(0.972 0.008 95);
  --surface: oklch(0.995 0.004 95);
  --ink: oklch(0.25 0.02 60);
  --ink-soft: oklch(0.45 0.02 70);
  --line: oklch(0.9 0.01 90);
  --primary: oklch(0.45 0.09 150);
  --primary-strong: oklch(0.38 0.08 150);
  --primary-soft: oklch(0.93 0.03 150);
  --warn: oklch(0.62 0.14 70);
  --warn-soft: oklch(0.94 0.05 80);
  --danger: oklch(0.52 0.16 25);
  --danger-soft: oklch(0.94 0.03 25);
  --radius: 14px;
  --shadow: 0 1px 3px oklch(0.3 0.02 60 / 0.08), 0 4px 14px oklch(0.3 0.02 60 / 0.06);
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}

button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.hidden, [hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Экраны ── */
.screen { min-height: 100dvh; }

/* ── Авторизация ── */
#screen-auth {
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}
.auth-logo {
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 22px;
}
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 800; }
.auth-sub { text-align: center; color: var(--ink-soft); margin-bottom: 20px; }

.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ── Поля форм ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  background: var(--surface);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; margin: 4px 0 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── Кнопки ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 15px;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: oklch(0.98 0.01 120); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: oklch(0.98 0.01 25); }
.btn-danger:hover { filter: brightness(0.92); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 7px 13px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 12px;
  background: transparent;
  color: var(--ink);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg); }

.badge {
  position: absolute;
  top: 4px; right: 2px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid; place-items: center;
}

/* ── Шапка ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: oklch(0.972 0.008 95 / 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header h1 { font-size: 21px; font-weight: 800; }

/* ── Контент ── */
#main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.view { animation: fade-in 0.18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ── Поиск и фильтры ── */
.search-row { margin-bottom: 10px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink-soft);
}
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 12px 0;
  min-width: 0;
}
.search-box input:focus { outline: none; }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  min-height: 44px;
  transition: all 0.15s;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: oklch(0.98 0.01 120); }

/* ── Карточки продуктов ── */
.product-list { display: flex; flex-direction: column; gap: 10px; }
.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, transform 0.1s;
}
.product-card:active { transform: scale(0.99); }
.product-info { flex: 1; min-width: 0; }
.product-name {
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-meta {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.status-pills { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.pill-low { background: var(--warn-soft); color: oklch(0.42 0.12 60); }
.pill-expiring { background: var(--warn-soft); color: oklch(0.42 0.12 60); }
.pill-out, .pill-expired { background: var(--danger-soft); color: var(--danger); }

.qty-ctrl { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.qty-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 20px;
  font-weight: 700;
  display: grid; place-items: center;
  color: var(--primary-strong);
  transition: background 0.12s, transform 0.1s;
}
.qty-btn:hover { background: var(--primary-soft); }
.qty-btn:active { transform: scale(0.92); }
.qty-value {
  min-width: 52px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}
.qty-unit { font-size: 12px; font-weight: 600; color: var(--ink-soft); }

/* ── Пустые состояния ── */
.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 48px 24px;
}
.empty-state svg { margin: 0 auto 12px; opacity: 0.5; }

/* ── Нижняя навигация ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  transition: color 0.15s;
  min-height: 44px;
}
.nav-btn.active { color: var(--primary-strong); }
.nav-btn:hover { color: var(--ink); }

/* ── Уведомления ── */
.notif-toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s;
}
.notif-item.unread { border-left: 4px solid var(--primary); }
.notif-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.notif-dot.low_stock, .notif-dot.expiring { background: var(--warn); }
.notif-dot.out, .notif-dot.expired { background: var(--danger); }
.notif-msg { font-size: 14.5px; }
.notif-item.unread .notif-msg { font-weight: 600; }
.notif-time { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

/* ── Настройки ── */
.settings-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.settings-group h2 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.settings-hint { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 10px; }
.settings-steps { font-size: 13.5px; color: var(--ink-soft); padding-left: 20px; margin-bottom: 12px; }
.settings-steps code {
  background: var(--bg);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
}
.version-note { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; }

/* ── Модалки ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: oklch(0.2 0.02 60 / 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-sheet { border-radius: 20px !important; max-height: 88dvh; }
}
.modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal-sheet { animation: none; } }
.modal-sheet-sm { max-width: 380px; padding: 22px 20px; }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 4px auto 10px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-head h2 { font-size: 20px; font-weight: 800; word-break: break-word; }
.modal-body { padding: 8px 0 4px; }
.modal-body dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  font-size: 14.5px;
}
.modal-body dt { color: var(--ink-soft); }
.modal-body dd { font-weight: 600; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.confirm-text { font-size: 15.5px; margin-bottom: 18px; }

/* ── Этикетка ── */
.label-section {
  border-top: 1px dashed var(--line);
  margin-top: 14px;
  padding-top: 14px;
}
.label-section h3 { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.label-preview {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  image-rendering: pixelated;
}

/* ── Тост ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  background: oklch(0.28 0.02 60);
  color: oklch(0.97 0.01 95);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: min(90vw, 420px);
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.toast-error { background: var(--danger); }
