/* Стиль по образцу редактора VK Рекламы */
:root {
  --accent: #2688eb;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #222;
  --muted: #818c99;
  --border: #e5e5e5;
  --own: #2688eb;
  --common: #b08000;
  --common-bg: #fff8e0;
  --error: #e64646;
  --warn: #c87a00;
  --ok: #4bb34b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; height: 100vh;
}
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.spacer { flex: 1; }
.card { background: var(--card); border-radius: 10px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; }
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 600; }
.btn-secondary { background: var(--bg); color: var(--accent); border: 0; border-radius: 8px; padding: 6px 12px; }
.pill { background: var(--bg); border-radius: 8px; padding: 4px 10px; }
.pill select { border: 0; background: transparent; font-weight: 600; }

.topbar { background: var(--card); display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.topbar .title { font-size: 17px; }

.sources { margin: 10px 10px 0; padding: 8px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 8px; padding: 4px 10px; margin-right: 6px; }
.chip img, .thumb { width: 34px; height: 26px; object-fit: cover; border-radius: 4px; background: #ddd; }
.chip .x { color: var(--muted); }

.layout { flex: 1; min-height: 0; display: flex; gap: 10px; margin: 10px; }
.tree { width: 320px; flex: none; display: flex; flex-direction: column; min-height: 0; }
.tree-tools { display: flex; gap: 6px; padding: 8px; }
.tree-tools input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; }
.hint { padding: 0 10px 6px; color: var(--muted); font-size: 12px; }
#tree { overflow: auto; flex: 1; padding-bottom: 8px; }
.node { padding: 3px 10px; display: flex; align-items: center; gap: 6px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node:hover { background: #f5f7fa; }
.node.campaign { font-weight: 600; }
.node.group { padding-left: 26px; }
.node.banner { padding-left: 44px; cursor: pointer; }
.node.copy { padding-left: 50px; color: var(--accent); cursor: pointer; font-size: 12px; }
.node.copy.active, .node.common.active { background: #e8f1fd; }
.node.common { background: var(--common-bg); border-left: 3px solid #e0b000; font-weight: 600; cursor: pointer; margin-bottom: 4px; }
.node.disabled { color: #aaa; }
.node.invalid, .node.copy.invalid { color: var(--error); }
.node .tag { font-size: 11px; color: var(--muted); font-weight: 400; }
.node .tag.warn { color: var(--warn); }
.node .tag.err { color: var(--error); }
.node .toggle { width: 12px; color: var(--muted); cursor: pointer; }
.node .name { overflow: hidden; text-overflow: ellipsis; }

.form { flex: 1; overflow: auto; padding: 14px 18px; }
.form h2 { font-size: 16px; margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.field-head { display: flex; justify-content: space-between; color: #666; margin-bottom: 3px; }
.field-head .count.over { color: var(--error); font-weight: 600; }
.origin { font-size: 11px; margin-left: 4px; }
.origin.own { color: var(--own); }
.origin.common { color: var(--common); }
.origin.source { color: var(--muted); }
.field textarea, .field input[type=text] {
  width: 100%; background: var(--bg); border: 1px solid transparent; border-radius: 8px; padding: 7px 10px; resize: vertical;
}
.field textarea:focus, .field input[type=text]:focus { outline: none; border-color: var(--accent); background: #fff; }
.field .readonly { background: #f6f6f6; border-radius: 8px; padding: 7px 10px; color: #888; }
.errors { background: #fdeaea; color: var(--error); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }
.slots { display: flex; gap: 10px; flex-wrap: wrap; }
.slot { width: 120px; }
.slot .img { width: 120px; height: 80px; border-radius: 6px; background: #ddd center/cover no-repeat; display: flex; align-items: flex-end; }
.slot .img span { background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 0 4px 0 6px; }
.slot .err { color: var(--error); font-size: 11px; }
.slot label { color: var(--accent); cursor: pointer; font-size: 12px; }

.preview { width: 260px; flex: none; padding: 14px; overflow: auto; }
.tabs { display: flex; gap: 4px; margin: 8px 0; }
.tab { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 3px 8px; }
.tab.active { border-color: var(--accent); }
.ad { border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.15); overflow: hidden; font-size: 12px; }
.ad .head { padding: 6px 8px; display: flex; gap: 6px; align-items: center; }
.ad .head img { width: 24px; height: 24px; border-radius: 50%; background: #ddd; }
.ad .pic { width: 100%; display: block; background: #ddd; min-height: 80px; object-fit: cover; }
.ad .cta { background: var(--accent); color: #fff; padding: 6px 8px; }
.ad .body { padding: 6px 8px; }

.footer { background: var(--card); display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; max-width: 460px; }
.modal-box .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(900px, 100%); background: #fff; box-shadow: -4px 0 16px rgba(0,0,0,.15); z-index: 10; display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15px; }
#drawer-body { overflow: auto; padding: 12px 16px; flex: 1; }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 8px 0 12px; }
.progress div { height: 100%; background: var(--accent); transition: width .3s; }
table.report { width: 100%; border-collapse: collapse; font-size: 12px; }
table.report th, table.report td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.st-created, .st-launched { color: var(--ok); }
.st-error { color: var(--error); }
.st-skipped { color: var(--warn); }
.st-pending { color: var(--muted); }
.warn-box { background: #fff4e0; color: var(--warn); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.drawer-actions { display: flex; gap: 10px; margin: 10px 0; align-items: center; }
.st-unknown { color: var(--warn); font-weight: 600; }

.tree-actions { display: flex; gap: 14px; padding: 0 10px 6px; font-size: 12px; }
.library-box { background: #fff; border-radius: 12px; width: min(960px, 96vw); height: min(720px, 90vh); display: flex; flex-direction: column; }
.library-tools { display: flex; gap: 12px; align-items: center; padding: 10px 16px; }
.library-tools input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.library-grid { flex: 1; overflow: auto; padding: 0 16px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; }
.lib-item { border: 2px solid transparent; border-radius: 8px; cursor: pointer; background: var(--bg); padding: 4px; font-size: 11px; }
.lib-item:hover { border-color: var(--accent); }
.lib-item img { width: 100%; height: 110px; object-fit: contain; display: block; background: #e8e8e8; border-radius: 6px; }
.lib-item .cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.node.copy.dup { color: var(--warn); }

/* вход */
.login-page { align-items: center; justify-content: center; }
.login-box { width: min(360px, 92vw); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; color: #666; }
.login-box input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.user-box { display: flex; gap: 10px; align-items: center; }

/* админка */
.admin-page { overflow: auto; }
.admin-section { margin: 10px; padding: 14px 18px; }
.admin-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.admin-row input:not([type=checkbox]) { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.user-card { border-top: 1px solid var(--border); padding: 10px 0; }
.accs { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0; }
.ok-text { color: var(--ok); }
.err-text { color: var(--error); }
.field-block { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.block-title { font-weight: 600; margin-bottom: 6px; }

/* режимы и копирование групп/кампаний */
.modes { display: flex; gap: 4px; }
.modes .tab.active { border-color: var(--accent); color: var(--accent); }
table.schedule { border-collapse: collapse; font-size: 10px; margin: 4px 0; }
table.schedule td { padding: 0; text-align: center; }
table.schedule input { margin: 0; width: 13px; height: 13px; }
.obj-results { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.obj-search { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; margin-top: 4px; }

/* ===== рестайл под редактор ВК (11.11.2026) ===== */
:root { --field: #f2f3f5; --field-hover: #ebedf0; --text2: #6d7885; --radius: 8px; }
body { font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

/* поля ввода — как в ВК: серый фон, без рамки, синий фокус */
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], select, textarea {
  background: var(--field); border: 1px solid transparent; border-radius: var(--radius);
  padding: 7px 10px; color: var(--text); font: inherit; outline: none; transition: border-color .15s, background .15s;
}
input[type=text]:hover, input[type=number]:hover, input[type=date]:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
select { cursor: pointer; padding-right: 28px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23818c99' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
input[type=number], input[type=date] { width: 180px; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; vertical-align: -2px; }
.field textarea, .field input[type=text] { width: 100%; }
.field { margin-bottom: 14px; }
.field-head { font-size: 13px; color: var(--text2); margin-bottom: 5px; align-items: center; }
.field .readonly { background: var(--field); color: var(--text2); }
.origin { font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.origin.own { background: #e5effc; color: var(--own); }
.origin.common { background: var(--common-bg); color: var(--common); }

/* шапка: режимы — вкладками с подчёркиванием */
.topbar { gap: 18px; }
.modes { gap: 2px; align-self: stretch; }
.modes .tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 10px 8px; color: var(--text2); font-weight: 500; }
.modes .tab:hover { color: var(--text); }
.modes .tab.active { border-bottom-color: var(--accent); color: var(--text); }
.pill { background: var(--field); }

/* дерево */
.ico { width: 15px; height: 15px; color: var(--text2); flex: none; }
.node { gap: 7px; padding: 4px 10px; border-radius: 6px; margin: 0 4px; }
.node.campaign { font-weight: 600; }
.node .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.node .tag { flex: none; }
.node.copy { padding-left: 46px; color: var(--text); font-size: 12px; }
.node.copy.active, .node.common.active { background: #e5effc; }
.node.common { border-left: 0; background: var(--common-bg); margin: 4px 4px 6px; }
.pill { flex: none; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.pill-none { background: var(--field); color: var(--text2); }
.pill-chg { background: #e5effc; color: var(--accent); }
.pill-err { background: #fdeaea; color: var(--error); }
.pill-skip, .pill-dup { background: #fff1db; color: var(--warn); }
.pill-ok { background: #e3f4e3; color: var(--ok); }
.pill-wait { background: var(--field); color: var(--text2); }
.tree-tools { padding: 10px 10px 6px; }
.tree-tools input { background: var(--field); border: 1px solid transparent; }
.tree-tools select { width: 120px; }
.tree-actions { padding: 0 12px 4px; }
.hint { font-size: 11px; line-height: 1.35; }

/* форма: блоки как в ВК */
.form { background: transparent; padding: 0 2px; }
.form > h2, .form > p, .form > .tabs, .form > #obj-errors, .form > #form-errors, .form > .field { margin-left: 4px; margin-right: 4px; }
.form > h2 { background: var(--card); margin: 0 0 10px; padding: 14px 18px; border-radius: 10px; font-size: 17px; }
.fblock, .form > .field, .field-block { background: var(--card); border-radius: 10px; padding: 14px 18px; margin: 0 0 10px; }
.form > .field-block { margin: 0 0 10px; }
.fblock-title, .block-title { font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.muted-block { opacity: .75; }
.form .tabs { background: var(--card); padding: 8px 12px; border-radius: 10px; margin-bottom: 10px; gap: 6px; }
.form .tabs .tab { border: 0; background: var(--field); border-radius: 8px; padding: 6px 12px; }
.form .tabs .tab.active { background: #e5effc; color: var(--accent); font-weight: 600; }
.form > p.muted { background: none; padding: 0 18px; margin: 0 0 8px; }

/* переключатель (флаг) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 34px; height: 20px; background: #c4c8cc; border-radius: 10px; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; cursor: pointer; }

/* расписание */
.sched-presets { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chip-btn { border: 0; background: var(--field); border-radius: 8px; padding: 5px 10px; font-size: 12px; }
.chip-btn:hover { background: var(--field-hover); }
table.schedule { border-collapse: separate; border-spacing: 2px; margin: 0 0 8px; }
table.schedule td.hour { font-size: 10px; color: var(--text2); text-align: center; }
table.schedule td.day { font-size: 11px; color: var(--text2); padding-right: 4px; }
table.schedule td.day.weekend { color: var(--error); }
table.schedule .cell input { display: none; }
table.schedule .cell span { display: block; width: 17px; height: 17px; border-radius: 3px; background: var(--field); cursor: pointer; }
table.schedule .cell span:hover { background: #d6e6fb; }
table.schedule .cell input:checked + span { background: var(--accent); }

/* регионы/аудитории: чипы */
.field .chip { background: var(--field); border-radius: 8px; padding: 4px 8px; margin: 0 6px 6px 0; }
.obj-search { margin-top: 2px; }
.obj-results .link { background: var(--field); border-radius: 8px; padding: 3px 8px; color: var(--text); }
.obj-results .link:hover { background: #e5effc; color: var(--accent); }

/* медиа: плитка, действия по наведению */
.slots { gap: 12px; }
.slot { width: 128px; }
.slot .img { width: 128px; height: 96px; border-radius: 8px; position: relative; overflow: hidden; display: block; background-color: var(--field); }
.slot-actions { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 0 14px; opacity: 0; transition: opacity .15s; }
.slot:hover .slot-actions { opacity: 1; }
.slot-btn { background: #fff; color: var(--text); border: 0; border-radius: 6px; padding: 4px 0; font-size: 12px; text-align: center; cursor: pointer; }
.slot-cap { font-size: 11px; color: var(--text2); margin-top: 4px; }

/* сводка справа */
.summary-card { background: var(--field); border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
.sum-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px solid #e3e5e8; }
.sum-row:last-child { border-bottom: 0; }

/* источник и футер */
.sources { padding: 8px 14px; }
.footer { box-shadow: 0 -1px 0 var(--border); border-top: 0; }
.btn-primary { padding: 9px 18px; }
.btn-primary:hover:not(:disabled) { background: #1d77d6; }
.node .name .ico { margin-right: 6px; vertical-align: -3px; }
.field-note { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.35; }
