/* LeadScaner admin UI — минимальные стили, без design system.
 * Базовый визуальный baseline: читаемый шрифт, ограничение ширины main, простая форма.
 */

html {
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* Phase 5.1: legacy global styles (body, header, main, form) removed — design system now lives in tokens.css + components.css. */

/* visually-hidden helper used by aria-only labels in some pages */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Page wrapper — width + padding для всех страниц через base.html <main class="page">. */
html, body { overflow-x: hidden; }
body { min-height: 100vh; }
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}
@media (max-width: 768px) {
  .page { padding: 16px 12px; }
}

/* Page header — uniform pattern across all pages. */
.page__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page__title { margin: 0 0 4px; }
.page__sub { color: var(--text-secondary); font-size: var(--fs-sm); max-width: 720px; }
.page__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Topnav mobile collapse — links scroll horizontally with -webkit-overflow-scrolling for iOS. */
.topnav__links {
  display: flex; align-items: center; gap: 4px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.topnav__links::-webkit-scrollbar { display: none; }
.topnav__link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-control, var(--radius-md));
  color: var(--nav-text);
  text-decoration: none;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topnav__link:hover { background: rgba(255,255,255,0.06); color: var(--nav-text-active); }
.topnav__link.is-active { background: rgba(255,255,255,0.08); color: var(--nav-text-active); }
.topnav__brand .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-500); margin-right: 8px; vertical-align: middle;
}
.topnav__right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.topnav__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  color: var(--nav-text);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.topnav__chip .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success-500);
  box-shadow: 0 0 0 0 var(--success-500);
  animation: ls-pulse 2s ease-out infinite;
}
@keyframes ls-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.topnav__user {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-500); color: white;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-decoration: none;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .topnav { padding: 0 12px; gap: 12px; }
  .topnav__chip { display: none; }  /* keep brand+nav+user visible on tiny screens */
}

/* Badge count для топ-нав счётчиков. */
.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-500); color: white;
  font-size: 10px; font-weight: var(--fw-semibold);
  margin-left: 4px;
}

/* Table responsive helper — добавлять class="hide-mobile" на низкоприоритетные колонки. */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  /* Table — позволяем горизонтальный скролл если много колонок. */
  .table-wrap { overflow-x: auto; }
  /* Filterbar — каждое поле на полную ширину. */
  .filterbar { flex-direction: column; align-items: stretch; }
  .filterbar .field { flex: 1 1 auto; width: 100%; }
}

/* Hotkey hint footer (used on /leads). */
.hotkeys-hint {
  display: flex; gap: 16px;
  margin-top: 16px;
  padding: 8px 4px;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.hotkeys-hint .kbd { margin-right: 2px; }
@media (max-width: 768px) {
  .hotkeys-hint { display: none; }  /* hotkeys irrelevant on touch */
}

/* Lead avatar circle (used in /leads list). */
.lead-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-50); color: var(--accent-700);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  flex-shrink: 0;
}

/* Score-bar (filled progress strip). */
.score-bar {
  display: inline-block; width: 56px; height: 4px;
  border-radius: var(--radius-pill);
  background: var(--gray-150);
  overflow: hidden;
  vertical-align: middle;
}
.score-bar__fill { display: block; height: 100%; background: var(--accent-500); }

/* Niche tag (small accent pill). */
.niche-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-50); color: var(--accent-700);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
}

/* Empty state — override components.css to use full container width on mobile. */
.empty { padding: 32px 16px; }
.empty__body { max-width: min(380px, 100%); }
/* Empty state inside table — sticky-left so it stays visible when table scrolls horizontally. */
@media (max-width: 768px) {
  .table-wrap td .empty {
    position: sticky;
    left: 0;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
  }
  .table-wrap td .empty__body { max-width: 100%; }
}

/* Stepper for wizards (e.g., /settings/accounts). */
.stepper { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.stepper__item { display: inline-flex; align-items: center; gap: 8px; color: var(--text-tertiary); font-size: var(--fs-sm); }
.stepper__item.is-active { color: var(--text-primary); font-weight: var(--fw-medium); }
.stepper__item.is-done { color: var(--success-700); }
.stepper__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-sunken); color: var(--text-tertiary);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
}
.stepper__item.is-active .stepper__num { background: var(--accent-500); color: white; }
.stepper__item.is-done .stepper__num { background: var(--success-500); color: white; }
.stepper__line { width: 24px; height: 1px; background: var(--border-default); }

/* KPI strip layout helper. */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Filterbar — override default label hiding so non-technical operator sees what each field is. */
.filterbar { align-items: flex-end; }
.filterbar .field {
  display: flex; flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}
.filterbar .field__label {
  display: block !important;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  margin: 0;
}
.filterbar .field__hint { display: none; }
/* Cap multi-select height inside filterbar — компактный размер для desktop. */
.filterbar select[multiple] {
  height: auto;
  min-height: var(--control-h, 34px);
  max-height: 120px;
}

/* Card header padding fix — design tokens leave padding 16px 20px, but if header has no border below we want to match body padding. */
.card .card__body > .field + .field { margin-top: 12px; }

/* Setting row — used on /settings/* — label left, control right with hint below. */
.setting-row {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 24px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  align-items: start;
}
.setting-row:first-child { border-top: 0; }
.setting-row__label { font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.setting-row__hint { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.setting-row__control { min-width: 0; }
.setting-row__control .field__hint { margin-top: 4px; }
@media (max-width: 768px) {
  .setting-row { grid-template-columns: 1fr; gap: 8px; padding: 12px 16px; }
}

[role="alert"],
.error {
  color: #b00020;
  background: #fdecea;
  padding: 0.5em 0.75em;
  border-radius: 3px;
  border: 1px solid #fbbcb3;
}

/* Login card — centered, narrow, hides nav distraction */
.login-card {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}
.login-card .login-hint {
  color: #666;
  font-size: 0.9em;
  margin: 0 0 1.5rem;
}
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-card label { font-size: 0.9em; color: #333; }
.login-card input[type="password"] {
  padding: 0.6em 0.75em;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}
.login-card input[type="password"]:focus {
  outline: 2px solid #1a1a1a;
  outline-offset: -1px;
  border-color: transparent;
}
.login-card .btn-primary,
.login-card button[type="submit"] {
  margin-top: 0.5rem;
  padding: 0.7em;
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}
.login-card .btn-primary:hover,
.login-card button[type="submit"]:hover { background: #333; }

code {
  background: #eee;
  padding: 0.1em 0.3em;
  border-radius: 2px;
  font-size: 0.95em;
}

a {
  color: #1866c0;
}

a:hover,
a:focus {
  text-decoration: underline;
}

/* ============================================================
 * Phase 2 / Plan 11 — /leads, /leads/{id}, /listeners styles
 * ============================================================ */

.filter-form {
  display: block;
  max-width: none;
}

.filter-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  font-size: 0.9em;
  min-width: 8em;
}

.filter-row input,
.filter-row select {
  padding: 0.4em;
  font-size: 0.95em;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.leads-table,
.listeners-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.leads-table th,
.leads-table td,
.listeners-table th,
.listeners-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
  vertical-align: middle;
}

.leads-table tr.lead-row.lead-high-score {
  background: #fffaea;
}

.score-bar {
  position: relative;
  width: 80px;
  height: 16px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.score-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #f39c12, #27ae60);
}

.score-value {
  position: relative;
  z-index: 1;
  padding: 0 0.5rem;
  font-size: 0.8em;
  line-height: 16px;
  color: #1a1a1a;
}

.status {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.85em;
}

.status-pending_review { background: #ffefc6; }
.status-approved       { background: #d4f4d1; }
.status-sent           { background: #cfe0ff; }
.status-responded      { background: #a0d995; }
.status-rejected       { background: #f5c8c1; }
.status-skipped        { background: #e8e8e8; }
.status-failed         { background: #f5c8c1; }
.status-active         { background: #d4f4d1; }
.status-pending_auth   { background: #ffefc6; }
.status-disabled       { background: #e8e8e8; }
.status-banned         { background: #f5c8c1; }
.status-flood_wait     { background: #fff4c6; }
.status-shadow_banned  { background: #f5c8c1; }

.badge-layer {
  font-size: 0.75em;
  padding: 1px 6px;
  background: #f0f0f0;
  border-radius: 2px;
}

.empty-state,
.loading-more {
  text-align: center;
  color: #888;
  padding: 1.25rem;
}

.heartbeat-ok          { background: #f6fff2; }
.heartbeat-stale       { background: #fff8e0; }
.heartbeat-never_seen  { background: #f5f5f5; }
.heartbeat-stopped     { background: #ffeded; }

.badge-ok       { color: #27ae60; font-weight: 500; }
.badge-warn     { color: #e67e22; font-weight: 500; }
.badge-err      { color: #c0392b; font-weight: 500; }
.badge-neutral  { color: #888; }

.help {
  margin-top: 1rem;
  color: #666;
  font-size: 0.9em;
}

/* Lead detail page (Plan 11 Task 2) */

.lead-detail section {
  margin-bottom: 2rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
}

.lead-detail h2 {
  margin-top: 0;
  font-size: 1.15em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid #eee;
}

.lead-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.lead-meta > span {
  padding: 2px 8px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  font-size: 0.9em;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
}

.warning-banner {
  background: #fff4c6;
  border: 1px solid #e0a000;
  padding: 0.75rem;
  border-radius: 4px;
  margin: 1rem 0;
}

.warning-banner button {
  margin-left: 1rem;
  padding: 4px 12px;
  cursor: pointer;
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 3px;
  font-size: 0.9em;
}

.warning-banner button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lead-detail dl dt {
  font-weight: 600;
  margin-top: 0.5rem;
}

.lead-detail dl dd {
  margin-left: 1rem;
  margin-bottom: 0.5rem;
}

.lead-detail details pre {
  background: #f5f5f5;
  padding: 0.5rem;
  overflow-x: auto;
  max-height: 400px;
  border-radius: 3px;
  font-size: 0.85em;
}

.score-bar-big {
  width: 100%;
  height: 24px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.score-fill-big {
  height: 100%;
  background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
}

.breakdown {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.75rem 0 0;
}

.breakdown-item {
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 0.9em;
}

.breakdown-green   { background: #d4f4d1; color: #1e5020; }
.breakdown-red     { background: #f5c8c1; color: #5a1410; }
.breakdown-neutral { background: #eaeaea; color: #333; }

.score-badge {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.85em;
}

.score-high { background: #d4f4d1; }
.score-mid  { background: #fff4c6; }
.score-low  { background: #f5c8c1; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  margin-right: 0.25rem;
}

.chip-warn {
  background: #fff4c6;
  border: 1px solid #e0a000;
  color: #a06000;
}

.profile-block {
  background: #f0f8ff;
  padding: 0.75rem;
  border-radius: 4px;
}

.main-nav {
  display: inline-flex;
  gap: 1rem;
  margin-left: 1.5rem;
}

.main-nav a {
  color: #ddd;
  text-decoration: none;
  font-size: 0.95em;
}

.main-nav a:hover,
.main-nav a:focus {
  color: #fff;
  text-decoration: underline;
}

/* ============================================================
 * Phase 3 additions (Plan 03-08) — per UI-SPEC §CSS additions.
 * Accent color discipline: #1a1a1a solid bg reserved for .btn-primary only.
 * ============================================================ */

/* Countdown timer — tabular-nums for stable width during tick */
.countdown {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  color: #1a1a1a;
}

/* HTMX indicator — fade-in when request in flight */
.htmx-indicator {
  display: inline-block;
  opacity: 0;
  transition: opacity 200ms;
  margin-left: 0.5em;
}
.htmx-request .htmx-indicator { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .htmx-indicator { transition: none; }
}

/* Primary button — accent reserved for 6 CTA locations per UI-SPEC §Color */
.btn-primary {
  padding: 8px 20px;
  min-height: 40px;
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus { background: #333; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Secondary button — outlined, preserves accent scarcity */
.btn-secondary {
  padding: 8px 16px;
  min-height: 36px;
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
}
.btn-secondary:hover, .btn-secondary:focus { background: #f0f0f0; }

/* Destructive button — outlined red (Reject, Remove, Delete) */
.btn-destructive {
  padding: 8px 16px;
  min-height: 36px;
  background: transparent;
  color: #c0392b;
  border: 1px solid #fbbcb3;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
}
.btn-destructive:hover, .btn-destructive:focus { background: #fdecea; }

/* Action buttons grouping */
.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

/* Modal — policy dry-run, focus-trapped */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
/* Honor HTML5 hidden attribute (Phase 6 fix — score-detail/golden modals start hidden). */
.modal-backdrop[hidden] {
  display: none !important;
}
.modal {
  background: #fff;
  padding: 24px;
  border-radius: 4px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.modal h2 { margin-top: 0; }

/* Data table — shared across templates/policy/blocklist/shadow-ban pages */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.data-table th, .data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  font-weight: 600;
  font-size: 14px;
  color: #666;
  background: #f5f5f5;
}

/* Responsive main widths for Phase 3 wider tables */
@media (min-width: 1024px) { main { max-width: 1100px; } }
@media (min-width: 1440px) { main { max-width: 1280px; } }
@media (min-width: 1440px) {
  .lead-action-panel {
    position: sticky;
    top: 16px;
  }
}

/* Table scroll wrapper for narrow screens */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Reply char count helper */
.reply-char-count {
  font-size: 14px;
  color: #666;
}
.reply-char-count.over-limit { color: #c0392b; font-weight: 600; }

/* Success chip — policy dry-run green */
.success-chip {
  display: inline-block;
  padding: 4px 12px;
  background: #d4f4d1;
  color: #1e5020;
  border-radius: 3px;
  font-size: 14px;
}

/* Success banner (template add confirmation) */
.success-banner {
  padding: 12px 16px;
  background: #d4f4d1;
  border: 1px solid #27ae60;
  color: #1e5020;
  border-radius: 3px;
  margin-bottom: 16px;
}

/* Global shadow-ban banner */
.shadow-ban-global {
  background: #fdecea;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 1px solid #fbbcb3;
}

/* ============================================================
 * Phase 4 additions — Inbox + Webhooks + opt-out + business-bot status
 * Inherits Phase 3 tokens. Adds only new surfaces / states.
 * ============================================================ */

/* --- Inbox page --- */
.inbox-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .inbox-layout {
    grid-template-columns: 1fr 280px;
  }
}

.inbox-unlinked-section {
  position: sticky;
  top: 16px;
  background: #fff4c6;
  border: 1px solid #e0a000;
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 24px;
  z-index: 10;
}

.inbox-unlinked-section h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: #a06000;
}

.inbox-card {
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: default;
}
.inbox-card[data-unlinked="true"] {
  cursor: grab;
}
.inbox-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* --- Drop targets (lead sidebar) --- */
#open-leads-sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 16px;
}
.lead-drop-target {
  display: block;
  padding: 16px;
  min-height: 64px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 3px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
}
.lead-drop-target:focus-visible {
  outline: 2px solid #1866c0;
  outline-offset: 2px;
}
.lead-drop-target.drop-hover {
  outline: 3px dashed #1866c0;
  outline-offset: -3px;
  background: #eef5ff;
}

/* --- Timeline (Переписка в ЛС) --- */
.inbox-thread summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 0;
}
.inbox-thread summary::-webkit-details-marker { display: none; }
.inbox-thread summary h2 {
  display: inline-block;
  margin: 0;
  font-size: 18px;
}
.inbox-thread summary::before {
  content: "▸ ";
  color: #666;
}
.inbox-thread details[open] summary::before {
  content: "▾ ";
}
.timeline {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}
.timeline-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: #fafafa;
}
.timeline-item.direction-in {
  margin-left: 0;
  margin-right: 24px;
}
.timeline-item.direction-out {
  margin-left: 24px;
  margin-right: 0;
  background: #eef5ff;
}
.direction-badge {
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin-right: 8px;
}
.timeline-item.direction-in .direction-badge {
  background: #f0f0f0;
  color: #666;
}
.timeline-item.direction-out .direction-badge {
  background: #1866c0;
  color: #fff;
}
.badge-first-response {
  display: inline-block;
  padding: 4px 8px;
  background: #d4f4d1;
  color: #1e5020;
  border-radius: 4px;
  font-size: 14px;
  margin-left: 8px;
}
.timeline-text {
  margin: 8px 0 0 0;
  font-size: 16px;
  line-height: 1.5;
}
.timeline-item time {
  font-size: 14px;
  color: #666;
  font-variant-numeric: tabular-nums;
}
.open-in-telegram {
  display: inline-block;
  margin-top: 4px;
  font-size: 14px;
}

/* --- Business-bot status dot --- */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.status-dot-connected    { background: #27ae60; }
.status-dot-stale        { background: #d06b14; } /* darker shade of #e67e22 for 3:1 graphical contrast */
.status-dot-disconnected { background: #c0392b; }

/* --- SSRF / form field error --- */
.input-error {
  border: 1px solid #c0392b !important;
}
.field-error {
  color: #c0392b;
  font-size: 14px;
  margin-top: 4px;
}

/* --- Webhooks deliveries journal status cells --- */
.delivery-status-delivered  { color: #1e5020; }
.delivery-status-retrying   { color: #a06000; }
.delivery-status-failed     { color: #c0392b; }
.delivery-status-pending    { color: #666; }
.delivery-status-cell {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
}

/* --- One-time secret reveal --- */
.secret-reveal {
  padding: 16px;
  background: #fff4c6;
  border: 1px solid #e0a000;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  word-break: break-all;
}
.secret-reveal code {
  display: block;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 3px;
  margin: 8px 0;
}

/* ============================================================
 * Phase 5 additions — Onboarding + Listener-chats Manager
 * Inherits Phase 4 tokens. Adds 11 status chips + progress bars + dialog-row states.
 * ============================================================ */

/* --- 11 onboarding status chips (D-22 taxonomy) --- */
.status-onb-pending          { background: #e8e8e8; color: #666; }
.status-onb-assigned         { background: #cfe0ff; color: #1a4a8e; }
.status-onb-joining          { background: #cfe0ff; color: #1a4a8e; }
.status-onb-joined           { background: #d4f4d1; color: #1e5020; }
.status-onb-failed           { background: #fdecea; color: #c0392b; }
.status-onb-skipped          { background: #e8e8e8; color: #666; }
.status-onb-already-member   { background: #d4f4d1; color: #1e5020; }
.status-onb-already-tracked  { background: #e8e8e8; color: #666; }
.status-onb-flood-wait       { background: #fff4c6; color: #a06000; }
.status-onb-pending-approval { background: #cfe0ff; color: #1a4a8e; }

/* --- Per-listener progress cards --- */
.listener-progress-section {
  margin-bottom: 24px;
}
.listener-progress-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 1024px) {
  .listener-progress-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}
.listener-progress-card {
  padding: 16px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
.listener-name {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-counter {
  font-size: 14px;
  color: #666;
  margin: 8px 0 4px;
}
.progress-bar {
  width: 100%;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #1866c0;
  transition: width 300ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}

/* --- Dialog-row states on /listeners/<name>/chats --- */
.dialog-row.row-excluded {
  background: #f5f5f5;
  opacity: 0.7;
}
.dialog-row .action-buttons {
  margin-top: 0;
}

/* --- Generic chip variants used across Phase 5 --- */
.chip-success {
  background: #d4f4d1;
  color: #1e5020;
  border: 1px solid #27ae60;
}
.chip-neutral {
  background: #e8e8e8;
  color: #666;
  border: 1px solid #ccc;
}

/* --- Info banner (Phase 5 introduces — quiet hours indicator) --- */
.info-banner {
  background: #cfe0ff;
  border: 1px solid #1a4a8e;
  color: #1a4a8e;
  padding: 16px;
  border-radius: 4px;
  margin: 1rem 0;
}

/* --- Disabled destructive button preserves visual weight (D-15 read_only_strict) --- */
.btn-destructive:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Invalid-URLs collapsible section --- */
.invalid-urls-section {
  background: #fdecea;
  border: 1px solid #fbbcb3;
  padding: 16px;
  border-radius: 4px;
  margin: 16px 0;
}
.invalid-urls-section summary {
  cursor: pointer;
  color: #c0392b;
}
.invalid-urls-section ul {
  margin: 8px 0 0 0;
  padding-left: 24px;
}
.invalid-urls-section code {
  background: #fff;
  border: 1px solid #fbbcb3;
}

/* --- Leave-success fade-out for dialog row --- */
.dialog-row.leaving {
  opacity: 0.5;
  transition: opacity 300ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .dialog-row.leaving { transition: none; opacity: 0; }
}

/* --- Listener-progress card chip alignment --- */
.listener-name .chip {
  font-size: 11px;
  padding: 4px 8px;
}

