:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --sep: rgba(128, 128, 128, .22);
  --soft: rgba(36, 129, 204, .12);
  --ok: #34a853;
  --warn: #f29900;
  --danger: #e5484d;
  --radius: 16px;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root { --sep: color-mix(in srgb, var(--hint) 22%, transparent); --soft: color-mix(in srgb, var(--accent) 12%, transparent); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; background: var(--bg2); color: var(--text); }
main { padding: 8px 12px calc(84px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.tab { display: none; animation: fade .18s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
[hidden] { display: none !important; }

/* ---------- заголовки ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 4px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.3px; }
h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--hint); font-size: 13px; }

/* ---------- кнопки и поля ---------- */
button { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 11px 16px; background: var(--accent); color: var(--accent-text); cursor: pointer; transition: transform .08s, opacity .15s; }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; pointer-events: none; }
button.secondary { background: var(--soft); color: var(--accent); }
button.danger { background: rgba(229,72,77,.14); background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
button.wide { width: 100%; margin-top: 8px; }
button.big { padding: 15px; font-size: 16px; border-radius: 14px; }
button.pill { padding: 7px 14px; border-radius: 999px; font-size: 14px; }
button.link { background: none; color: var(--link); padding: 6px 4px; font-weight: 500; }
button.icon { background: var(--bg2); color: var(--text); padding: 8px 10px; font-weight: 500; font-size: 13px; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1.5px solid transparent; border-radius: 12px; padding: 11px 12px; outline: none; transition: border-color .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
.field-row { display: flex; gap: 8px; }
.field-row > select { flex: 0 0 40%; }
.field-row > button { flex: 0 0 auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.lbl { display: block; font-size: 12px; color: var(--hint); margin: 0 0 4px 2px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.note { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--soft); font-size: 13px; }
.warn { margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(242,153,0,.16); background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: 13px; }

/* ---------- карточки ---------- */
.card, .step { background: var(--section); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.list { display: flex; flex-direction: column; }
.step-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 10px; }
.num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 13px; }
.empty { text-align: center; padding: 40px 16px; color: var(--hint); }
.empty .big-emoji { font-size: 44px; display: block; margin-bottom: 8px; }
.empty button { margin-top: 14px; }

/* ---------- статистика ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stat { background: var(--section); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--hint); }

/* ---------- рассылки ---------- */
.camp { cursor: pointer; }
.camp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.camp-title { font-weight: 700; }
.camp-text { color: var(--hint); font-size: 14px; margin-top: 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.progress { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; margin-top: 10px; display: flex; }
.progress .s { background: var(--ok); transition: width .4s; } .progress .f { background: var(--danger); transition: width .4s; }
.camp-nums { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--hint); }
.camp-nums b { color: var(--text); }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg2); color: var(--hint); white-space: nowrap; }
.badge.running, .badge.active { background: rgba(52,168,83,.15); background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.paused, .badge.limited, .badge.draft { background: rgba(242,153,0,.16); background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.dead, .badge.stopped { background: rgba(229,72,77,.14); background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.done { background: var(--soft); color: var(--accent); }
.badge.running::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions button { flex: 1; padding: 9px 10px; font-size: 14px; }

/* ---------- новая рассылка ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); font-weight: 600; }
.chip.total { background: var(--accent); color: var(--accent-text); }
.file-btn { flex: 0 0 auto; font-size: 13px; color: var(--link); cursor: pointer; font-weight: 600; }
.toolbar { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.toolbar button { background: var(--bg2); color: var(--text); padding: 7px 0; min-width: 40px; flex: 1; font-weight: 500; }
.toolbar button.tb-name { flex: 0 0 auto; padding: 7px 12px; white-space: nowrap; color: var(--link); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.chat { border-radius: 14px; padding: 16px 12px; background-color: var(--bg2); background:
  radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 55%),
  radial-gradient(circle at 80% 90%, color-mix(in srgb, var(--ok) 12%, transparent), transparent 50%),
  var(--bg2); }
.bubble { position: relative; max-width: 88%; background: var(--bg); border-radius: 16px 16px 16px 4px; padding: 8px 12px 6px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.bubble-name { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble-text { white-space: pre-wrap; word-wrap: break-word; }
.bubble-text a { color: var(--link); }
.bubble-text code, .bubble-text pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--bg2); border-radius: 4px; padding: 0 3px; }
.bubble-text pre { padding: 6px 8px; margin: 4px 0; white-space: pre-wrap; }
.bubble-text blockquote { margin: 4px 0; padding: 2px 8px; border-left: 3px solid var(--accent); background: var(--soft); border-radius: 4px; }
.bubble-time { text-align: right; font-size: 11px; color: var(--hint); margin-top: 2px; }
.test-box { margin-top: 10px; }

.acc-pick { display: flex; flex-direction: column; gap: 6px; }
.acc-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--bg2); cursor: pointer; }
.acc-opt input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.acc-opt .meta { flex: 1; min-width: 0; }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 3px; margin-top: 10px; gap: 2px; }
.seg button { flex: 1; background: none; color: var(--hint); padding: 8px 4px; font-size: 14px; border-radius: 10px; font-weight: 600; }
.seg button.active { background: var(--section); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.launch-bar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); margin-top: 12px; z-index: 4; }
.launch-bar button { box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- аккаунты ---------- */
.acc { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; flex: 0 0 auto; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.acc .meta { flex: 1; min-width: 0; }
.acc .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr { background: #fff; padding: 10px; border-radius: 16px; width: 220px; max-width: 100%; margin: 12px auto 4px; }
.qr svg { width: 100%; height: auto; display: block; }
.howto { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: var(--hint); }
.howto li { margin: 3px 0; }
#add-acc input { margin-top: 10px; }

/* ---------- нижнее меню ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--sep); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.bottom-nav button { flex: 1; background: none; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: 11px; font-weight: 600; border-radius: 10px; }
.bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button.active { color: var(--accent); }

/* ---------- шторка ---------- */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 10; animation: fade .15s; }
.sheet-body { position: relative; background: var(--bg); width: 100%; max-width: 720px; margin: 0 auto; max-height: 86vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 10px; }
.sheet .close { position: absolute; right: 10px; top: 10px; background: var(--bg2); color: var(--hint); padding: 4px 10px; border-radius: 999px; }
.sheet h2 { margin: 4px 0 10px; font-size: 20px; }
.filters { display: flex; gap: 6px; margin: 12px 0 6px; overflow-x: auto; }
.filters button { background: var(--bg2); color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.filters button.active { background: var(--accent); color: var(--accent-text); }
.tline { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--sep); font-size: 14px; }
.tline .err { color: var(--danger); font-size: 12px; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; background: rgba(30,30,30,.94); color: #fff; padding: 12px 14px; border-radius: 14px; z-index: 20; font-size: 14px; animation: fade .2s; }

/* ---------- чаты ---------- */
.bottom-nav button { position: relative; }
.nav-badge { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 11px/18px system-ui, sans-serif; font-style: normal; box-sizing: border-box; text-align: center; }
#chats-search { margin-bottom: 8px; }
.dialogs { background: var(--section); border-radius: 16px; overflow: hidden; margin-top: 8px; }
.dlg { display: flex; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; position: relative; }
.dlg + .dlg::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; border-top: 1px solid var(--sep); }
.dlg:active { background: var(--bg2); }
.dlg .meta { flex: 1; min-width: 0; }
.dlg-top, .dlg-bottom { display: flex; gap: 8px; align-items: baseline; }
.dlg-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-time { font-size: 12px; color: var(--hint); white-space: nowrap; }
.dlg-text { flex: 1; min-width: 0; color: var(--hint); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-text .you { color: var(--text); }
.dlg-acc { font-size: 11px; color: var(--accent); }
.unread { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; display: grid; place-items: center; box-sizing: border-box; }
.ticks { color: var(--accent); font-size: 12px; }

.chat-view { position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--bg2); }
.cv-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--sep); }
.cv-back { background: none; color: var(--accent); font-size: 30px; line-height: 1; padding: 0 8px 4px 0; }
.cv-meta { min-width: 0; }
.cv-meta .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-meta .muted { font-size: 13px; }
.cv-body { flex: 1; overflow-y: auto; padding: 10px 10px 6px; }
#cv-more { text-align: center; margin-bottom: 8px; }
#cv-messages { display: flex; flex-direction: column; gap: 4px; max-width: 720px; margin: 0 auto; }
.msg { max-width: 82%; align-self: flex-start; margin-right: auto; background: var(--bg); border-radius: 16px 16px 16px 4px; padding: 6px 10px 4px; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: pre-wrap; word-wrap: break-word; }
.msg.out { align-self: flex-end; margin-left: auto; margin-right: 0; background: var(--accent); color: var(--accent-text); border-radius: 16px 16px 4px 16px; }
.msg.out .m-time, .msg.out .m-quote, .msg.out .m-media { color: var(--accent-text); opacity: .8; }
.msg.out .m-quote { border-left-color: var(--accent-text); }
.msg.out a { color: var(--accent-text); text-decoration: underline; }
.msg .m-media { color: var(--accent); font-size: 14px; }
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin: 2px 0 4px; }
.msg .m-time { float: right; margin: 6px 0 0 10px; font-size: 11px; color: var(--hint); }
.msg .m-quote { font-size: 13px; border-left: 2px solid var(--accent); padding-left: 6px; margin-bottom: 3px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.service { align-self: center; margin: 0 auto; background: var(--soft); color: var(--hint); font-size: 12px; box-shadow: none; }
.day { align-self: center; font-size: 12px; color: var(--hint); background: var(--soft); padding: 2px 10px; border-radius: 10px; margin: 6px 0; }
.cv-reply { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg); border-top: 1px solid var(--sep); font-size: 13px; border-left: 3px solid var(--accent); }
.cv-reply span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-input { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--sep); }
.cv-input textarea { resize: none; min-height: 42px; height: 42px; max-height: 140px; box-sizing: border-box; line-height: 1.4; border-radius: 20px; padding: 9px 14px; }
.cv-input button { width: 42px; height: 42px; border-radius: 50%; padding: 0; display: grid; place-items: center; flex: 0 0 auto; }
.cv-input svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
#chats-accounts { margin-top: 0; }
#chats-accounts button:not(.active) { background: var(--section); }
.cv-attach { width: 42px; height: 42px; display: grid; place-items: center; color: var(--hint); cursor: pointer; flex: 0 0 auto; }
.cv-attach svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cv-files { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; background: var(--bg); border-top: 1px solid var(--sep); }
.cv-file { position: relative; flex: 0 0 auto; width: 76px; font-size: 11px; color: var(--hint); text-align: center; }
.cv-file .thumb { width: 76px; height: 76px; border-radius: 10px; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; font-size: 26px; }
.cv-file .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cv-file .x { position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 12px; line-height: 22px; }
.cv-file .bar { position: absolute; left: 4px; right: 4px; top: 66px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.25); overflow: hidden; }
.cv-file .bar i { display: block; height: 100%; width: 0; background: var(--accent); }

.app-version { text-align: center; font-size: 12px; opacity: .45; padding: 18px 0 4px; user-select: text; }
.camp-from { font-size: 13px; color: var(--hint); margin: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.from-box { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--bg2); }
.from-box .lbl { font-weight: 600; margin-bottom: 4px; }
.from-box .from-by { margin-top: 6px; font-size: 13px; }

/* действия с сообщениями */

.msg { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.msg.picked { transform: scale(1.02); box-shadow: 0 0 0 2px var(--accent); }
.msg .m-fwd { font-size: 12px; color: var(--accent); margin-bottom: 2px; font-weight: 500; }
.msg.out .m-fwd { color: var(--accent-text); opacity: .85; }
.m-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0; }
.m-reacts .rc { background: var(--soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 14px; line-height: 22px; min-height: 0; }
.m-reacts .rc.my { background: var(--accent); color: var(--accent-text); }
.msg.out .m-reacts .rc { background: rgba(255,255,255,.22); color: var(--accent-text); }
.msg.out .m-reacts .rc.my { background: var(--accent-text); color: var(--accent); }
.mm { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; animation: fade .12s; }
.mm-panel { width: 100%; max-width: 720px; margin: 0 auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); max-height: 75%; overflow: auto; }
.mm-react { display: flex; justify-content: space-between; gap: 2px; padding: 4px 2px 10px; border-bottom: 1px solid var(--sep); margin-bottom: 4px; }
.mm-react button { background: none; font-size: 26px; padding: 4px; border-radius: 12px; line-height: 1; min-height: 0; }
.mm-react button.my { background: var(--soft); }
.mm-title { font-size: 13px; color: var(--hint); padding: 6px 8px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-list > button { display: flex; align-items: center; gap: 12px; width: 100%; background: none; color: var(--text); text-align: left; padding: 12px 10px; border-radius: 12px; font-weight: 400; }
.mm-list > button span { width: 22px; text-align: center; }
.mm-list > button:active { background: var(--bg2); }
.mm-list > button.danger { color: #e53935; }
.mm-list input { margin: 0 0 6px; }
.mm-chats { display: flex; flex-direction: column; }
.mm-chats button { display: flex; align-items: center; gap: 10px; background: none; color: var(--text); padding: 8px; border-radius: 12px; text-align: left; font-weight: 400; }
.mm-chats button:active { background: var(--bg2); }

/* право назначать админов */
.mgr-toggle { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sep); font-size: 14px; cursor: pointer; }
.mgr-toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }

/* ================= сайт АвтоТрейд ================= */
.side-brand.brand, .side-user { display: none; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; background: linear-gradient(135deg, #2b8fe0, #123a63); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 14px rgba(18,58,99,.3); }
.brand-logo svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -.4px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--hint); }

body.logged-out main, body.logged-out .bottom-nav, body.logged-out .app-version { display: none; }
.login { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; overflow: auto;
  background: radial-gradient(circle at 20% 10%, #2b8fe0 0, transparent 45%), linear-gradient(135deg, #0d2238, #123a63 60%, #1d6bb0); }
.login-card { background: var(--bg); color: var(--text); border-radius: 24px; padding: 36px; width: 100%; max-width: 820px; display: grid; grid-template-columns: 1fr 260px; gap: 36px; align-items: center; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login h1 { font-size: 30px; margin: 28px 0 6px; }
.login ol { padding-left: 20px; margin: 14px 0 20px; line-height: 1.8; }
.btn-tg { display: inline-flex; align-items: center; gap: 8px; background: #2aabee; color: #fff; text-decoration: none; font-weight: 600; padding: 12px 22px; border-radius: 12px; }
.btn-tg:hover { filter: brightness(1.06); }
.login-qr { background: #fff; border-radius: 18px; padding: 12px; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--sep); }
.login-qr svg { width: 100%; height: auto; display: block; }
@media (max-width: 720px) { .login-card { grid-template-columns: 1fr; padding: 24px; } .login-qr { max-width: 240px; margin: 0 auto; } }

@media (prefers-color-scheme: dark) {
  body.site { --bg: #17212b; --bg2: #0e1621; --section: #17212b; --text: #e9eef3; --hint: #7d8b99; --link: #5eb5f7; --accent: #3a8fd9; }
}

@media (min-width: 900px) {
  body.site { padding-left: 252px; }
  body.site main { max-width: 1120px; padding: 28px 40px 48px; }
  body.site .bottom-nav { top: 0; bottom: 0; right: auto; width: 252px; flex-direction: column; gap: 2px; padding: 22px 14px 16px; border-top: 0; border-right: 1px solid var(--sep); background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  body.site .side-brand { display: flex; padding: 0 8px 26px; }
  body.site .bottom-nav button[data-tab] { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; font-size: 15px; font-weight: 500; color: var(--text); }
  body.site .bottom-nav button[data-tab]:hover { background: var(--bg2); }
  body.site .bottom-nav button[data-tab].active { background: var(--soft); color: var(--accent); font-weight: 600; }
  body.site .bottom-nav button:active { transform: none; }
  body.site .bottom-nav svg { width: 21px; height: 21px; }
  body.site .nav-badge { position: static; margin-left: auto; }
  body.site .side-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--sep); }
  body.site .side-user .meta { flex: 1; min-width: 0; }
  body.site .side-user .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.site .app-version { position: fixed; left: 0; bottom: 4px; width: 252px; padding: 0; font-size: 11px; }
  body.site .side-user { margin-bottom: 14px; }

  body.site h1 { font-size: 28px; }
  body.site .page-head { padding: 0 4px 8px; }
  body.site button:hover:not(:disabled) { filter: brightness(1.05); }
  body.site button.link:hover { text-decoration: underline; filter: none; }
  body.site .launch-bar { bottom: 16px; }
  body.site .toast { left: auto; right: 24px; bottom: 24px; width: 380px; margin: 0; }
  body.site .sheet { align-items: center; }
  body.site .sheet-body { border-radius: 20px; max-height: 88vh; padding: 18px 26px 26px; max-width: 760px; }
  body.site .grab { display: none; }
  body.site #campaigns-list, body.site #accounts-list, body.site #admins-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 12px; align-items: start; }
  body.site #campaigns-list > *, body.site #accounts-list > *, body.site #admins-list > * { margin-top: 0; }
  body.site #campaigns-list { margin-top: 12px; }
  body.site #tab-new, body.site #tab-admins > .card, body.site #tab-admins > .note, body.site #add-acc { max-width: 820px; }
  body.site #admins-list { grid-template-columns: 1fr; max-width: 820px; }

  /* чаты: список слева, переписка справа */
  body.site.on-chats { overflow: auto !important; }
  body.site.on-chats main { max-width: none; margin: 0; width: 420px; padding: 28px 16px 24px 20px; }
  body.site.on-chats::after { content: "Выберите чат слева"; position: fixed; left: 672px; right: 0; top: 0; bottom: 0; display: grid; place-items: center; color: var(--hint); background: var(--bg2); border-left: 1px solid var(--sep); z-index: 1; }
  body.site .chat-view { left: 672px; z-index: 3; border-left: 1px solid var(--sep); }
  body.site .cv-head { padding: 12px 20px; }
  body.site .cv-body { padding-left: max(20px, calc((100% - 860px) / 2)); padding-right: max(20px, calc((100% - 860px) / 2)); }
  body.site .msg { max-width: 68%; }
  body.site .dlg:hover { background: var(--bg2); }
  body.site .dlg.current { background: var(--soft); }
  body.site .mm { align-items: center; }
  body.site .mm-panel { max-width: 400px; border-radius: 18px; padding-bottom: 12px; }
}

/* ---------- отложенные рассылки и папки клиентов ---------- */
.badge.scheduled { background: rgba(51,144,236,.14); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.camp-when { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 4px; }
.quick-when { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.quick-when button { font-size: 13px; padding: 6px 10px; }
#when-box input, .resched input { margin-top: 10px; }
.resched { margin-top: 10px; }
.folder-pick { margin-bottom: 8px; }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { background: var(--bg2); color: var(--text); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 500; }
.fchip span { color: var(--hint); font-size: 12px; margin-left: 2px; }
.fchip.on { background: var(--accent); color: #fff; }
.fchip.on span { color: rgba(255,255,255,.8); }
.card.folder { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.card.folder .meta { flex: 1; min-width: 0; }
.card.folder .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.folder > button { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }
.folder-ico { font-size: 26px; }
.fc-add { margin-top: 14px; }
.sel-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding: 8px; border-radius: 12px; background: var(--bg2); }
.sel-bar select { flex: 1; min-width: 120px; width: auto; }
.sel-bar button { padding: 7px 10px; font-size: 13px; }
.fc-all { border-bottom: 0; }
.tline.client { cursor: pointer; }
.tline.client { align-items: center; }
.tline.client .c-main { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tline.client .c-name { font-weight: 600; margin-right: 6px; }
.tline .c-target { color: var(--hint); font-size: 13px; }
.tline.client .c-side { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tline .c-edit { padding: 2px 4px; font-size: 14px; opacity: .55; }
.tline .c-edit:hover, .tline.client:hover .c-edit { opacity: 1; }
.client-edit { align-items: center; flex-wrap: wrap; }
.client-edit input { flex: 1 1 180px; min-width: 0; padding: 8px 10px; }
.client-edit .c-target { flex-basis: 100%; order: 3; }
.tline.client input, .fc-all input { width: 18px; height: 18px; padding: 0; margin: 0 8px 0 0; vertical-align: -3px; accent-color: var(--accent); }

/* голосовые */
.vmsg { display: inline-flex; align-items: center; gap: 10px; min-width: 200px; max-width: 100%; padding: 4px 0; vertical-align: middle; }
.vplay { width: 40px; height: 40px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 15px; flex: 0 0 auto; }
.vplay.on { box-shadow: 0 0 0 3px var(--soft); }
.vwave { --p: 0%; flex: 1; min-width: 80px; height: 22px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p), color-mix(in srgb, var(--accent) 30%, transparent) var(--p));
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 5px); mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 5px);
  clip-path: polygon(0 35%, 10% 10%, 20% 45%, 30% 0, 40% 30%, 50% 15%, 60% 50%, 70% 5%, 80% 35%, 90% 20%, 100% 40%, 100% 100%, 0 100%); }
.vtime { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; min-width: 32px; }
.msg .vmsg { display: flex; }
.voice-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--sep); }
.voice-btns { display: flex; align-items: center; gap: 12px; }
.voice-btns button { padding: 7px 12px; font-size: 13px; }
.voice-rec, .voice-ready, .cv-rec { display: flex; align-items: center; gap: 10px; }
.voice-rec button { padding: 7px 12px; font-size: 13px; }
.voice-ready .vmsg { min-width: 0; flex: 0 1 260px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; animation: recpulse 1s ease-in-out infinite; }
@keyframes recpulse { 50% { opacity: .25; transform: scale(.8); } }
.cv-rec { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--sep); }
.cv-rec button { padding: 9px 14px; font-size: 14px; }
.cv-input button.cv-mic { background: none; color: var(--hint); }
.cv-input button.cv-mic svg { stroke-linecap: round; }
.msg.out .vplay { background: var(--accent-text); color: var(--accent); }
.msg.out .vwave { background: linear-gradient(90deg, var(--accent-text) var(--p), color-mix(in srgb, var(--accent-text) 45%, transparent) var(--p)); }
.msg.out .vtime { color: var(--accent-text); opacity: .8; }
.access-card .access-row { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.access-card .access-row > div { min-width: 0; }
.access-card .muted { font-size: 13px; margin-top: 3px; }
.access-card button { flex: 0 0 auto; white-space: nowrap; }
.access-card.open { box-shadow: inset 3px 0 0 var(--warn, #e5a63a); }
@media (max-width: 520px) { .access-card .access-row { flex-direction: column; align-items: stretch; } }
.head-btns { display: flex; gap: 8px; }
.cv-call { margin-left: auto; background: none; border: 0; font-size: 22px; padding: 4px 8px; cursor: pointer; }
.call-ov { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.call-ov[hidden] { display: none; }
.call-box { background: var(--bg); border-radius: 18px; padding: 24px 20px; width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.call-ico { font-size: 44px; }
.call-ov[data-state="ringing"] .call-ico { animation: call-pulse 1.2s infinite; }
@keyframes call-pulse { 50% { transform: scale(1.15); } }
.call-name { font-size: 20px; font-weight: 600; }
.call-timer { font-size: 28px; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.call-hint { font-size: 12px; }
#call-setup { display: flex; flex-direction: column; gap: 8px; }
#call-setup[hidden] { display: none; }
.call-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.m-file { display: flex; align-items: center; gap: 10px; background: rgba(127,127,127,.12); border: 0; border-radius: 10px; padding: 8px 10px; margin: 2px 0 4px; color: inherit; text-align: left; cursor: pointer; max-width: 100%; font: inherit; }
.m-file-ico { font-size: 26px; }
.m-file-meta { display: flex; flex-direction: column; min-width: 0; }
.m-file-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.m-file-meta .muted { font-size: 12px; }
.fc-chats { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(127,127,127,.18); display: flex; flex-direction: column; gap: 6px; }
.fc-chats-lbl { font-size: 13px; opacity: .7; }
.fc-chats-row { display: flex; gap: 8px; align-items: stretch; }
.fc-chats-row select { flex: 1; min-width: 0; margin: 0; height: 44px; }
.fc-chats-row button { flex: none; margin: 0; height: 44px; white-space: nowrap; padding: 0 16px; }
.m-sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
#cv-form[hidden], .cv-call[hidden] { display: none; }
.pv-ov { position: fixed; inset: 0; z-index: 210; background: rgba(0,0,0,.88); display: flex; flex-direction: column; }
.pv-ov[hidden] { display: none; }
.pv-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; color: #fff; }
.pv-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pv-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-meta .muted { color: rgba(255,255,255,.6); font-size: 13px; }
.pv-head button { margin: 0; width: auto; flex: none; }
.pv-x { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 40px !important; height: 40px; font-size: 18px; cursor: pointer; padding: 0; }
.pv-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); color: #fff; text-align: center; }
.pv-body img, .pv-body video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.pv-body iframe { width: 100%; height: 100%; max-width: 1000px; border: 0; border-radius: 8px; background: #fff; }
.pv-body pre { width: 100%; max-width: 1000px; height: 100%; overflow: auto; margin: 0; text-align: left; background: #111; color: #eee; padding: 14px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.pv-audio { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.pv-big { font-size: 64px; }
#cv-messages img[data-photo][src] { cursor: zoom-in; }
.head-btns { display: flex; gap: 14px; align-items: center; }
.jn-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; }
.jn-accs { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; margin-bottom: 12px; }
.jn-acc { display: flex; align-items: center; gap: 10px; padding: 6px 4px; cursor: pointer; }
.jn-acc input { width: 18px; height: 18px; margin: 0; flex: none; }
#jn-res { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
#jn-res .err { color: var(--danger, #e5534b); }
.cv-selbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid rgba(127,127,127,.18); flex-wrap: wrap; }
.cv-selbar[hidden] { display: none; }
.cv-selbar button { width: auto; margin: 0; padding: 4px 2px; }
.cv-selbar .sel-sp { flex: 1; }
.cv-selbar .danger-link { color: #e5534b; }
#sel-x { font-size: 18px; }
.chat-view.selecting .msg { cursor: pointer; user-select: none; }
.msg.sel { outline: 2px solid var(--accent, #3b8fd9); outline-offset: 2px; position: relative; }
.msg.sel::after { content: "✓"; position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent, #3b8fd9); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.pv-pages { width: 100%; max-width: 900px; height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 10px; align-items: center; -webkit-overflow-scrolling: touch; }
.pv-pages img { width: 100%; max-height: none; background: #fff; border-radius: 4px; min-height: 120px; }
.pv-list { width: 100%; max-width: 800px; height: 100%; overflow: auto; text-align: left; background: #111; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.pv-li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.pv-li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-li .muted, .pv-list > .muted { color: rgba(255,255,255,.55); }
@media (max-width: 600px) { .cv-selbar { gap: 10px; font-size: 14px; } .pv-head #pv-dl { padding: 8px 10px; } }
.pv-scroll { width: 100%; height: 100%; overflow: auto; display: flex; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pv-scroll > .pv-z { margin: auto; flex: none; }
.pv-scroll > img.pv-z { max-width: 100%; max-height: 100%; }
.pv-scroll > img.pv-z.zoomed, .pv-scroll > .pv-col.zoomed { max-width: none; max-height: none; height: auto; border-radius: 0; }
.pv-pages.pv-scroll { max-width: none; flex-direction: row; align-items: stretch; }
.pv-col { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 0 auto; }
.pv-col img { width: 100%; max-width: none !important; max-height: none !important; background: #fff; border-radius: 4px; min-height: 120px; }
.pv-x[hidden] { display: none; }
