/* Pismoteka — тема панели */
:root {
  --bg: #f4f1ea; --panel: #fffdf9; --panel-2: #f9f6ef; --ink: #16201b; --muted: #6b716c; --line: #e6e0d3;
  --accent: #1f5f4a; --accent-2: #174a3a; --accent-ink: #ffffff; --accent-soft: #e2ede6;
  --amber: #f2b84b; --amber-soft: #fcf0d6; --amber-ink: #7a5410;
  --violet: #6b5bd6; --violet-soft: #ecebfd;
  --warn: #8f5a00; --warn-soft: #fcf0d6; --err: #b0322a; --err-soft: #fbe6e2;
  --ok-soft: #e2ede6; --radius: 14px; --side: 248px;
  --shadow: 0 1px 0 rgba(22, 32, 27, .04), 0 10px 30px -18px rgba(22, 32, 27, .22);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1311; --panel: #171c19; --panel-2: #1c221f; --ink: #ecefe9; --muted: #98a19b; --line: #2a322e;
    --accent: #5fc39a; --accent-2: #7ad3ad; --accent-ink: #0b1410; --accent-soft: #1c3329;
    --amber: #f2b84b; --amber-soft: #3a2f17; --amber-ink: #f6cf7f;
    --violet: #a59bf5; --violet-soft: #262245;
    --warn: #f0b24f; --warn-soft: #36291a; --err: #f28b80; --err-soft: #3b211e; --ok-soft: #1c3329;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 30px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/static/fonts/manrope-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/static/fonts/manrope-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* запасной шрифт под размеры Manrope: пока Manrope грузится, строки переносятся так же — вёрстка не прыгает (CLS) */
@font-face { font-family: "Manrope Fallback"; font-weight: 100 549; size-adjust: 101.6%;
  ascent-override: 105.3%; descent-override: 29.5%; line-gap-override: 0%;
  src: local("Arial"), local("ArialMT"), local("Helvetica"), local("Liberation Sans"), local("Roboto"); }
@font-face { font-family: "Manrope Fallback"; font-weight: 550 649; size-adjust: 97%;
  ascent-override: 110%; descent-override: 31%; line-gap-override: 0%;
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Bold"), local("Liberation Sans Bold"), local("Roboto Bold"); }
@font-face { font-family: "Manrope Fallback"; font-weight: 650 1000; size-adjust: 100.5%;
  ascent-override: 106.5%; descent-override: 29.9%; line-gap-override: 0%;
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Bold"), local("Liberation Sans Bold"), local("Roboto Bold"); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Manrope", "Manrope Fallback", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--amber); color: #16201b; }

/* ---------- каркас: боковое меню ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px 16px; display: flex;
  flex-direction: column; gap: 2px; border-right: 1px solid var(--line); background: var(--panel-2); }
.side .brand { margin: 0 8px 18px; }
.side .group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 16px 12px 6px; }
.side a.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: var(--ink);
  font-weight: 600; font-size: 14.5px; opacity: .82; transition: background .15s, opacity .15s; }
.side a.nav svg { width: 19px; height: 19px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.side a.nav:hover { background: var(--line); opacity: 1; text-decoration: none; }
.side a.nav.on { background: var(--ink); color: var(--panel); opacity: 1; }
.side a.nav.on .badge { background: var(--amber); color: #16201b; }
.side a.nav .badge { margin-left: auto; }
.side .sp { flex: 1; min-height: 16px; }
.side .me { margin: 10px 4px 0; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; display: flex; align-items: center; gap: 10px; }
.side .me .av { width: 32px; height: 32px; border-radius: 50%; background: var(--amber); color: #16201b; display: grid;
  place-items: center; font-weight: 800; flex: 0 0 auto; }
.side .me .em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.side .me a { color: var(--muted); }
.menu-btn { display: none; }

.brand { font-weight: 800; letter-spacing: -.03em; color: var(--ink); display: inline-flex; align-items: center;
  gap: 10px; font-size: 19px; }
.brand:hover { text-decoration: none; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 11.5px; font-weight: 700;
  padding: 1px 7px; margin-left: 6px; line-height: 1.5; }
.spacer { flex: 1; }

main { max-width: 1200px; width: 100%; margin: 0 auto; padding: 30px 32px 70px; }

/* гостевая шапка (вход, регистрация, документы) */
.top.guest { background: transparent; }
.top.guest .in { max-width: 1200px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; }
.top.guest nav a { font-weight: 700; color: var(--ink); }

/* ---------- типографика ---------- */
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 20px; letter-spacing: -.03em; font-weight: 800; }
h2 { font-size: 18px; margin: 0 0 14px; letter-spacing: -.015em; font-weight: 800; }
h3 { font-size: 15px; margin: 16px 0 6px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px; }
.page-head h1 { margin-bottom: 14px; }

/* ---------- карточки и сетки ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  margin-bottom: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + * { margin-top: 18px; }
.stat { font-size: 38px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; margin-top: 6px; }
.g3 > .card { position: relative; overflow: hidden; }

.g3 > .card > * { position: relative; z-index: 1; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom-width: 1px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.tw { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
td.cut { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- формы ---------- */
input, select, textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 11px;
  background: var(--panel); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 50%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 8px; background: var(--panel-2); }
textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.55; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 500; }
label.inline input { width: auto; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > form, .row > .actions { flex: 0 0 auto; min-width: 0; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { flex: 1; min-width: 140px; }
.filters label { margin-top: 0; }

/* ---------- кнопки ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px;
  border-radius: 11px; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); font: inherit;
  font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform .12s, background .15s,
  border-color .15s, box-shadow .15s; }
/* единый стиль: обычная (белая) кнопка при наведении темнеет, главная — зелёная, удаление — красное */
button:hover, .btn:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; transform: none; }
button:disabled:hover { background: var(--panel); border-color: var(--line); color: var(--ink); }
.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent); }
.primary:hover, .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.primary:disabled:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.danger, .btn.danger { color: var(--err); }
.danger:hover, .btn.danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
button.small, .btn.small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.locked:hover { background: var(--panel); color: var(--ink); border-color: var(--ink); }
/* значок «готово» вместо кнопки */
.done-tag { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 11px; font-weight: 700;
  font-size: 14px; color: var(--accent); background: var(--accent-soft); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 600; text-decoration: underline;
  text-underline-offset: 3px; box-shadow: none; }
form.i { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- метки статусов ---------- */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.running, .pill.active, .pill.sent, .pill.reply, .pill.replied { background: var(--ok-soft); color: var(--accent);
  border-color: transparent; }
.pill.paused, .pill.auto, .pill.pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bounced, .pill.error, .pill.negative, .pill.bounce, .pill.stopped { background: var(--err-soft); color: var(--err);
  border-color: transparent; }
.pill.ai { background: var(--violet-soft); color: var(--violet); border-color: transparent; }

/* ---------- сообщения ---------- */
.flash { padding: 12px 16px 12px 40px; border-radius: 12px; margin-bottom: 14px; background: var(--ok-soft);
  position: relative; font-weight: 500; }
.flash::before { content: ""; position: absolute; left: 16px; top: 18px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); }
.flash.err { background: var(--err-soft); color: var(--err); }
.flash.err::before { background: var(--err); }
.note { background: var(--amber-soft); color: var(--ink); padding: 14px 18px; border-radius: 12px; font-size: 14px; }
.note a { font-weight: 700; }

/* ---------- прочее ---------- */
.bar { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden;
  margin-top: 7px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.pre { white-space: pre-wrap; font-size: 14px; background: var(--panel-2); padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); line-height: 1.6; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 5px 12px; border-radius: 99px; color: var(--muted); font-weight: 600; }
.tabs a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--ink); color: var(--panel); }
.login { max-width: 420px; margin: 6vh auto; padding: 30px; }
.login h1 { font-size: 28px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* плитки-итоги (импорт) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tile:hover { text-decoration: none; transform: translateY(-2px); }
.tile b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.tile span { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile.ok b { color: var(--accent); }
.tile.warn b { color: var(--warn); }
.tile.err b { color: var(--err); }
.tile.on { border-color: var(--ink); }
.ai-card { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: linear-gradient(0deg, var(--violet-soft), var(--violet-soft)); border-color: transparent; }
.ai-card h2 { color: var(--violet); }
.commit { position: sticky; bottom: 14px; z-index: 3; border: 1.5px solid var(--ink); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; margin: 6px 0 0;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--panel-2); color: var(--muted); cursor: pointer;
  text-align: center; font-weight: 500; transition: border-color .15s, background .15s; }
.drop b { color: var(--accent); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
table.map td { vertical-align: middle; }

.choice { border-width: 1.5px; }
.choice.on { border-color: var(--accent); }
.choice-h { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.choice-h h2 { margin: 2px 0 4px; }
.choice-h p { margin: 0; }
.choice-ic { flex: 0 0 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 20px; font-weight: 800; }
.mbox { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.mbox-line { padding: 8px 0; border-top: 1px solid var(--line); }
.sender-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.mode-opt { display: flex !important; gap: 10px; align-items: flex-start; margin: 0 !important; padding: 14px;
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink) !important; font-weight: 500 !important; }
.mode-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt input { margin-top: 3px; }
label.choice { display: block; margin: 0; color: var(--ink); font-size: 15px; font-weight: 500; cursor: default; }
.mail-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: var(--panel-2); }
.mail-group-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin-bottom: 8px; }
.big-ic { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-size: 30px; }
/* тарифы */
.usage { margin-bottom: 18px; }
.usage-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.usage-link { display: block; color: var(--ink); }
.usage-link:hover { text-decoration: none; border-color: var(--ink); }
.usage-link.warn { border-color: var(--err); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-bottom: 14px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 4px; margin: 0; }
.plan.featured { border: 2px solid var(--accent); }
.plan.current { background: var(--accent-soft); }
.plan-tag { position: absolute; top: -12px; left: 20px; background: var(--amber); color: #16201b; font-weight: 800;
  font-size: 12px; padding: 3px 10px; border-radius: 99px; }
.plan-name { font-size: 20px; font-weight: 800; }
.plan-price { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 8px 0; }
.plan-price span { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.ticks-sm { list-style: none; padding: 0; margin: 4px 0 16px; flex: 1; font-size: 14px; }
.ticks-sm li { padding: 4px 0 4px 22px; position: relative; }
.ticks-sm li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--ink); color: var(--panel);
  padding: 14px 18px; border-radius: 14px; font-weight: 700; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); max-width: 360px; }
.toast:hover { text-decoration: none; background: var(--accent); color: var(--accent-ink); }
.seed-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line); }

/* кампании: шаги редактора и список */
.step-h { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 6px; }
.step-h > div { flex: 1; }
.step-h h2 { margin: 2px 0 2px; }
.step-h p { margin: 0; }
.step-h .num { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--panel);
  display: grid; place-items: center; font-weight: 800; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.save-bar { position: sticky; bottom: 14px; z-index: 3; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; border: 1.5px solid var(--ink); }
.new-camp { display: flex; gap: 10px; flex: 1; max-width: 560px; }
.new-camp input { flex: 1; }
.camp { display: grid; grid-template-columns: minmax(220px, 1.3fr) minmax(300px, 2fr) auto; gap: 18px; align-items: center; }
.camp-name { font-size: 17px; font-weight: 800; color: var(--ink); margin-right: 8px; }
.camp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.camp-stats b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.camp-stats span { font-size: 12px; color: var(--muted); }
.camp-actions { justify-content: flex-end; }
@media (max-width: 1100px) { .camp { grid-template-columns: 1fr; } .camp-actions { justify-content: flex-start; } }
@media (max-width: 600px) { .camp-stats { grid-template-columns: repeat(2, 1fr); } .new-camp { flex-direction: column; max-width: none; }
  .save-bar { position: static; } }

/* юридические страницы */
.doc { max-width: 780px; margin: 10px auto 40px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 40px 48px; font-size: 15.5px; line-height: 1.7; box-shadow: var(--shadow); }
.doc h1 { font-size: 30px; line-height: 1.2; margin-bottom: 20px; }
.doc h2 { font-size: 18px; margin: 30px 0 10px; }
.doc p, .doc li { margin: 0 0 10px; }
.doc ul { padding-left: 22px; }
.legal-foot { text-align: center; font-size: 13px; color: var(--muted); padding: 0 16px 30px; }
.legal-foot a { color: var(--muted); text-decoration: underline; }
.consent-box { font-size: 13.5px; color: var(--ink); line-height: 1.45; align-items: flex-start !important; }
.consent-box input { margin-top: 3px; flex: 0 0 auto; }

/* поддержка */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { margin: 0; color: var(--ink); font-size: 14px; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg span { display: inline-block; padding: 7px 14px; border: 1.5px solid var(--line); border-radius: 99px; cursor: pointer;
  font-weight: 600; transition: border-color .15s, background .15s; }
.seg span:hover { border-color: var(--ink); }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ticket-row { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line);
  color: var(--ink); }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { text-decoration: none; }
.ticket-row:hover .ticket-subj { color: var(--accent); }
.ticket-subj { font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-right: 7px;
  vertical-align: 1px; box-shadow: 0 0 0 3px var(--amber-soft); }
/* чат поддержки — как мессенджер (префикс cm-, чтобы не пересекаться с .bubble и .msg) */
.cm { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden; height: calc(100vh - 210px); min-height: 420px; max-width: 900px; }
.cm-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cm-head-main { flex: 1; min-width: 0; }
.cm-ava { flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.cm-title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cm-sub .pill { font-size: 11px; padding: 1px 7px; }
.cm-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.cm-day { align-self: center; margin: 10px 0 6px; }
.cm-day span { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  border-radius: 99px; padding: 3px 11px; }
.cm-empty { margin: auto; color: var(--muted); font-size: 14px; }
.cm-msg { display: flex; max-width: 76%; }
.cm-msg.mine { align-self: flex-end; }
.cm-msg.theirs { align-self: flex-start; }
.cm-msg.mine + .cm-msg.theirs, .cm-msg.theirs + .cm-msg.mine { margin-top: 8px; }
.cm-bub { padding: 8px 12px 7px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; font-size: 15px; }
.cm-msg.mine .cm-bub { background: var(--accent); color: var(--accent-ink); border-color: transparent; border-bottom-right-radius: 5px; }
.cm-msg.theirs .cm-bub { border-bottom-left-radius: 5px; }
.cm-time { float: right; font-size: 11px; opacity: .65; margin: 7px 0 -3px 10px; white-space: nowrap; }
.cm-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); margin: 0; }
.cm-form textarea { flex: 1; min-height: 42px; max-height: 180px; resize: none; font-family: inherit; font-size: 15px;
  border-radius: 21px; padding: 10px 16px; line-height: 1.35; margin: 0; }
.cm-send { flex: 0 0 42px; width: 42px; height: 42px; min-width: 0; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center; }
@media (max-width: 600px) { .cm { height: calc(100vh - 170px); border-radius: 14px; } .cm-msg { max-width: 88%; } }
/* облачко чата на витрине (cw-), пузыри — общие cm- */
.cw { position: fixed; right: 22px; bottom: 22px; z-index: 900; font-size: 15px; line-height: 1.45; }
.cw-btn { width: 60px; height: 60px; border-radius: 50%; padding: 0; min-width: 0; border: 0; position: relative;
  background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45); cursor: pointer; transition: transform .15s; }
.cw-btn:hover { transform: scale(1.06); background: var(--accent-2); color: var(--accent-ink); }
.cw-btn .cw-ic-x, .cw.open .cw-btn .cw-ic-chat { display: none; }
.cw.open .cw-btn .cw-ic-x { display: block; }
.cw-badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 99px; background: #e5484d;
  color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px;
  border: 2px solid var(--bg); }
.cw-teaser { position: absolute; right: 0; bottom: 74px; width: max-content; max-width: 240px; background: var(--panel);
  color: var(--ink); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px; padding: 10px 14px; font-size: 14px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .3); cursor: pointer; animation: cw-in .25s ease-out; }
.cw-panel { position: absolute; right: 0; bottom: 76px; width: 370px; height: min(600px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  overflow: hidden; box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .45); animation: cw-in .2s ease-out; }
.cw-panel[hidden], .cw-teaser[hidden], .cw-badge[hidden], .cw-form[hidden], .cw-compose[hidden], .cw-err[hidden] { display: none; }
@keyframes cw-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cw-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--accent); color: var(--accent-ink); }
.cw-head .cm-ava { background: var(--accent-ink); color: var(--accent); }
.cw-head-main { flex: 1; min-width: 0; }
.cw-title { font-weight: 700; font-size: 16px; }
.cw-sub { font-size: 12.5px; opacity: .85; }
.cw-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-right: 6px; vertical-align: 1px; }
.cw-x { border: 0; background: none; color: inherit; padding: 6px; min-width: 0; box-shadow: none; opacity: .85; cursor: pointer; }
.cw-x:hover { opacity: 1; background: rgba(255, 255, 255, .12); color: inherit; }
.cw-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.cw-body .cm-msg { max-width: 85%; }
.cw-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; }
.cw-form input:not([type=checkbox]), .cw-form textarea { width: 100%; margin: 0; font-family: inherit; font-size: 15px; box-sizing: border-box; }
.cw-form textarea { resize: vertical; min-height: 70px; }
.cw-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); line-height: 1.35; font-weight: 400; }
.cw-consent input { margin: 2px 0 0; flex: 0 0 auto; }
.cw-err { color: var(--err); font-size: 13.5px; }
.cw-note { align-self: center; text-align: center; font-size: 12.5px; color: var(--muted); max-width: 90%; margin: 8px 0; }
.cw-compose .cm-send { flex-basis: 40px; width: 40px; height: 40px; }
.cw-compose textarea { min-height: 40px; padding: 9px 14px; }
@media (max-width: 600px) {
  .cw { right: 14px; bottom: 14px; }
  .cw-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; border: 0; }
  .cw.open .cw-btn { display: none; }
}

/* ---------- телефон и планшет ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { margin: 0; }
  .menu-btn { display: inline-flex; margin-left: auto; padding: 8px 12px; }
  .side .group, .side a.nav, .side .me, .side .sp { display: none; }
  .side.open { max-height: 100vh; overflow-y: auto; }
  .side.open .group, .side.open a.nav { display: flex; flex: 1 0 100%; }
  .side.open .group { display: block; }
  .side.open .me { display: flex; flex: 1 0 100%; }
  main { padding: 20px 16px 60px; }
  h1 { font-size: 25px; }
  .card { padding: 18px; }
  .g2 { grid-template-columns: 1fr; }
  .doc { padding: 24px 18px; }
  .commit { position: static; }
}
@media (max-width: 600px) {
  .row > *, .filters > div { flex: 1 1 100% !important; min-width: 0 !important; }
  .row > form button, .actions > * { white-space: normal; }
  .page-head { flex-direction: column; align-items: stretch; }
}

.btn.locked { opacity: .75; }
.pay-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* шапка страниц входа и регистрации — как у сайта */
.top.guest { background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: 0 8px 24px -18px rgba(22, 32, 27, .3); }
.top.guest .in { max-width: 1160px; padding: 14px 24px; gap: 22px; }
.top.guest nav { display: flex; gap: 6px; align-items: center; }
.top.guest nav a { padding: 8px 12px; border-radius: 10px; font-weight: 600; color: var(--ink); }
.top.guest nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.top.guest nav a.btn.primary { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 640px) { .top.guest .site-links { display: none; } }
.req { color: var(--err); font-weight: 700; }

/* пустые строки таблиц не подсвечиваются — в них нечего нажимать */
table tr.empty:hover td { background: none; }
tr.empty td { padding: 18px 12px; }
/* плитки-показатели на главной: одна палитра, иконка, вся плитка — ссылка */
.kpi { display: flex; gap: 14px; align-items: center; color: var(--ink); transition: transform .15s, border-color .15s; }
.kpi:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.kpi .ic { flex: 0 0 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; }
.kpi .ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi .stat { margin-top: 0; font-size: 32px; }
.kpi .muted { margin-bottom: 2px; }
/* контакты: строка поиска сверху, под ней список и сортировка */
.csearch { margin-bottom: 10px; }
.csearch-q { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 6px 6px 6px 14px; background: var(--panel); }
.csearch-q:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.csearch-q svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.csearch-q input { border: 0; box-shadow: none; padding: 8px 0; font-size: 16px; background: transparent; flex: 1; min-width: 0; }
.csearch-q input:focus { outline: none; box-shadow: none; }
.csearch-q button { flex: 0 0 auto; padding: 10px 22px; }
.csearch-opts { margin-top: 10px; }

/* редактор письма */
.ed { border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel); margin-top: 4px; }
.ed:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ed-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); border-radius: 11px 11px 0 0; }
.ed-bar button { padding: 5px 10px; font-size: 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); min-width: 34px; box-shadow: none; }
.ed-bar button:hover { border-color: var(--accent); color: var(--accent); }
.ed-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ed-bar button.ed-ico { padding: 5px 7px; display: inline-flex; align-items: center; justify-content: center; }
.ed-bar button.on { background: var(--accent-soft) !important; border-color: var(--accent); color: var(--accent); }
.ed-bar .ed-ai { margin-left: auto; padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: 14px; white-space: nowrap;
  background: var(--panel); border: 1.5px solid var(--accent); color: var(--accent); text-decoration: none; cursor: pointer; }
.ed-bar button.ed-ai:hover { background: var(--accent) !important; color: #fff; }
.ed-bar a.ed-ai.locked { border-color: var(--line); color: var(--muted); }
.ed-box ul, .ed-box ol { margin: 2px 0; padding-left: 26px; white-space: normal; }
.ed-box li { white-space: pre-wrap; }
.ed-box blockquote { margin: 4px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.ed-box a { color: var(--accent); text-decoration: underline; }
.ed-vars { position: relative; }
.ed-add { color: var(--accent) !important; font-weight: 700; }
.ed-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 210px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.ed-menu[hidden] { display: none; }
.ed-menu button { text-align: left; border: 0 !important; background: none !important; padding: 8px 10px; }
.ed-menu button:hover { background: var(--accent-soft) !important; }
.ed-box { min-height: 200px; padding: 12px 14px; outline: none; line-height: 1.6; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.ed-single .ed-box { min-height: 0; white-space: nowrap; overflow-x: auto; }
.ed-box.empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; position: absolute; }
.chip { display: inline-block; background: var(--amber-soft); color: var(--amber-ink); border-radius: 6px; padding: 0 7px;
  font-weight: 700; font-size: .92em; cursor: pointer; user-select: all; margin: 0 1px; }
.chip i { font-weight: 500; font-style: normal; opacity: .75; }
.chip:hover { outline: 2px solid var(--amber); }
/* файл к письму */
.attach { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.attach label.btn { cursor: pointer; margin: 0; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 14px; }
.att-chip[hidden] { display: none; }
.att-chip button { border: 0; background: none; padding: 0 6px; color: inherit; box-shadow: none; font-size: 13px; }
/* повторные письма — свёрнуты */
.fu-box { margin-top: 18px; border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel-2); }
.fu-box summary { cursor: pointer; font-weight: 700; }
.ed-box { position: relative; }
/* уведомление «облачком» у нажатой кнопки */
.bubble { position: absolute; z-index: 1000; max-width: min(420px, calc(100vw - 24px)); background: var(--ink); color: var(--bg);
  border-radius: 14px; padding: 12px 40px 12px 16px; font-size: 14.5px; line-height: 1.45; font-weight: 600;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45); opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.bubble.in { opacity: 1; transform: none; }
.bubble::before { content: ""; position: absolute; top: -7px; left: calc(var(--arrow, 50%) - 7px); width: 14px; height: 14px;
  background: inherit; transform: rotate(45deg); border-radius: 3px; }
.bubble.fixed { position: fixed; top: 84px; left: 50%; transform: translate(-50%, -6px); }
.bubble.fixed.in { transform: translate(-50%, 0); }
.bubble.fixed::before { display: none; }
.bubble.err { background: var(--err); color: #fff; }
.bubble div + div { margin-top: 6px; }
.bubble-x { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: inherit; opacity: .7; padding: 2px 6px;
  font-size: 13px; box-shadow: none; min-width: 0; }
.bubble-x:hover { opacity: 1; }
/* облачко привязано к кнопке на экране (кнопки бывают «прилипшими» к низу) */
.bubble.pinned { position: fixed; }
.bubble.up::before { top: auto; bottom: -7px; }
.ed-menu button { display: block; width: 100%; text-align: left; }
.note-err { background: var(--err-soft); color: var(--err); border-radius: 12px; padding: 12px 16px; margin: 0 0 14px; font-size: 14px; }

/* лиды */
.lead-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.lead-tabs a { padding: 7px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-weight: 600; font-size: 14px; }
.lead-tabs a b { margin-left: 4px; color: var(--muted); font-weight: 700; }
.lead-tabs a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lead-tabs a.on b { color: inherit; opacity: .8; }
table.leads tr.unread td { background: var(--accent-soft); }
table.leads tr.unread .lead-who b::after { content: " •"; color: var(--accent); }
.lead-who, .lead-snip { color: var(--ink); }
.lead-snip { display: block; max-width: 420px; }
.st-select { width: 100%; padding: 6px 8px; border-radius: 10px; font-weight: 600; font-size: 13.5px; }
.st-new { --st: var(--accent); --st-bg: var(--accent-soft); }
.st-work { --st: #1d4ed8; --st-bg: #dbeafe; }
.st-meeting { --st: #6b5bd6; --st-bg: var(--violet-soft); }
.st-deal { --st: #0f7a3a; --st-bg: #d8f3e2; }
.st-later { --st: var(--warn); --st-bg: var(--warn-soft); }
.st-no { --st: var(--err); --st-bg: var(--err-soft); }
select.st-select, .pill[class*="st-"] { color: var(--st); background: var(--st-bg); border-color: transparent; }
.remind-due { color: var(--err); font-weight: 700; }
.st-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.st-opt { margin: 0; cursor: pointer; }
.st-opt input { position: absolute; opacity: 0; pointer-events: none; }
.st-opt span { display: inline-block; padding: 7px 12px; border-radius: 99px; border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; }
.st-opt input:checked + span { background: var(--st-bg); color: var(--st); border-color: var(--st); }
.st-opt input:focus-visible + span { outline: 2px solid var(--accent); }
table.kv th { text-align: left; color: var(--muted); font-weight: 600; width: 38%; vertical-align: top; text-transform: none;
  letter-spacing: 0; font-size: 14px; }
table.kv td, table.kv th { padding: 7px 8px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { border-radius: 14px; padding: 10px 14px; max-width: 86%; }
.msg.we { background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; }
.msg.they { background: var(--accent-soft); align-self: flex-end; }
.msg-h { font-size: 13px; }
.msg-s { font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.pre.mail-html { white-space: normal; }
.msg .pre { background: transparent; padding: 0; border: 0; margin: 0; }
.lead-grid textarea { font-family: inherit; font-size: 15px; }
#reply textarea { font-family: inherit; font-size: 15px; }

/* служебные кнопки не темнеют при наведении (панель редактора, крестики) */
.ed-bar button:hover { background: var(--panel); }
.att-chip button:hover, .bubble-x:hover { background: none; color: inherit; }
button.link:hover { background: none; color: var(--ink); }
.menu-btn:hover { background: var(--panel); color: var(--ink); }
.list-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 6px 0 10px; }

/* --- админка: карточки пользователя и кампании --- */
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.g4 .stat { font-size: 30px; }
.err-text { color: var(--err); }
.diag { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.diag li { padding: 10px 14px 10px 40px; border-radius: 12px; position: relative; line-height: 1.45; }
.diag li::before { position: absolute; left: 14px; top: 10px; font-weight: 800; }
.diag li.err { background: var(--err-soft); color: var(--err); }
.diag li.err::before { content: "✕"; }
.diag li.warn { background: var(--warn-soft); color: var(--warn); }
.diag li.warn::before { content: "!"; left: 18px; }
.diag li.ok { background: var(--ok-soft); color: var(--accent); }
.diag li.ok::before { content: "✓"; }
.camp-no { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; white-space: nowrap; }
.rights td, .rights th { text-align: center; }
.rights td:first-child, .rights th:first-child { text-align: left; }
.rights .yes { color: var(--accent); font-weight: 800; }
.rights .no { color: var(--muted); }
/* тарифы в кабинете: акция и правка для администратора */
.plan-old { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-weight: 700; }
.plan-old s { text-decoration-thickness: 2px; text-decoration-color: var(--err); }
.plan-old span { font-size: 12px; font-weight: 800; color: #fff; background: var(--err); padding: 1px 8px; border-radius: 99px; }
.plan-price.promo { color: var(--err); margin-top: 0; }
.plan-price.promo span { color: var(--muted); }
.ticks-sm li.off { color: var(--muted); }
.ticks-sm li.off::before { content: "–"; color: var(--muted); }
.plan-edit-link { position: absolute; top: 14px; right: 16px; font-weight: 700; }
.plan-edit .card { margin: 0; }

/* таблица контактов — компактная: строка в одну линию, длинное — с «…» (щелчок по строке раскрывает) */
table.ctable { font-size: 13.5px; }
table.ctable th { white-space: nowrap; }
table.ctable td { padding: 7px 10px; vertical-align: middle; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.ctable tr:not(.empty) td { cursor: default; }
table.ctable tr.open td { white-space: normal; overflow: visible; vertical-align: top; }
table.ctable tr.empty td { white-space: normal; max-width: none; }
table.ctable td:first-child, table.ctable td:last-child { width: 1%; }
table.ctable td:last-child button { padding: 2px 8px; }
/* переключатель страниц */
.pager-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; margin-top: 12px; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager a, .pager span { min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; font-weight: 600; font-size: 14px; border: 1px solid var(--line); color: var(--ink); background: var(--panel); text-decoration: none; }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .gap { border: 0; background: none; min-width: 20px; padding: 0; color: var(--muted); }
.pager .off { opacity: .35; }
.per-form { margin: 0; }
.per-form label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.per-form select { width: auto; padding: 4px 8px; }
.csearch-opts .sort-box { flex: 0 1 240px; }
.csearch-opts .opt-btn { flex: 0 0 auto; min-width: 0; align-self: end; }
.csearch-opts .opt-btn .btn, .csearch-opts .opt-btn button { white-space: nowrap; }
/* подсветка блока, к которому привела кнопка (например, «Загрузить контакты») */
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 var(--accent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.card.pulse { animation: pulse-ring 1s ease-out 2; }
