:root {
  --bg: #F2F1EE; --card: #FFFFFF; --card2: #F7F6F3; --line: rgba(60, 55, 45, .12);
  --ink: #1C1C1E; --ink2: #6E6B66; --ink3: #A29E97;
  --acc: #2E4A3E; --acc-ink: #FFFFFF; --acc-soft: #E3ECE6; --acc-text: #2E4A3E;
  --warn: #B4691C; --warn-soft: #F8EBDD; --bad: #C2412D; --bad-soft: #F9E4E0;
  --ok: #2F8F5B; --bar: rgba(242, 241, 238, .86);
  --r: 18px; --tab-h: 52px;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --card2: #2A2A2D; --line: rgba(255, 255, 255, .12);
    --ink: #F5F5F7; --ink2: #A1A1A6; --ink3: #6C6C70;
    --acc: #4F7F69; --acc-ink: #FFFFFF; --acc-soft: #1F2E27; --acc-text: #9CCBB3;
    --warn: #E3A35B; --warn-soft: #33261A; --bad: #FF7A66; --bad-soft: #3A1E1A;
    --ok: #5CC88C; --bar: rgba(10, 10, 10, .82);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.38 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .4; }
a { color: var(--acc-text); text-decoration: none; }
[hidden] { display: none !important; }

/* ---- шапка ---- */
#top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--st) + 10px) 20px 10px;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent; transition: border-color .2s;
}
#top.scrolled { border-bottom-color: var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .37px; margin: 0; }
#sub { margin: 2px 0 0; font-size: 15px; color: var(--ink2); min-height: 20px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px;
  border-radius: 16px; background: var(--card); font-size: 15px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 0 0 .5px var(--line);
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink3); }
.pill.run i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.pill.pause i { background: var(--warn); }
.pill.bad i { background: var(--bad); }

main { padding: 6px 16px calc(var(--tab-h) + var(--sb) + 24px); }
main.with-dock { padding-bottom: calc(var(--tab-h) + var(--sb) + 150px); }

/* ---- нижние вкладки ---- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--sb)); padding-bottom: var(--sb);
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
#tabs button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink3); font-size: 10.5px; font-weight: 500; }
#tabs button.on { color: var(--acc-text); }
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on svg path:first-child { fill: color-mix(in srgb, currentColor 14%, transparent); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 12px; line-height: 18px; font-weight: 600; text-align: center; }
.badge:empty { display: none; }

/* ---- общие блоки ---- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 0 0 12px; }
.hint { color: var(--ink2); font-size: 15px; }
.muted { color: var(--ink3); }
.banner { display: flex; gap: 12px; align-items: center; border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; font-size: 15px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.acc { background: var(--acc-soft); color: var(--acc-text); }
.banner b { font-weight: 600; }
.banner .grow { flex: 1; }
.banner button { font-weight: 600; white-space: nowrap; }
.empty { text-align: center; padding: 70px 24px; color: var(--ink2); }
.empty .big { font-size: 46px; margin-bottom: 8px; }
.empty h2 { font-size: 22px; color: var(--ink); margin: 0 0 6px; }

/* ---- карточка заявки ---- */
.counter { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 4px 10px; font-size: 15px; color: var(--ink2); }
.counter button { color: var(--acc-text); font-weight: 500; }
.who { display: flex; align-items: center; gap: 12px; }
.ava { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; font-weight: 600; color: var(--acc-text); background: var(--acc-soft); overflow: hidden; }
.who .h { font-size: 20px; font-weight: 700; letter-spacing: -.2px; overflow-wrap: break-word; }
.who .n { font-size: 15px; color: var(--ink2); }
.who a.open { margin-left: auto; flex: none; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--card2); display: inline-flex; align-items: center; font-size: 15px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 0 0; border-radius: 14px; background: var(--card2); }
.stats div { padding: 9px 4px; text-align: center; }
.stats div + div { box-shadow: -.5px 0 0 var(--line); }
.stats b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.stats b.low { color: var(--bad); }
.stats span { font-size: 12px; color: var(--ink2); }
.meta { margin: 10px 2px 0; font-size: 14px; color: var(--ink2); }
.bubble { margin: 14px 0 0; padding: 11px 14px; border-radius: 20px 20px 20px 6px; background: var(--card2); font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble + .bubble { margin-top: 6px; }
.rec { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; font-size: 15px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.rec .ic { grid-row: span 2; font-size: 20px; line-height: 22px; }
.rec b { font-weight: 600; }
.rec.decline { background: var(--card2); }
.rec.later { background: var(--acc-soft); color: var(--acc-text); }
.rec.self { background: var(--warn-soft); color: var(--warn); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 14px -16px 0; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--card2); }
.grid img:first-child { border-top-left-radius: 0; }
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
.shots button { position: relative; border-radius: 12px; overflow: hidden; background: var(--card2); aspect-ratio: 16/10; }
.shots img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }
.shots span { position: absolute; left: 8px; bottom: 6px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.bio { margin: 12px 2px 0; font-size: 15px; color: var(--ink2); white-space: pre-wrap; }
.err { margin-top: 12px; color: var(--bad); font-size: 15px; }

/* ---- панель решений ---- */
#dock {
  position: fixed; left: 0; right: 0; z-index: 4;
  bottom: calc(var(--tab-h) + var(--sb));
  padding: 12px 16px 10px;
  background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}
#dock .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { height: 54px; border-radius: 16px; font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; transition: transform .12s; }
.btn:active { transform: scale(.97); }
.btn.fill { background: var(--acc); color: var(--acc-ink); }
.btn.soft { background: var(--card); box-shadow: 0 0 0 .5px var(--line); }
.btn.sug { box-shadow: 0 0 0 2.5px var(--acc-text); }
.btn small { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.22); }
.btn.soft small { background: var(--acc-soft); color: var(--acc-text); }
#dock .links { display: flex; justify-content: space-around; margin-top: 4px; }
#dock .links button { height: 40px; padding: 0 10px; font-size: 15px; color: var(--acc-text); font-weight: 500; }

/* ---- списки ---- */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; margin: 0 0 14px; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; position: relative; }
.item + .item::before { content: ""; position: absolute; top: 0; left: 80px; right: 0; border-top: .5px solid var(--line); }
.item .ava { width: 48px; height: 48px; font-size: 18px; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 15px; color: var(--ink2); }
.item .s.bad { color: var(--bad); }
.item .act { flex: none; font-size: 15px; font-weight: 500; color: var(--acc-text); padding: 8px 0 8px 6px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--card2); color: var(--ink2); vertical-align: 1px; }
.tag.acc { background: var(--acc-soft); color: var(--acc-text); }
.sec { margin: 22px 16px 7px; font-size: 13px; color: var(--ink2); text-transform: uppercase; letter-spacing: .3px; }
.sec:first-child { margin-top: 6px; }

/* ---- настройки ---- */
.big-toggle { width: 100%; height: 58px; border-radius: 16px; font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.big-toggle.go { background: var(--acc); color: var(--acc-ink); }
.big-toggle.stop { background: var(--warn-soft); color: var(--warn); }
.set { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; position: relative; }
.set + .set::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.set .l { flex: 1; }
.set .l small { display: block; font-size: 13px; color: var(--ink2); }
.step { display: flex; align-items: center; background: var(--card2); border-radius: 10px; }
.step button { width: 40px; height: 34px; font-size: 22px; color: var(--acc-text); }
.step output { min-width: 52px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--card2); border-radius: 10px; padding: 2px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 15px; font-weight: 500; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.set .go { color: var(--acc-text); font-weight: 500; }
.log { font-size: 14px; color: var(--ink2); padding: 4px 16px 10px; }
.log div { padding: 7px 0; border-bottom: .5px solid var(--line); display: flex; gap: 10px; }
.log div:last-child { border: 0; }
.log time { flex: none; color: var(--ink3); font-variant-numeric: tabular-nums; }

/* ---- нижний лист ---- */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.36); display: flex; align-items: flex-end; animation: fade .2s; }
#sheet .pane {
  width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px 14px 0 0; padding: 8px 16px calc(var(--sb) + 14px);
  animation: up .28s cubic-bezier(.2,.9,.3,1);
}
#sheet .pane.tall { height: calc(100dvh - var(--st) - 10px); max-height: none; margin-top: calc(var(--st) + 10px); align-self: flex-start; padding-bottom: 12px; }
#sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--ink3); opacity: .5; margin: 0 auto 10px; }
#sheet .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#sheet .head h3 { margin: 0; font-size: 17px; font-weight: 600; }
#sheet .head button { color: var(--acc-text); font-size: 17px; min-width: 70px; height: 36px; }
#sheet .head button.b { font-weight: 600; text-align: right; }
#sheet textarea {
  width: 100%; flex: 1; min-height: 260px; border: 0; border-radius: 14px; padding: 14px; resize: none;
  background: var(--card); color: var(--ink); font: 17px/1.4 -apple-system, system-ui, sans-serif; outline: none;
}
#sheet .chips { display: flex; gap: 8px; margin: 10px 0 0; overflow-x: auto; }
#sheet .chips button { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card); font-size: 15px; font-weight: 500; }
#sheet .chips button.on { background: var(--acc); color: var(--acc-ink); }
#sheet p { margin: 0 0 14px; color: var(--ink2); font-size: 15px; }
#sheet .stack { display: grid; gap: 10px; }

/* ---- просмотр фото ---- */
#viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: grid; place-items: center; animation: fade .15s; }
#viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

#toast {
  position: fixed; z-index: 25; left: 12px; right: 12px; top: calc(var(--st) + 8px);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 14px;
  background: rgba(30, 30, 32, .94); color: #fff; font-size: 15px; animation: up .25s;
}
#toast span { flex: 1; }
#toast button { color: #9CCBB3; font-weight: 600; }

.slide-out { animation: out .22s forwards; }
.slide-in { animation: in .26s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes down { from { transform: translateY(-30px); opacity: 0; } }
#toast { animation: down .25s; }
@keyframes fade { from { opacity: 0; } }
@keyframes out { to { transform: translateX(-30%); opacity: 0; } }
@keyframes in { from { transform: translateX(18%); opacity: 0; } }

/* ---- вход ---- */
.gate { padding: 80px 8px; text-align: center; }
.gate h2 { font-size: 24px; margin: 0 0 10px; }
.gate input { width: 100%; height: 50px; border-radius: 12px; border: 0; padding: 0 14px; font-size: 17px; background: var(--card); color: var(--ink); margin: 18px 0 10px; }
