/* Единый стиль мини-приложения — образцы владельца 05.11 (docs/miniapp-mockups/4-bybit.html,
   5-bybit-ad.html): светлая тема, белые карточки 28px, отступы 16px, акцент #5AA6F2. */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --muted: #6c6c70;
  --line: #e5e5ea;
  --accent: #5aa6f2;
  --accent-soft: #dcebfb;
  --link: #0a63d6;
  --on: #34c759;
  --chip: #efeff4;
  --seg: #e4e4ea;
  --chevron: #c7c7cc;
  --green: #1e7b34;
  --green-soft: #e3f6ea;
  --yellow: #b45309;
  --yellow-soft: #fff6db;
  --red: #d70015;
  --red-soft: #ffe5e7;
  --grey: #c7c7cc;
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { font: 15px/1.35 -apple-system, 'SF Pro Text', Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
main { max-width: 640px; margin: 0 auto; padding: calc(14px + var(--tg-top, 0px)) 16px 88px; }
main > div { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; overflow-wrap: anywhere; }

/* ── шапки ── */
header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
header.top h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
header.top .totals { font-size: 13px; color: var(--muted); }
header.top.agent { justify-content: flex-start; align-items: center; }
.totals.line { font-size: 13px; color: var(--muted); margin-top: -6px; }
.status { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status.ok { color: var(--green); }
.status.bad { color: var(--red); }
.status-detail { color: var(--red); font-size: 14px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 4px -8px; font-weight: 600; }
h2.need-head { color: var(--yellow); }

/* ── капсулы ── */
.capsule { height: 38px; padding: 0 14px; border-radius: 999px; background: var(--card); border: 0; display: inline-flex; align-items: center; gap: 8px; font: 500 15px -apple-system, Inter, sans-serif; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.capsule.agent { background: var(--accent); color: #0b1a2b; font-size: 13px; font-weight: 600; padding: 0 14px; cursor: default; }
.capsule .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--chip); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; margin-left: -8px; }
.capsule svg { flex: none; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 38px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--card); font: 600 15px -apple-system, Inter, sans-serif; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chip .count { color: var(--muted); font-weight: 400; }

/* ── метки и точки ── */
.pill { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--chip); color: var(--muted); white-space: nowrap; align-self: center; }
.pill.online, .pill.completed { background: var(--green-soft); color: var(--green); }
.pill.pending { background: var(--accent-soft); color: var(--link); }
.pill.on_appeal { background: #ffedd5; color: #c2410c; }
.pill.unknown { background: var(--red-soft); color: var(--red); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.green { background: var(--on); }
.dot.yellow { background: #f59e0b; }
.dot.red { background: #ff3b30; }
.dot.grey { background: var(--grey); }
.dot.blue { background: var(--accent); }

/* ── карточки ── */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.card.rows { padding: 2px 14px; }
.card-title { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.hero { background: var(--card); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; gap: 12px; }
.halo { width: 60px; height: 60px; flex: none; border-radius: 50%; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; }
.halo .ico { width: 40px; height: 40px; font-size: 18px; }
.hero .big { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.hero .sub { font-size: 13px; color: var(--muted); }
.hero .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ico { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; }
.ico.off { background: var(--grey); }

/* Строка списка: иконка, текст, стрелка. */
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.item:last-child { border-bottom: 0; }
.item .txt { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.item .head { display: flex; align-items: center; gap: 8px; }
.item .price { font-size: 16px; font-weight: 600; }
.item .name { font-size: 15px; font-weight: 500; }
.item .sub { font-size: 13px; color: var(--muted); }
.item .feat { font-size: 12px; color: var(--link); }
.item.static { cursor: default; }
.item .chev { color: var(--chevron); display: flex; }
.kvrow { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kvrow:last-child { border-bottom: 0; }
.kvrow .k { color: var(--muted); flex: none; }
.kvrow .v { text-align: right; overflow-wrap: anywhere; }
.seg { background: var(--seg); border-radius: 999px; padding: 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button { height: 34px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 500 13px -apple-system, Inter, sans-serif; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; }

/* ── панель: строки сделок ── */
.list { background: var(--card); border-radius: var(--radius); padding: 2px 14px; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.row:last-child { border-bottom: 0; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.row .title .right { display: inline-flex; align-items: center; gap: 10px; }
.row .title .sum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cards.need { display: flex; flex-direction: column; gap: 10px; }
.cards.need .row { background: var(--yellow-soft); border-radius: var(--radius); padding: 12px 14px; border: 0; }
.cards.need .need-text { color: var(--yellow); font-size: 13px; margin-top: 2px; }
.cards.need .whose { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { padding: 11px 0; color: var(--muted); font-size: 13px; }
.fold-btn { width: 100%; text-align: left; border: 0; background: var(--card); color: var(--link); border-radius: var(--radius); padding: 12px 14px; font: 500 15px -apple-system, Inter, sans-serif; cursor: pointer; }
.list.closed { opacity: .7; }
.actions-row { display: flex; justify-content: flex-end; }
.actions-off { background: var(--red-soft); color: var(--red); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; }
.agent-top { display: flex; justify-content: space-between; align-items: center; }

/* ── экран сделки ── */
.deal-head { display: flex; flex-direction: column; gap: 4px; }
.deal-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.deal-head .meta { color: var(--muted); font-size: 13px; }
.note { font-size: 13px; color: var(--yellow); }
.stages { display: flex; gap: 4px; }
.stage { flex: 1; text-align: center; font-size: 11px; color: var(--chevron); }
.stage .bar { height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 5px; }
.stage.done { color: var(--muted); }
.stage.done .bar { background: var(--on); }
.stage.current { color: var(--text); font-weight: 600; }
.stage.current .bar { background: var(--accent); }
.pay { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.pay:last-child { border-bottom: 0; }
.pay .pay-sum { font-weight: 600; }
.shot { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.shot:last-child { border-bottom: 0; }
.shot img { width: 60px; height: 106px; object-fit: cover; border-radius: 12px; background: var(--chip); flex: none; cursor: zoom-in; }
.shot .read { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.shot .verdict { font-weight: 600; }
.advice { background: var(--green-soft); }
.advice .label { color: var(--green); font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.advice .item-text { font-size: 15px; padding: 2px 0; }
.advice .item-text.решение { font-weight: 600; }
.advice .item-text.предупреждение { color: var(--yellow); font-size: 13px; }
.group .what { font-size: 13px; color: var(--muted); margin: 0 4px 8px; overflow-wrap: anywhere; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.buttons.decide { flex-wrap: nowrap; }
.btn { border: 0; border-radius: 999px; height: 38px; padding: 0 16px; font: 600 15px -apple-system, Inter, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn.primary { background: var(--link); color: #fff; }
.btn.secondary { background: var(--card); color: var(--text); }
.btn.green { background: var(--on); color: #fff; flex: 1; }
.btn.big { height: 40px; padding: 0 18px; font-size: 15px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.feedback textarea { width: 100%; font: inherit; border: 0; border-radius: 16px; padding: 12px; margin-bottom: 8px; resize: vertical; background: var(--card); }
.section-title { color: var(--muted); font-size: 13px; margin: 0 4px -6px; }
.log { background: var(--card); border-radius: var(--radius); padding: 2px 14px; font-size: 13px; }
.log .e { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.log .e:last-child { border-bottom: 0; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.chat .msg { max-width: 85%; margin: 5px 0; padding: 7px 11px; border-radius: 16px; background: var(--chip); font-size: 14px; }
.chat .msg.мы { margin-left: auto; background: var(--accent-soft); }
.chat .msg.система { margin: 6px auto; background: none; color: var(--muted); font-size: 12px; text-align: center; }
.chat .msg img { max-width: 160px; border-radius: 12px; display: block; cursor: zoom-in; }
.chat .msg .t { color: var(--muted); font-size: 11px; text-align: right; }
.chat .msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.zoom { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; z-index: 10; }
.zoom img { max-width: 100%; max-height: 100%; }

/* ── тумблер (только внутри объекта: агент, объявление) ── */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; user-select: none; -webkit-tap-highlight-color: transparent; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: relative; width: 51px; height: 31px; border-radius: 999px; background: #e9e9ea; transition: background .15s; flex: none; }
.switch .slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch.on .slider { background: var(--on); }
.switch.on .slider::after { transform: translateX(20px); }
.switch .switch-text { color: var(--text); }
.switch.off .switch-text { color: var(--muted); }

/* ── нижнее меню: плавающая капсула ── */
.tabbar { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); height: 56px; padding: 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0, 0, 0, .08); display: grid; grid-template-columns: repeat(2, 104px); gap: 4px; z-index: 5; }
.tabbar .tab { border: 0; background: none; border-radius: 999px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: 500 11px -apple-system, Inter, sans-serif; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tabbar .tab.on { background: var(--chip); color: var(--link); font-weight: 600; }
.tabbar .tab-ico svg { width: 22px; height: 22px; display: block; }
.ico svg { width: 18px; height: 18px; }
.halo .ico svg { width: 20px; height: 20px; }

/* «Дальше»: чей ход (05.11) */
.card.next.agent { background: var(--card); }
.card.next.yours { background: var(--yellow-soft); }
.card.next .label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.card.next.yours .label { color: var(--yellow); }
.card.next .basis { font-size: 13px; color: var(--muted); margin-top: 2px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .field { flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font: inherit; background: var(--bg); }
