* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: #f4f5f7; color: #1f2328; }
header { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: #fff; border-bottom: 1px solid #e3e5e8; position: sticky; top: 0; z-index: 1; flex-wrap: wrap; }
.brand { font-weight: 700; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; min-width: 0; }
nav a { padding: 6px 10px; border-radius: 6px; color: #444; text-decoration: none; }
nav a:hover { background: #f0f1f3; }
nav a.active { background: #e7f0ff; color: #0b57d0; font-weight: 600; }
.me { color: #666; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h3 { margin: 0 0 10px; font-size: 15px; }
.card { background: #fff; border: 1px solid #e3e5e8; border-radius: 10px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.nums b { display: block; font-size: 26px; }
.nums span { color: #666; font-size: 12px; }
.ok { color: #1a7f37; } .bad { color: #cf222e; } .muted { color: #6b7280; } .small { font-size: 12px; font-weight: normal; }
td.text { white-space: pre-wrap; word-break: break-word; max-width: 420px; }
.nowrap { white-space: nowrap; }
.reason { font-size: 12px; color: #6b7280; margin-top: 2px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef0f2; }
.badge.created { background: #dafbe1; color: #1a7f37; }
.badge.error { background: #ffebe9; color: #cf222e; }
.badge.excluded, .badge.ignored { background: #fff8c5; color: #7d4e00; }
.badge.autoreply { background: #e7f0ff; color: #0b57d0; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 6px; background: #fff; }
textarea { width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .grow { flex: 1; min-width: 200px; }
.btn { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid #d0d7de; background: #f6f8fa; cursor: pointer; color: inherit; text-decoration: none; display: inline-block; }
.btn:hover { background: #eef0f2; }
.btn.primary { background: #0b57d0; border-color: #0b57d0; color: #fff; }
.btn.danger { color: #cf222e; }
.btn.link { border: none; background: none; color: #0b57d0; padding: 0 4px; }
form.inline { display: inline; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: #dafbe1; } .flash.err { background: #ffebe9; }
.login { max-width: 360px; margin: 80px auto; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[name=q] { flex: 1; min-width: 220px; }
.pager { display: flex; gap: 8px; justify-content: center; }
code { background: #f6f8fa; padding: 1px 5px; border-radius: 4px; }
table.compact td { padding: 3px 6px 3px 0; border: none; }
td.team select, td.team input { display: block; margin-bottom: 4px; max-width: 260px; }
.defaults .grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.defaults select, .defaults input { width: 100%; }
table.chats col.c-name { width: 24%; } table.chats col.c-on { width: 135px; } table.chats col.c-sel { width: 21%; }
table.chats col.c-note { width: 13%; } table.chats col.c-act { width: 165px; }
table.chats td { vertical-align: middle; overflow-wrap: anywhere; }
table.chats select, table.chats input[name=note], table.chats input[name=responsible_id], table.chats input[name=b24_group_id] { width: 100%; }
.btn.icon { padding: 4px 9px; font-size: 16px; line-height: 1; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
tr.head th, table > tr:first-child th { background: #f8f9fb; font-size: 12px; color: #57606a; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid #e3e5e8; white-space: nowrap; }
tr.head th:first-child { border-top-left-radius: 8px; } tr.head th:last-child { border-top-right-radius: 8px; }
table.data tr:not(.head):hover td { background: #f8fafd; }
table.data tr:last-child td { border-bottom: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { color: #8b949e; background: #fafafa; }
tr.off td select, tr.off td input { opacity: .75; }
.card > table { margin: -4px 0; }
.card:has(> table.data) { padding: 8px 12px; }
td .small.muted { margin-top: 2px; }
table.data td select, table.data td input:not([type=checkbox]) { max-width: 100%; }

/* таблица групп */
table.chats { table-layout: fixed; min-width: 960px; }
table.chats td.actions-cell { white-space: nowrap; }
table.chats .actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
table.chats .actions .btn { padding: 5px 10px; }
select.status { font-weight: 600; }
tr:not(.off) select.status { color: #1a7f37; border-color: #b7e4c4; background: #f3fbf5; }
tr.off select.status { color: #6b7280; }

/* журнал */
table.log td.text { color: #1f2328; }
table.log td:first-child { white-space: nowrap; color: #57606a; font-variant-numeric: tabular-nums; }

a { color: #0b57d0; }
table.chats .actions { flex-wrap: nowrap; }
.mobile-only { display: none; }
main > .row { margin-bottom: 12px; }

/* ---------- узкие экраны: строки таблиц становятся карточками ---------- */
@media (max-width: 760px) {
  header { gap: 8px; padding: 8px 12px; }
  nav { flex-wrap: nowrap; overflow-x: auto; order: 3; flex-basis: 100%; -webkit-overflow-scrolling: touch; }
  nav a { white-space: nowrap; }
  main { padding: 12px 10px 40px; }
  .card { padding: 12px; }
  .nums { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: 1fr; }
  table.data, table.data tbody { display: block; min-width: 0 !important; table-layout: auto; }
  table.data colgroup, table.data tr.head { display: none; }
  table.data tr { display: block; border: 1px solid #e3e5e8; border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; background: #fff; }
  table.data tr.off { background: #fafafa; }
  table.data td { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 7px 0;
    border-bottom: 1px dashed #eef0f2; text-align: right; max-width: none; }
  table.data td:last-child { border-bottom: none; }
  table.data td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 12px; color: #57606a; font-weight: 600; }
  table.data td:not([data-label])::before, table.data td[data-label=""]::before { display: none; }
  table.data td > * { max-width: 62%; }
  table.data td select, table.data td input:not([type=checkbox]) { width: 100%; }
  table.data td:first-child { display: block; text-align: left; border-bottom: 1px solid #eef0f2; padding-bottom: 8px; }
  table.data td:first-child::before { display: none; }
  table.data td:first-child > * { max-width: none; }
  table.data td.text { display: block; text-align: left; }
  table.data td.text::before { display: block; margin-bottom: 4px; }
  table.chats .actions { justify-content: flex-end; }
  .mobile-only { display: flex; margin-bottom: 10px; }
  .filters > * { flex: 1 1 100%; }
  .defaults .grid4 { grid-template-columns: 1fr; }
}

/* длинные тексты в таблицах */
table.data td { vertical-align: top; }
table.chats td, table.data td.num { vertical-align: middle; }
table.data td.text { min-width: 260px; }
table.data td.text .clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
table.data td.text .clamp:hover { -webkit-line-clamp: unset; }
table.data code { word-break: break-all; white-space: normal; }
@media (max-width: 760px) { table.data td.text { min-width: 0; } }
table.rules { table-layout: fixed; min-width: 820px; }
table.rules td { overflow-wrap: anywhere; }
table.data .actions { display: flex; gap: 4px; align-items: center; }
code.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
tr.off .badge { background: #eef0f2; color: #6b7280; }
a.btn.icon { text-decoration: none; color: inherit; }
@media (max-width: 760px) { table.rules { min-width: 0 !important; } table.data .actions { justify-content: flex-end; } }

/* ---------- мягкая тема ---------- */
body { background: #f6f7fb; color: #2a2f3a; }
header { border-bottom: none; box-shadow: 0 1px 0 rgba(20,30,60,.05), 0 4px 16px rgba(20,30,60,.04); }
nav a { border-radius: 10px; color: #5b6272; }
nav a.active { background: #eef3ff; color: #3561d4; }
.card { border: none; border-radius: 16px; box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 6px 24px rgba(20,30,60,.05); padding: 18px 20px; }
.card:has(> table.data) { padding: 10px 14px; }
input, select, textarea { border: 1px solid #e3e7ef; border-radius: 10px; background: #fbfcfe; padding: 7px 10px; transition: border-color .15s, box-shadow .15s, background .15s; }
input:hover, select:hover, textarea:hover { border-color: #d3d9e4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #a9bff5; background: #fff; box-shadow: 0 0 0 3px rgba(80,120,230,.12); }
.btn { border: 1px solid #e3e7ef; border-radius: 10px; background: #fff; color: #3a4150; transition: background .15s, color .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: #f3f5fa; border-color: #d8dde7; }
.btn.primary { background: #4f74e3; border-color: #4f74e3; box-shadow: 0 2px 8px rgba(79,116,227,.25); }
.btn.primary:hover { background: #4368d8; border-color: #4368d8; }
.btn.link { border: none; background: none; box-shadow: none; color: #4f74e3; }
.btn.danger { color: #d0505a; }

/* иконки */
.ico { display: block; }
.btn.icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  border-radius: 10px; border-color: transparent; background: #f2f4f9; color: #6b7385; }
.btn.icon:hover { background: #e8ecf6; color: #3a4150; border-color: transparent; }
.btn.icon.on { background: #eaf7ef; color: #2f9e5b; }
.btn.icon.on:hover { background: #dcf2e5; }
.btn.icon.danger { background: #fdf1f2; color: #d0505a; }
.btn.icon.danger:hover { background: #fbe2e4; }
.btn.icon.save { background: #eef3ff; color: #4f74e3; }
.btn.icon.save:hover { background: #4f74e3; color: #fff; }
table.chats .actions .btn.icon { padding: 0; }
th .btn.icon { width: 30px; height: 30px; background: #fff; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
.actions { gap: 6px !important; }

/* таблицы */
th, td { border-bottom: 1px solid #f0f2f6; padding: 12px 14px; }
tr.head th, table > tr:first-child th { background: transparent; color: #8a91a1; font-size: 11.5px; letter-spacing: .05em;
  border-bottom: 1px solid #eceff4; }
table.data tr:not(.head):hover td { background: #f8f9fd; }
table.data tr:not(.head) td:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
table.data tr:not(.head) td:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
tr.off td { color: #9aa1af; background: transparent; }
tr.off td b { color: #8a91a1; }
code { background: #f3f5fa; border-radius: 6px; color: #4a5263; }

/* бейджи и статусы */
.badge { padding: 3px 10px; border-radius: 999px; font-weight: 500; background: #f1f3f7; color: #6b7385; }
.badge.created { background: #eaf7ef; color: #2f8a52; }
.badge.error { background: #fdf0f1; color: #c4434d; }
.badge.excluded, .badge.ignored { background: #fff6e5; color: #a1660a; }
.badge.autoreply { background: #eef3ff; color: #3d63d1; }
tr:not(.off) select.status { color: #2f8a52; border-color: #cfeedb; background: #f2fbf5; }
tr.off select.status { color: #8a91a1; background: #f6f7fa; }
.flash { border-radius: 12px; }
.flash.ok { background: #eaf7ef; color: #23643c; } .flash.err { background: #fdf0f1; color: #9b2c35; }
.ok { color: #2f9e5b; } .bad { color: #d0505a; }

@media (max-width: 760px) {
  table.data tr { border: none; border-radius: 14px; box-shadow: 0 1px 2px rgba(20,30,60,.05), 0 4px 14px rgba(20,30,60,.05); padding: 8px 14px; }
  table.data td { border-bottom: 1px solid #f2f4f8; }
  table.data tr:not(.head) td:first-child, table.data tr:not(.head) td:last-child { border-radius: 0; }
  table.data tr:not(.head):hover td { background: transparent; }
  .card:has(> table.data) { background: transparent; box-shadow: none; padding: 0; }
}
.btn.icon { flex: 0 0 auto; }
table.chats col.c-on { width: 150px; } table.chats col.c-act { width: 120px; }
select.status { padding-right: 4px; }
@media (max-width: 760px) { table.data td.actions-cell .actions, table.data td:last-child .actions { margin-left: auto; } }
.badge { white-space: nowrap; }

/* мягкие выпадающие списки */
select { -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer;
  padding: 7px 34px 7px 12px; border-radius: 12px; background-color: #f7f8fc; border: 1px solid #e6e9f1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 14px;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden; color: #3a4150; }
select:hover { background-color: #f1f3f9; border-color: #dde2ec; }
select:focus { background-color: #fff; border-color: #a9bff5; box-shadow: 0 0 0 3px rgba(80,120,230,.12); }
select option { color: #2a2f3a; background: #fff; }
select.status { padding-right: 30px; background-position: right 9px center; border-radius: 999px; }
tr:not(.off) select.status { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f8a52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
select::-ms-expand { display: none; }
tr select.status { background-repeat: no-repeat !important; background-position: right 9px center !important; background-size: 14px !important; }
tr.off select.status { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
table.chats col.c-on { width: 160px; }

/* ---------- свой выпадающий список ---------- */
select.sel-hidden { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; padding: 0 !important; border: 0 !important; margin: 0 !important; }
.sel { font: inherit; text-align: left; display: inline-flex; align-items: center; min-width: 0; max-width: 100%; cursor: pointer;
  padding: 7px 34px 7px 12px; border-radius: 12px; background-color: #f7f8fc; border: 1px solid #e6e9f1; color: #3a4150;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 14px;
  transition: background-color .15s, border-color .15s, box-shadow .15s; }
.sel-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sel:hover { background-color: #f1f3f9; border-color: #dde2ec; }
.sel:focus-visible, .sel.open { outline: none; background-color: #fff; border-color: #a9bff5; box-shadow: 0 0 0 3px rgba(80,120,230,.12); }
.sel:disabled { opacity: .6; cursor: default; }
td .sel, .defaults .sel, label .sel, .stack .sel { width: 100%; }
.sel.status { border-radius: 999px; font-weight: 600; padding-right: 30px; background-position: right 9px center; }
tr:not(.off) .sel.status { color: #2f8a52; border-color: #cfeedb; background-color: #f2fbf5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f8a52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
tr.off .sel.status { color: #8a91a1; background-color: #f6f7fa; }
tr.off .sel { opacity: .8; }
.sel-pop { position: fixed; z-index: 50; background: #fff; border-radius: 14px; padding: 6px; display: flex; flex-direction: column;
  box-shadow: 0 10px 30px rgba(20,30,60,.12), 0 2px 6px rgba(20,30,60,.06); border: 1px solid #eef0f5; animation: selIn .12s ease-out; }
@keyframes selIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sel-search { margin: 2px 2px 6px; padding: 8px 12px; border-radius: 10px; background: #f5f6fa; border: 1px solid transparent; width: auto; }
.sel-search:focus { background: #fff; }
.sel-list { overflow-y: auto; min-height: 0; flex: 1; }
.sel-list::-webkit-scrollbar { width: 8px; } .sel-list::-webkit-scrollbar-thumb { background: #e3e6ee; border-radius: 8px; border: 2px solid #fff; }
.sel-opt { padding: 8px 12px; border-radius: 9px; cursor: pointer; color: #3a4150; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-opt.active { background: #f2f5fc; }
.sel-opt.selected { background: #eef3ff; color: #3561d4; font-weight: 600; }
.sel-opt.selected::after { content: "✓"; float: right; margin-left: 8px; color: #4f74e3; }
.sel-opt.disabled { color: #b4b9c5; cursor: default; }
.sel-empty { padding: 10px 12px; color: #9aa1af; font-size: 13px; }
@media (max-width: 760px) { table.data td > .sel { max-width: 62%; width: 100%; } }
.sel-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; white-space: normal; line-height: 1.35; }
.sel-opt.selected::after { float: none; margin: 0; flex: 0 0 auto; }

/* ---------- мультиселект получателей ---------- */
.ms { position: relative; }
.ms-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 52px; padding: 7px; cursor: text;
  border: 1px solid #e6e9f1; border-radius: 14px; background: #f7f8fc; transition: border-color .15s, box-shadow .15s, background .15s; }
.ms-box:hover { border-color: #d5dbea; }
.ms.open .ms-box { background: #fff; border-color: #a9bff5; box-shadow: 0 0 0 4px rgba(80,120,230,.12); }
.ms-chips { display: contents; }
.ms-chip { display: inline-flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: 999px; max-width: 100%;
  background: #fff; border: 1px solid #e4e8f2; box-shadow: 0 1px 2px rgba(20,30,60,.05); color: #2a2f3a; font-size: 13px; line-height: 1.2; }
.ms-chip.unknown { background: #fffaf0; border-color: #f3dfb7; }
.ms-av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.ms-txt { display: flex; flex-direction: column; min-width: 0; }
.ms-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-user { font-size: 12px; color: #7a8294; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-chip.unknown .ms-user { color: #b0761b; }
button.ms-x { all: unset; flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; margin-left: 2px;
  color: #8a92a3; cursor: pointer; transition: background .15s, color .15s; }
button.ms-x:hover { background: #fdecef; color: #d9485f; }
button.ms-x:focus-visible { outline: 2px solid #a9bff5; }
.ms-input { flex: 1; min-width: 200px; height: 36px; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 8px !important; font-size: 14px; }
.ms-input::placeholder { color: #8a92a3; }
.ms-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 300px; overflow-y: auto; background: #fff;
  border-radius: 14px; padding: 6px; border: 1px solid #eef0f5; box-shadow: 0 14px 36px rgba(20,30,60,.14), 0 2px 6px rgba(20,30,60,.06); }
.ms-opt { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 7px; border-radius: 10px; cursor: pointer; }
.ms-opt .ms-txt { flex: 1; }
.ms-opt:hover, .ms-opt.active { background: #f2f5fd; }
.ms-plus { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; color: #4f74e3; background: #eef3ff; opacity: 0; transition: opacity .15s; }
.ms-opt:hover .ms-plus, .ms-opt.active .ms-plus { opacity: 1; }
.ms-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f5f7fc; color: #6a7285; font-size: 13px; line-height: 1.45; }
.ms-note svg { flex: none; margin-top: 1px; color: #4f74e3; }
.ms-note a { color: #3561d4; }

/* =====================================================================
   Стиль Apple (macOS): боковое меню, системный шрифт, мягкие карточки
   ===================================================================== */
:root {
  --blue: #0071e3; --blue-h: #0077ed; --ink: #1d1d1f; --ink2: #424245; --muted: #86868b;
  --bg: #f5f5f7; --card: #fff; --fill: rgba(118,118,128,.12); --fill2: rgba(118,118,128,.08);
  --sep: rgba(60,60,67,.12); --green: #34c759; --red: #ff3b30; --orange: #ff9500;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI Variable", "Segoe UI", Roboto, Arial, sans-serif;
  --side: 248px;
}
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.47 var(--font); letter-spacing: -.012em; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
::selection { background: rgba(0,113,227,.2); }

/* ---- боковое меню ---- */
header.side { position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 20; display: flex; flex-direction: column; align-items: stretch; gap: 0;
  padding: 18px 12px 14px; background: rgba(246,246,248,.82); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--sep); box-shadow: none; flex-wrap: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; letter-spacing: -.02em; }
.brand-mark { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #5ac8fa, #0071e3); box-shadow: 0 2px 6px rgba(0,113,227,.3); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand small { font-size: 11.5px; font-weight: 400; color: var(--muted); }
header.side nav { flex-direction: column; flex-wrap: nowrap; gap: 1px; flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--muted); padding: 14px 10px 5px; letter-spacing: .01em; }
.nav-group:first-child { padding-top: 2px; }
header.side nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 7px; border-radius: 8px; color: var(--ink); font-size: 13.5px; text-decoration: none; transition: background .12s; }
header.side nav a i { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.08); }
header.side nav a i svg { width: 14px; height: 14px; }
header.side nav a:hover { background: rgba(0,0,0,.05); }
header.side nav a.active { background: var(--blue); color: #fff; font-weight: 500; }
header.side nav a.active i { box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); }
header.side .me { display: flex; align-items: center; gap: 9px; padding: 12px 8px 0; margin-top: 8px; border-top: 1px solid var(--sep); color: var(--ink); font-size: 13px; }
.me-av { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #a2a2a7, #6e6e73); color: #fff; font-weight: 600; font-size: 12px; }
.me-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
header.side .me .btn.link { font-size: 13px; color: var(--blue); padding: 4px 6px; border-radius: 6px; }
header.side .me .btn.link:hover { background: var(--fill2); }

body.has-side main { margin-left: var(--side); max-width: none; padding: 34px 40px 80px; }
body.has-side main > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
body.has-side main > .card, body.has-side main > form, body.has-side main > .tiles { max-width: 1120px; }

/* ---- заголовки и текст ---- */
h1 { font-size: 30px; line-height: 1.12; font-weight: 700; letter-spacing: -.028em; margin: 0 auto 10px; }
main > h1 + p, main > p { color: var(--ink2); font-size: 14.5px; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 14px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.ok { color: #248a3d; } .bad { color: #d70015; }
code { font: 12.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--fill2); color: var(--ink2); padding: 1px 6px; border-radius: 6px; }
details summary { cursor: pointer; color: var(--blue); font-size: 13px; margin-top: 8px; }

/* ---- карточки ---- */
.card { background: var(--card); border: 0; border-radius: 18px; padding: 22px 24px; margin-bottom: 18px;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.04), 0 2px 10px rgba(0,0,0,.035); }
.card:has(> table.data) { padding: 6px 10px; }
.tiles { gap: 18px; }
.nums { gap: 12px; }
.nums b { font-size: 34px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.nums span { color: var(--muted); font-size: 12.5px; }

/* ---- поля ввода ---- */
input, select, textarea, .sel { font: inherit; font-size: 14px; color: var(--ink); border: 1px solid transparent; border-radius: 10px;
  background-color: var(--fill2); padding: 8px 12px; transition: background-color .15s, border-color .15s, box-shadow .15s; }
input:hover, textarea:hover, select:hover, .sel:hover { background-color: var(--fill); border-color: transparent; }
input:focus, select:focus, textarea:focus, .sel:focus-visible, .sel.open { outline: none; background-color: #fff; border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0,113,227,.16); }
input::placeholder, textarea::placeholder { color: #a1a1a6; }
textarea { line-height: 1.45; min-height: 90px; }
label { font-size: 13px; color: var(--ink2); font-weight: 500; gap: 6px; }
label > input, label > textarea, label > select, label > .sel { font-weight: 400; }
.stack { gap: 16px; }
.sel { padding-right: 34px; }

/* переключатели вместо галочек */
input[type=checkbox] { -webkit-appearance: none; appearance: none; flex: none; width: 40px; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 999px;
  background: rgba(120,120,128,.22); position: relative; cursor: pointer; transition: background .2s; box-shadow: none; }
input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.08); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
input[type=checkbox]:checked { background: var(--green); }
input[type=checkbox]:checked::after { transform: translateX(16px); }
input[type=checkbox]:hover { background-color: rgba(120,120,128,.3); }
input[type=checkbox]:checked:hover { background-color: #30b350; }
input[type=checkbox]:focus-visible { box-shadow: 0 0 0 4px rgba(0,113,227,.2); }
label.check { gap: 12px; font-weight: 400; color: var(--ink); font-size: 14px; cursor: pointer; }

/* ---- кнопки ---- */
.btn { font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; border-radius: 980px; border: 0; background: var(--fill2); color: var(--blue);
  box-shadow: none; cursor: pointer; transition: background .15s, transform .1s, filter .15s; }
.btn:hover { background: var(--fill); border: 0; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; border: 0; box-shadow: none; }
.btn.primary:hover { background: var(--blue-h); }
.btn.danger { color: #d70015; }
.btn.link { background: none; padding: 0 4px; color: var(--blue); border-radius: 6px; }
.btn.link:hover { background: none; text-decoration: underline; }
.btn.icon { width: 32px; height: 32px; border-radius: 50%; background: var(--fill2); color: #6e6e73; }
.btn.icon:hover { background: var(--fill); color: var(--ink); }
.btn.icon.on { background: rgba(52,199,89,.14); color: #248a3d; }
.btn.icon.danger { background: rgba(255,59,48,.1); color: #d70015; }
.btn.icon.danger:hover { background: rgba(255,59,48,.18); }
.btn.icon.save { background: rgba(0,113,227,.1); color: var(--blue); }
.btn.icon.save:hover { background: var(--blue); color: #fff; }
.row { gap: 10px; }

/* ---- таблицы ---- */
th, td { padding: 12px 14px; border-bottom: 1px solid var(--sep); }
tr.head th, table > tr:first-child th { background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0;
  border-bottom: 1px solid var(--sep); }
table.data tr:not(.head):hover td { background: rgba(0,0,0,.02); }
tr.off td { color: #a1a1a6; }
.card:has(> table.data) { overflow-x: auto; }
table.chats, table.rules { min-width: 0; }
@media (min-width: 761px) { table.chats { min-width: 900px; } table.rules { min-width: 760px; } }
td[colspan] { color: var(--muted); padding: 22px 14px; }

/* ---- бейджи и уведомления ---- */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--fill2); color: var(--ink2); }
.badge.created { background: rgba(52,199,89,.14); color: #248a3d; }
.badge.error { background: rgba(255,59,48,.1); color: #d70015; }
.badge.excluded, .badge.ignored { background: rgba(255,149,0,.14); color: #c93400; }
.badge.autoreply { background: rgba(0,113,227,.1); color: var(--blue); }
.flash { border-radius: 14px; padding: 12px 16px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.flash.ok { background: rgba(52,199,89,.12); color: #1d6b31; }
.flash.err { background: rgba(255,59,48,.1); color: #b0000f; }
.flash.ok::before { content: "✓"; font-weight: 700; }
.flash.err::before { content: "!"; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; background: #d70015; color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }

/* статус-список в таблице групп */
tr:not(.off) .sel.status, tr:not(.off) select.status { color: #248a3d; background-color: rgba(52,199,89,.12); border-color: transparent; }
tr.off .sel.status, tr.off select.status { color: var(--muted); background-color: var(--fill2); }

/* выпадающие списки и мультиселект в тон */
.sel-pop, .ms-pop { border-radius: 12px; border: .5px solid rgba(0,0,0,.08); box-shadow: 0 12px 40px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.06);
  background: rgba(255,255,255,.96); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.sel-opt { border-radius: 7px; }
.sel-opt.active, .ms-opt.active, .ms-opt:hover { background: var(--blue); color: #fff; }
.ms-opt.active .ms-user, .ms-opt:hover .ms-user { color: rgba(255,255,255,.8); }
.sel-opt.selected { background: transparent; color: var(--blue); }
.sel-opt.selected.active { background: var(--blue); color: #fff; }
.sel-opt.selected::after { color: inherit; }
.ms-box { background: var(--fill2); border-color: transparent; border-radius: 12px; }
.ms-box:hover { background: var(--fill); border-color: transparent; }
.ms.open .ms-box { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.16); }
.ms-plus { background: rgba(255,255,255,.25); color: #fff; }
.ms-note { background: var(--fill2); color: var(--ink2); }
.ms-note svg, .ms-note a { color: var(--blue); }

/* ---- вход ---- */
body.no-side main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(380px, 100%); margin: 0; padding: 36px 32px 30px; text-align: center; border-radius: 22px; box-shadow: 0 0 0 .5px rgba(0,0,0,.05), 0 20px 60px rgba(0,0,0,.08); }
.login-mark { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 15px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #5ac8fa, #0071e3); box-shadow: 0 6px 16px rgba(0,113,227,.3); }
.login h1 { font-size: 24px; margin-bottom: 2px; }
.login-sub { margin: 0 0 22px; font-size: 13px; }
.login form { gap: 14px; text-align: left; }
.login .btn { padding: 11px; font-size: 15px; margin-top: 6px; }

/* ---- телефон и планшет: меню сверху, прокручивается ---- */
@media (max-width: 980px) {
  header.side { position: sticky; inset: auto; top: 0; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    padding: 10px 14px 8px; border-right: 0; border-bottom: 1px solid var(--sep); background: rgba(246,246,248,.86); }
  .brand { padding: 0; flex: 1; }
  .brand small { display: none; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  header.side .me { border: 0; margin: 0; padding: 0; }
  header.side .me .me-name { display: none; }
  header.side nav { order: 3; flex: 1 0 100%; flex-direction: row; overflow-x: auto; gap: 4px; margin: 6px -14px 0; padding: 0 14px 2px; scrollbar-width: none; }
  header.side nav::-webkit-scrollbar { display: none; }
  .nav-group { display: none; }
  header.side nav a { flex: none; padding: 5px 12px 5px 5px; border-radius: 999px; font-size: 13px; background: var(--fill2); }
  header.side nav a i { width: 20px; height: 20px; border-radius: 50%; }
  header.side nav a i svg { width: 12px; height: 12px; }
  body.has-side main { margin-left: 0; padding: 22px 16px 60px; }
  h1 { font-size: 26px; }
}
@media (max-width: 760px) {
  .card { padding: 18px 16px; border-radius: 16px; }
  .nums b { font-size: 28px; }
  table.data tr { border-radius: 14px; box-shadow: 0 0 0 .5px rgba(0,0,0,.04), 0 2px 10px rgba(0,0,0,.04); }
  table.data td::before { color: var(--muted); font-weight: 500; }
  .card:has(> table.data) { background: transparent; box-shadow: none; padding: 0; overflow: visible; }
}
/* раздел «Сайт и шаблоны»: админка ReplyHelper во фрейме на всю правую часть */
body.rh-page main { padding: 0 !important; height: 100vh; }
body.rh-page main > * { max-width: none !important; }
body.rh-page main > .flash { display: none; }
.rh-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
@media (max-width: 980px) {
  body.rh-page { display: flex; flex-direction: column; height: 100dvh; }
  body.rh-page main { flex: 1; min-height: 0; height: auto; width: 100%; margin: 0 !important; }
}
/* ---- выравнивание: одна линия для таблиц, подсказок и форм ---- */
@media (min-width: 761px) {
  .card:has(> table.data) { padding: 4px 0 2px; }
  .card:has(> table.data) th:first-child, .card:has(> table.data) td:first-child { padding-left: 24px; }
  .card:has(> table.data) th:last-child, .card:has(> table.data) td:last-child { padding-right: 24px; }
  .card:has(> table.data) td[colspan] { padding: 26px 24px; text-align: left; }
  .card:has(> table.data) > :not(table) { margin-left: 24px; margin-right: 24px; }
  .card:has(> table.data) > p, .card:has(> table.data) > .small { margin-top: 12px; margin-bottom: 14px; }
  .card:has(> table.data) > h3 { margin-top: 18px; }
  table.data tr:last-child td { border-bottom: 0; }
  table.data th, table.data td { vertical-align: middle; }
  table.data th:last-child:has(.btn), table.data td:last-child:has(.btn) { text-align: right; white-space: nowrap; }
}
table.data { width: 100%; border-collapse: collapse; }
/* строка «заголовок + кнопка» над карточками */
main > .row { justify-content: space-between; align-items: center; margin-bottom: 16px; min-height: 36px; }
main > .row > .muted, main > .row > p { margin: 0; }
/* формы в строку: поля одинаковой ширины, кнопка в конце */
.card form.row, form.card.row { align-items: center; gap: 10px; }
.card form.row > input:not([type=checkbox]), .card form.row > .sel, .card form.row > select:not(.sel-hidden), .card form.row > textarea { flex: 1 1 170px; min-width: 0; width: auto; }
.card form.row > .btn { flex: none; margin-left: auto; }
.card form.row > label.check { flex: none; }
/* сетки полей: подписи и поля на одной высоте */
.grid2, .grid3, .grid4 { align-items: end; }
.grid2 > label, .grid3 > label, .grid4 > label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.grid2 > label > *, .grid3 > label > *, .grid4 > label > * { width: 100%; }
input:not([type=checkbox]), .sel, select:not(.sel-hidden) { min-height: 38px; box-sizing: border-box; }
.btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box; }
.btn.link { min-height: 0; }
.btn.icon { padding: 0; min-height: 0; flex: none; }
h1 + .row, h1 + p { margin-top: 0; }
.card:has(> table.data) { overflow-y: hidden; }
.card:has(> table.data) > :last-child { margin-bottom: 0; }
.card:has(> table.data) > p:last-child { margin-bottom: 16px; }
/* статистика: равные колонки цифр и ровные подписи */
.nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.nums > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nums span { line-height: 1.3; }
table.even { table-layout: fixed; width: 100%; }
table.even th:first-child, table.even td:first-child { width: 30%; }
@media (max-width: 760px) { .nums { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; } table.even { table-layout: auto; } }
/* уведомления: статусы ровной сеткой, пункты списком */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 18px; }
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-list > .small { margin-bottom: 0 !important; }
.nums { grid-template-columns: repeat(4, auto); justify-content: space-between; column-gap: 16px; }
@media (max-width: 760px) { .nums { grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; } }
label > .row > input:not([type=checkbox]), label > .row > .sel, label > .row > select:not(.sel-hidden) { flex: 1 1 200px; min-width: 0; }
.tiles { margin-bottom: 18px; }
.tiles > .card { margin-bottom: 0; }
@media (max-width: 760px) {
  table.even th:first-child, table.even td:first-child { width: auto; }
  .tiles { gap: 14px; margin-bottom: 14px; }
}
/* языки: переключатель в меню, выбор языка группы, блок перевода */
.langs { display: flex; gap: 2px; padding: 3px; margin: 10px 4px 0; background: var(--fill2); border-radius: 9px; }
.langs a { flex: 1; text-align: center; padding: 4px 0; border-radius: 7px; font-size: 12.5px; color: var(--ink2); text-decoration: none; }
.langs a:hover { background: rgba(0,0,0,.05); }
.langs a.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
select.lang-sel { min-width: 0; }
col.c-lang { width: 150px; }
details.tr-box { border: 1px dashed var(--sep); border-radius: 12px; padding: 10px 14px; background: var(--fill2); }
details.tr-box[open] { border-style: solid; background: transparent; }
details.tr-box > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.tr-box > summary::-webkit-details-marker { display: none; }
.tr-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-weight: 500; font-size: 13.5px; }
.tr-btn::before { content: "文A"; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: rgba(0,113,227,.1); }
details.tr-box > label, details.tr-box > .tr-preview, details.tr-box > .small { display: block; margin-top: 10px; }
.tr-preview { display: block; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--fill2); white-space: pre-wrap; }
.tr-preview[hidden] { display: none; }

@media (max-width: 760px) { .langs { margin: 0; } }
