:root {
  --accent: #0f766e; --accent2: #14b8a6; --bg: #f6f8f8; --text: #0f1f1e; --gray: #52625f; --line: #dbe4e2; --card: #ffffff; --r: 16px;
  /* «телеграмные» цвета чатов */
  --wall1: #dfe8cf; --wall2: #c9d8b4; --in: #ffffff; --out: #e3f7cf; --in-text: #111; --meta: #8a9a87; --kb: rgba(52, 72, 40, .34); --head: #ffffff; --head-text: #111; --sub: #7d8b88; --inbar: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1514; --text: #e8f0ef; --gray: #9db0ac; --line: #263432; --card: #152020;
    --wall1: #1b2a24; --wall2: #13201b; --in: #212d2b; --out: #2b4a37; --in-text: #eef3f2; --meta: #8aa59b; --kb: rgba(255, 255, 255, .13); --head: #1a2523; --head-text: #eef3f2; --sub: #8fa29e; --inbar: #1a2523;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; overflow-x: hidden; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

.plate { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 16px; background: var(--card); border-bottom: 1px solid var(--line); font-size: 13.5px; }
.plate-t { color: var(--gray); font-weight: 600; text-align: center; flex: 1; }
.back-all { text-decoration: none; font-weight: 600; white-space: nowrap; }
.reset { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }
.reset:hover { border-color: var(--accent); color: var(--accent); }

.intro { max-width: 1240px; margin: 0 auto; padding: 14px 24px 4px; }
.intro h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.intro p { margin: 4px 0 0; color: var(--gray); max-width: 900px; font-size: 14.5px; }

.tabs { display: none; }
.stage { max-width: 1240px; margin: 0 auto; padding: 14px 24px 8px; display: grid; grid-template-columns: 404px minmax(0, 1fr); gap: 24px; align-items: start; }
.col-customer { display: flex; flex-direction: column; align-items: center; }
.cap { margin: 8px 0 0; color: var(--gray); font-size: 13px; font-weight: 600; }
.phone { width: 404px; height: var(--ph, 780px); background: #10161a; border-radius: 46px; padding: 12px; box-shadow: 0 18px 40px rgba(15, 31, 30, .18), inset 0 0 0 2px #2a3338; }
.screen { width: 100%; height: 100%; border-radius: 35px; overflow: hidden; position: relative; background: var(--wall1); }

.col-owner { display: flex; flex-direction: column; height: calc(var(--ph, 780px) + 30px); min-width: 0; }
.otabs { display: flex; gap: 6px; margin-bottom: 10px; }
.otabs button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 16px; font-weight: 600; font-size: 14px; position: relative; }
.otabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.col-owner .pane { flex: 1; min-height: 0; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.col-owner .pane-panel { display: none; }
.col-owner.show-panel .pane-owner { display: none; }
.col-owner.show-panel .pane-panel { display: block; }
.pane-panel iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; font-style: normal; line-height: 18px; font-weight: 700; }

/* ---------- чат ---------- */
.tg { position: relative; height: 100%; display: flex; flex-direction: column; background: linear-gradient(160deg, var(--wall1), var(--wall2)); overflow: hidden; }
.tg::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .35) 1.2px, transparent 1.3px); background-size: 22px 22px; pointer-events: none; }
.tg-head { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 34px 12px 9px; background: var(--head); color: var(--head-text); box-shadow: 0 1px 0 rgba(0, 0, 0, .06); }
.desk .tg-head { padding-top: 10px; }
.tg-back { font-size: 20px; color: var(--sub); width: 18px; }
.ava { width: 38px; height: 38px; border-radius: 50%; }
.tg-title b { display: block; font-size: 15.5px; line-height: 1.2; }
.tg-title small { color: var(--sub); font-size: 13px; }
.tg-msgs { position: relative; z-index: 1; flex: 1; overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.desk .tg-msgs { padding: 14px 18px 8px; }
.svc { align-self: center; background: rgba(40, 60, 30, .38); color: #fff; font-size: 12.5px; padding: 4px 11px; border-radius: 12px; max-width: 86%; text-align: center; margin: 4px 0; }
.msg { display: flex; flex-direction: column; max-width: 88%; align-self: flex-start; animation: pop .22s ease-out; }
.desk .msg { max-width: min(560px, 80%); }
.msg:has(.kb) { min-width: min(100%, 300px); }
.desk .msg:has(.kb) { min-width: min(100%, 420px); }
.msg.out { align-self: flex-end; align-items: flex-end; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble { position: relative; background: var(--in); color: var(--in-text); border-radius: 15px 15px 15px 5px; padding: 7px 10px 7px 11px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); font-size: 14.5px; line-height: 1.38; }
.msg.out .bubble { background: var(--out); border-radius: 15px 15px 5px 15px; }
.txt { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.txt code { font: 12.5px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tm { float: right; font-size: 11px; color: var(--meta); margin: 6px 0 -3px 10px; }
.msg.out .tm::after { content: " ✓✓"; color: #4fae4e; }
.msg.flash .bubble { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px #f5b84b; } 100% { box-shadow: 0 1px 1px rgba(0, 0, 0, .1); } }
.kb { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; width: 100%; }
.kb-row { display: flex; gap: 4px; }
.kb button { flex: 1; min-width: 0; border: 0; border-radius: 10px; background: var(--kb); color: #fff; font-size: 13.5px; font-weight: 600; padding: 9px 6px; backdrop-filter: blur(4px); line-height: 1.2; position: relative; text-shadow: 0 1px 1px rgba(0, 0, 0, .15); }
.kb button:hover { filter: brightness(1.08); }
.kb button.wa::after { content: "↗"; position: absolute; right: 7px; top: 4px; font-size: 11px; opacity: .8; }
.kb button:active { transform: scale(.98); }
.kb button.pressed { animation: press .5s; }
@keyframes press { 0% { background: rgba(255, 255, 255, .55); } 100% { background: var(--kb); } }
.reply-link { align-self: flex-start; border: 0; background: none; color: #2a6a3b; font-size: 12.5px; font-weight: 600; padding: 2px 4px; }
@media (prefers-color-scheme: dark) { .reply-link { color: #8fd3a0; } }
.inv { width: 250px; }
.inv b { display: block; font-size: 15px; }
.inv .inv-d { color: var(--meta); font-size: 13px; margin: 2px 0 6px; }
.inv .inv-a { font-size: 20px; font-weight: 700; }
.inv .inv-paid { color: #2f8a3e; font-weight: 700; }

.tg-start { position: relative; z-index: 2; padding: 10px 12px 14px; background: var(--inbar); display: none; }
.tg.fresh .tg-start { display: block; }
.tg.fresh .tg-input { display: none; }
.tg-start button { width: 100%; border: 0; background: none; color: #2a8bd1; font-weight: 700; letter-spacing: .04em; padding: 10px; font-size: 15px; border-radius: 10px; }
.tg-start button:hover { background: rgba(42, 139, 209, .08); }
.tg-input { position: relative; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 8px 10px 14px; background: var(--inbar); }
.desk .tg-input { padding-bottom: 10px; }
.tg-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--head-text); font: inherit; font-size: 15px; padding: 8px 4px; }
.send { border: 0; background: none; color: #2a8bd1; font-size: 20px; padding: 4px 6px; }
.menu-btn { border: 0; background: #2a8bd1; color: #fff; border-radius: 9px; padding: 6px 10px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.chips { position: relative; z-index: 2; display: flex; gap: 6px; padding: 6px 12px; background: var(--inbar); border-top: 1px solid var(--line); overflow-x: auto; }
.chips button { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.reply-bar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; background: var(--inbar); border-top: 1px solid var(--line); border-left: 3px solid #2a8bd1; font-size: 13px; color: var(--gray); }
.reply-bar button { border: 0; background: none; color: var(--gray); }

.tg-toast { position: absolute; z-index: 30; left: 50%; top: 92px; transform: translateX(-50%); background: rgba(20, 24, 22, .88); color: #fff; font-size: 13.5px; padding: 9px 14px; border-radius: 12px; max-width: 86%; text-align: center; animation: pop .2s; }
.desk .tg-toast { top: 70px; }
.tg-modal { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: grid; place-items: center; padding: 20px; }
.tg-modal .box { background: var(--head); color: var(--head-text); border-radius: 16px; padding: 18px; width: 100%; max-width: 300px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.tg-modal .box p { margin: 0 0 14px; white-space: pre-wrap; }
.tg-modal .box h3 { margin: 0 0 8px; font-size: 17px; }
.tg-modal .box .acts { display: flex; justify-content: flex-end; gap: 8px; }
.tg-modal .box button { border: 0; background: none; color: #2a8bd1; font-weight: 700; padding: 8px 10px; }
.tg-modal .box button.pri { background: #2a8bd1; color: #fff; border-radius: 10px; padding: 10px 14px; width: 100%; }
.card-f { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--gray); }
.small { font-size: 12px; color: var(--sub); margin: 0 0 10px !important; }

/* ---------- мини-приложение поверх чата ---------- */
.miniapp { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #f4f1ec; transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.miniapp.open { transform: none; }
.ma-head { display: flex; align-items: center; gap: 8px; padding: 34px 10px 8px; background: #f4f1ec; color: #1d1a17; }
.ma-left { border: 0; background: none; color: #2a8bd1; font-weight: 600; font-size: 14.5px; padding: 4px 6px; min-width: 92px; text-align: left; }
.ma-title { flex: 1; text-align: center; line-height: 1.15; }
.ma-title b { display: block; font-size: 15px; }
.ma-title small { color: #8b847c; font-size: 12px; }
.ma-dots { min-width: 92px; text-align: right; color: #8b847c; font-size: 18px; padding-right: 6px; }
.miniapp iframe { flex: 1; width: 100%; border: 0; display: block; background: #f4f1ec; }
.ma-main { border: 0; margin: 0; padding: 15px 12px 22px; font-size: 16px; font-weight: 650; color: #fff; background: #b4531b; display: block; width: 100%; }
.ma-main[disabled] { opacity: .7; }
.ma-main .spin { display: inline-block; width: 16px; height: 16px; border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-color-scheme: dark) {
  .miniapp, .ma-head, .miniapp iframe { background: #141312; color: #f2eee9; }
}

/* ---------- блоки под демо ---------- */
.how { max-width: 1240px; margin: 18px auto 0; padding: 0 24px; }
.how h2 { font-size: 20px; margin: 0 0 10px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: s; }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 14px 52px; position: relative; counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.steps b { display: block; margin-bottom: 3px; }
.steps span { color: var(--gray); font-size: 14px; }
.try { color: var(--gray); font-size: 14px; }
.try code { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: 13px; }
.foot { text-align: center; padding: 18px 16px 40px; }
.cta { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; padding: 14px 28px; border-radius: 14px; font-size: 16px; box-shadow: 0 6px 18px rgba(15, 118, 110, .25); }
.cta:hover { background: #0b5f59; }

/* ---------- телефон и планшет ---------- */
@media (max-width: 980px) {
  .intro { display: none; }
  .plate { padding: 6px 12px; gap: 8px; }
  .plate-t { font-size: 12px; line-height: 1.25; }
  .back-all { font-size: 13px; }
  .reset { padding: 4px 10px; font-size: 12.5px; }
  .tabs { display: flex; position: sticky; top: var(--plate-h, 37px); z-index: 45; background: var(--card); border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; border: 0; background: none; color: var(--gray); padding: 11px 4px 10px; font-weight: 700; font-size: 14.5px; border-bottom: 3px solid transparent; position: relative; }
  .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
  .tabs .badge { position: static; display: inline-block; margin-left: 5px; vertical-align: 1px; }
  .tabs .badge[hidden] { display: none; }
  .stage { display: block; padding: 0; max-width: none; }
  .col-customer, .col-owner { display: none; }
  .stage[data-tab="customer"] .col-customer { display: block; }
  .stage[data-tab="owner"] .col-owner, .stage[data-tab="panel"] .col-owner { display: flex; }
  .stage[data-tab="owner"] .col-owner .pane-panel { display: none; }
  .stage[data-tab="owner"] .col-owner .pane-owner { display: block; }
  .stage[data-tab="panel"] .col-owner .pane-owner { display: none; }
  .stage[data-tab="panel"] .col-owner .pane-panel { display: block; }
  .otabs, .cap { display: none; }
  .phone { width: 100%; height: calc(100dvh - var(--top-h, 84px)); border-radius: 0; padding: 0; box-shadow: none; background: none; }
  .screen { border-radius: 0; }
  .col-owner { height: calc(100dvh - var(--top-h, 84px)); }
  .col-owner .pane { border: 0; border-radius: 0; }
  .tg-head { padding-top: 9px; }
  .ma-head { padding-top: 10px; }
  .miniapp { position: fixed; z-index: 100; }
  .tg-toast { top: 64px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .how { padding: 0 16px; }
}
@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .desk .msg { max-width: 92%; }
}
