/* Дизайн A «Ночной премиум» (макет docs/design/mini-app-mockup.html):
   тёмный глубокий фон, стеклянные карточки, фиолетово-голубое свечение, градиентные акценты; всегда тёмный.
   Слои: depth-0 фон (body), depth-1 свечения (.glow), depth-2 карточки, depth-4 текст. Анимации — только
   transform/opacity; prefers-reduced-motion — статично. */
:root {
  --bg-0: #07070d; --bg-1: #0b0c16; --bg-2: #1c1f3a;
  --text: #eef0ff; --muted: #8a8fb3; --line: rgba(255, 255, 255, .09);
  --glass: rgba(255, 255, 255, .06); --glass-strong: rgba(255, 255, 255, .1);
  --accent-1: #7b6bff; --accent-2: #39c6ff; --accent: #9d90ff;
  --ok: #4ce0a6; --warn: #ffc46b; --bad: #ff7b90; --info: #60a5fa;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; }
html, body { min-height: 100%; }
body { font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; color: var(--text);
       background: radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg-1) 55%, var(--bg-0) 100%) fixed;
       -webkit-font-smoothing: antialiased; }

/* depth-1: свечения, медленный дрейф */
.glow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.glow i { position: absolute; border-radius: 50%; filter: blur(56px); animation: drift 14s ease-in-out infinite alternate; }
.glow i:nth-child(1) { width: 300px; height: 300px; background: #6d5cff; opacity: .42; top: -80px; left: -90px; }
.glow i:nth-child(2) { width: 240px; height: 240px; background: #00d1ff; opacity: .24; top: 45%; right: -110px; animation-duration: 18s; }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(26px, -32px, 0) scale(1.15); } }

#app { position: relative; z-index: 1; }
header { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 8px; }
header .title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
header .sub { font-size: 12px; color: var(--muted); }
main { padding: 6px 14px 96px; }

/* depth-2: стекло */
.card { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
        margin-bottom: 10px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.card h2 { font-size: 16px; margin-bottom: 6px; }
.hero { background: linear-gradient(135deg, rgba(123, 107, 255, .35), rgba(57, 198, 255, .18)); border-color: rgba(160, 170, 255, .3); }
.hint, .muted { color: var(--muted); font-size: 13px; }
.error { color: var(--bad); }
.issue { color: var(--warn); }

.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; display: inline-block; }
.chip.ok { background: rgba(52, 211, 153, .15); color: var(--ok); }
.chip.warn { background: rgba(255, 184, 77, .15); color: var(--warn); }
.chip.bad { background: rgba(255, 91, 118, .15); color: var(--bad); }
.chip.accent { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #fff; }

.seg { display: flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--glass); margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 0; border-radius: 9px;
              font: 600 13px/1 inherit; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #fff; box-shadow: 0 6px 18px -6px #6d5cff; }

.code { font: 600 15px/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .5px; padding: 9px 11px;
        border-radius: 10px; display: flex; justify-content: space-between; align-items: center; margin-top: 8px;
        background: rgba(0, 0, 0, .35); border: 1px dashed rgba(140, 160, 255, .35); color: #cfd6ff; }

/* вход каскадом и «живой» элемент */
.enter > * { opacity: 0; transform: translateY(14px); animation: rise .6s cubic-bezier(.2, .8, .2, 1) forwards; }
.enter > *:nth-child(1) { animation-delay: .04s } .enter > *:nth-child(2) { animation-delay: .1s }
.enter > *:nth-child(3) { animation-delay: .16s } .enter > *:nth-child(4) { animation-delay: .22s }
.enter > *:nth-child(5) { animation-delay: .28s } .enter > *:nth-child(n+6) { animation-delay: .34s }
@keyframes rise { to { opacity: 1; transform: none; } }
.float { animation: float 9s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-4px); } }

/* hero и в каскаде, и парит: обе анимации списком (иначе .float затирает rise и hero остаётся opacity 0) */
.enter > .float { animation: rise .6s cubic-bezier(.2, .8, .2, 1) .04s forwards, float 9s ease-in-out .7s infinite; }

/* экраны «Просмотра» */
.row, .line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.line { font-size: 13px; padding: 4px 0; }
.card .muted { margin-top: 4px; }
.hero .muted { color: #c9cdf0; }
.big { font-size: 20px; font-weight: 800; margin-top: 2px; }
.huge { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.point { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.chip { border: 0; font-family: inherit; color: var(--text); background: var(--glass-strong); }
.chip.info { background: rgba(96, 165, 250, .15); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.card .chips { margin: 10px 0 0; }
.chips button { cursor: pointer; }
.code button { border: 0; background: none; color: var(--accent); font: 600 13px/1 inherit; cursor: pointer; padding: 2px 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid .card { margin-bottom: 0; }
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.tile .d { font-size: 11px; font-weight: 700; margin-top: 2px; color: var(--muted); }
.tile .d.up { color: var(--ok); } .tile .d.down { color: var(--bad); }
.acc { cursor: pointer; }
.accrow { display: flex; gap: 8px; align-items: stretch; }
.accrow .card { flex: 1; min-width: 0; }
.pausebtn { flex: none; width: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass);
  color: inherit; font-size: 16px; margin-bottom: 12px; }
.pausebtn.on { border-color: var(--warn); color: var(--warn); }
button.back, button.link, button.more { border: 0; background: none; color: var(--accent); font: 600 14px/1.2 inherit; cursor: pointer; padding: 0; }
button.back { margin: 0 0 10px 4px; }
button.link { font-size: 12px; }
button.more { display: block; width: 100%; padding: 10px 0 2px; }
button.more:disabled { opacity: .5; }

/* «Товары»: кнопки действий, поля, крупный график (Chart.js) */
.btn { border: 1px solid var(--line); background: var(--glass-strong); color: var(--text); border-radius: 12px;
       padding: 10px 14px; font: 600 14px/1.2 inherit; cursor: pointer; transition: opacity .2s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
               box-shadow: 0 8px 22px -10px #6d5cff; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.busy { opacity: 1; animation: pulse 1.4s ease-in-out infinite; }
.btn.wide { display: block; width: 100%; margin-bottom: 10px; }
.btn .muted { font-size: 11px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn.primary { flex: 1 1 100%; }
.btn.danger { color: var(--bad); border-color: rgba(255, 91, 118, .35); }
.input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3);
         color: var(--text); font: 15px/1.2 inherit; outline: none; }
.input:focus { border-color: var(--accent); }
.input.search { margin-bottom: 10px; }
.field-row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.field-row .input { flex: 1; }
.chart { position: relative; height: 210px; margin-top: 10px; }
.prod { cursor: pointer; }

/* мини-графики: линия рисуется, столбики растут */
.spark { display: block; width: 100%; height: 50px; margin-top: 8px; }
.spark path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .9;
              stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s .4s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.bars { display: flex; gap: 3px; align-items: flex-end; height: 54px; margin-top: 10px; }
.bars i { flex: 1; border-radius: 4px 4px 2px 2px; transform-origin: bottom; background: linear-gradient(180deg, #8f80ff, #3c48ff);
          animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; }
.bars i.bad { background: linear-gradient(180deg, #ff9aac, var(--bad)); }
@keyframes grow { from { transform: scaleY(0); } }

/* журнал */
.ev { display: flex; gap: 10px; padding: 9px 0; align-items: flex-start; border-bottom: 1px solid var(--line); }
.ev:last-of-type { border-bottom: 0; }
.ev .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--info); }
.ev .dot.warning { background: var(--warn); } .ev .dot.error { background: var(--bad); }
.ev .t { font-size: 11px; color: var(--muted); margin-top: 3px; flex: none; }
.evday { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 8px 0 2px; }
.ev .chips { margin: 4px 0 0; }
.ev .m { flex: 1; font-size: 13px; word-break: break-word; }

/* скелетон загрузки */
.skeleton { height: 86px; background: linear-gradient(90deg, var(--glass), var(--glass-strong), var(--glass)); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* нижняя навигация */
nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 2; display: flex; padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
      background: rgba(10, 11, 22, .8); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid rgba(255, 255, 255, .06); }
nav button { flex: 1; border: 0; background: none; color: #6f7393; font: 600 10px/1.1 inherit; display: flex;
             flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; cursor: pointer; transition: color .2s; }
nav button .icon { font-size: 20px; transition: transform .2s; }
nav button.active { color: var(--accent); text-shadow: 0 0 14px #6d5cff; }
nav button.active .icon { transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---- «Заказы» и «Дома»: практичный экран для работы на ПВЗ ----------------------------------------------
   Карточка задачи → блоки ПВЗ; число вводится степпером (− / поле / +) с крупными целями нажатия; коды — компактные
   чипы (тап = копия); статус и «осталось» видны с первого взгляда. */
.task { padding: 0; overflow: hidden; }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.task-head b { font-size: 16px; }
.progress { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 0 14px 10px; }
.progress i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
              transition: width .4s; }
.progress i.ok { background: linear-gradient(90deg, #2fcf9a, var(--ok)); }
.pvz { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.pvz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pvz-head b { font-size: 15px; line-height: 1.25; }
.pvz-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat3 > div { background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stat3 .n { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.stat3 .l { display: block; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat3 .warn .n { color: var(--warn); } .stat3 .ok .n { color: var(--ok); }
.codes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.code-chip { border: 1px dashed rgba(140, 160, 255, .4); background: rgba(0, 0, 0, .3); color: #cfd6ff; border-radius: 10px;
             padding: 7px 10px; font: 600 13px/1.1 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .4px; cursor: pointer; }
.code-chip:active { transform: scale(.97); }
/* копирование — маленькие «таблетки» в строку, не кнопки на всю ширину */
.copy-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
/* Ряд кнопок копирования («Все коды разом» и по ПВЗ): одна строка, прокручивается вбок */
.copy-scroll { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.copy-scroll::-webkit-scrollbar { display: none; }
.copy-scroll .btn { flex: none; white-space: nowrap; }
/* Чипы городов («Все / Москва / …»): одна строка, прокручивается вбок */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--glass); color: var(--muted); padding: 6px 13px;
  border-radius: 999px; font: 600 13px/1.2 inherit; cursor: pointer; white-space: nowrap; }
.chips button.on { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #fff; border-color: transparent; }
.copy-row .btn, .btn.copy { flex: none; width: auto; padding: 4px 10px; font-size: 12px; font-weight: 600; line-height: 1.3;
                            border-radius: 99px; color: var(--accent); background: var(--glass); }
.act { margin-top: 12px; }
.act .quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.act .quick button { border: 1px solid var(--line); background: var(--glass); color: var(--text); border-radius: 99px;
                     padding: 6px 12px; font: 600 12px/1 inherit; cursor: pointer; }
.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button { width: 48px; border: 1px solid var(--line); background: var(--glass-strong); color: var(--text);
                  border-radius: 14px; font: 700 24px/1 inherit; cursor: pointer; }
.stepper button:active { transform: scale(.94); }
.stepper .input { flex: 1; text-align: center; font-size: 22px; font-weight: 800; padding: 12px 6px; border-radius: 14px; }
.btn.go { display: block; width: 100%; margin-top: 8px; padding: 14px; font-size: 16px; border-radius: 14px; border: 0;
          color: #fff; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); box-shadow: 0 10px 24px -12px #6d5cff; }
.btn.go:disabled { opacity: .5; box-shadow: none; }
.btn.soft { display: block; width: 100%; margin-top: 8px; padding: 12px; border-radius: 14px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.note { background: rgba(76, 224, 166, .12); border: 1px solid rgba(76, 224, 166, .3); color: #b9f5dc; border-radius: 14px;
        padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.chip.info { background: rgba(96, 165, 250, .15); color: var(--info); }
.sum { display: flex; gap: 8px; margin-bottom: 10px; }
.sum > div { flex: 1; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; text-align: center; }
.sum .n { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.sum .l { display: block; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.city-row { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line);
            background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.city-row span:last-child { color: var(--muted); font-size: 12px; text-align: right; }
.sect { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 14px 4px 8px; }

/* раскрываемая карточка задачи: свёрнутая строка — номер, дата, итог одной фразой; подробности внутри */
.task-toggle { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: 0; background: none;
               color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tt-id { display: flex; flex-direction: column; line-height: 1.2; }
.tt-id b { font-size: 15px; }
.tt-id .muted { font-size: 11px; margin-top: 2px; }
.tt-sum { flex: 1; text-align: right; font-size: 13px; font-weight: 600; color: #cfd6ff; }
.chev { color: var(--muted); font-size: 14px; transition: transform .2s; }
.task.open .chev { transform: rotate(180deg); }
.task > .progress { margin: 0 14px 12px; }
.task-body { border-top: 1px solid var(--line); }
.task-body > .pvz:first-child { border-top: 0; }
.info { padding: 12px 14px 4px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv span { color: var(--muted); }
.kv b { text-align: right; font-weight: 600; word-break: break-word; }
.fold { margin-top: 10px; }
.fold summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--accent); padding: 6px 0; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "▸ "; }
.fold[open] summary::before { content: "▾ "; }
.ord { padding: 7px 0; border-top: 1px solid var(--line); }
.ord .muted { font-size: 11px; margin-top: 2px; word-break: break-word; }
.danger-zone { padding: 6px 14px 14px; }
.danger-link { color: var(--bad); }
.btn.danger { color: var(--bad); border-color: rgba(255, 91, 118, .4); }

/* Состав задачи с несколькими товарами: прогресс, таблица, метки состава заказа */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; flex: none; }
.tprog { margin-bottom: 12px; }
.tprog .big { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.tprog .big span { font-size: 14px; font-weight: 600; color: #cfd6ff; }
.bar2 { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; display: flex; margin: 8px 0 6px; }
.bar2 u { display: block; height: 100%; text-decoration: none; }
.bar2 .ok { background: var(--ok); } .bar2 .wait { background: var(--warn); }
.comp { margin-bottom: 12px; }
.comp table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.comp th { font-weight: 600; font-size: 11px; color: var(--muted); text-align: right; padding-bottom: 5px; }
.comp th:first-child, .comp td:first-child { text-align: left; }
.comp td { padding: 7px 0; border-top: 1px solid var(--line); text-align: right; }
.comp td:first-child { max-width: 150px; }
.comp tr.x td { color: var(--muted); }
.mix { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0 4px; }
.mix .m { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: rgba(255, 255, 255, .08); display: inline-flex; align-items: center; }
.mix .m.x { background: none; border: 1px dashed rgba(255, 255, 255, .28); color: var(--muted); font-weight: 500; }

/* Статистика: фильтр «Товар», нижний лист выбора, строки «По товарам» */
.pfilter { display: flex; align-items: stretch; margin-bottom: 10px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); }
.pfilter.on { border-color: rgba(160, 170, 255, .5); }
.pf-main { flex: 1; min-width: 0; min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; }
.pf-main b { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-act { color: var(--accent); font-size: 13px; font-weight: 600; }
.pf-x { min-width: 48px; border: 0; background: none; color: var(--muted); font-size: 22px; }
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 82vh; overflow: auto; background: #141729; border-radius: 22px 22px 0 0; border-top: 1px solid rgba(160, 170, 255, .3); padding: 10px 14px 18px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); margin: 0 auto 12px; }
.sh-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.opts { margin: 6px 0 4px; }
.opt { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 56px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; }
.opt .r { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box; flex: none; }
.opt.on .r { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 45%, transparent 50%); }
.opt .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.opt .t b { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.prow { width: 100%; display: block; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; }
.prow .ph { display: flex; justify-content: space-between; align-items: center; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.prow .pm { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.prow .pbar { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 7px; }
.prow .pbar u { display: block; height: 100%; text-decoration: none; }
select.sel { width: 100%; min-height: 44px; margin: 8px 0; }
