:root {
  --bg: #f4f5fa;
  --card: #ffffff;
  --text: #1c1f2e;
  --muted: #7a7f96;
  --line: #e7e9f2;
  --soft: #f0f1f8;
  --accent: #4f46e5;
  --accent2: #0ea5e9;
  --accent-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f8ee;
  --orange: #ea8a0c;
  --orange-soft: #fff4e2;
  --red: #e11d48;
  --red-soft: #ffe9ee;
  --blue-soft: #e6f5fd;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 60, .04), 0 4px 16px rgba(20, 24, 60, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.hide { display: none !important; }

/* ---------- каркас ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .logo { width: 32px; height: 32px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.top b { flex: 1; font-size: 17px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.burger { border: 0; background: var(--soft); width: 42px; height: 42px; border-radius: 12px; font-size: 21px; cursor: pointer; flex: none; color: var(--text); }
.burger:hover { background: var(--accent-soft); color: var(--accent); }
.drawer-ov { position: fixed; inset: 0; z-index: 90; background: rgba(18, 20, 40, 0); pointer-events: none; transition: background .2s; }
.drawer-ov.on { background: rgba(18, 20, 40, .42); pointer-events: auto; }
.side { width: 270px; max-width: 85vw; background: var(--card); padding: 18px 14px calc(18px + var(--safe-b)); height: 100%;
  display: flex; flex-direction: column; gap: 4px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0,0,0,.12); }
.drawer-ov.on .side { transform: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .5px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
.brand b { font-size: 17px; display: block; }
.brand span { font-size: 12px; color: var(--muted); }
.nav-a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text);
  font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.nav-a:hover { background: var(--soft); }
.nav-a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-a .ic { width: 22px; text-align: center; font-size: 17px; }
.side .grow { flex: 1; }
.side .me b { display: block; }
.side .me { padding: 10px 12px; border-radius: 12px; background: var(--soft); font-size: 13px; display: flex; align-items: center; gap: 8px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 28px 60px; }

.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { flex: 1; min-width: 0; }
.back { border: 0; background: var(--card); width: 38px; height: 38px; border-radius: 12px; box-shadow: var(--shadow);
  cursor: pointer; font-size: 18px; flex: none; }

.syncdot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.syncdot i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.syncdot.off i { background: var(--orange); }
.syncdot.wait i { background: var(--accent2); }

@media (max-width: 899px) {
  .wrap { padding: 14px 14px calc(40px + var(--safe-b)); }
  .top { padding: 8px 12px; }
  .top .syncdot span { display: none; }
  h1 { font-size: 21px; }
  .head { margin-bottom: 14px; gap: 10px; }
  .head h1 { flex: 1 1 55%; }
  .head > .btn { flex: 1 1 auto; }
  .head .seg { order: 5; width: 100%; }
  .head .search { order: 4; }
}

/* ---------- элементы ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .sec, .sec + .card, .sec + .sec { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.sec-h { display: flex; align-items: center; gap: 10px; margin: 22px 2px 10px; }
.sec-h h2 { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrapr { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 899px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2.m1 { grid-template-columns: 1fr; } }

.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: transform .05s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.red { background: var(--red-soft); color: var(--red); }
.btn.green { background: var(--green-soft); color: var(--green); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.icon-btn { border: 0; background: var(--soft); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; flex: none; font-size: 15px; }
.icon-btn:hover { background: var(--line); }

.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.acc { background: linear-gradient(135deg, var(--accent), #6d5df6); color: #fff; }
.stat.acc .l, .stat.acc .s { color: rgba(255,255,255,.8); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: #0284c7; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 13px; cursor: pointer; font-size: 14px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg { display: inline-flex; background: var(--soft); padding: 4px; border-radius: 12px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -2px 16px; padding: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: var(--card); padding: 9px 15px; border-radius: 12px; cursor: pointer; font-weight: 500;
  white-space: nowrap; box-shadow: var(--shadow); color: var(--muted); }
.tabs button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* поля */
label.f { display: block; margin-bottom: 12px; }
div.f { margin-bottom: 14px; }
.f .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
label.f > span {display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.inp, select.inp, textarea.inp { width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; outline: none; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
textarea.inp { min-height: 70px; resize: vertical; }
.inp.sm { padding: 6px 8px; border-radius: 9px; }
.search { max-width: 280px; }
@media (max-width: 899px) { .search { max-width: none; width: 100%; } }

/* списки */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li:hover { background: #fafbff; }
.li .t { font-weight: 600; }
.li .s { font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 38px; margin-bottom: 6px; }

.ph { width: 46px; height: 46px; border-radius: 12px; background: var(--soft); flex: none; object-fit: cover; display: grid; place-items: center;
  font-size: 20px; color: var(--muted); overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph.lg { width: 96px; height: 96px; border-radius: 18px; font-size: 34px; }

/* товары */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .pgrid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.pcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: transform .12s; }
.pcard:hover { transform: translateY(-2px); }
.pcard .img { aspect-ratio: 4/4.4; background: var(--soft); display: grid; place-items: center; font-size: 44px; color: #c3c7da; }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard .b { padding: 11px 13px 13px; }
.pcard .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .a { font-size: 12px; color: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 9px; }
.mini div { background: var(--soft); border-radius: 9px; padding: 5px 2px; text-align: center; }
.mini b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.mini span { font-size: 10px; color: var(--muted); }
.dots { display: flex; gap: 4px; margin-top: 6px; }
.dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); display: inline-block; flex: none; }

/* таблицы */
.tblw { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; padding-left: 2px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.tot td { font-weight: 700; background: var(--soft); }
table.t tr.tot td:first-child { border-radius: 10px 0 0 10px; padding-left: 10px; }
table.t tr.tot td:last-child { border-radius: 0 10px 10px 0; }
table.t td.z { color: #c3c7da; }
table.t .cin { width: 58px; text-align: center; padding: 6px 4px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; outline: none; }
table.t .cin:focus { border-color: var(--accent); }
table.t .cin.over { border-color: var(--red); background: var(--red-soft); }
table.t td .hint { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
table.t th.col-way, table.t td.col-way { background: #f5fbff; }
table.t th.col-wb, table.t td.col-wb { background: #f7f5ff; }
table.t.left td, table.t.left th { text-align: left; }
table.t.left td.r, table.t.left th.r { text-align: right; }

/* доска этапов */
.board { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; }
.col { flex: 0 0 210px; background: #eceef7; border-radius: 14px; padding: 10px; scroll-snap-align: start; }
.col .ch { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin: 2px 4px 8px; }
.col .ch .n { width: 20px; height: 20px; border-radius: 6px; background: #fff; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.col .ch .c { margin-left: auto; color: var(--muted); font-weight: 500; }
.bchip { background: var(--card); border-radius: 11px; padding: 8px; display: flex; gap: 8px; align-items: center; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 7px; }
.bchip:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.bchip .ph { width: 34px; height: 34px; border-radius: 9px; font-size: 15px; }
.bchip .t { font-size: 13px; font-weight: 600; line-height: 1.2; }
.bchip .s { font-size: 11px; color: var(--muted); }
.col .none { font-size: 12px; color: #a6abc1; text-align: center; padding: 10px 0; }

/* прогресс этапов */
.prog { height: 6px; background: var(--soft); border-radius: 9px; overflow: hidden; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 9px; }
.steps { position: relative; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; cursor: pointer; position: relative; }
.step .o { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: #fff; flex: none; display: grid;
  place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); position: relative; z-index: 1; }
.step:not(:last-child)::after { content: ''; position: absolute; left: 12px; top: 33px; bottom: -7px; width: 2px; background: var(--line); }
.step.done .o { background: var(--green); border-color: var(--green); color: #fff; }
.step.done:not(:last-child)::after { background: var(--green); }
.step.cur .o { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px rgba(79, 70, 229, .15); }
.step .tx { padding-top: 2px; flex: 1; }
.step .tx b { font-weight: 600; }
.step.fut .tx b { color: var(--muted); font-weight: 500; }
.step .tx .d { font-size: 12px; color: var(--muted); }

/* задачи */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.chk { width: 22px; height: 22px; border-radius: 7px; border: 2px solid #c9cde0; background: #fff; flex: none; cursor: pointer;
  display: grid; place-items: center; color: #fff; font-size: 13px; margin-top: 1px; }
.task.done .chk { background: var(--green); border-color: var(--green); }
.task.done .tt { text-decoration: line-through; color: var(--muted); }
.task .tt { font-weight: 500; cursor: pointer; }
.task .tm { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.task .late { color: var(--red); font-weight: 600; }

/* расходы */
.bar { height: 8px; border-radius: 9px; background: var(--soft); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv.big .v { font-size: 18px; color: var(--accent); }
.hl { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: #3730a3; font-size: 14px; }
.hl.warn { background: var(--orange-soft); color: #9a5a00; }
.hl.ok { background: var(--green-soft); color: #166534; }
.hl.bad { background: var(--red-soft); color: #9f1239; }
.who { display: inline-flex; align-items: center; gap: 6px; }
.av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }

/* модальные окна */
.ov { position: fixed; inset: 0; background: rgba(18, 20, 40, .42); z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade .15s; }
.md { background: var(--card); border-radius: 22px; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: pop .18s; }
.md.wide { max-width: 860px; }
.md .mh { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.md .mh h2 { flex: 1; }
.md .mb { padding: 10px 20px; overflow-y: auto; }
.md .mf { display: flex; gap: 10px; padding: 12px 20px 18px; justify-content: flex-end; flex-wrap: wrap; }
.md .mf .sp { flex: 1; }
@media (max-width: 899px) {
  .ov { align-items: flex-end; padding: 0; }
  .md { border-radius: 22px 22px 0 0; max-height: 92vh; animation: up .22s; }
  .md .mf { padding-bottom: calc(16px + var(--safe-b)); }
  .md .mf .btn { flex: 1; }
  .md .mf .sp { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1c1f2e; color: #fff;
  padding: 11px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 10% -10%, #e4e6ff, transparent), radial-gradient(900px 500px at 110% 110%, #dff3fd, transparent), var(--bg); }
.login .box { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; box-shadow: 0 20px 60px rgba(30, 30, 90, .1); padding: 30px 26px; }
.login .logo { width: 64px; height: 64px; border-radius: 18px; font-size: 24px; margin: 0 auto 14px; }
.login h1 { text-align: center; }
.login p { text-align: center; color: var(--muted); margin: 6px 0 20px; }
.pick { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pick button { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.pick button:hover { border-color: var(--accent); }

/* настройки */
.srow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .no { width: 24px; color: var(--muted); font-size: 13px; text-align: center; }
.srow .inp { padding: 7px 10px; }

.photo-pick { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.colorrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.draft { border: 2px dashed #c9cde0; }
.feed .li { cursor: default; }
.feed .li .s b { color: var(--text); font-weight: 600; }
