/* Placement Manager base styles */
:root{
  --bg:#0b0d12; --card:#111523; --card2:#0f1422; --line:#232a3d;
  --text:#e9ecf5; --muted:#9aa3b2; --btn:#1b2236; --btn2:#2b63ff; --danger:#ff4d5e;
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --r:16px;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}
body{ margin:0; background:var(--bg); color:var(--text); }

.pm-wrap{ display:flex; justify-content:center; align-items:center; min-height:100vh; padding:24px; }
.pm-card{ width:min(520px, 100%); background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)); border:1px solid var(--line); border-radius:24px; padding:24px; box-shadow:var(--shadow); }
.pm-title{ font-size:24px; font-weight:700; margin-bottom:6px; }
.pm-sub{ color:var(--muted); margin-bottom:18px; }
.pm-field{ margin:14px 0; }
.pm-field label{ display:block; font-size:13px; color:var(--muted); margin-bottom:8px; }

input, select{
  width:100%; background:#0c1020; border:1px solid var(--line); color:var(--text);
  border-radius:14px; padding:12px 12px; outline:none;
}
input:focus, select:focus{ border-color:rgba(43,99,255,.7); box-shadow:0 0 0 3px rgba(43,99,255,.15); }

.pm-row{ display:flex; align-items:center; gap:12px; margin-top:14px; }
.pm-err{ color:#ff7b86; font-size:13px; }

.btn{
  background:var(--btn); color:var(--text); border:1px solid var(--line);
  border-radius:14px; padding:10px 14px; cursor:pointer;
}
.btn:hover{ filter:brightness(1.08); }
.btn-primary{ background:var(--btn2); border-color:rgba(43,99,255,.6); }
.btn-danger{ background:var(--danger); border-color:rgba(255,77,94,.6); }

.pm-topbar{
  display:flex; align-items:center; gap:12px;
  padding:14px 18px; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:rgba(11,13,18,.9); backdrop-filter: blur(8px);
  z-index:10;
}
.pm-brand{ font-weight:800; font-size:18px; }
.pm-pill{
  padding:6px 10px; border-radius:999px; border:1px solid var(--line);
  color:var(--muted); font-size:13px; background:rgba(255,255,255,.02);
}

.pm-layout{
  display:grid; grid-template-columns: 420px 1fr; gap:14px;
  padding:14px;
}
.pm-left, .pm-right{ min-height: calc(100vh - 70px); }

.pm-left{
  border:1px solid var(--line); border-radius:var(--r); background:rgba(255,255,255,.02);
  overflow:hidden;
}
.pm-left-head{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 12px; border-bottom:1px solid var(--line);
}
.pm-left-title{ color:var(--muted); font-size:13px; }

.pm-search-wrap{
  display:flex; gap:8px; padding:8px 10px; border-bottom:1px solid var(--line);
}
.pm-search-input{
  flex:1; background:#0c1020; border:1px solid var(--line); color:var(--text);
  border-radius:10px; padding:8px 12px; outline:none; font-size:13px; width:auto;
}
.pm-search-input:focus{ border-color:rgba(43,99,255,.7); box-shadow:0 0 0 3px rgba(43,99,255,.15); }
.pm-refresh-btn{ padding:7px 12px; font-size:16px; border-radius:10px; }
.pm-refresh-btn.loading{ opacity:.5; cursor:wait; }

.pm-tree{ padding:10px 10px 14px 10px; max-height: calc(100vh - 180px); overflow:auto; }

.pm-right .pm-card2{
  border:1px solid var(--line); border-radius:var(--r);
  background:rgba(255,255,255,.02); padding:16px;
}
.pm-h2{ font-size:22px; font-weight:800; margin-bottom:8px; }
.pm-h3{ font-size:14px; color:var(--muted); margin-bottom:10px; }

.pm-chg{ display:grid; grid-template-columns: 220px 1fr; gap:12px; align-items:center; margin:10px 0; }
.pm-checkrow{ display:flex; gap:10px; align-items:center; }
.pm-checkrow input{ width:auto; }

.pm-num-wrap{
  display:flex; align-items:stretch;
}
.pm-num-wrap input{
  flex:1; border-radius:14px 0 0 14px; border-right:none;
}
.pm-num-arrows{
  display:flex; flex-direction:column; width:28px; flex-shrink:0;
}
.pm-num-arrows button{
  flex:1; background:var(--btn); border:1px solid var(--line);
  color:var(--muted); cursor:pointer; font-size:9px; padding:0;
  line-height:1;
}
.pm-num-arrows button:first-child{ border-radius:0 8px 0 0; border-bottom:none; }
.pm-num-arrows button:last-child{ border-radius:0 0 8px 0; }
.pm-num-arrows button:hover{ color:var(--text); background:#243050; }

.pm-dspbox{
  margin-top:10px; border:1px dashed rgba(154,163,178,.35);
  border-radius:16px; padding:12px;
}
.pm-dsprow{ display:grid; grid-template-columns: 1fr 140px; gap:12px; }
.pm-dsp-quicksel{ display:flex; gap:6px; margin:10px 0 6px; flex-wrap:wrap; }
.btn-sm{ padding:5px 10px; font-size:12px; border-radius:10px; }
.pm-dsp-list{
  max-height:180px; overflow-y:auto; border:1px solid var(--line);
  border-radius:12px; padding:4px 6px; margin-top:4px;
}
.pm-dsp-item{
  display:flex; align-items:center; gap:8px;
  padding:5px 6px; border-radius:8px; font-size:13px; cursor:pointer;
  user-select:none;
}
.pm-dsp-item:hover{ background:rgba(255,255,255,.04); }
.pm-dsp-item.disabled{ opacity:.45; cursor:default; }
.pm-dsp-item input[type="checkbox"]{ width:auto; flex-shrink:0; cursor:pointer; }

.pm-actions{ display:flex; gap:10px; margin-top:14px; }

.pm-status-bar{
  display:flex; align-items:center; gap:10px;
  margin-top:10px; padding:10px 14px;
  border:1px solid rgba(43,99,255,.35); border-radius:12px;
  background:rgba(43,99,255,.07); font-size:13px; color:var(--text);
}
.pm-spinner{
  width:18px; height:18px; flex-shrink:0;
  border:2px solid rgba(43,99,255,.25);
  border-top-color:#2b63ff;
  border-radius:50%;
  animation:pm-spin .75s linear infinite;
}
@keyframes pm-spin{ to{ transform:rotate(360deg); } }

.pm-logs{
  background:#0c1020; border:1px solid var(--line);
  border-radius:16px; padding:10px; max-height:220px; overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:12px;
}

.log{ padding:4px 0; }
.log-ts{ color:#788196; }
.log-info{ color:#dce1ee; }
.log-warn{ color:#ffd17a; }
.log-error{ color:#ff7b86; }

/* Tree */
.tree-row{ display:flex; align-items:center; gap:10px; padding:6px 6px; border-radius:12px; }
.tree-row:hover{ background:rgba(255,255,255,.03); }

.tree-caret{
  width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center;
  background:rgba(255,255,255,.02); border:1px solid var(--line); border-radius:10px; color:var(--muted);
  cursor:pointer;
}
.tree-spacer{ width:26px; height:26px; }
.tree-cb{ width:16px; height:16px; }
.tree-label{ line-height:1.2; }

.tree-children{ margin-left:28px; border-left:1px solid rgba(35,42,61,.8); padding-left:10px; }
.tree-empty{ padding:6px 6px; }

.tree-tag{
  display:inline-block; font-size:11px; color:var(--muted);
  border:1px solid var(--line); padding:2px 6px; border-radius:999px; margin-right:6px;
  background:rgba(255,255,255,.02);
}

.muted{ color:var(--muted); }

.pm-warn{
  margin:10px; padding:10px; border-radius:14px;
  border:1px solid rgba(255,209,122,.35);
  color:#ffd17a; background:rgba(255,209,122,.06);
  font-size:12px;
}

/* Отключённый паблишер: видим, но помечен */
.tree-disabled .tree-label{ opacity:.6; }
.tree-badge-off{
  display:inline-block; font-size:10px; font-weight:700; letter-spacing:.04em;
  text-transform:uppercase; color:#ffd17a;
  border:1px solid rgba(255,209,122,.4); background:rgba(255,209,122,.08);
  padding:1px 6px; border-radius:999px; margin-left:6px;
}

/* Отключение от DSP */
.pm-hint{ font-size:12px; color:var(--muted); line-height:1.5; }
.pm-hint code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size:11px; background:rgba(255,255,255,.05); padding:1px 5px; border-radius:6px;
}
.pm-note-input{ margin-top:10px; font-size:13px; }

.pm-unlink-result:empty{ display:none; }
.pm-unlink-sum{
  margin-top:12px; padding:10px 12px; border-radius:12px;
  border:1px solid var(--line); background:rgba(255,255,255,.02); font-size:13px;
}
.pm-unlink-empty{ margin-top:12px; font-size:13px; color:var(--muted); }
.pm-unlink-stale{
  margin-top:12px; padding:10px 12px; border-radius:12px; font-size:13px;
  border:1px solid rgba(255,209,122,.35); color:#ffd17a; background:rgba(255,209,122,.06);
}
.pm-unlink-note{ margin-top:8px; font-size:11px; }
.pm-unlink-warn{
  margin-top:8px; padding:8px 10px; border-radius:10px; font-size:12px;
  border:1px solid rgba(255,209,122,.3); color:#ffd17a; background:rgba(255,209,122,.05);
}
.pm-unlink-table{
  width:100%; margin-top:10px; border-collapse:collapse; font-size:12px;
  display:block; max-height:240px; overflow-y:auto;
}
.pm-unlink-table th{
  text-align:left; color:var(--muted); font-weight:500; padding:6px 8px;
  border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--card2);
}
.pm-unlink-table td{ padding:6px 8px; border-bottom:1px solid rgba(35,42,61,.5); }
.pm-unlink-table .num{ text-align:right; white-space:nowrap; }

/* История отключений */
.pm-h3-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.pm-h3-row .pm-h3{ margin-bottom:0; }
.pm-history{ margin-top:10px; max-height:260px; overflow-y:auto; }
.pm-hist-row{
  display:flex; align-items:center; gap:10px;
  padding:10px; border:1px solid var(--line); border-radius:12px; margin-bottom:8px;
  background:rgba(255,255,255,.02);
}
.pm-hist-main{ flex:1; min-width:0; }
.pm-hist-title{ font-size:13px; font-weight:600; }
.pm-hist-meta{ font-size:11px; margin-top:3px; }
.pm-hist-note{ font-size:12px; margin-top:4px; color:var(--text); opacity:.8; }
.pm-hist-revert{ flex-shrink:0; }
.pm-hist-badge{
  display:inline-block; font-size:10px; font-weight:600; text-transform:uppercase;
  padding:2px 7px; border-radius:999px; margin-left:6px; letter-spacing:.03em;
}
.pm-hist-badge.ok{ color:#7ee2a8; border:1px solid rgba(126,226,168,.35); background:rgba(126,226,168,.08); }
.pm-hist-badge.reverted{ color:#9aa3b2; border:1px solid var(--line); background:rgba(255,255,255,.03); }
.pm-hist-badge.fail{ color:#ff7b86; border:1px solid rgba(255,123,134,.35); background:rgba(255,123,134,.08); }

@media (max-width: 1100px){
  .pm-layout{ grid-template-columns: 1fr; }
  .pm-left{ min-height:auto; }
  .pm-tree{ max-height: 360px; }
}
