/* Underground broadcast UI — SPAMIMPAKTER */
#tab-broadcast,
#tab-parsing,
#toolParsing,
#ugBroadcastModals,
#ugParserModals,
.ug-broadcast-tab {
  --bg-dark: #0a0a0a;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --border: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --primary: #f59e0b;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --input-bg: #1a1a1a;
  --text: #ffffff;
  --accent-dim: #cccccc;
}

#tab-broadcast.tab.active,
#tab-parsing.tab.active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.ug-broadcast-tab {
  background: var(--bg-dark);
}

.bc-page-header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.bc-summary-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.bc-summary-chip {
  flex: 1;
  min-width: 90px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.bc-summary-chip:hover { border-color: var(--primary); background: rgba(255,255,255,0.06); }
.bc-summary-chip.active { border-color: var(--primary); background: rgba(200,245,66,0.08); }

.bc-summary-chip .val {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--primary);
}

.bc-summary-chip .lbl {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Поиск в тулбаре рассылки */
.bc-tb-search {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
  height: 32px;
  padding: 0 12px;
  background: var(--input-bg, #1a1a1a);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.bc-tb-search:focus { border-color: var(--primary); }
.bc-tb-search::placeholder { color: var(--text-secondary); }

/* Закрепляемые чипы статусов внутри панели управления (строка 2) */
#broadcastStatusQuick {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Карточка задачи: строка источника + подписи к метрикам */
#tab-broadcast .job-card-meta { justify-content: flex-start; gap: 5px 14px; }
.job-card-source {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-secondary);
  margin-bottom: 6px;
}
.job-card-source .bc-ico { width: 13px; height: 13px; opacity: .7; flex-shrink: 0; }
.job-card-meta .bc-mi b { color: var(--text); font-weight: 700; }

/* Контейнер модалок — поверх всего приложения */
#ugBroadcastModals {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

#ugBroadcastModals .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
  z-index: 10001;
}

#ugBroadcastModals .modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Внутренний блок — НЕ fixed (иначе style.css ломает центр) */
#ugBroadcastModals .modal-overlay > .modal {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  width: min(850px, 100%);
  max-width: 850px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  margin: 0;
  flex-shrink: 0;
  display: block;
  z-index: 1;
}

#ugBroadcastModals #broadcastDetailsModal.modal-overlay > .modal {
  max-width: 720px;
  width: min(720px, 100%);
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
}

/* ── Детали задачи рассылки: sticky-шапка + скролл-тело + sticky-футер ── */
.bcd-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.bcd-title {
  font-size: 1.05rem; font-weight: 700; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bcd-close {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  font-size: 1.05rem; line-height: 1; padding: 6px 9px; border-radius: 8px; flex-shrink: 0;
}
.bcd-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.bcd-body { padding: 16px 20px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }

.bcd-hint {
  margin-bottom: 12px; padding: 8px 12px; border-radius: 8px;
  font-size: 0.78rem; line-height: 1.4;
}
.bcd-hint--info { background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-secondary); }
.bcd-hint--warn { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.35); color: #f59e0b; }
.bcd-hint--err  { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.4); color: #fc8181; }

.bcd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.bcd-stat { background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px; padding: 10px 6px; text-align: center; }
.bcd-stat-val { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.bcd-stat-lbl { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); margin-top: 3px; }
.bcd-stat--ok .bcd-stat-val { color: var(--success); }
.bcd-stat--err .bcd-stat-val { color: var(--error); }
.bcd-stat--warn .bcd-stat-val { color: var(--warning); }
.bcd-stat--queue .bcd-stat-val { color: var(--text-primary); }

.bcd-section { margin-bottom: 16px; }
.bcd-section:last-child { margin-bottom: 0; }
.bcd-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 10px; }
.bcd-section-head h3 { font-size: 0.74rem; font-weight: 600; color: var(--text-secondary); margin: 0; text-transform: uppercase; letter-spacing: .04em; }

.bcd-accounts { display: flex; flex-direction: column; gap: 4px; max-height: 170px; overflow-y: auto; }
.bcd-acc { display: flex; justify-content: space-between; align-items: center; padding: 5px 9px; background: var(--bg-hover); border-radius: 6px; font-size: 0.8rem; gap: 8px; }

.bcd-logs {
  max-height: 280px; overflow-y: auto; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 0.74rem; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.bcd-muted { color: var(--text-secondary); text-align: center; padding: 10px; }

.bcd-mini-btn { padding: 4px 9px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); cursor: pointer; font-size: 0.72rem; font-family: inherit; }
.bcd-mini-btn:hover { border-color: var(--primary); }

.bcd-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.bcd-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg-hover);
  color: var(--text-primary); cursor: pointer; font-size: 0.8rem; font-family: inherit;
  transition: border-color .15s, background .15s, filter .15s;
}
.bcd-btn:hover { border-color: var(--primary); }
.bcd-btn--start { background: var(--success); border-color: var(--success); color: #06210f; font-weight: 700; flex: 1; justify-content: center; min-width: 130px; }
.bcd-btn--start:hover { filter: brightness(1.08); border-color: var(--success); }
.bcd-btn--stop { background: var(--error); border-color: var(--error); color: #fff; font-weight: 700; flex: 1; justify-content: center; min-width: 120px; }
.bcd-btn--stop:hover { filter: brightness(1.08); border-color: var(--error); }
.bcd-btn--warn { color: var(--warning); border-color: rgba(245,158,11,0.4); }
.bcd-btn--warn:hover { background: rgba(245,158,11,0.12); border-color: var(--warning); }
.bcd-btn--danger { color: var(--error); border-color: rgba(239,68,68,0.4); }
.bcd-btn--danger:hover { background: rgba(239,68,68,0.12); border-color: var(--error); }
.bcd-btn--wait { flex: 1; justify-content: center; opacity: .55; cursor: default; }
.bcd-actions-spacer { flex: 1 1 12px; }

#ugParserModals .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
  z-index: 10001;
}

#ugParserModals .modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#ugParserModals .modal-overlay > .modal {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  width: min(900px, 100%);
  max-width: 900px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  margin: 0;
  flex-shrink: 0;
  display: block;
  z-index: 1;
}

body.ug-bc-modal-open {
  overflow: hidden;
}

.job-card {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.job-card:hover {
  border-color: var(--primary) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  box-shadow: 0 2px 12px rgba(255, 165, 0, 0.08);
}

.job-card:active {
  background: rgba(255, 255, 255, 0.06) !important;
}

.btn-small {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.btn-small.btn-primary {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 600;
}

.btn-small.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.btn-small.btn-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.35);
}

#ugParserModals {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.status-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 165, 0, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: status-spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 2px;
}

@keyframes status-spin {
  to {
    transform: rotate(360deg);
  }
}

.glow-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.3s ease;
  z-index: 1;
}

.glow-btn:hover {
  transform: translateY(-2px);
}

.glow-btn:active {
  transform: scale(0.95) translateY(0);
}

.glow-btn::before {
  content: '';
  position: absolute;
  inset: -150%;
  z-index: -2;
  animation: glow-spin 2s linear infinite;
}

.glow-btn::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 6px;
  z-index: -1;
  transition: background 0.3s ease;
}

@keyframes glow-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    opacity: 0.85;
    filter: brightness(1.2);
  }
}

.glow-btn-start::before {
  background: conic-gradient(
    from 90deg at 50% 50%,
    #f59e0b 0%,
    #fbbf24 20%,
    #fcd34d 40%,
    #f59e0b 60%,
    #d97706 80%,
    #f59e0b 100%
  );
}

.glow-btn-start::after {
  background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
}

.glow-btn-start {
  color: #f59e0b;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3), inset 0 0 20px rgba(245, 158, 11, 0.1);
  animation: glow-pulse 2s ease-in-out infinite;
}

.glow-btn-stop::before {
  background: conic-gradient(
    from 90deg at 50% 50%,
    #dc2626 0%,
    #ef4444 20%,
    #f87171 40%,
    #ef4444 60%,
    #b91c1c 80%,
    #dc2626 100%
  );
}

.glow-btn-stop::after {
  background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
}

.glow-btn-stop {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), inset 0 0 20px rgba(239, 68, 68, 0.1);
  animation: glow-pulse 1.5s ease-in-out infinite;
}

.glow-btn-create::before {
  background: conic-gradient(
    from 90deg at 50% 50%,
    #f59e0b 0%,
    #fbbf24 20%,
    #fde68a 40%,
    #fbbf24 60%,
    #d97706 80%,
    #f59e0b 100%
  );
}

.glow-btn-create::after {
  background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
}

.glow-btn-create {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.4), inset 0 0 20px rgba(245, 158, 11, 0.1);
  animation: glow-pulse 2s ease-in-out infinite;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.status-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

#tab-broadcast select,
#ugBroadcastModals select,
#ugBroadcastModals input,
#ugBroadcastModals textarea {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.bc-jobs-loading {
  padding: 48px;
  text-align: center;
  color: var(--text-secondary);
}

.bc-jobs-loading .status-spinner {
  width: 22px;
  height: 22px;
  border-width: 3px;
  margin: 0 auto 12px;
  display: block;
}
