/* Рогалик · закупка — дизайн 2a («Эспрессо») */
/* Темы: html[data-theme="light"|"dark"], переключение в app.js (авто = Telegram/система) */

:root, [data-theme="light"] {
  --bg: #f9f6f3;
  --card: #ffffff;
  --tx: #27201b;
  --tx2: #8f8279;
  --ac: #c75f2e;
  --ac-tx: #ffffff;
  --ac-soft: rgba(199, 95, 46, .1);
  --line: rgba(39, 32, 27, .09);
  --red: #d64545;
  --red-soft: rgba(214, 69, 69, .1);
  --green: #1e9e68;
  --green-soft: rgba(30, 158, 104, .12);
}
[data-theme="dark"] {
  --bg: #151112;
  --card: #1f1a1b;
  --tx: #f1eae6;
  --tx2: #96897f;
  --ac: #e58452;
  --ac-tx: #2b1206;
  --ac-soft: rgba(229, 132, 82, .14);
  --line: rgba(241, 234, 230, .09);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, .12);
  --green: #4ecb96;
  --green-soft: rgba(78, 203, 150, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: 'Onest', system-ui, sans-serif;
  transition: background-color .35s, color .35s;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; padding: 0; }
button:active { transform: scale(.96); }
input { font-family: inherit; outline: none; }
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }

/* ---------- сплэш ---------- */
.splash {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .5s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-emoji { font-size: 64px; animation: bob 1.4s ease-in-out infinite; }
.splash-emoji img { width: 96px; height: 96px; border-radius: 26px; object-fit: cover; display: block; }
.brand span img { width: 22px; height: 22px; border-radius: 7px; object-fit: cover; vertical-align: -5px; }
.splash-emoji svg { width: 120px; height: auto; display: block; color: var(--tx); }
.brand span svg { width: 32px; height: 32px; vertical-align: -11px; color: var(--tx); }
.splash-name { font-size: 24px; font-weight: 800; letter-spacing: 6px; margin-top: 18px; }
.splash-sub { font-size: 11.5px; color: var(--ac); letter-spacing: 4px; margin-top: 8px; font-weight: 600; }
.splash-bar { width: 170px; height: 5px; border-radius: 3px; background: var(--line); margin-top: 26px; overflow: hidden; }
.splash-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--ac), #f0c9a8); animation: fill 2s linear both; }

/* ---------- шапка ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 800; letter-spacing: -.2px; }
.brand span { font-size: 19px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ac-soft); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: var(--ac); }

/* ---------- контент ---------- */
.content { flex: 1; overflow: auto; padding: 4px 18px 96px; }
.screen { display: none; }
.screen.active { display: block; }
.screen.active > * { animation: in .4s both; }
.screen.active > *:nth-child(2) { animation-delay: .04s; }
.screen.active > *:nth-child(3) { animation-delay: .08s; }
.screen.active > *:nth-child(4) { animation-delay: .12s; }
.screen.active > *:nth-child(5) { animation-delay: .16s; }

.h1 { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.sub { font-size: 11.5px; color: var(--tx2); margin-top: 2px; }
.search {
  width: 100%; height: 44px; border-radius: 12px; margin-top: 2px;
  background: var(--card); border: 1px solid var(--line); color: var(--tx);
  padding: 0 14px; font-size: 13.5px; transition: border-color .2s;
}
.search:focus { border-color: var(--ac); }
.search::placeholder { color: var(--tx2); }

/* каталог — плитки */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; text-align: left; }
.tile:active { transform: scale(.95); }
.tile-emoji { font-size: 28px; }
.tile-name { font-size: 14.5px; font-weight: 700; margin-top: 8px; }
.tile-meta { font-size: 11.5px; color: var(--tx2); margin-top: 2px; }
.tile.dashed { background: none; border: 1.5px dashed var(--tx2); color: var(--tx2); }

.chip-inlist { display: inline-block; background: var(--ac-soft); color: var(--ac); font-size: 10.5px; font-weight: 700; border-radius: 12px; padding: 3px 8px; margin-top: 8px; }

/* списки-карточки */
.list-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 11.5px; color: var(--tx2); margin-top: 1px; }
.row-sub.accent { color: var(--ac); font-weight: 600; }

/* кнопки */
.add-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--ac-soft); color: var(--ac); font-size: 20px; font-weight: 600; flex: none; }
.add-btn:active { transform: scale(.78); }
.step-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 16px; flex: none; }
.step-btn.minus { background: var(--bg); border: 1px solid var(--line); color: var(--tx2); }
.step-btn.plus { background: var(--ac); color: var(--ac-tx); font-weight: 700; }
.step-btn:active { transform: scale(.85); }
.qty { min-width: 26px; text-align: center; font-size: 15px; font-weight: 800; }
.qty small { display: block; font-size: 9px; font-weight: 600; color: var(--tx2); line-height: 1; }
.x-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); color: var(--red); font-size: 14px; flex: none; }
.btn-primary { width: 100%; height: 50px; border-radius: 14px; background: var(--ac); color: var(--ac-tx); font-size: 13.5px; font-weight: 700; margin-top: 14px; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; }
.btn-dashed { width: 100%; height: 48px; border-radius: 14px; border: 1.5px dashed var(--tx2); color: var(--tx2); font-size: 13px; font-weight: 600; margin-top: 12px; }
.back-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 17px; color: var(--tx2); flex: none; }
.screen-head { display: flex; align-items: center; gap: 10px; }

/* статусы */
.status { font-size: 11px; font-weight: 700; border-radius: 20px; padding: 5px 10px; white-space: nowrap; }
.status.amber { background: var(--ac-soft); color: var(--ac); }
.status.green { background: var(--green-soft); color: var(--green); }
.status.violet { background: rgba(147, 100, 235, .13); color: #9364eb; }

/* карточка закупки в списке */
.buy-card { display: block; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; text-align: left; margin-top: 10px; }
.buy-card:active { transform: scale(.98); }
.buy-card-top { display: flex; align-items: center; justify-content: space-between; }
.buy-card-title { font-size: 15.5px; font-weight: 700; }
.buy-card-meta { font-size: 12px; color: var(--tx2); margin-top: 6px; }
.buy-card-meta b { color: var(--tx); font-weight: 700; }

/* прогресс */
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; border-radius: 3px; background: var(--ac); transition: width .5s; }
.progress i.green { background: var(--green); }
.progress-labels { display: flex; justify-content: space-between; font-size: 10.5px; margin-top: 6px; color: var(--tx2); }
.progress-labels .on { color: var(--ac); font-weight: 700; }

/* история */
.hist-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 12px; }
.hist-log { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; font-size: 12.5px; color: var(--tx2); }
.hist-log b { color: var(--tx); font-weight: 600; }
.hist-accepted { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.hist-accepted-title { font-size: 12px; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.hist-accepted-title.red { color: var(--red); }
.hist-accepted-title.muted { color: var(--tx2); }
.hist-items { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.hist-comment { color: var(--tx2); font-size: 11.5px; }

/* настройки */
.seg-chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.seg-chip { height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--tx2); font-size: 12.5px; font-weight: 600; padding: 0 14px; }
.seg-chip.on { background: var(--ac); border-color: var(--ac); color: var(--ac-tx); font-weight: 700; }
.person-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 10px; }
.person-head { display: flex; align-items: center; gap: 8px; }
.person-name { font-size: 14px; font-weight: 700; }
.person-nick { font-size: 11.5px; color: var(--tx2); }
.person-role { margin-left: auto; background: var(--ac-soft); color: var(--ac); font-size: 10.5px; font-weight: 700; border-radius: 20px; padding: 4px 9px; }
.person-head .mini-btn { margin-left: auto; }
.person-head .person-role { margin-left: 0; }
.point-chip { display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border-radius: 20px;
  background: var(--ac-soft); color: var(--ac); font-size: 12px; font-weight: 700; max-width: 44vw; }
.point-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.point-row { display: flex; align-items: center; gap: 10px; width: 100%; height: 52px; padding: 0 12px;
  border-radius: 12px; background: var(--bg); border: 1px solid var(--line); margin-top: 8px; }
.point-row.on { border-color: var(--ac); background: var(--ac-soft); }
.point-row-ico { font-size: 20px; }
.point-row-name { flex: 1; text-align: left; font-size: 14px; font-weight: 600; color: var(--tx); }
.point-row-cur { font-size: 10.5px; font-weight: 700; color: var(--ac); background: var(--ac-soft);
  border-radius: 20px; padding: 3px 8px; }
.users-bar { display: flex; gap: 8px; margin-top: 12px; }
.filter-select { flex: 0 0 auto; max-width: 52%; height: 42px; padding: 0 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--tx); font-size: 12.5px;
  font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search.slim { flex: 1; height: 42px; margin: 0; font-size: 13px; }
.picker-sep { margin: 12px 0 2px; font-size: 11px; font-weight: 700; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .04em; }
.seg-chips.wrap { flex-wrap: wrap; }
.group-title { margin-top: 14px; font-weight: 700; }
.group-title.accent { color: var(--ac); }
.group-title.muted { color: var(--tx2); }
.point-summary { font-size: 11.5px; color: var(--tx2); line-height: 1.5; margin-bottom: 8px; }
.btn-dashed.sm { height: 36px; margin: 0; font-size: 12px; }
.picker.wide { max-height: 78vh; display: flex; flex-direction: column; }
.picker-scroll { overflow-y: auto; }
.picker-scroll .point-access:first-child { border-top: 0; padding-top: 0; }
.point-access { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.point-access-name { font-size: 12px; font-weight: 700; color: var(--tx2); margin-bottom: 6px; }
.role-btn.sm { height: 32px; font-size: 11.5px; padding: 0 10px; }
.person-seen { margin-top: 8px; font-size: 11.5px; color: var(--tx2); }
.person-seen.online { color: var(--green); font-weight: 600; }
.role-btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.role-btn { height: 38px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--tx2); font-size: 12px; font-weight: 600; padding: 0 12px; }
.role-btn.on { background: var(--ac); border-color: var(--ac); color: var(--ac-tx); font-weight: 700; }
.role-btn.ban { background: var(--red-soft); border-color: transparent; color: var(--red); font-size: 13px; }
.theme-row { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.theme-row-label { flex: 1; font-size: 13.5px; font-weight: 600; }
.theme-seg { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.theme-seg button { height: 32px; padding: 0 10px; border-radius: 8px; font-size: 11.5px; font-weight: 700; color: var(--tx2); }
.theme-seg button.on { background: var(--ac); color: var(--ac-tx); }
.footer-note { text-align: center; font-size: 11.5px; color: var(--tx2); margin-top: 16px; }

/* ---------- тост ---------- */
.toast {
  position: fixed; bottom: 92px; left: 50%; z-index: 40;
  background: var(--tx); color: var(--bg); font-size: 12.5px; font-weight: 600;
  border-radius: 20px; padding: 10px 16px; white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transform: translate(-50%, 8px) scale(.9);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- нижняя навигация ---------- */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: calc(68px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 30;
}
.nav-dot {
  position: absolute; bottom: calc(7px + env(safe-area-inset-bottom));
  width: 5px; height: 5px; border-radius: 50%; background: var(--ac);
  transform: translateX(-50%); transition: left .35s cubic-bezier(.3, 1.3, .4, 1);
}
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--tx2); }
.nav-btn.on { color: var(--ac); }
.nav-btn:active { transform: none; }
.nav-emoji { font-size: 19px; position: relative; }
.nav-badge {
  position: absolute; top: -4px; right: -10px;
  background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 8px; min-width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ================= расширения к дизайну (наша логика) ================= */

/* заголовок группы-категории внутри списка закупки */
.row-cat {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px 4px; font-size: 10.5px; font-weight: 800;
  color: var(--tx2); letter-spacing: .8px; text-transform: uppercase;
}
.row-cat + .row { border-top: 0; }
.row-cat i { font-style: normal; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; font-size: 10px; }

/* срочная позиция */
.row.urgent { box-shadow: inset 3px 0 0 var(--ac); background: var(--ac-soft); }

/* мини-кнопки в строке (комментарий/срочно) */
.mini-btn {
  width: 34px; height: 34px; border-radius: 50%; flex: none; font-size: 13px;
  background: var(--bg); border: 1px solid var(--line); color: var(--tx2);
}
.mini-btn.on { background: var(--ac-soft); border-color: transparent; color: var(--ac); }
.mini-btn.ok { background: var(--green-soft); border-color: transparent; color: var(--green); }
.mini-btn.no { background: var(--red-soft); border-color: transparent; color: var(--red); }

/* чип единицы измерения */
.unit-chip {
  display: inline-block; background: var(--ac-soft); color: var(--ac);
  font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 7px;
  vertical-align: 1px;
}
.unit-btn {
  height: 34px; border-radius: 10px; padding: 0 10px; flex: none;
  background: var(--bg); border: 1px solid var(--line); color: var(--tx2);
  font-size: 11px; font-weight: 700;
}

/* статус-иконка позиции (закупка/приёмка) */
.st-ico { width: 20px; text-align: center; font-size: 14px; flex: none; }

/* пустые состояния */
.empty { text-align: center; color: var(--tx2); padding: 44px 16px; font-size: 13px; line-height: 1.6; }
.empty .big { font-size: 42px; margin-bottom: 10px; }

/* пикеры (иконка категории / единица) */
.picker-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.picker { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; max-width: 340px; width: 100%; }
.picker-title { font-weight: 800; font-size: 14px; text-align: center; margin-bottom: 12px; }
.picker-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.picker-grid.units { grid-template-columns: repeat(4, 1fr); }
.picker-cell { aspect-ratio: 1; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 17px; }
.picker-cell.unit { aspect-ratio: auto; padding: 11px 0; font-size: 13px; font-weight: 700; color: var(--tx); }
.picker .btn-dashed { margin-top: 10px; height: 42px; }

/* настройки: строки с пилюлями */
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 10px; }
.set-title { font-size: 13.5px; font-weight: 700; }
.set-note { font-size: 11.5px; color: var(--tx2); margin-top: 4px; line-height: 1.5; }
.set-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.set-row > span { font-size: 11.5px; color: var(--tx2); min-width: 96px; }
.time-input {
  height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--tx); font-size: 13px; font-weight: 700; padding: 0 10px;
}

/* график в отчёте */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 12px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.chart-bar { width: 100%; max-width: 18px; border-radius: 4px 4px 0 0; background: var(--ac); }
.chart-bar.zero { background: var(--line); border-radius: 2px; }
.chart-val { font-size: 10px; font-weight: 800; }
.chart-day { font-size: 9px; color: var(--tx2); }

/* ---------- анимации ---------- */
@keyframes in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes fill { from { width: 0; } to { width: 100%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
