:root {
  --bg: #F6F5F2;
  --panel: #FFFFFF;
  --sidebar: #FBFAF8;
  --ink: #17171A;
  --ink-2: #4A4A52;
  --muted: #8A8A93;
  --line: #E7E5E0;
  --line-2: #D9D6CF;
  --accent: #17171A;
  --hover: #F0EEE9;
  --danger: #D92D20;
  --danger-bg: #FEF3F2;
  --warn: #B54708;
  --warn-bg: #FFFAEB;
  --ok: #067647;
  --ok-bg: #ECFDF3;
  --info-bg: #EFF4FF;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 16, 20, .05), 0 1px 1px rgba(16, 16, 20, .03);
  --shadow-lg: 0 24px 64px rgba(16, 16, 20, .18), 0 2px 8px rgba(16, 16, 20, .08);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 12px; display: flex;
  flex-direction: column; gap: 2px; overflow-y: auto; }
.main { overflow-y: auto; padding: 22px 28px 40px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  padding: 4px 10px 14px; color: var(--ink); }
.brand-mark { display: grid; gap: 2px; width: 22px; }
.brand-mark i { display: block; height: 4px; border-radius: 2px; }
.brand-mark i:nth-child(2) { width: 65%; }
.brand-mark i:nth-child(3) { width: 82%; }

.sidebar-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 18px 10px 6px; font-weight: 600; }
.nav-item, .company-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px;
  border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: var(--ink-2); }
.nav-item:hover, .company-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active, .company-item.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
  outline: 1px solid var(--line); }
.nav-icon { width: 16px; text-align: center; color: var(--muted); }
.company-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.company-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-list { display: flex; flex-direction: column; gap: 2px; }
.add-company { margin: 6px 0 0; justify-content: flex-start; }

.legend { display: flex; flex-direction: column; gap: 5px; padding: 2px 10px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.legend-row .tag { margin-left: auto; font-size: 11px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 600; background: var(--line); color: var(--ink-2); }
.badge.danger { background: var(--danger); color: #fff; }
.badge.warn { background: #F79009; color: #fff; }
.nav-item .badge, .company-item .badge { margin-left: auto; }

/* ---------- header / tabs ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.company-chip { width: 14px; height: 14px; border-radius: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .badge { margin-left: 4px; }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer;
  font-weight: 500; white-space: nowrap; box-shadow: var(--shadow); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2C2C33; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: none; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=url], input[type=password], input[type=datetime-local], input[type=search],
select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); outline: none; font-size: 14px; font-weight: 400; color: var(--ink); }
textarea { height: auto; min-height: 90px; padding: 9px 10px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #8E8C86; box-shadow: 0 0 0 3px rgba(23, 23, 26, .08); }
input[type=color] { width: 36px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.section-title { font-weight: 650; font-size: 15px; margin: 0 0 12px; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty b { color: var(--ink); display: block; font-size: 15px; margin-bottom: 4px; }

/* ---------- platform chips ---------- */
.pchip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 6px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.pchip.outline { background: var(--panel) !important; color: var(--ink-2); border: 1px solid var(--line-2); }
.pchip.outline .swatch { width: 9px; height: 9px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px;
  border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--ink-2); user-select: none; }
.filter-chip .swatch { width: 10px; height: 10px; border-radius: 50%; }
.filter-chip.off { opacity: .45; background: transparent; }
.filter-chip.off .swatch { background: transparent !important; outline: 1.5px solid var(--muted); outline-offset: -1.5px; }

/* ---------- statuses ---------- */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { color: #6B6B73; background: #F2F1EE; }
.st-scheduled { color: #1849A9; background: var(--info-bg); }
.st-publishing { color: #6941C6; background: #F4F3FF; }
.st-published { color: var(--ok); background: var(--ok-bg); }
.st-failed { color: var(--danger); background: var(--danger-bg); }
.st-manual_due { color: var(--warn); background: var(--warn-bg); }
.st-cancelled { color: var(--muted); background: #F2F1EE; text-decoration: line-through; }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-wrap { padding: 14px; }
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #FFF8E6; --fc-page-bg-color: var(--panel);
  --fc-neutral-bg-color: #FAF9F7; --fc-button-bg-color: var(--panel); --fc-button-border-color: var(--line-2);
  --fc-button-text-color: var(--ink); --fc-button-hover-bg-color: var(--hover); --fc-button-hover-border-color: var(--line-2);
  --fc-button-active-bg-color: var(--ink); --fc-button-active-border-color: var(--ink); --fc-event-border-color: transparent;
  font-size: 13px; }
.fc .fc-button { box-shadow: var(--shadow); font-weight: 500; text-transform: none; padding: 5px 11px; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-button:focus { box-shadow: 0 0 0 3px rgba(23, 23, 26, .1) !important; }
.fc .fc-toolbar-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; text-transform: capitalize; }
.fc .fc-col-header-cell-cushion { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase;
  text-decoration: none; padding: 8px 4px; }
.fc .fc-daygrid-day-number { color: var(--ink-2); text-decoration: none; font-weight: 500; padding: 6px 8px; }
.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number { color: #C2C0BA; }
.fc .fc-daygrid-day-frame { min-height: 108px; cursor: copy; }
.fc-theme-standard .fc-scrollgrid { border-radius: 8px; overflow: hidden; }
.fc .fc-daygrid-event { margin: 1px 4px 2px !important; border-radius: 6px; }
.fc .fc-daygrid-more-link { font-weight: 600; color: var(--ink-2); padding-left: 6px; }
.fc .fc-timegrid-event { border-radius: 6px; }
.fc-list-event { cursor: pointer; }

.ev { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 2px 6px; color: #fff;
  font-size: 12px; line-height: 1.35; overflow: hidden; }
.ev .ev-plat { font-weight: 800; font-size: 10px; letter-spacing: .03em; padding: 0 4px; border-radius: 3px;
  background: rgba(255, 255, 255, .22); flex: none; }
.ev .ev-time { font-weight: 600; opacity: .92; flex: none; font-variant-numeric: tabular-nums; }
.ev .ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.ev .ev-icon { flex: none; font-size: 11px; }
.fc-event.is-draft { opacity: .55; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px) !important; }
.fc-event.is-cancelled { opacity: .3; text-decoration: line-through; }
.fc-event.is-failed { box-shadow: 0 0 0 2px var(--danger) inset, 0 0 0 1px #fff; }
.fc-event.is-manual_due { box-shadow: 0 0 0 2px #F79009 inset; }
.fc-event.is-published .ev-title { opacity: .9; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: #FAF9F7; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click:hover td { background: #FAF9F7; cursor: pointer; }
.table .err { color: var(--danger); font-size: 12px; max-width: 320px; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }

/* ---------- channels ---------- */
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.channel { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border-left: 4px solid; }
.channel-head { display: flex; align-items: center; gap: 8px; }
.channel-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .creds { font-size: 13px; display: grid; gap: 3px; }
.check-result { font-size: 12px; padding: 7px 9px; border-radius: 6px; }
.check-result.ok { background: var(--ok-bg); color: var(--ok); }
.check-result.bad { background: var(--danger-bg); color: var(--danger); }
.plat-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.plat-option { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; text-align: left; }
.plat-option.selected { outline: 2px solid var(--ink); border-color: transparent; }
.plat-option small { color: var(--muted); font-size: 11px; }
.help { background: #FAF9F7; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px;
  font-size: 12px; color: var(--ink-2); }

/* ---------- media ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-tile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #ECEAE5;
  border: 1px solid var(--line); }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .file { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 12px;
  color: var(--ink-2); padding: 8px; text-align: center; word-break: break-all; }
.media-tile .kind { position: absolute; left: 6px; bottom: 6px; font-size: 10px; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, .55); border-radius: 4px; padding: 1px 5px; }
.media-tile .del { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .55); color: #fff; border: 0;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; opacity: 0; }
.media-tile:hover .del { opacity: 1; }
.media-tile.pick { cursor: pointer; }
.media-tile.pick.selected { outline: 3px solid var(--ink); outline-offset: -3px; }
.media-tile.pick .num { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 18px; text-align: center;
  color: var(--muted); cursor: pointer; background: #FCFBF9; }
.dropzone.drag { border-color: var(--ink); background: var(--hover); color: var(--ink); }

/* ---------- modal / editor ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23, 23, 26, .38); display: flex; justify-content: flex-end;
  z-index: 50; animation: fade .15s ease; }
.modal-backdrop.center { align-items: center; justify-content: center; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer { width: min(1180px, 96vw); height: 100%; background: var(--bg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide .18s ease; }
.dialog { width: min(560px, 94vw); max-height: 90vh; overflow: auto; background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow-lg); }
.dialog-head, .drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--panel); }
.dialog-head h2, .drawer-head h2 { font-size: 16px; margin: 0; flex: 1; }
.dialog-body { padding: 18px 20px; }
.dialog-foot, .drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px;
  border-top: 1px solid var(--line); background: var(--panel); align-items: center; }
.drawer-body { flex: 1; overflow: hidden; display: grid; grid-template-columns: 360px 1fr; }
.post-col { border-right: 1px solid var(--line); overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); }
.variants-col { overflow-y: auto; padding: 0 0 24px; min-width: 0; }

.vtabs { display: flex; gap: 6px; padding: 12px 20px 0; flex-wrap: wrap; align-items: center; position: sticky; top: 0;
  background: var(--bg); z-index: 5; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.vtab { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 8px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500; font-size: 13px; max-width: 240px; }
.vtab .swatch { width: 12px; height: 12px; }
.vtab .vt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtab.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.vtab .vt-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.vtab .vt-warn { color: #F79009; font-weight: 800; }
.add-variant { position: relative; }
.menu { position: absolute; top: 36px; left: 0; min-width: 260px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; background: none;
  border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.vpanel { padding: 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.vpanel .stack { min-width: 0; }
.editor-box { border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; }
.editor-box:focus-within { border-color: #8E8C86; box-shadow: 0 0 0 3px rgba(23, 23, 26, .08); }
.editor-tools { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); align-items: center; background: #FCFBF9; }
.editor-tools button { white-space: nowrap; border: 0; background: none; min-width: 28px; height: 26px; border-radius: 5px; cursor: pointer; color: var(--ink-2); }
.editor-tools button:hover { background: var(--hover); color: var(--ink); }
.editor-tools .counter { white-space: nowrap; margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-right: 4px; }
.editor-tools .counter.over { color: var(--danger); font-weight: 700; }
.editor-box textarea { border: 0; border-radius: 0; min-height: 220px; box-shadow: none !important; font-size: 14px; }

.buttons-list { display: flex; flex-direction: column; gap: 6px; }
.button-row { display: grid; grid-template-columns: 1fr 1.5fr auto auto; gap: 6px; align-items: center; }
.button-row input { height: 32px; font-size: 13px; }

.subcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.subcard > .head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.subcard > .head .spacer { flex: 1; }
details.subcard > summary { cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.subcard > summary::-webkit-details-marker { display: none; }
details.subcard > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.subcard[open] > summary::before { transform: rotate(90deg); }
details.subcard[open] > summary { margin-bottom: 10px; }

.preview { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; }
.phone { background: #DCE6EC; border-radius: 16px; padding: 14px 12px; min-height: 160px; }
.phone.vk { background: #EDEEF0; }
.phone.max { background: linear-gradient(160deg, #EEE8FF, #E3ECFF); }
.bubble { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); font-size: 13px; }
.bubble .b-media { display: grid; gap: 2px; grid-template-columns: repeat(2, 1fr); }
.bubble .b-media.one { grid-template-columns: 1fr; }
.bubble .b-media img, .bubble .b-media .vid { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #222; }
.bubble .b-media .vid { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; }
.bubble .b-head { display: flex; align-items: center; gap: 8px; padding: 9px 11px 0; font-weight: 600; font-size: 12px; }
.bubble .b-avatar { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.bubble .b-text { padding: 8px 11px 10px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.bubble .b-text a { color: #1A73E8; }
.bubble .b-text blockquote { margin: 4px 0; padding-left: 8px; border-left: 3px solid #1FA4DD; }
.b-buttons { display: grid; gap: 4px; margin-top: 4px; }
.b-buttons .b-row { display: flex; gap: 4px; }
.b-buttons .b-btn { flex: 1; text-align: center; background: rgba(255, 255, 255, .78); border-radius: 8px; padding: 7px 6px;
  font-size: 12px; font-weight: 600; color: #1A73E8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnings { display: flex; flex-direction: column; gap: 4px; }
.warning { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 6px 9px; }
.err-box { font-size: 12px; color: var(--danger); background: var(--danger-bg); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; }
.logs { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; max-height: 160px; overflow: auto; }
.logs .bad { color: var(--danger); }
.utm-preview { font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }

/* ---------- overview ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; cursor: pointer; }
.kpi:hover { border-color: var(--line-2); }
.kpi .k-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.kpi .k-nums { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.kpi .k-nums b { display: block; font-size: 18px; color: var(--ink); font-weight: 650; }
.kpi .k-plats { display: flex; gap: 3px; margin-top: 10px; }
.kpi .k-plats .swatch { width: 10px; height: 10px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg);
  font-size: 13px; max-width: 420px; animation: fade .2s ease; }
.toast.error { background: var(--danger); }
.toast.ok { background: #0B6E4F; }

@media (max-width: 1100px) {
  .drawer-body { grid-template-columns: 1fr; overflow-y: auto; }
  .post-col { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .variants-col { overflow: visible; }
  .vpanel { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; }
  .main { padding: 16px; overflow: visible; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .plat-picker { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- импорт / массовые действия ---------- */
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px; background: var(--ink);
  color: #fff; border-radius: var(--radius); position: sticky; top: 0; z-index: 4; }
.bulkbar .btn { box-shadow: none; color: var(--ink); border-color: transparent; }
.bulkbar .btn.danger { color: var(--danger); }
.bulkbar .btn.ghost { color: #ddd; }
.bulkbar .btn.ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.row-warn { font-size: 12px; color: var(--warn); margin-top: 2px; font-weight: 400; }
.table input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--ink); cursor: pointer; }
.imp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.imp-stats > div { background: #FAF9F7; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.imp-stats b { display: block; font-size: 20px; color: var(--ink); font-weight: 650; }
.imp-stats span { display: block; margin-top: 2px; }
.imp-list { margin-top: 10px; max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-size: 13px;
  border-top: 1px solid var(--line); padding-top: 8px; }
.imp-list > div { display: flex; align-items: center; gap: 8px; }
.imp-list > div > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check input[type=radio] { width: 15px; height: 15px; accent-color: var(--ink); flex: none; margin-top: 2px; }
.check:has(input[type=radio]) { align-items: flex-start; }
.plan-line { font-size: 12px; color: var(--ink-2); background: #FAF9F7; border: 1px dashed var(--line-2); border-radius: 6px; padding: 6px 10px; }
.b-poll { margin: 0 11px 10px; padding: 8px 10px; background: #F5F6F8; border-radius: 8px; display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.b-poll span { background: #fff; border: 1px solid #E3E4E8; border-radius: 6px; padding: 5px 8px; }
.dialog:has(#imp-result) { width: min(720px, 94vw); }
@media (max-width: 760px) { .imp-stats { grid-template-columns: repeat(2, 1fr); } }
.field-head { display: flex; align-items: center; gap: 7px; }
.b-link { margin: 0 11px 10px; border-left: 3px solid #1FA4DD; background: #F3F7FA; border-radius: 6px; padding: 7px 9px; font-size: 12px; }
.phone.vk .b-link { border-left: 0; border: 1px solid #E3E4E8; background: #fff; }
.b-link .cover { height: 64px; border-radius: 4px; margin-bottom: 6px; background: repeating-linear-gradient(135deg, #E6E9EE 0 8px, #EEF0F3 8px 16px);
  display: flex; align-items: center; justify-content: center; color: #8A8F98; font-size: 11px; }
.b-link b { display: block; color: #1A73E8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- OAuth / ручные площадки ---------- */
.oauth-help { background: var(--info-bg); border-color: #C7D7FE; }
.loc-row { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.loc-row:has(input:checked) { border-color: var(--ink); }
.channel .row.wrap { gap: 6px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
input[type=datetime-local] { min-width: 0; }

/* ---------- вход ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login-card p { margin: -8px 0 4px; }
.login-card .btn { height: 40px; }

/* ---------- сайдбар: пользователь ---------- */
.sidebar-spacer { flex: 1; min-height: 16px; }
.user-box { border-top: 1px solid var(--line); padding: 12px 10px 4px; }
.user-name { font-weight: 600; }

/* ---------- чек-лист готовности ---------- */
.readiness { margin-bottom: 14px; padding: 12px 16px; border-color: #F5D9A8; background: #FFFCF5; }
.readiness summary { cursor: pointer; list-style: none; }
.readiness summary::-webkit-details-marker { display: none; }
.ready-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; margin-top: 12px; }
.ready-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.ready-item > div { flex: 1; min-width: 0; }
.ready-item.ok { opacity: .65; }
.ready-mark { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.ready-item.ok .ready-mark { background: var(--ok-bg); color: var(--ok); }

/* ---------- аналитика ---------- */
.period { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.seg { height: 30px; padding: 0 11px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 7px; cursor: pointer; font-size: 13px; }
.seg.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.period input[type=date] { width: 140px; height: 30px; font-size: 13px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi-tile { padding: 14px 16px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-tile.good .kpi-value { color: var(--ok); }
.an-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: #C9C5BC; }
.chart .bar:hover { fill: #8E8C86; }
.chart .line { fill: none; stroke: #1FA4DD; stroke-width: 2; }
.chart .dot { fill: #1FA4DD; }
.chart .axis { font-size: 10px; fill: var(--muted); }
.chart .grid { stroke: var(--line-2); }
.legend-inline { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend-inline i { display: inline-block; width: 12px; height: 8px; margin-right: 5px; border-radius: 2px; vertical-align: middle; }
.lg-bar { background: #C9C5BC; }
.lg-line { background: #1FA4DD; height: 2px !important; }
.hbars { margin-bottom: 14px; }
.hbars-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 64px; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; }
.hbar-name { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.hbar-track { height: 8px; background: #F0EEE9; border-radius: 4px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 4px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap, .nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.good { color: var(--ok); }
.bad { color: var(--danger); }
.company-chip.inline { display: inline-block; width: 10px; height: 10px; vertical-align: middle; }

/* ---------- чаты ботов, отчёты, ключи ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--line-2);
  background: var(--panel); cursor: pointer; font-size: 13px; }
.chat-chip.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: #F7F6F3; }
.found-chats { background: #FAF9F7; border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.report-preview { background: #EEF3F7; border-radius: 12px; padding: 14px; font-size: 13px; line-height: 1.5; max-height: 60vh; overflow: auto; }
.report-preview a { color: #1A73E8; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.key-row { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.tag-ok { font-size: 11px; font-weight: 600; color: var(--ok); background: var(--ok-bg); padding: 1px 6px; border-radius: 6px; }
.tag-no { font-size: 11px; font-weight: 600; color: var(--muted); background: #F2F1EE; padding: 1px 6px; border-radius: 6px; }
.cred-box { background: #17171A; color: #fff; padding: 12px 14px; border-radius: 8px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; margin: 0; }
.ro-note { margin-right: auto; }
@media (max-width: 1000px) { .an-grid { grid-template-columns: 1fr; } }

/* ---------- вовлечённость: воронка, выводы, комментарии ---------- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr; gap: 2px 12px; align-items: center; }
.funnel-label { font-size: 13px; }
.funnel-bar-wrap { display: flex; align-items: center; gap: 8px; height: 26px; }
.funnel-bar { height: 100%; max-width: calc(100% - 70px); background: #3E3E46; border-radius: 6px; flex: none; }
.funnel-val { font-weight: 600; font-size: 14px; white-space: nowrap; }
.funnel-note { grid-column: 2; }
.insights { display: flex; flex-direction: column; gap: 8px; }
.insight { padding: 8px 10px; border-radius: 8px; border-left: 3px solid var(--line-2); background: #FAFAF8; }
.insight .small { margin-top: 2px; color: var(--muted); }
.insight.lv-warn { border-left-color: #F79009; background: #FFF8EC; }
.insight.lv-good { border-left-color: var(--ok); background: var(--ok-bg); }
.sent-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; font-size: 12px; }
.sent-bar span { display: flex; align-items: center; justify-content: center; white-space: nowrap; min-width: 46px; }
.sent-bar .s-positive { background: #DCFAE6; }
.sent-bar .s-neutral { background: #F2F1EE; }
.sent-bar .s-negative { background: #FEE4E2; }
.chip-btn { border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip-btn:hover { border-color: var(--ink); }
.word { display: inline-block; margin: 0 4px; }
.tag { font-size: 11px; background: #F2F1EE; padding: 1px 7px; border-radius: 6px; }
.cm-item { border-top: 1px solid var(--line); padding: 8px 0; }
.cm-item.done { opacity: .55; }
.cm-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cm-sent { margin-left: auto; }
.cm-text { margin: 4px 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.cm-list { max-height: 65vh; overflow: auto; min-width: min(640px, 80vw); }
@media (max-width: 700px) { .funnel-row { grid-template-columns: 1fr; } .funnel-note { grid-column: 1; } }

/* ---------- подключение: ключи, мастер, карточки каналов ---------- */
.dialog.wide { width: min(820px, 96vw); }
.wiz-steps { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.wiz-steps .on { color: var(--ink); font-weight: 650; }
.wiz-steps .done { color: var(--ok); }
.wiz-plats { grid-template-columns: repeat(3, 1fr); }
.wiz-chan { display: grid; gap: 8px; }
.wiz-chan input[type=text] { width: 100%; }
.tag-no.warn { color: var(--warn); background: var(--warn-bg); }

.guide-list { display: grid; gap: 10px; }
.guide { padding: 0; overflow: hidden; }
.guide > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 26px 1fr; gap: 2px 10px; padding: 14px 18px; align-items: center; }
.guide > summary::-webkit-details-marker { display: none; }
.guide > summary:hover { background: var(--hover); }
.guide-mark { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.guide.st-ok .guide-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.guide.st-part .guide-mark { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.guide-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; }
.guide-what { grid-column: 2; }
.guide-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; padding: 4px 18px 18px 54px; }
.guide-steps ol { margin: 6px 0 10px; padding-left: 20px; display: grid; gap: 7px; line-height: 1.5; }
.guide-steps a { color: #1D4ED8; }
.guide-steps code, .copy-row code { font-family: var(--mono); font-size: 12px; background: #F2F1EE; padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.copy-row code { word-break: break-all; }
.copy-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 6px; }
.guide-form .field input, .guide-form .field textarea { width: 100%; }
.helper input { flex: 1; min-width: 0; }

.ch-status { font-size: 13px; font-weight: 600; }
.ch-status.ok { color: var(--ok); }
.ch-status.bad { color: var(--danger); }
.ch-status.manual { color: var(--muted); font-weight: 500; }
.ch-where { font-weight: 500; word-break: break-all; }

.legend-more > summary { cursor: pointer; list-style: none; padding: 4px 10px; }
.legend-more > summary::-webkit-details-marker { display: none; }

@media (max-width: 900px) {
  .guide-body { grid-template-columns: 1fr; padding-left: 18px; }
  .wiz-plats { grid-template-columns: repeat(2, 1fr); }
  .copy-row { grid-template-columns: 1fr auto; }
  .copy-row > span { grid-column: 1 / -1; }
}
