/* ============================================================
   Панель Baby Shark · стили CRM и вкладки «Бот».
   Живёт поверх app.css и использует его переменные темы
   (--card, --accent, --accent-grad, --line и т.д.).
   ============================================================ */

/* ---------- подвкладки (второй ряд .seg) ---------- */
.seg.sub { margin: 0 0 14px; }
.seg.sub button { font-size: 13px; padding: 8px 4px; }

/* ---------- общее: поля, не покрытые app.css ---------- */
input[type=number], input[type=time], input[type=tel] {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--text);
  background: rgba(255,255,255,0.06); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 13px 14px; outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input[type=number]:focus, input[type=time]:focus, input[type=tel]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=time] { color-scheme: dark; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 8px 0 2px; }
.range-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); }
.mono, textarea.mono, input.mono { font-family: Menlo, Consolas, monospace; font-size: 14px; }
.err { color: #ff8a80; font-size: 14px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-head h2 { margin-bottom: 0 !important; }
.subblock { margin-top: 12px; padding-left: 14px; border-left: 2px solid var(--line); }

/* ============================================================
   CRM · доска заявок (канбан-лента, кнопки вместо drag-n-drop)
   ============================================================ */
.kanban {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -20px; padding: 0 20px 8px; -webkit-overflow-scrolling: touch;
}
@media (max-width: 420px) { .kanban { margin: 0 -16px; padding: 0 16px 8px; } }
.kcol { flex: 0 0 82%; max-width: 300px; scroll-snap-align: start; }
.kcol-bar { height: 3px; border-radius: 2px; }
.kcol-head { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14.5px; padding: 10px 2px 10px; }
.kcount { font-size: 12px; font-weight: 700; color: var(--text-2); background: rgba(255,255,255,0.08); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.kempty { color: var(--text-3); font-size: 13.5px; padding: 14px 4px; }
.kcard {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft); padding: 13px 14px; margin-bottom: 10px;
}
.kcard-name { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-phone { display: inline-block; font-size: 13.5px; color: var(--accent-2); text-decoration: none; margin-top: 2px; }
.kcard-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.kcard-msg {
  font-size: 13px; color: var(--text-2); margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kcard .badge { margin-top: 7px; }
.kcard-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kbtn {
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.06); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600; border-radius: 12px;
  padding: 8px 11px; min-height: 40px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.kbtn:active { transform: scale(0.96); }

/* ============================================================
   CRM · воронка учеников
   ============================================================ */
.fstage { padding: 10px 0 4px; border-top: 1px solid var(--line); }
.fstage:first-of-type { border-top: none; padding-top: 2px; }
.fstage-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  border: none; background: none; color: var(--text); font-family: inherit; font-size: 15px;
  font-weight: 600; padding: 6px 2px; cursor: pointer; -webkit-tap-highlight-color: transparent; min-height: 40px;
}
.fstage-n { font-size: 16px; font-weight: 700; color: var(--accent-2); }
.fbar { height: 8px; border-radius: 5px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 2px 2px 6px; }
.fbar > i { display: block; height: 100%; border-radius: 5px; background: var(--accent-grad); box-shadow: var(--glow); transition: width .4s ease; }
.fstage-list { padding: 2px 2px 6px; }

/* ============================================================
   CRM · диалоги (список + тред WhatsApp)
   ============================================================ */
.wa-wrap .wa-pane { display: none; }
.wa-wrap.has-dlg .wa-list { display: none; }
.wa-wrap.has-dlg .wa-pane { display: flex; }
.wa-list { padding: 16px; }
.wa-list h2 { padding: 0 4px; }
.dlg {
  display: flex; width: 100%; text-align: left; gap: 10px; align-items: flex-start;
  border: none; background: none; color: var(--text); font-family: inherit; cursor: pointer;
  padding: 12px 4px; border-top: 1px solid var(--line); -webkit-tap-highlight-color: transparent;
}
.dlg:first-of-type { border-top: none; }
.dlg.on { background: var(--accent-soft); border-radius: var(--radius-sm); border-top-color: transparent; }
.dlg-main { flex: 1; min-width: 0; }
.dlg-top { display: flex; align-items: baseline; gap: 8px; }
.dlg-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-time { flex: none; font-size: 11.5px; color: var(--text-3); }
.dlg-bot { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.dlg-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-unread {
  flex: none; min-width: 20px; height: 20px; border-radius: 999px; padding: 0 6px;
  background: linear-gradient(135deg, #10b981, #34d399); color: #05261b;
  font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; box-shadow: 0 0 10px rgba(52,211,153,0.5);
}

.wa-pane {
  flex-direction: column; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 12px 14px 12px;
  height: calc(100dvh - 235px); min-height: 380px;
}
.wa-none { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 14px; }
.wa-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.wa-head .back { flex: none; padding: 8px 4px 8px 0; }
.wa-title { flex: 1; min-width: 0; }
.wa-name { font-size: 15.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-phone { display: block; font-size: 12.5px; color: var(--accent-2); text-decoration: none; }
.wa-pause { flex: none; }
.wa-pause .toggle-lbl { font-size: 12.5px; color: var(--text-2); }
.wa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.chip {
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.05); color: var(--text-2);
  font-family: inherit; font-size: 12.5px; font-weight: 600; border-radius: 999px;
  padding: 7px 12px; min-height: 36px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chip.on { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: var(--glow); }
.wa-thread {
  flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; padding: 12px; background: rgba(0,0,0,0.18); border-radius: var(--radius-sm);
}
.wa-msg {
  max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.wa-msg.client { align-self: flex-start; background: rgba(255,255,255,0.07); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.wa-msg.bot { align-self: flex-end; background: linear-gradient(135deg, #0f6b4d, #12805c); color: #eafff6; border-bottom-right-radius: 6px; }
.wa-msg.op { align-self: flex-end; background: var(--accent-grad); color: #fff; border-bottom-right-radius: 6px; }
.m-meta { font-size: 10.5px; opacity: 0.65; margin-top: 4px; }
.wa-reply { display: flex; align-items: flex-end; gap: 8px; padding-top: 10px; }
.wa-reply textarea { flex: 1; min-height: 44px; max-height: 116px; resize: none; padding: 11px 14px; border-radius: 18px; }
.wa-send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-grad); color: #fff; font-size: 17px; box-shadow: var(--glow);
  -webkit-tap-highlight-color: transparent;
}
.wa-send[disabled] { opacity: 0.5; pointer-events: none; }
.wa-hint { margin: 6px 4px 0; }

@media (min-width: 900px) {
  .wa-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
  .wa-wrap .wa-list, .wa-wrap.has-dlg .wa-list { display: block; max-height: calc(100dvh - 235px); overflow-y: auto; }
  .wa-wrap .wa-pane { display: flex; }
  .wa-head .back { display: none; }
}

/* ============================================================
   «Мой бот» · переключатели, карточки-опции, чек-лист
   ============================================================ */
.toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; min-height: 24px; }
.toggle-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle { flex: none; width: 36px; height: 20px; border-radius: 999px; background: rgba(255,255,255,0.16); position: relative; transition: background .15s ease; margin-top: 2px; }
.toggle i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.toggle-row input:checked + .toggle { background: var(--accent); box-shadow: 0 0 10px rgba(168,85,247,0.5); }
.toggle-row input:checked + .toggle i { transform: translateX(16px); }
.toggle-row input:disabled + .toggle { opacity: 0.35; }
.toggle-row.dis { opacity: 0.6; cursor: default; }
.toggle-lbl { font-size: 14.5px; line-height: 1.45; }

.opt-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.opt-grid.cols3 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 480px) { .opt-grid.cols2 { grid-template-columns: repeat(2, 1fr); } }
.opt-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; font-family: inherit; color: var(--text);
  background: rgba(255,255,255,0.04); border: 2px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 11px 13px; min-height: 40px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color .12s ease, background .12s ease;
}
.opt-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 14px rgba(168,85,247,0.25); }
.opt-card .t { font-weight: 600; font-size: 14px; }
.opt-card .d { font-size: 11.5px; color: var(--text-2); }
.opt-card .d.dim { color: var(--text-3); font-size: 11px; }

.check-card { border-radius: var(--radius); border: 1px solid; padding: 16px 18px; margin-bottom: 16px; }
.check-card.ok { background: rgba(52,211,153,0.10); border-color: rgba(52,211,153,0.35); }
.check-card.warn { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.35); }
.check-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 14.5px; }
.check-track { flex: 1; max-width: 160px; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; margin-left: auto; }
.check-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent-grad); transition: width .4s ease; }
.check-card.ok .check-track i { background: linear-gradient(135deg, #10b981, #34d399); }
.ck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.ck-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.ck-dot {
  flex: none; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); border: 1px solid var(--card-border); color: transparent;
}
.ck-dot.ok { background: var(--ok); border-color: var(--ok); color: #05261b; }
.ck-item .req { color: #ff8a80; margin-left: 2px; }

/* каналы общения */
.chan {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; margin-bottom: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chan:active { transform: scale(0.99); }
.chan.dis { opacity: 0.55; cursor: default; }
.chan.dis:active { transform: none; }
.chan-ic { font-size: 22px; flex: none; }
.chan-main { flex: 1; min-width: 0; }
.chan-name { font-size: 14.5px; font-weight: 650; }
.chan-st { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.chan .badge:not(.ok):not(.wait) { background: rgba(255,255,255,0.08); color: var(--text-3); }

/* кнопки генератора промпта */
.sec-actions { display: flex; gap: 6px; }
.genbtn {
  border: none; background: var(--accent-soft); color: var(--accent-2); font-family: inherit;
  font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 8px 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.genbtn.alt { background: rgba(255,255,255,0.07); color: var(--text-2); }
.genbtn[disabled] { opacity: 0.45; pointer-events: none; }

/* расписание по дням */
.check-master {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: var(--radius-sm); cursor: pointer;
}
.check-master input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check-master b { display: block; font-size: 14.5px; }
.check-master small { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.sched-off { opacity: 0.5; pointer-events: none; }
.day-grid { display: flex; flex-direction: column; gap: 6px; }
.day-row {
  display: grid; grid-template-columns: 92px 1fr 1fr; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 12px; border: 1px solid var(--card-border); background: rgba(255,255,255,0.03);
}
.day-row.off { opacity: 0.55; }
.day-row input[type=time] { padding: 9px 10px; font-size: 14px; border-radius: 10px; }
.day-row .toggle-lbl { font-weight: 600; font-size: 13.5px; }
.sched-presets { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* КП и переменные */
.kp-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
}
.kp-price { font-size: 13.5px; font-weight: 700; color: var(--accent-2); flex: none; }
.kp-file { flex: 1; min-width: 120px; font-size: 13.5px; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-actions { display: flex; gap: 4px; flex: none; }
.kp-actions .danger { color: #ff8a80; }
.kp-add { display: flex; gap: 8px; align-items: stretch; }
.kp-add input { flex: 0 0 132px; }
.kp-add-btn {
  flex: 1; border: 2px dashed var(--card-border); background: none; color: var(--text-2);
  font-family: inherit; font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.kp-add-btn:active { transform: scale(0.98); }
.kp-add-btn[disabled] { opacity: 0.5; pointer-events: none; }
.mark { font-family: Menlo, Consolas, monospace; font-size: 12px; background: rgba(0,0,0,0.3); border-radius: 6px; padding: 1px 6px; color: var(--accent-2); }
.var-row { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.var-del { border: none; background: none; color: var(--text-3); font-size: 15px; cursor: pointer; padding: 10px 4px; min-height: 40px; }

/* ---------- sticky-бар сохранения ---------- */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(18,10,34,0.85); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line); padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
}
.savebar-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sb-status { font-size: 12.5px; color: var(--text-2); min-height: 18px; }
.sb-dirty { color: #fcd34d; }
body.has-savebar main { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }

/* ---------- bottom-sheet (генератор промпта) ---------- */
.sheet-ovl {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,5,20,0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto;
  background: var(--card-solid); border: 1px solid var(--card-border); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; font-size: 17px; }
.sheet-x { border: none; background: none; color: var(--text-3); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.sheet .err { min-height: 0; margin-top: 8px; }

/* ---------- тест-чат ---------- */
.warn-strip {
  background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.35); color: #fcd34d;
  font-size: 13px; border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0 12px;
}
.tc-wrap { display: flex; flex-direction: column; height: calc(100dvh - 210px); min-height: 420px; padding: 14px 14px 12px; }
.tc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 10px; font-size: 15px; }
.tc-msgs {
  flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; padding: 12px; background: rgba(0,0,0,0.18); border-radius: var(--radius-sm);
}
.tc-msg {
  max-width: 85%; padding: 9px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.tc-msg.user { align-self: flex-end; background: var(--accent-grad); color: #fff; border-bottom-right-radius: 6px; }
.tc-msg.bot { align-self: flex-start; background: rgba(255,255,255,0.07); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.tc-msg.typing { display: flex; gap: 5px; align-items: center; padding: 13px 14px; }
.tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); animation: tcb 1.1s ease-in-out infinite; }
.tc-msg.typing .tdot:nth-child(2) { animation-delay: .16s; }
.tc-msg.typing .tdot:nth-child(3) { animation-delay: .32s; }
@keyframes tcb { 0%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.tc-input { display: flex; align-items: flex-end; gap: 8px; padding-top: 10px; }
.tc-input textarea { flex: 1; min-height: 48px; resize: none; padding: 12px 14px; border-radius: 18px; }
.tc-input .btn { min-height: 48px; }

/* ---------- WhatsApp QR ---------- */
.state-card { background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 16px 18px; font-size: 14.5px; }
.state-card.ok { background: rgba(52,211,153,0.10); border-color: rgba(52,211,153,0.35); }
.state-card.warn { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.35); color: #fcd34d; }
.state-card.bad { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.4); color: #ffb4ae; }
.state-sub { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.qr-steps { margin: 0 0 14px; padding-left: 20px; font-size: 13.5px; color: var(--text-2); }
.qr-steps li { margin: 4px 0; }
.qr-box { display: flex; justify-content: center; margin-bottom: 12px; }
.qr-img { width: 256px; height: 256px; border-radius: var(--radius-sm); background: #fff; padding: 8px; }
.qr-wait {
  width: 256px; height: 256px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); border: 1px dashed var(--card-border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; color: var(--text-2); text-align: center; padding: 16px;
}
.qr-wait span { animation: qrp 1.4s ease-in-out infinite; }
.qr-wait small { color: var(--text-3); font-variant-numeric: tabular-nums; }
@keyframes qrp { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.qr-ttl { font-size: 12px; color: var(--text-2); margin-bottom: 5px; text-align: center; font-variant-numeric: tabular-nums; }
.qr-progress { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; max-width: 256px; margin: 0 auto; }
.qr-progress i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .5s linear, background .3s ease; }
.qr-links { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }

/* ===== СВЕТЛАЯ ТЕМА (body.adm) — редизайн-пасс ===== */
/* Вся админка — светлый Apple-минимал (как ProEducation), акцент — фиолетовый бренда «Речи».
   Слой ниже перекрывает тёмные значения app.css/admin.css только внутри body.adm. */

body.adm {
  --card: #ffffff;
  --card-solid: #ffffff;
  --card-border: rgba(29, 29, 31, 0.08);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #98959e;
  --accent: #7c3aed;
  --accent-2: #6d28d9; /* тёмный: на нём .back/.logout/.badge.wait/кикеры */
  --accent-grad: linear-gradient(135deg, #7c3aed, #8b5cf6);
  --accent-soft: rgba(124, 58, 237, 0.10);
  --glow: 0 0 0 rgba(0, 0, 0, 0);
  --ok: #248a3d;
  --line: rgba(0, 0, 0, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.05);
  --bg-alt: #f7f5fb;
  color: var(--text);
  background: #ffffff;
}

/* ---------- каркас ---------- */
body.adm .topbar {
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--line);
}

/* ---------- поля ввода ---------- */
body.adm input[type=text], body.adm input[type=email], body.adm input[type=password],
body.adm input[type=date], body.adm input[type=search], body.adm input[type=number],
body.adm input[type=time], body.adm input[type=tel], body.adm select, body.adm textarea {
  background: var(--bg-alt); border-color: transparent; color: var(--text);
}
body.adm input:focus, body.adm select:focus, body.adm textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
body.adm input::placeholder, body.adm textarea::placeholder { color: var(--text-3); }
body.adm input[type=date], body.adm input[type=time] { color-scheme: light; }

/* ---------- кнопки ---------- */
/* голый .btn в портированной разметке «Курсов» — главное действие (как в target) */
body.adm .btn { background: var(--accent); color: #fff; border: none; box-shadow: none; }
body.adm .btn:hover { background: var(--accent-2); }
body.adm .btn-primary, body.adm .btn-accent { background: var(--accent); color: #fff; border: none; box-shadow: none; }
body.adm .btn-primary:hover, body.adm .btn-accent:hover { background: var(--accent-2); }
body.adm .btn-ghost, body.adm .btn.ghost { background: rgba(124, 58, 237, 0.08); color: var(--accent); border: none; box-shadow: none; }
body.adm .btn-ghost:hover, body.adm .btn.ghost:hover { background: rgba(124, 58, 237, 0.13); }
body.adm .btn.danger { background: rgba(255, 59, 48, 0.09); color: #ff3b30; border: none; box-shadow: none; }
body.adm .btn.danger:hover { background: rgba(255, 59, 48, 0.14); }
body.adm .btn.sm { padding: 8px 18px; font-size: 15px; }

/* ---------- существующие компоненты rech ---------- */
/* критично: в app.css .stat .n — градиентный текст с transparent-заливкой, на белом невидим */
body.adm .stat .n {
  background: none; -webkit-background-clip: initial; background-clip: initial;
  -webkit-text-fill-color: var(--text); color: var(--text);
}
body.adm .badge.ok { background: rgba(52, 199, 89, 0.12); color: #248a3d; }
body.adm .badge.wait { background: rgba(124, 58, 237, 0.10); color: var(--accent); }
body.adm .admin-section { background: #fff; border: none; box-shadow: var(--shadow); }
body.adm .toast { background: rgba(29, 29, 31, 0.92); border: none; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22); }
body.adm .code-box { background: #f5f5f7; border-color: var(--line); color: var(--text); }
body.adm .seg { background: #f5f5f7; border-radius: 12px; }
body.adm .seg button { color: var(--text-2); }
body.adm .seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
body.adm .err, body.adm .gate .err { color: #d70015; }

/* ---------- вкладки-пилюли (порт .tabs из target) ---------- */
body.adm .tabs {
  display: flex; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  background: #f5f5f7; border-radius: 12px; padding: 3px; gap: 2px; margin: 4px 0 18px;
}
body.adm .tabs::-webkit-scrollbar { display: none; }
body.adm .tabs button {
  flex: 1; background: transparent; border: none; color: var(--text-2);
  padding: 8px 10px; border-radius: 9px; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
body.adm .tabs button:hover { color: var(--text); }
body.adm .tabs button.on { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

/* ---------- порт «Курсов»: формы target ---------- */
body.adm .serif { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em; }
body.adm label.f { display: block; margin-bottom: 16px; }
body.adm label.f span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
body.adm .input, body.adm textarea.input, body.adm select.input {
  width: 100%; background: var(--bg-alt); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 13px 14px; font-size: 16px; font-family: inherit;
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
  -webkit-appearance: none; appearance: none;
}
body.adm .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15); background: #fff; }
body.adm textarea.input { resize: vertical; min-height: 90px; }

body.adm .card { background: #fff; border: none; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-soft); }
body.adm .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { body.adm .row2 { grid-template-columns: 1fr; } }

body.adm .pill { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.5; padding: 2px 10px; border-radius: 99px; background: rgba(124, 58, 237, 0.10); color: var(--accent); white-space: nowrap; }
body.adm .pill.off { color: var(--text-2); background: rgba(0, 0, 0, 0.05); }
body.adm .pill.ok { color: #248a3d; background: rgba(52, 199, 89, 0.12); }
body.adm .pill.warn { color: #c04d00; background: rgba(255, 149, 0, 0.14); }
body.adm .pill.danger { color: #ff3b30; background: rgba(255, 59, 48, 0.10); }

body.adm .iconbtn { background: none; border: none; color: var(--text-2); cursor: pointer; font-family: inherit; font-size: 15px; padding: 4px 8px; border-radius: 8px; transition: color .15s, background .15s; }
body.adm .iconbtn:hover { color: var(--accent); background: var(--bg-alt); }

body.adm .lesson-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 15px; flex-wrap: wrap; }
body.adm .lesson-item .t { flex: 1; min-width: 140px; cursor: pointer; }
body.adm .lesson-item .t:hover { color: var(--accent); }

body.adm .check {
  width: 22px; height: 22px; min-width: 22px; border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.18); background: transparent;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: #fff;
}
body.adm .check.on { background: #34c759; border-color: #34c759; }
body.adm .check.on::before { content: '✓'; font-weight: 700; }

body.adm .upzone { border: 1.5px dashed rgba(0, 0, 0, 0.18); border-radius: var(--radius-sm); padding: 18px; text-align: center; color: var(--text-2); font-size: 14px; cursor: pointer; transition: background .2s, border-color .2s; }
body.adm .upzone:hover { background: var(--bg-alt); border-color: var(--accent); }
body.adm .upbar { margin-top: 10px; }
body.adm .pbar { height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.09); overflow: hidden; }
body.adm .pbar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .5s ease; }

body.adm .course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
body.adm .course-card {
  display: block; color: var(--text); overflow: hidden;
  background: var(--bg-alt); border: none; border-radius: var(--radius);
  transition: transform .25s ease, box-shadow .25s ease;
}
body.adm .course-card:hover { transform: translateY(-3px); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06); }
body.adm .course-cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #f5f5f7, #e8e8ed) center/cover no-repeat; position: relative; }
body.adm .course-cover.empty::before {
  content: 'Baby Shark'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-2);
}
/* обложка в начале карточки курса: превью слева, загрузка справа */
body.adm .cover-edit { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
body.adm .cover-prev { flex: none; width: 220px; aspect-ratio: 16 / 9; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f5f5f7, #e8e8ed) center/cover no-repeat; position: relative; }
body.adm .cover-prev.empty::before {
  content: 'Нет обложки'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-2);
}
body.adm .cover-edit-r { flex: 1; min-width: 220px; }
body.adm .cover-edit-t { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
@media (max-width: 640px) { body.adm .cover-prev { width: 100%; } }

body.adm .course-body { padding: 16px 18px 18px; }
body.adm .course-body h3 { font-size: 18px; margin-bottom: 4px; }
body.adm .course-body .sub { color: var(--text-2); font-size: 14px; }
body.adm .course-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
body.adm .module-num { font-family: var(--font-display); font-weight: 600; color: var(--text-3); line-height: 1; }

body.adm .creds { background: var(--bg-alt); border: none; border-radius: var(--radius-sm); padding: 16px 18px; margin: 16px 0; font-size: 15px; }
body.adm .creds b { font-family: ui-monospace, 'SF Mono', Menlo, monospace; color: var(--text); letter-spacing: 0.3px; }
body.adm .creds .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; flex-wrap: wrap; }

/* чекбоксы курсов в форме приглашения */
body.adm .ckcol { display: flex; flex-direction: column; gap: 9px; padding: 2px 0; }
body.adm .ck { display: flex; align-items: center; gap: 9px; font-size: 15px; cursor: pointer; color: var(--text); }
body.adm .ck input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }

/* ---------- единая модалка dialog#modal ---------- */
body.adm dialog {
  background: #fff; color: var(--text); border: none; border-radius: var(--radius);
  padding: 24px; max-width: min(94vw, 640px); width: 100%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  margin: auto; /* глобальный reset * { margin: 0 } убивает центрирование UA — возвращаем */
}
body.adm dialog::backdrop { background: rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
body.adm dialog.wide { max-width: min(96vw, 880px); }
body.adm .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
@media (max-width: 480px) { body.adm dialog { padding: 18px; } }

/* ---------- аудит-перекраска: CRM ---------- */
body.adm .kcol { background: var(--bg-alt); border-radius: 14px; padding: 6px 10px 4px; }
body.adm .kcount { background: rgba(0, 0, 0, 0.06); color: var(--text-2); }
body.adm .kbtn { background: rgba(0, 0, 0, 0.03); }
body.adm .kbtn:hover { background: rgba(0, 0, 0, 0.06); }
body.adm .fbar { background: rgba(0, 0, 0, 0.06); }
body.adm .dlg-unread { background: #248a3d; color: #fff; box-shadow: none; }
body.adm .chip { background: rgba(0, 0, 0, 0.04); }
body.adm .wa-thread { background: var(--bg-alt); }
body.adm .wa-msg.client { background: #fff; border: 1px solid var(--line); color: var(--text); }
body.adm .wa-msg.bot { background: rgba(124, 58, 237, 0.12); color: var(--text); }
body.adm .wa-msg.op { background: rgba(124, 58, 237, 0.12); color: var(--text); }
body.adm .m-meta { color: var(--text-3); opacity: 1; }

/* ---------- аудит-перекраска: «Мой бот» ---------- */
body.adm .toggle { background: rgba(0, 0, 0, 0.15); }
body.adm .toggle i { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
body.adm .toggle-row input:checked + .toggle { background: var(--accent); box-shadow: none; }
body.adm .opt-card { background: #fff; }
body.adm .opt-card.on { border-color: var(--accent); background: rgba(124, 58, 237, 0.06); box-shadow: none; }
body.adm .check-track { background: rgba(0, 0, 0, 0.08); }
body.adm .ck-dot { background: rgba(0, 0, 0, 0.06); }
body.adm .ck-dot.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
body.adm .ck-item .req { color: #d70015; }
body.adm .chan { background: #fff; }
body.adm .chan .badge:not(.ok):not(.wait) { background: rgba(0, 0, 0, 0.05); color: var(--text-2); }
body.adm .genbtn.alt { background: rgba(0, 0, 0, 0.05); color: var(--text-2); }
body.adm .check-master { background: #fff; }
body.adm .day-row { background: #fff; }
body.adm .kp-row { background: var(--bg-alt); border-color: transparent; }
body.adm .kp-actions .danger { color: #ff3b30; }
body.adm .mark { background: rgba(0, 0, 0, 0.05); }
body.adm .warn-strip { color: #c04d00; }
body.adm .sb-dirty { color: #c04d00; }
body.adm .savebar { background: rgba(255, 255, 255, 0.85); }
body.adm .sheet-ovl { background: rgba(0, 0, 0, 0.35); }
body.adm .tc-msgs { background: var(--bg-alt); }
body.adm .tc-msg.bot { background: #fff; border: 1px solid var(--line); color: var(--text); }
body.adm .state-card { background: var(--bg-alt); }
body.adm .state-card.ok { background: rgba(52, 199, 89, 0.10); }
body.adm .state-card.warn { background: rgba(245, 158, 11, 0.12); color: #c04d00; }
body.adm .state-card.bad { background: rgba(248, 113, 113, 0.10); color: #d70015; }
body.adm .qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
body.adm .qr-wait { background: var(--bg-alt); }
body.adm .qr-progress { background: rgba(0, 0, 0, 0.08); }

/* ===== десктоп (≥900px): админка на всю ширину, кабинет бота — одной страницей ===== */
@media (min-width: 900px) {
  body.adm .wrap { max-width: min(1500px, 96vw); }
  /* все разделы бота сразу: masonry на CSS-колонках, блоки не рвутся */
  body.adm .bot-all { columns: 2; column-gap: 18px; }
  body.adm .bot-all > * { break-inside: avoid; }
  body.adm .bot-all .admin-section { break-inside: avoid; margin-top: 0; margin-bottom: 18px; }
  /* CRM-канбан: на широком экране все 4 колонки видны без горизонтального скролла */
  body.adm .kanban { margin: 0; padding: 0 0 8px; }
  body.adm .kcol { flex: 1 1 0; max-width: none; }
  /* диалоги на странице бота: во всю ширину под колонками настроек */
  body.adm .bot-dlgs-wrap { margin-top: 4px; }
  body.adm .bot-dlgs-wrap .wa-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
  body.adm .bot-dlgs-wrap .wa-list { max-height: 560px; overflow-y: auto; }
  body.adm .bot-dlgs-wrap .wa-pane:empty::after { content: 'Выберите диалог слева'; color: var(--text-3); display: block; padding: 40px 20px; text-align: center; }
}

body.adm .wa-pausebadge { padding: 4px 14px 0; }
body.adm .wa-pausebadge:empty { display: none; }

/* ===== CRM: настраиваемые воронки продаж ===== */
/* шапка канбана: селектор воронки + кнопка настройки (тап-таргеты ≥40px) */
body.adm .crm-pipes { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; }
body.adm .pipe-sel {
  flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 12px;
  font: inherit; font-weight: 650; color: var(--text);
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 12px;
}
body.adm .pipe-cfg { min-height: 40px; white-space: nowrap; }
/* компактный селект «Этап: …» на карточке — быстрый прыжок в любой этап */
body.adm .ksel-wrap { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
body.adm .ksel {
  flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 6px 8px;
  font: inherit; font-size: 13px; color: var(--text);
  background: rgba(0, 0, 0, 0.03); border: 1px solid var(--line); border-radius: 10px;
}
/* модалка «Настройка воронки»: строка этапа */
body.adm .pstages { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 12px; }
body.adm .pstage { display: flex; align-items: center; gap: 6px; padding-top: 8px; }
body.adm .pstage-dot { flex: 0 0 14px; width: 14px; height: 14px; border-radius: 50%; }
body.adm .pstage-color {
  flex: 0 0 auto; width: 86px; min-height: 40px; padding: 6px 4px;
  font: inherit; font-size: 12.5px; color: var(--text-2);
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 10px;
}
body.adm .pstage-title { flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 10px; }
body.adm .pstage-btn { min-width: 40px; min-height: 40px; }
body.adm .pstage-btn:disabled { opacity: 0.35; }
body.adm .pstage-paid { display: flex; align-items: center; gap: 3px; min-height: 40px; padding: 0 2px; cursor: pointer; }
body.adm .pstage-del { color: #d70015; }
body.adm .pstage-sub { font-size: 12px; color: var(--text-3); padding: 3px 0 6px 20px; border-bottom: 1px dashed var(--line); }
body.adm .pstage-mkstart { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 12px; color: var(--accent-2); text-decoration: underline; cursor: pointer; }
body.adm .pipe-danger { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
body.adm .pipe-del { color: #d70015; }
body.adm .pipe-del:disabled { opacity: 0.45; }

/* карточка клиента (модалка CRM) */
body.adm .card-rows { display: grid; gap: 8px; margin: 4px 0 14px; }
body.adm .card-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
body.adm .card-row span { color: var(--text-2); }
body.adm .card-h4 { font-size: 14px; font-weight: 700; margin: 14px 0 8px; }
body.adm .card-note { font-size: 13.5px; color: var(--text-2); padding: 8px 10px; background: var(--bg-alt); border-radius: 10px; margin-bottom: 6px; }
body.adm .card-msgs { max-height: 260px; overflow-y: auto; display: grid; gap: 6px; }
body.adm .card-msg { font-size: 13px; padding: 7px 10px; border-radius: 10px; background: var(--bg-alt); }
body.adm .card-msg.bot, body.adm .card-msg.operator { background: rgba(124,58,237,0.10); }

/* ---------- города учеников: где собирать живую встречу ---------- */
.cities { display: grid; gap: 8px; }
.city-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 40px; align-items: center; gap: 12px; }
.city-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city-bar { height: 10px; border-radius: 6px; background: rgba(124, 58, 237, .12); overflow: hidden; }
.city-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #8b5cf6, #c084fc); }
.city-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- счета Kaspi: сколько выставил бот и что оплатили ---------- */
body.adm .inv-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
body.adm .inv-card { background: var(--bg-alt); border-radius: 12px; padding: 12px 14px; }
body.adm .inv-label { font-size: 12px; color: var(--text-2); }
body.adm .inv-value { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
body.adm .inv-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
body.adm .inv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 10px; }
body.adm .inv-table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
body.adm .inv-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
body.adm .inv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
body.adm .inv-badge { font-weight: 700; font-size: 12.5px; }
body.adm .inv-scroll { overflow-x: auto; }
body.adm .btn.mini.on { background: rgba(124, 58, 237, .12); color: #7c3aed; }

/* ---------- график продаж ---------- */
body.adm .chart-wrap { overflow-x: auto; background: var(--bg-alt); border-radius: 12px; padding: 10px 6px 4px; }
body.adm .chart-wrap svg { width: 100%; height: auto; min-width: 560px; display: block; }
body.adm .chart-wrap .ax { font-size: 10.5px; fill: var(--text-2); }
body.adm .chart-wrap .val { font-size: 11px; font-weight: 700; fill: var(--text); }
body.adm .chart-legend { display: flex; gap: 14px; align-items: center; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
body.adm .chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
