:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f0f3f7;
  --text: #182230;
  --muted: #64748b;
  --line: #d7dee8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --success: #166534;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --panel: #191b1f;
  --panel-2: #22252a;
  --text: #f2f4f7;
  --muted: #a4abb6;
  --line: #32363d;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --blue: #93c5fd;
  --success: #86efac;
  --danger: #fca5a5;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body[data-theme="dark"] .login-view {
  background: #0c100f;
}

body[data-theme="dark"] .primary-btn {
  color: #06201d;
}

body[data-theme="dark"] .secondary-btn,
body[data-theme="dark"] .icon-btn,
body[data-theme="dark"] .danger-btn,
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .search-input,
body[data-theme="dark"] .select-input {
  background: #121417;
  color: var(--text);
  border-color: var(--line);
}

body[data-theme="dark"] .segmented-control {
  background: #121417;
}

body[data-theme="dark"] .segmented-control button.active,
body[data-theme="dark"] .lead-table th,
body[data-theme="dark"] .kanban-column-head,
body[data-theme="dark"] .lead-kanban-card,
body[data-theme="dark"] .settings-list-item,
body[data-theme="dark"] .budget-card,
body[data-theme="dark"] .budget-forecast span,
body[data-theme="dark"] .budget-ops div {
  background: #22252a;
}

body[data-theme="dark"] .lead-table tbody tr:hover,
body[data-theme="dark"] .lead-table tbody tr.selected,
body[data-theme="dark"] .lead-kanban-card:hover,
body[data-theme="dark"] .lead-kanban-card.selected {
  background: #20302f;
}

body[data-theme="dark"] .app-shell,
body[data-theme="dark"] .main {
  background: var(--bg);
}

body[data-theme="dark"] .sidebar {
  background: #141519;
  border-right-color: #2b2f36;
  color: var(--text);
}

body[data-theme="dark"] .brand-subtitle {
  color: #9da5b1;
}

body[data-theme="dark"] .nav-item {
  color: #c5cad3;
}

body[data-theme="dark"] .nav-item.active,
body[data-theme="dark"] .nav-item:hover {
  background: #252932;
  color: #ffffff;
}

body[data-theme="dark"] .language-switch,
body[data-theme="dark"] .mode-switch,
body[data-theme="dark"] .theme-switch,
body[data-theme="dark"] .table-panel,
body[data-theme="dark"] .detail-panel,
body[data-theme="dark"] .section-block,
body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .kanban-column,
body[data-theme="dark"] .dialog,
body[data-theme="dark"] .login-panel {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .table-panel.flat {
  background: var(--panel);
}

body[data-theme="dark"] .lead-detail-shell,
body[data-theme="dark"] .lead-detail-modal-head,
body[data-theme="dark"] .lead-journey,
body[data-theme="dark"] .lead-journey-dot {
  background: #191b1f;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .lead-conversation-compose.has-agent-draft {
  background: #2a1d21;
  border-color: #7f3745;
}

body[data-theme="dark"] .lead-draft-label {
  color: #f5a6b5;
}

body[data-theme="dark"] .lead-table tbody tr,
body[data-theme="dark"] .lead-table td {
  background: var(--panel);
  color: var(--text);
}

body[data-theme="dark"] .lead-table tbody tr:nth-child(even) td {
  background: #1c1f24;
}

body[data-theme="dark"] .lead-table tbody tr:hover td,
body[data-theme="dark"] .lead-table tbody tr.selected td {
  background: #20302f;
}

body[data-theme="dark"] .source-card,
body[data-theme="dark"] .purpose-card,
body[data-theme="dark"] .action-required-item,
body[data-theme="dark"] .booking-slot-item,
body[data-theme="dark"] .control-item,
body[data-theme="dark"] .setup-item,
body[data-theme="dark"] .setup-card,
body[data-theme="dark"] .check-item,
body[data-theme="dark"] .pilot-queue-item,
body[data-theme="dark"] .command-block,
body[data-theme="dark"] .partner-card,
body[data-theme="dark"] .funnel-step,
body[data-theme="dark"] .queue-tab,
body[data-theme="dark"] .queue-item,
body[data-theme="dark"] .event-row,
body[data-theme="dark"] .quick-panel,
body[data-theme="dark"] .telegram-account-card,
body[data-theme="dark"] .audit-card,
body[data-theme="dark"] .empty,
body[data-theme="dark"] .compact-empty,
body[data-theme="dark"] .modal-card,
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .discovery-source-card,
body[data-theme="dark"] .source-input-item,
body[data-theme="dark"] .communication-panel,
body[data-theme="dark"] .lead-source-reason,
body[data-theme="dark"] .settings-list-item {
  background: #1f2227;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .explain-panel,
body[data-theme="dark"] .candidate-review-warning {
  background: #1f2227;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .source-input-item strong,
body[data-theme="dark"] .source-input-item p,
body[data-theme="dark"] .source-input-item .muted,
body[data-theme="dark"] .explain-panel,
body[data-theme="dark"] .explain-panel p {
  color: var(--text);
}

body[data-theme="dark"] .source-input-item .muted,
body[data-theme="dark"] .source-input-item p,
body[data-theme="dark"] .explain-panel span {
  color: var(--muted);
}

body[data-theme="dark"] .funnel-step:hover,
body[data-theme="dark"] .queue-item:hover,
body[data-theme="dark"] .event-row:hover,
body[data-theme="dark"] .queue-tab.active,
body[data-theme="dark"] .link-btn:hover {
  background: #20302f;
  border-color: var(--accent);
}

body[data-theme="dark"] .link-btn {
  background: #202329;
  color: var(--text);
}

body[data-theme="dark"] .budget-panel {
  background: #17191d;
  border-color: var(--line);
}

body[data-theme="dark"] .budget-card,
body[data-theme="dark"] .budget-forecast span,
body[data-theme="dark"] .budget-ops div {
  background: #202329;
  border-color: #383d45;
  color: var(--text);
}

body[data-theme="dark"] .report-box {
  background: #101114;
  color: #e5e7eb;
}

body[data-theme="dark"] .explain-panel span {
  color: var(--muted);
}

body[data-theme="dark"] .candidate-draft-lint-ok {
  background: #13271c;
  border-color: #295c3a;
  color: #bbf7d0;
}

body[data-theme="dark"] .candidate-draft-lint-warn {
  background: #2c2114;
  border-color: #7c4a1f;
  color: #fed7aa;
}

body[data-theme="dark"] .secondary-btn,
body[data-theme="dark"] .icon-btn {
  background: #202329;
}

body[data-theme="dark"] .secondary-btn:hover,
body[data-theme="dark"] .icon-btn:hover {
  background: #2a2f36;
}

body[data-theme="dark"] .danger-btn {
  background: #2a1718;
  color: #fecaca;
  border-color: #653236;
}

body[data-theme="dark"] .pill.blue {
  background: #15345f;
  color: #bfdbfe;
}

body[data-theme="dark"] .pill.green {
  background: #123524;
  color: #bbf7d0;
}

body[data-theme="dark"] .pill.red {
  background: #3b1518;
  color: #fecaca;
}

body[data-theme="dark"] .lead-kanban-card,
body[data-theme="dark"] .task-card,
body[data-theme="dark"] .warm-touch-card,
body[data-theme="dark"] .action-required-item,
body[data-theme="dark"] .conversation-item,
body[data-theme="dark"] .communication-task {
  background: #1f2227;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .conversation-item.outbound {
  background: #17322f;
  border-color: #275e57;
}

body[data-theme="dark"] .conversation-item.inbound {
  background: #23262c;
}

body[data-theme="dark"] .conversation-item.draft,
body[data-theme="dark"] .conversation-draft-panel .conversation-item {
  background: #351c22;
  border-color: #7f3d46;
}

body[data-theme="dark"] .conversation-compose,
body[data-theme="dark"] .warm-touch-toolbar,
body[data-theme="dark"] .mini-metric,
body[data-theme="dark"] .emoji-panel {
  background: #181b20;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .emoji-panel button {
  background: #23272f;
  border-color: var(--line);
}

body[data-theme="dark"] .conversation-text,
body[data-theme="dark"] .conversation-item,
body[data-theme="dark"] .conversation-item p,
body[data-theme="dark"] .communication-task,
body[data-theme="dark"] .communication-task p,
body[data-theme="dark"] .lead-kanban-card,
body[data-theme="dark"] .lead-kanban-card strong,
body[data-theme="dark"] .lead-kanban-card span,
body[data-theme="dark"] .task-card,
body[data-theme="dark"] .task-card strong,
body[data-theme="dark"] .task-card p,
body[data-theme="dark"] .action-required-item,
body[data-theme="dark"] .action-required-item strong,
body[data-theme="dark"] .action-required-item span {
  color: var(--text);
}

body[data-theme="dark"] .conversation-meta,
body[data-theme="dark"] .conversation-meta small,
body[data-theme="dark"] .task-card small,
body[data-theme="dark"] .action-required-item small,
body[data-theme="dark"] .kanban-card-meta,
body[data-theme="dark"] .kanban-card-contact,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .table-note {
  color: var(--muted);
}

body[data-theme="dark"] .warm-touch-message {
  background: #121417;
  border-color: #383d45;
  color: var(--text);
}

body[data-theme="dark"] .metric-card span {
  color: var(--muted);
}

body[data-theme="dark"] .metric-card strong {
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: #edf1f0;
}

.login-panel {
  width: min(540px, 100%);
  display: grid;
  gap: 22px;
  padding: 46px 48px 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

.login-brand-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: var(--accent);
  color: #06201d;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

.login-heading {
  display: grid;
  gap: 12px;
}

.login-eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h1 {
  font-size: 38px;
  line-height: 1.1;
}

.login-panel p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.login-field {
  display: grid;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.login-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-field input::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.login-password-wrap {
  position: relative;
}

.login-password-wrap input {
  padding-right: 52px;
}

.login-password-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.login-password-toggle:hover,
.login-password-toggle:focus-visible {
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.login-submit {
  position: relative;
  min-height: 52px;
  width: 100%;
  font-size: 16px;
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.76;
}

.login-submit-spinner {
  position: absolute;
  right: 18px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(6, 32, 29, 0.28);
  border-top-color: #06201d;
  border-radius: 50%;
  animation: login-spin 700ms linear infinite;
}

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

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.32);
  border-radius: 6px;
  background: rgba(180, 35, 24, 0.08);
  line-height: 1.4;
}

.login-security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.login-security-note > span:first-child {
  color: var(--accent);
  font-size: 9px;
}

body[data-theme="dark"] .login-panel {
  background: #121816;
  border-color: #293a35;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
}

body[data-theme="dark"] .login-field input {
  background: #0d1311;
  border-color: #30443e;
}

body[data-theme="dark"] .login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

body[data-theme="dark"] .login-password-toggle:hover,
body[data-theme="dark"] .login-password-toggle:focus-visible {
  background: #1d2824;
}

@media (max-width: 640px) {
  .login-view {
    align-items: center;
    padding: 18px 14px;
  }

  .login-panel {
    gap: 18px;
    padding: 30px 24px 26px;
  }

  .login-brand-mark {
    width: 60px;
    height: 60px;
    font-size: 14px;
  }

  .login-panel h1 {
    font-size: 32px;
  }

  .login-panel p {
    font-size: 14px;
  }
}

.form-error {
  color: var(--danger);
  font-size: 13px;
}

.user-label {
  max-width: 180px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #f8fafc;
  padding: 20px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 12px;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle {
  color: #a7b2c2;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -22px 0 18px;
  padding: 22px 0 14px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

body[data-theme="dark"] .topbar {
  background: rgba(17, 18, 20, 0.96);
  border-bottom-color: #24272d;
  backdrop-filter: blur(10px);
}

body[data-theme="light"] .topbar {
  background: rgba(247, 248, 250, 0.96);
  backdrop-filter: blur(10px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
}

#viewSubtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.language-switch,
.mode-switch,
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 12px;
}

.language-switch select,
.mode-switch select,
.theme-switch select {
  width: auto;
  min-height: 28px;
  padding: 0 22px 0 8px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.mode-hidden {
  display: none !important;
}

body[data-crm-mode="user"] .admin-only,
body[data-crm-mode="user"] .admin-mode-only {
  display: none !important;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 12px;
  background: white;
  color: var(--text);
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn:hover,
.danger-btn:hover,
.icon-btn:hover {
  background: var(--panel-2);
}

.danger-btn {
  background: #fff;
  border-color: #fecaca;
  color: #b91c1c;
}

.inline-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.view.hidden,
.hidden {
  display: none !important;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 180px;
  gap: 10px;
  margin-bottom: 14px;
}

#leadsView .toolbar {
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
}

.segmented-control {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  width: max-content;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segmented-control button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented-control button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.lead-view-toggle {
  justify-self: end;
}

.compact-toolbar {
  grid-template-columns: minmax(180px, 1fr) 180px 180px;
}

.audit-toolbar {
  grid-template-columns: minmax(180px, 1fr) 150px 150px 150px 135px 135px auto auto;
  padding: 0 14px 14px;
  margin-bottom: 0;
}

.search-input,
.select-input,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

.lead-layout {
  display: block;
}

.lead-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.agent-run-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.table-panel,
.detail-panel,
.section-block,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-panel {
  overflow: hidden;
}

.table-panel.flat {
  box-shadow: none;
}

.lead-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.lead-table th,
.lead-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lead-table tr {
  height: 52px;
}

.lead-table tbody tr {
  cursor: pointer;
}

.lead-table tbody tr:hover,
.lead-table tbody tr.selected {
  background: #eef6f5;
}

.lead-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  min-height: 520px;
}

.lead-dialog-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.lead-dialog-legend > span,
.lead-table-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dialog-led {
  display: inline-block;
  flex: 0 0 11px;
  width: 11px;
  height: 11px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
}

.dialog-led.blue {
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.17), 0 0 8px rgba(59, 130, 246, 0.8);
}

.dialog-led.red {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.17), 0 0 8px rgba(239, 68, 68, 0.8);
}

.dialog-led.yellow {
  background: #facc15;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.17), 0 0 8px rgba(250, 204, 21, 0.82);
}

.dialog-led.green {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.17), 0 0 8px rgba(34, 197, 94, 0.8);
}

.kanban-column {
  display: grid;
  grid-template-rows: auto 1fr;
  flex: 0 0 276px;
  min-height: 220px;
  max-height: calc(100vh - 245px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kanban-column-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.kanban-card-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding: 10px;
}

.lead-kanban-card {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 118px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: none;
  color: var(--text);
  text-align: left;
}

.lead-kanban-card:hover,
.lead-kanban-card.selected {
  border-color: var(--accent);
  background: #eef6f5;
}

.kanban-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.kanban-card-title .dialog-led {
  margin-left: auto;
}

.kanban-card-title strong,
.kanban-card-step,
.kanban-card-contact {
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-title strong {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.kanban-card-step {
  display: -webkit-box;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.kanban-card-contact {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.source-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.source-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.section-subblock {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.compact-text {
  max-width: 420px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
}

.candidate-checkline {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.candidate-checkline small {
  color: var(--muted);
  font-size: 11px;
}

.candidate-review-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.candidate-review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.candidate-review-warning {
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.35;
}

.source-input-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(150px, 0.8fr) minmax(110px, 0.6fr);
  gap: 10px;
}

.source-input-form .source-url-input,
.source-input-form textarea,
.source-input-form button {
  grid-column: 1 / -1;
}

.source-input-form textarea {
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
}

.source-input-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.source-input-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.lead-source-reason {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.lead-source-reason p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-input-item a {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.source-input-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.source-input-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  background: #dcfce7;
  color: #166534;
}

.pill.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.orange {
  background: #ffedd5;
  color: #9a3412;
}

.candidate-evidence {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.candidate-evidence p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.section-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.pill.red {
  background: #fee2e2;
  color: var(--danger);
}

.lead-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.lead-detail-modal.hidden {
  display: none;
}

.lead-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.74);
  backdrop-filter: blur(3px);
}

.lead-detail-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1480px, calc(100vw - 36px));
  height: min(920px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.lead-detail-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.lead-detail-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
}

.lead-detail-scroll {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 24px;
}

.lead-detail-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.lead-detail-conversation,
.lead-detail-summary {
  min-width: 0;
}

.lead-detail-summary {
  display: grid;
  gap: 12px;
}

.lead-detail-summary > .mini-list,
.lead-detail-summary > .lead-source-reason {
  margin: 0;
}

body.lead-modal-open {
  overflow: hidden;
}

.lead-journey {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft, #f8fafc);
}

.lead-journey-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lead-journey-head h2,
.lead-journey-head p {
  margin: 0;
}

.lead-journey-head h2 {
  font-size: 15px;
}

.lead-journey-head p,
.lead-journey-branch {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.lead-journey-track {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 4px 2px 8px;
}

.lead-journey-step {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  flex: 0 0 118px;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.lead-journey-step::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line);
}

.lead-journey-step:first-child::before {
  left: 50%;
}

.lead-journey-step:last-child::before {
  right: 50%;
}

.lead-journey-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}

.lead-journey-step.completed::before,
.lead-journey-step.current::before {
  background: var(--accent);
}

.lead-journey-step.completed .lead-journey-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: #06201d;
}

.lead-journey-step.current {
  color: var(--text);
  font-weight: 700;
}

.lead-journey-step.current .lead-journey-dot {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(45, 207, 190, 0.14);
}

.agent-run-detail {
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.detail-empty,
.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.detail-title {
  font-size: 18px;
  font-weight: 800;
  word-break: break-word;
}

.detail-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.lead-help-panel {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.lead-help-panel h2 {
  margin: 0;
  font-size: 14px;
}

.lead-help-panel p {
  margin: 0;
}

body[data-theme="dark"] .lead-help-panel {
  border-color: #334155;
  background: #151a21;
  color: #e5e7eb;
}

body[data-theme="dark"] .lead-help-panel h2,
body[data-theme="dark"] .lead-help-panel p,
body[data-theme="dark"] .lead-help-panel strong {
  color: #e5e7eb;
}

.detail-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.detail-grid.tight-grid {
  gap: 6px;
  margin: 6px 0 10px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.contact-mini-list {
  margin-top: 14px;
}

.payload-block {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.payload-block h2 {
  margin-bottom: 8px;
}

.payload-block pre {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.explain-panel {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--text);
}

.explain-panel strong {
  font-size: 14px;
}

.explain-panel span {
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

.admin-purpose-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.purpose-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.purpose-card strong {
  font-size: 13px;
}

.purpose-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.action-required-block {
  margin-bottom: 14px;
}

.action-required-list {
  display: grid;
  gap: 8px;
}

.action-required-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.action-required-item strong,
.action-required-item span,
.action-required-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-required-item span {
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.action-required-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.action-required-side {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: 132px;
}

.action-required-side em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-align: right;
}

.report-box {
  min-height: 220px;
  max-height: 520px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.setup-list {
  display: grid;
  gap: 14px;
}

.setup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.setup-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.setup-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.setup-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.check-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 6px 8px;
}

.check-item span {
  font-size: 11px;
  font-weight: 800;
}

.check-item.passed span {
  color: var(--success);
}

.check-item.missing span {
  color: var(--danger);
}

.check-item strong {
  min-width: 0;
  font-size: 12px;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 9px;
  text-align: left;
  font-size: 12px;
}

.mini-row:hover {
  background: var(--panel-2);
}

.mini-row.static-row {
  cursor: default;
}

.mini-row.static-row:hover {
  background: var(--panel);
}

.communication-panel {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.communication-signals,
.communication-task-list {
  display: grid;
  gap: 8px;
}

.communication-signal {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  font-size: 12px;
}

.communication-signal span,
.communication-signal small {
  color: var(--muted);
}

.communication-signal strong {
  min-width: 0;
  font-weight: 600;
  word-break: break-word;
}

.communication-task {
  background: #ffffff;
}

.conversation-panel {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.lead-telegram-panel {
  margin-top: 12px;
}

.conversation-list {
  display: grid;
  gap: 8px;
  max-height: min(64vh, 720px);
  overflow-y: auto;
  padding-right: 6px;
}

.compact-conversation-list {
  min-height: 360px;
  max-height: min(52vh, 620px);
}

.lead-conversation-compose.has-agent-draft {
  padding: 12px;
  border: 1px solid #f1a2aa;
  border-radius: 8px;
  background: #fff1f2;
}

.lead-draft-label {
  color: #9f1239;
  font-size: 12px;
  font-weight: 600;
}

.conversation-item {
  display: grid;
  gap: 5px;
  max-width: 92%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.conversation-item.outbound {
  justify-self: end;
  background: #eef6f5;
}

.conversation-item.inbound {
  justify-self: start;
}

.conversation-item.draft,
.conversation-draft-panel .conversation-item {
  max-width: 100%;
  background: #fff1f2;
  border-color: #fecdd3;
}

.conversation-draft-panel {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.conversation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.conversation-meta small {
  margin-left: auto;
}

.conversation-meta-line {
  font-size: 12px;
  line-height: 1.4;
}

.conversation-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.conversation-message-footer {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-message-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  color: var(--muted);
}

.telegram-delivery-status {
  display: inline-block;
  min-width: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

.telegram-delivery-status.read {
  color: #2a9df4;
}

.conversation-message-footer small {
  color: var(--muted);
  font-size: 11px;
}

.conversation-message-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.mini-icon-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  font-size: 15px;
}

.danger-icon-btn {
  color: var(--danger);
}

.danger-icon-btn:hover {
  border-color: var(--danger);
}

.conversation-compose {
  display: grid;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding: 10px 0 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.lead-conversation-compose {
  margin-top: 0;
}

.conversation-compose-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.emoji-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 36px);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.emoji-panel button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 18px;
  cursor: pointer;
}

.emoji-panel button:hover {
  border-color: var(--primary);
}

.conversation-compose textarea,
.conversation-item.draft textarea {
  width: 100%;
  font-weight: 400;
  resize: vertical;
}

.conversation-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.warm-touch-toolbar {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.mini-metric {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.mini-metric span {
  color: var(--muted);
  font-size: 12px;
}

.mini-metric strong {
  font-size: 20px;
}

.warm-touch-card.needs-reply {
  border-color: #f59e0b;
}

.hermes-diagnostics-panel {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.hermes-diagnostics-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hermes-chain-list {
  display: grid;
  gap: 8px;
}

.hermes-chain-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(130px, auto);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 9px;
  text-align: left;
}

.hermes-chain-item:hover {
  background: #eef6f5;
}

.hermes-chain-main,
.hermes-chain-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.hermes-chain-main strong,
.hermes-chain-main small,
.hermes-chain-meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hermes-chain-main small,
.hermes-chain-meta small {
  color: var(--muted);
  font-size: 12px;
}

.hermes-chain-meta {
  text-align: right;
}

.mini-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  font-size: 13px;
}

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

.field-value {
  min-width: 0;
  word-break: break-word;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: start;
}

.booking-slots-panel {
  margin-bottom: 14px;
}

.booking-slots-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.booking-slot-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: center;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.booking-slot-time,
.booking-slot-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booking-slot-time {
  font-weight: 800;
}

.booking-slot-meta {
  color: var(--muted);
  font-size: 12px;
}

.booking-slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  grid-row: 1 / span 2;
  grid-column: 2;
}

.panel-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.calendar-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.calendar-status small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
  align-items: start;
}

.pilot-queue {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
}

.pilot-queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.pilot-queue-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pilot-queue-main strong,
.pilot-queue-main span,
.pilot-queue-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pilot-queue-main span,
.pilot-queue-main small {
  color: var(--muted);
  font-size: 12px;
}

.pilot-queue-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.compact-empty {
  grid-column: 1 / -1;
  min-height: 38px;
}

.metric-card {
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  font-size: 26px;
  font-weight: 900;
  margin-top: 6px;
}

.compact-value {
  font-size: 20px;
  line-height: 1.15;
  word-break: break-word;
}

.section-block {
  padding: 14px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-header.compact {
  margin-bottom: 6px;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.tab-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #06201d;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.task-card strong,
.task-card small,
.task-card p {
  display: block;
}

.task-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.warm-touch-card {
  grid-template-columns: minmax(0, 1fr) auto;
}

.warm-touch-card > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.warm-touch-message {
  width: 100%;
  min-height: 92px;
  font-weight: 400;
  line-height: 1.45;
}

.warm-touch-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions {
  align-items: center;
}

.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.link-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  text-decoration: none;
}

.link-btn:hover {
  background: #eef6f5;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.control-list {
  display: grid;
  gap: 9px;
}

.control-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.control-item strong,
.control-item span {
  display: block;
  min-width: 0;
}

.control-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.command-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.command-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.command-block pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.partner-card {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-title {
  font-weight: 800;
}

.timeline-summary,
.timeline-time {
  color: var(--muted);
  margin-top: 3px;
}

.status-bars {
  display: grid;
  gap: 10px;
}

.funnel-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.funnel-step,
.queue-tab,
.queue-item,
.event-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
}

.funnel-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 9px;
  text-align: left;
}

.funnel-step:hover,
.queue-item:hover,
.event-row:hover {
  background: #eef6f5;
}

.funnel-index {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.funnel-label,
.funnel-count {
  min-width: 0;
  font-size: 12px;
  font-weight: 800;
}

.funnel-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.queue-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.queue-tab {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
  font-size: 12px;
}

.queue-tab.active {
  border-color: var(--accent);
  background: #eef6f5;
  color: var(--accent-strong);
}

.queue-list,
.event-list {
  display: grid;
  gap: 8px;
}

.queue-item,
.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  min-height: 52px;
  padding: 9px 10px;
  text-align: left;
}

.queue-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.operator-review-row-actions,
.operator-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.operator-review-row-actions {
  margin-top: 8px;
}

.operator-review-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.operator-review-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.meeting-link-task,
.manual-send-task {
  display: grid;
  gap: 8px;
  min-width: 260px;
}

.meeting-link-task-head,
.manual-send-task-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.meeting-link-task-message,
.manual-send-task-message {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.candidate-draft-lint {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
}

.candidate-draft-lint strong {
  font-size: 12px;
}

.candidate-draft-lint ul {
  margin: 0;
  padding-left: 18px;
}

.candidate-draft-lint-ok {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.candidate-draft-lint-warn {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.meeting-link-task-meta,
.manual-send-task-meta {
  display: grid;
  gap: 4px;
}

.meeting-link-task-meta .field-row,
.manual-send-task-meta .field-row {
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.meeting-link-task-meta .field-label,
.meeting-link-task-meta .field-value,
.manual-send-task-meta .field-label,
.manual-send-task-meta .field-value {
  font-size: 12px;
}

.danger-lite {
  border-color: #fecaca;
  color: var(--danger);
}

.quick-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.checkbox-label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.checkbox-line {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.queue-item span,
.event-row span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.queue-item strong,
.event-row strong,
.queue-item small,
.event-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item small,
.event-row small,
.queue-item em,
.event-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.compact-empty {
  padding: 14px;
}

.status-row {
  display: grid;
  grid-template-columns: 150px 1fr 44px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.asset-list {
  display: grid;
  gap: 10px;
}

.asset-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.asset-key {
  font-weight: 800;
}

.asset-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px;
}

.settings-tab {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 12px;
}

.settings-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

body[data-theme="dark"] .settings-tab {
  background: #17191d;
  color: #cbd5e1;
}

body[data-theme="dark"] .settings-tab.active {
  background: var(--accent);
  color: #06201d;
}

.settings-grid .section-block.admin-only:first-of-type {
  grid-row: span 2;
}

.partner-settings-block {
  grid-column: 1 / -1;
}

.partner-settings-form {
  padding-top: 10px;
}

.partner-settings-form input,
.partner-settings-form select,
.partner-settings-form textarea {
  font-weight: 400;
}

.compact-form {
  margin-top: 10px;
}

.settings-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.settings-list-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.settings-list-item strong,
.settings-list-item small {
  display: block;
}

.settings-list-item small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.auth-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.compact-header {
  margin-bottom: 0;
}

.auth-status {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-status small {
  color: var(--muted);
}

.budget-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.budget-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.budget-header strong,
.budget-header small {
  display: block;
}

.budget-header small {
  color: var(--muted);
  margin-top: 4px;
}

.budget-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.budget-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 112px;
  padding: 10px;
}

.budget-card-value {
  font-size: 18px;
  font-weight: 800;
}

.budget-card small {
  color: var(--muted);
  font-size: 12px;
}

.budget-forecast,
.budget-ops {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.budget-forecast span,
.budget-ops div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.budget-ops {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-grid {
  gap: 12px;
}

.audit-block {
  grid-column: 1 / -1;
}

.stack-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.stack-form .primary-btn {
  justify-self: start;
}

.table-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog.wide-dialog {
  width: min(980px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-form {
  padding: 16px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.full {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    overflow-y: visible;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
  }

  .brand {
    margin: 0;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .lead-layout {
    grid-template-columns: 1fr;
  }

  .lead-kanban {
    min-height: 420px;
  }

  .agent-run-layout {
    grid-template-columns: 1fr;
  }

  .lead-detail-modal {
    position: fixed;
    padding: 8px;
  }

  .lead-detail-shell {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .lead-detail-content-grid {
    grid-template-columns: 1fr;
  }

  .lead-detail-scroll {
    padding: 12px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .booking-slots-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-grid,
  .command-grid {
    grid-template-columns: 1fr;
  }

  .admin-purpose-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid .section-block:first-child {
    grid-row: auto;
  }

  .quick-panel,
  .queue-item,
  .event-row,
  .hermes-chain-item {
    grid-template-columns: 1fr;
  }

  .hermes-chain-meta {
    text-align: left;
  }

  .funnel-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-input-form,
  .source-input-item {
    grid-template-columns: 1fr;
  }

  .candidate-review-grid {
    grid-template-columns: 1fr;
  }

  .source-input-meta {
    justify-items: start;
  }
}

.secret-input-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.secret-input-wrap input {
  min-width: 0;
  padding-right: 12px;
}

.secret-state-badge {
  min-width: 78px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.secret-state-badge.configured {
  border-color: rgba(45, 207, 188, 0.45);
  color: var(--success-text, #a7f3d0);
  background: rgba(20, 120, 104, 0.16);
}

.secret-visibility-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  font-size: 16px;
}

.secret-visibility-btn:hover,
.secret-visibility-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 640px) {
  .secret-input-wrap {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .secret-state-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin: -14px 0 16px;
    padding: 14px 0 12px;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  #leadsView .toolbar {
    grid-template-columns: 1fr;
  }

  .lead-view-toggle {
    justify-self: stretch;
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }

  .lead-table th:nth-child(3),
  .lead-table td:nth-child(3),
  .lead-table th:nth-child(4),
  .lead-table td:nth-child(4),
  .lead-table th:nth-child(5),
  .lead-table td:nth-child(5) {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .budget-grid,
  .budget-forecast,
  .budget-ops {
    grid-template-columns: 1fr;
  }

  .booking-slots-list {
    grid-template-columns: 1fr;
  }

  .control-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .action-required-item {
    grid-template-columns: 1fr;
  }

  .action-required-side {
    justify-items: stretch;
  }

  .action-required-side em {
    text-align: left;
  }

  .pilot-queue-item {
    grid-template-columns: 1fr;
  }

  .task-card {
    grid-template-columns: 1fr;
  }

  .pilot-queue-actions {
    justify-content: stretch;
  }

  .pilot-queue-actions .small-btn {
    flex: 1 1 96px;
  }

  .funnel-strip {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: 110px 1fr 36px;
  }
}
