:root {
  --bg: #151515;
  --card: #1f1f1f;
  --card2: #262626;
  --line: #333;
  --text: #f0f0f0;
  --muted: #9a9a9a;
  --lime: #cce200;
  --lime-ink: #151515;
  --red: #ff6b6b;
  --green: #7ddc8a;
  --r: 14px;
  --tabs: 64px;
  --safe: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  padding-bottom: calc(var(--tabs) + var(--safe) + 8px);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--lime); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.red { color: var(--red); }
.green { color: var(--green); }

/* шапка и вкладки */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(21,21,21,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--lime); font-weight: 800; letter-spacing: .02em; text-decoration: none; font-size: 18px; }
.who { color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }
.who button { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px 0; cursor: pointer; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabs) + var(--safe)); padding-bottom: var(--safe);
  background: #101010; border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; min-width: 0;
}
.tabs a b { font-size: 20px; line-height: 1; font-weight: 400; }
.tabs a.on { color: var(--lime); }

main { max-width: 980px; margin: 0 auto; }
h1 { font-size: 22px; margin: 16px 16px 8px; }
h2 { font-size: 17px; margin: 20px 16px 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section { padding: 0 16px; }

/* поля и кнопки */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.field > span { color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--lime); }
input[type=date] { min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn.main { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 15px; white-space: nowrap;
}
.chip.on { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); font-weight: 700; }
.search { position: sticky; top: 49px; z-index: 10; padding: 10px 16px; background: var(--bg); }

/* касса: плитки */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 4px 16px 16px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 820px) { .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.tile {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer;
}
.tile.in { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime) inset; }
.tile .pic { aspect-ratio: 4 / 3; background: var(--card2) center / cover no-repeat; display: grid; place-items: center;
  font-size: 28px; font-weight: 800; color: #555; }
.tile .t { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
/* без фото — только текст; счётчик сверху справа, «минус» снизу справа, чтобы не закрывать название */
.tile.np .t { padding: 12px 46px 12px 12px; min-height: 86px; justify-content: space-between; }
.tile.np .n { min-height: 0; }
.tile.np .badge { top: 10px; right: 10px; }
.tile.np .minus { top: auto; left: auto; bottom: 8px; right: 8px; background: var(--card2); border: 1px solid var(--line); }
.tile .n { font-size: 14px; line-height: 1.25; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.tile .s { font-size: 13px; color: var(--muted); }
.tile .badge {
  position: absolute; top: 8px; right: 8px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px;
  background: var(--lime); color: var(--lime-ink); font-weight: 800; display: grid; place-items: center;
}
.tile .minus {
  position: absolute; top: 8px; left: 8px; width: 34px; height: 34px; border-radius: 17px; border: 0;
  background: rgba(0,0,0,.7); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.cartbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs) + var(--safe)); z-index: 25;
  padding: 10px 16px; background: rgba(16,16,16,.96); border-top: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.cartbar .sum { font-size: 15px; }
.cartbar .sum b { font-size: 17px; }
body.has-cart { padding-bottom: calc(var(--tabs) + var(--safe) + 76px); }

/* списки */
.list { margin: 0 16px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.item { display: flex; gap: 12px; align-items: center; padding: 12px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.item:first-child { border-top: 0; }
.thumb { flex: none; width: 48px; height: 48px; border-radius: 10px; background: var(--card2) center / cover no-repeat;
  display: grid; place-items: center; color: #555; font-weight: 800; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: 13px; }
.item .right { text-align: right; flex: none; }
.off { opacity: .5; }
.strike { text-decoration: line-through; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.tag.warn { background: #3a3200; color: var(--lime); }
.tag.bad { background: #3a1515; color: var(--red); }

/* таблицы отчёта */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.card .k { color: var(--muted); font-size: 13px; }
.card .v { font-size: 22px; font-weight: 800; margin-top: 2px; }
.tbl { width: calc(100% - 32px); margin: 0 16px; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: 15px; }
.tbl th, .tbl td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; border-top: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.name { overflow-wrap: anywhere; }
.tbl tfoot td { font-weight: 700; }

/* документы */
.doc { margin: 0 16px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.doc summary { list-style: none; padding: 12px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.doc summary::-webkit-details-marker { display: none; }
.doc .body { padding: 0 12px 12px; }
.doc .ln { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 15px; }
.doc .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* шторка */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 88vh; overflow-y: auto;
  background: #1a1a1a; border-top-left-radius: 20px; border-top-right-radius: 20px; border-top: 1px solid var(--line);
  padding: 16px 16px calc(16px + var(--safe)); max-width: 640px; margin: 0 auto;
}
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-size: 20px; cursor: pointer; }
.qty input { width: 64px; text-align: center; min-height: 38px; padding: 6px; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs) + var(--safe) + 84px); z-index: 60;
  max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 12px; background: #2a2f00; color: var(--lime);
  border: 1px solid var(--lime); font-weight: 600;
}
.toast.err { background: #3a1515; color: var(--red); border-color: var(--red); }

/* вход */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { margin: 0 0 6px; font-size: 28px; color: var(--lime); }
.err { color: var(--red); min-height: 22px; margin: 0 0 8px; }

/* фото подарка */
.hero { margin: 0 16px; border-radius: var(--r); overflow: hidden; background: var(--card2) center / cover no-repeat;
  aspect-ratio: 4 / 3; max-height: 320px; display: grid; place-items: center; color: #555; font-size: 42px; font-weight: 800; }
.hero.empty { aspect-ratio: auto; height: 96px; font-size: 30px; gap: 0; grid-auto-flow: row; align-content: center; }
.hero.empty span { font-size: 13px; font-weight: 400; color: var(--muted); }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.picker { margin: 6px 0 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.picker button { display: block; width: 100%; text-align: left; padding: 10px 12px; background: var(--card); border: 0;
  border-top: 1px solid var(--line); cursor: pointer; }
.picker button:first-child { border-top: 0; }
.rline { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.rline .grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
