:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #eef2f7;
  --text: #18202b;
  --muted: #647184;
  --line: #d8e0ea;
  --accent: #1769d2;
  --accent-hover: #1258b2;
  --accent-soft: #e7f0fc;
  --danger: #b52e3a;
  --danger-soft: #fae9eb;
  --success: #167153;
  --warning: #9a6700;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(36, 56, 82, 0.055);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #191f27;
    --surface-soft: #222a35;
    --text: #edf2f7;
    --muted: #a0adbd;
    --line: #303a47;
    --accent: #67a8fa;
    --accent-hover: #8bbdff;
    --accent-soft: #172d48;
    --danger: #f27b85;
    --danger-soft: #3a2025;
    --success: #65c9a5;
    --warning: #f0b84b;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 36px 28px 56px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 0;
  font-size: 0.94rem;
}

.connection-state {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 350px) minmax(360px, 0.95fr) minmax(380px, 1.15fr);
  gap: 20px;
  align-items: start;
}

.sidebar,
.main-workspace {
  display: grid;
  min-width: 0;
  gap: 20px;
  align-content: start;
}

@media (min-width: 1181px) {
  .main-workspace {
    display: contents;
  }
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 34px;
  margin-bottom: 22px;
}

.panel-heading > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack + .form-stack,
.account-summary + .form-stack {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.settings-stack {
  display: grid;
  gap: 12px;
}

.settings-panel {
  padding: 0;
  overflow: hidden;
}

.settings-disclosure > summary {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.settings-disclosure > summary::-webkit-details-marker,
.credentials-settings > summary::-webkit-details-marker {
  display: none;
}

.settings-disclosure > summary:focus-visible,
.credentials-settings > summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: -3px;
}

.settings-heading {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.settings-heading strong {
  font-size: 1rem;
}

.settings-heading small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 450;
  line-height: 1.4;
}

.disclosure-action {
  flex: none;
  color: var(--accent);
  font-size: 0;
  font-weight: 700;
}

.disclosure-action::after {
  content: "Изменить";
  font-size: 0.78rem;
}

.settings-disclosure[open] .disclosure-action {
  color: var(--muted);
}

.settings-disclosure[open] .disclosure-action::after {
  content: "Скрыть";
}

.settings-disclosure[open] > summary {
  border-bottom: 1px solid var(--line);
}

.settings-disclosure > .form-stack {
  padding: 18px 20px 20px;
}

.delay-group {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.delay-group legend {
  padding: 0 5px;
  font-size: 0.8rem;
  font-weight: 720;
}

.delay-group legend span {
  color: var(--muted);
  font-weight: 500;
}

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

.delay-group .field {
  grid-template-rows: auto 40px;
  gap: 5px;
  font-size: 0.76rem;
}

.delay-group input {
  height: 40px;
  min-height: 40px;
  background: var(--surface);
}

.cooldown-every {
  margin-bottom: 10px;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-actions .button {
  width: 100%;
  white-space: normal;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.65fr) minmax(160px, 1.35fr);
  gap: 12px;
}

.sidebar .field-row {
  grid-template-columns: 1fr;
}

.credentials-settings {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.credentials-settings > summary {
  padding: 15px 0 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  list-style: none;
}

.credentials-settings[open] > summary {
  color: var(--text);
}

.credentials-settings > .form-stack {
  margin-top: 16px;
}

.field {
  display: grid;
  grid-template-rows: auto 42px auto;
  align-content: start;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 450;
  line-height: 1.35;
}

input {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 720;
  transition: background-color 140ms ease, border-color 140ms ease, transform 90ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .button-primary {
    color: #10151b;
  }
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button-secondary,
.button-quiet {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  border-color: var(--accent);
}

.button-quiet {
  min-height: 34px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
}

.button-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

.account-summary,
.safety-note,
.run-detail {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.account-summary {
  display: grid;
  gap: 4px;
}

.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.compact-field {
  margin-bottom: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mode-button {
  min-height: 38px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.mode-button.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.mode-button:disabled { cursor: not-allowed; opacity: .6; }
.group-controls { display: grid; gap: 18px; }
.group-preview { display: grid; gap: 5px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.group-warning { margin: 5px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.source-choice { display: grid; gap: 9px; margin: 0; padding: 13px; border: 1px solid var(--line); border-radius: 8px; }
.source-choice legend { padding: 0 5px; font-size: .84rem; font-weight: 700; }
.source-choice label { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; font-size: .8rem; }
.source-choice input { width: 17px; height: 17px; min-height: 17px; margin: 0; accent-color: var(--accent); }
.group-progress { margin: -10px 0 20px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--muted); font-size: .76rem; line-height: 1.4; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-grid .button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

#groupStartButton {
  grid-column: 1 / -1;
}

.safety-note {
  margin-top: 20px;
  border-left: 3px solid var(--accent);
}

.safety-note strong {
  font-size: 0.82rem;
}

.safety-note p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.metric strong {
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.run-detail {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  margin-bottom: 22px;
}

.run-detail > div {
  display: grid;
  gap: 5px;
}

.run-detail strong {
  font-size: 0.84rem;
}

.content-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.content-tab {
  flex: 1;
  min-height: 38px;
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 720;
}

.content-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.content-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.results-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.logs-list {
  display: grid;
  align-content: start;
  max-height: 560px;
  min-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 60%, var(--surface));
}

.log-entry {
  display: grid;
  grid-template-columns: 68px 8px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.76rem;
  line-height: 1.45;
}

.log-entry:last-child {
  border-bottom: 0;
}

.log-entry time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.log-marker {
  width: 7px;
  height: 7px;
  margin-top: .3em;
  border-radius: 50%;
  background: var(--accent);
}

.log-success .log-marker { background: var(--success); }
.log-warning .log-marker { background: var(--warning); }
.log-error .log-marker { background: var(--danger); }
.log-error > span:last-child { color: var(--danger); }

.group-exports-heading { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.group-exports-list { display: grid; gap: 8px; }
.group-export-item { display: grid; gap: 7px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.group-export-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 3px; }
.group-export-actions .button { min-height: 34px; padding: 6px 10px; }

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-item strong,
.result-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item .result-meta,
.result-item .result-bio {
  color: var(--muted);
  font-size: 0.74rem;
}

.result-item .result-bio {
  grid-column: 1 / -1;
}

.result-status {
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 750;
}

.result-status.error {
  color: var(--danger);
}

.empty-state {
  margin: 0;
  padding: 24px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
}

.notice {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.84rem;
}

.notice-error {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 14% 18%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 27rem),
    var(--bg);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  width: min(940px, 100%);
  min-height: 590px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(18, 35, 58, 0.13);
}

.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 6vw, 68px);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 13%, var(--surface)), var(--surface));
  border-right: 1px solid var(--line);
}

.auth-brand {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.auth-intro h1 {
  margin-bottom: 20px;
  font-size: clamp(2.8rem, 6vw, 4.7rem);
  line-height: 0.92;
  letter-spacing: -0.065em;
}

.auth-description {
  max-width: 28rem;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.auth-security-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.security-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 12%, transparent);
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 7vw, 78px);
}

.auth-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

.auth-card-copy {
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.auth-submit {
  min-height: 48px;
  margin-top: 4px;
}

.auth-help {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(320px, 350px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .main-workspace {
    display: contents;
  }

  .connection-panel { order: 1; }
  .control-panel { order: 2; }
  .settings-panel { order: 3; }
  .progress-panel { order: 4; }
}

@media (max-width: 767px) {
  .shell {
    padding: 22px 14px 38px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .action-grid,
  .run-detail,
  .settings-actions {
    grid-template-columns: 1fr;
  }
}

.lead-monitor-panel {
  width: calc(100% - 2 * clamp(16px, 2vw, 32px));
  margin-inline: auto;
}

.lead-monitor-heading {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.lead-monitor-heading h2 {
  margin-bottom: 7px;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}

.lead-monitor-heading .muted {
  margin: 0;
  font-size: 0.8rem;
}

.telegram-connection-badge,
.monitor-badge {
  flex: none;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
}

.telegram-connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.telegram-connection-badge::before {
  width: 7px;
  height: 7px;
  flex: none;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  content: "";
}

.telegram-connection-badge.connected {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  color: var(--success);
}

.telegram-connection-badge.connected::before {
  border-color: var(--success);
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 14%, transparent);
}

.monitor-badge.enabled {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  color: var(--success);
}

.lead-monitor-layout {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.lead-config-panel,
.lead-feed-panel {
  min-width: 0;
}

.monitor-form-heading,
.lead-feed-heading,
.lead-feed-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.monitor-form-heading > div {
  display: grid;
  gap: 4px;
}

.monitor-form-heading .muted {
  font-size: 0.72rem;
}

.monitor-enable {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.monitor-enable input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}

.lead-source-picker {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.lead-source-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.lead-sources-list {
  min-height: 92px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.lead-source-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

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

.lead-source-item:hover {
  background: var(--surface);
}

.lead-source-item input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.lead-source-item > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.lead-source-item strong,
.lead-source-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-source-item strong {
  font-size: 0.82rem;
}

.lead-source-item small {
  color: var(--muted);
  font-size: 0.68rem;
}

.lead-feed-heading {
  align-items: flex-start;
}

.lead-feed-heading > div:first-child > div {
  display: grid;
  gap: 5px;
}

.lead-feed-heading .muted {
  font-size: 0.74rem;
}

.lead-feed-actions {
  flex: none;
}

.leads-list {
  display: grid;
  gap: 12px;
  max-height: min(73dvh, 820px);
  overflow-y: auto;
  padding-right: 3px;
}

.lead-item {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: var(--surface-soft);
}

.lead-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lead-item-header > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.lead-item-header strong {
  font-size: 0.9rem;
}

.lead-item-header span {
  color: var(--muted);
  font-size: 0.7rem;
}

.lead-open-link {
  flex: none;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  text-decoration: none;
}

.lead-open-link:hover {
  text-decoration: underline;
}

.lead-message {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.55;
}

.lead-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lead-keywords span {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 750;
}

@media (max-width: 900px) {
  .lead-monitor-layout {
    grid-template-columns: 1fr;
  }

  .leads-list {
    max-height: none;
  }
}

@media (max-width: 767px) {
  .lead-monitor-panel {
    width: calc(100% - 28px);
  }

  .lead-monitor-heading,
  .lead-feed-heading,
  .lead-item-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .lead-feed-actions {
    width: 100%;
  }

  .lead-feed-actions .button {
    flex: 1;
  }
}

@media (max-width: 720px) {
  .auth-page {
    display: block;
    padding: 0;
    background: var(--surface);
  }

  .auth-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-intro {
    min-height: 310px;
    padding: 38px 26px 42px;
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-brand {
    margin-bottom: 28px;
  }

  .auth-intro h1 {
    font-size: 3.2rem;
  }

  .auth-description {
    margin-bottom: 22px;
  }

  .auth-card {
    padding: 38px 26px 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Visual direction inspired by AI Рассвет: strong type, near-black navigation,
   warm coral accent, white working surfaces and soft technical depth. */
:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-soft: #f0f0ec;
  --text: #191918;
  --muted: #686862;
  --line: #deded8;
  --accent: #ff6e42;
  --accent-hover: #ed5c32;
  --accent-soft: #fff0eb;
  --danger: #c83d45;
  --danger-soft: #fff0f1;
  --success: #159a54;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(37, 36, 31, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background:
    radial-gradient(circle at 84% 8%, rgba(255, 110, 66, 0.08), transparent 28rem),
    var(--bg);
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 64px;
}

.topbar {
  align-items: center;
  margin: 0 0 32px;
  padding: 18px clamp(18px, 3vw, 42px);
  background: #131312;
  color: #f8f8f5;
}

.workspace-brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.workspace-brand > div {
  min-width: 0;
}

.brand-symbol {
  display: grid;
  flex: none;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.topbar .kicker {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.66rem;
}

.topbar h1 {
  color: #f8f8f5;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  letter-spacing: -0.04em;
}

.topbar-actions {
  gap: 12px;
}

.topbar .connection-state {
  border-color: #353532;
  background: #20201e;
  color: #d8d8d2;
}

.topbar .telegram-connection-badge {
  border-color: #353532;
  background: #20201e;
  color: #d8d8d2;
}

.topbar .telegram-connection-badge.connected {
  border-color: rgba(91, 212, 145, 0.38);
  background: rgba(21, 154, 84, 0.14);
  color: #5bd491;
}

.topbar .telegram-connection-badge.connected::before {
  border-color: currentColor;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(91, 212, 145, 0.13);
}

.topbar .button-quiet {
  border-color: #3b3b37;
  color: #f5f5f2;
}

.topbar .button-quiet:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.workspace,
.shell > .notice {
  width: calc(100% - 2 * clamp(16px, 2vw, 32px));
  margin-right: auto;
  margin-left: auto;
}

.workspace {
  grid-template-columns: minmax(310px, 340px) minmax(360px, 0.92fr) minmax(400px, 1.16fr);
  gap: 22px;
}

.panel {
  padding: 22px;
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading {
  margin-bottom: 24px;
}

h2 {
  font-size: 1.12rem;
  letter-spacing: -0.025em;
}

h3 {
  letter-spacing: -0.015em;
}

.field {
  grid-template-rows: auto 46px auto;
  gap: 8px;
  font-weight: 700;
}

input {
  height: 46px;
  min-height: 46px;
  padding: 10px 13px;
  border-color: #d2d2cb;
  border-radius: 11px;
  background: #ffffff;
  color: #191918;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input:hover {
  border-color: #b9b9b1;
}

input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(255, 110, 66, 0.15);
}

button,
.button,
.mode-button,
.text-button {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:active,
.button:active,
.mode-button:active {
  transform: scale(0.98);
}

.button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 800;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 9px 24px rgba(255, 110, 66, 0.22);
}

.button-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  box-shadow: 0 12px 28px rgba(255, 110, 66, 0.27);
}

.button-secondary {
  border-color: #cecec7;
  background: #ffffff;
  color: #242421;
}

.button-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #8f2d12;
}

.button-quiet {
  border: 1px solid var(--line);
  background: transparent;
}

.mode-switch {
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.mode-button {
  border-radius: 10px;
  color: var(--muted);
}

.mode-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(37, 36, 31, 0.08);
}

.metrics {
  gap: 10px;
}

.metric {
  border-radius: 13px;
  background: var(--surface-soft);
}

.metric strong {
  color: var(--text);
  font-size: 1.75rem;
  letter-spacing: -0.055em;
}

.metric:first-child strong,
.text-button {
  color: var(--accent);
}

.run-detail,
.account-summary,
.group-preview,
.group-progress {
  border-radius: 13px;
}

.result-item,
.group-export-item {
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
}

.settings-disclosure > summary {
  min-height: 86px;
}

.settings-disclosure[open] > summary {
  background: var(--accent-soft);
}

.delay-group {
  border-radius: 12px;
}

.notice {
  border-radius: 13px;
}

/* Login */
.auth-page {
  display: block;
  padding: 0;
  background: var(--surface);
}

.auth-shell {
  grid-template-columns: minmax(390px, 1.05fr) minmax(420px, 0.95fr);
  width: 100%;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.auth-intro {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  padding: clamp(40px, 6vw, 82px);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 88% 76%, rgba(255, 110, 66, 0.2), transparent 23rem),
    linear-gradient(145deg, #f7f7f4 0%, #ffffff 72%);
}

.auth-intro::after {
  content: "";
  position: absolute;
  right: -9rem;
  bottom: -10rem;
  z-index: -1;
  width: 29rem;
  height: 29rem;
  border: 5.6rem solid rgba(255, 110, 66, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.auth-brand {
  position: absolute;
  top: clamp(28px, 4vw, 48px);
  left: clamp(30px, 6vw, 82px);
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.auth-intro .kicker {
  margin-top: 68px;
  margin-bottom: 20px;
  color: var(--accent);
}

.auth-intro h1 {
  max-width: 760px;
  margin-bottom: 28px;
  font-size: clamp(3.7rem, 7.5vw, 7.4rem);
  line-height: 0.86;
  letter-spacing: -0.075em;
}

.auth-intro h1 span {
  color: var(--accent);
}

.auth-description {
  max-width: 36rem;
  margin-bottom: 0;
  color: #66665f;
  font-size: clamp(0.94rem, 1.4vw, 1.12rem);
  line-height: 1.55;
}

.auth-card {
  width: min(100%, 580px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(42px, 7vw, 88px);
  background: var(--surface);
}

.auth-card > div:first-child,
.auth-card > form,
.auth-card > .notice,
.auth-card > .auth-help {
  width: min(100%, 420px);
  margin-right: auto;
  margin-left: auto;
}

.auth-card .kicker {
  margin-bottom: 14px;
}

.auth-card h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.auth-card-copy {
  margin-bottom: 36px;
  font-size: 0.92rem;
}

.auth-card .field {
  grid-template-rows: auto 54px;
}

.auth-card input {
  height: 54px;
  min-height: 54px;
  border-radius: 13px;
  font-size: 1rem;
}

.auth-submit {
  min-height: 54px;
  margin-top: 8px;
  font-size: 1rem;
}

.auth-help {
  color: #72726c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1a1a18;
    --surface-soft: #242421;
    --text: #f2f2ee;
    --muted: #aaa9a1;
    --line: #363632;
    --accent: #ff7951;
    --accent-hover: #ff8c69;
    --accent-soft: #38231c;
    --danger: #ff7c84;
    --danger-soft: #3b2023;
    --success: #54cc85;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  }

  body {
    background:
      radial-gradient(circle at 84% 8%, rgba(255, 121, 81, 0.08), transparent 28rem),
      var(--bg);
  }

  input {
    border-color: #484843;
    background: #20201e;
    color: #f2f2ee;
  }

  input:hover {
    border-color: #5c5c55;
  }

  .button-secondary {
    border-color: #4a4a45;
    background: #242421;
    color: #f2f2ee;
  }

  .button-secondary:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: #ffd5c8;
  }

  .auth-page {
    background: var(--surface);
  }

  .auth-intro {
    background:
      radial-gradient(circle at 88% 76%, rgba(255, 121, 81, 0.17), transparent 23rem),
      linear-gradient(145deg, #171715 0%, #111110 72%);
  }

  .auth-description,
  .auth-help {
    color: #aaa9a1;
  }

  .result-item,
  .group-export-item {
    background: #20201e;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(310px, 340px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

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

  .auth-intro {
    min-height: auto;
    padding: 112px 26px 46px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-brand {
    top: 24px;
    left: 26px;
  }

  .auth-intro .kicker {
    margin-top: 0;
    margin-bottom: 14px;
  }

  .auth-intro h1 {
    margin-bottom: 22px;
    font-size: clamp(3.1rem, 15vw, 5.4rem);
    line-height: 0.88;
  }

  .auth-card {
    width: 100%;
    min-height: auto;
    padding: 44px 26px 54px;
  }
}

@media (max-width: 767px) {
  .shell {
    padding-bottom: 38px;
  }

  .topbar {
    gap: 18px;
    margin-bottom: 24px;
    padding: 16px 18px;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .topbar .button-quiet,
  .topbar .connection-state,
  .topbar .telegram-connection-badge {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .workspace,
  .shell > .notice {
    width: calc(100% - 28px);
  }
}

@media (max-width: 440px) {
  .auth-intro h1 {
    font-size: clamp(2.85rem, 15vw, 4.2rem);
  }

  .auth-description {
    font-size: 0.9rem;
  }

  .workspace-brand .brand-symbol {
    width: 38px;
    height: 38px;
  }

  .topbar h1 {
    font-size: 1.1rem;
  }
}

.agent-panel { display: grid; gap: 16px; }
.agent-heading {
  align-items: flex-start;
  margin-bottom: 0;
}
.panel-heading > .agent-title {
  display: flex;
  align-items: center;
  gap: 11px;
}
.agent-title > div {
  display: grid;
  gap: 3px;
}
.agent-title .kicker {
  margin: 0;
  font-size: 0.67rem;
}
.agent-icon {
  width: 34px;
  height: 34px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 850;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 22%, transparent);
}
.agent-description {
  line-height: 1.55;
  margin: -2px 0 0;
  padding-bottom: 2px;
}
.agent-badge {
  flex: none;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
  font-size: 0.65rem; font-weight: 750; padding: 6px 9px; text-transform: uppercase;
  letter-spacing: 0.035em;
}
.agent-badge.enabled {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-color: color-mix(in srgb, var(--success) 35%, var(--line)); color: var(--success);
}
.agent-endpoint {
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px;
  display: grid; gap: 7px; padding: 12px 13px;
}
.agent-endpoint code {
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.agent-actions { display: grid; gap: 8px; grid-template-columns: 1fr; }
.agent-actions .button { width: 100%; }
.agent-token-meta:empty,
.agent-limit-meta:empty { display: none; }
.agent-limit-meta {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-soft) 72%, var(--surface));
  font-size: 0.72rem;
  line-height: 1.45;
}
.agent-setup {
  border-top: 1px solid var(--line); display: grid; gap: 14px; padding-top: 16px;
}
.token-warning {
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line));
  border-radius: 10px; font-size: 0.82rem; line-height: 1.45; padding: 11px 12px;
}
.agent-limit-warning {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: 10px; font-size: 0.82rem; line-height: 1.45; padding: 11px 12px;
}
.copy-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; }
.copy-button { padding-inline: 12px; }
.agent-tabs {
  background: var(--surface-soft); border-radius: 10px; display: grid; gap: 3px;
  grid-template-columns: repeat(3, 1fr); padding: 3px;
}
.agent-tab {
  background: transparent; border: 0; border-radius: 8px; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 0.75rem; font-weight: 700; padding: 9px 5px;
}
.agent-tab.active {
  background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / 8%); color: var(--text);
}
.agent-tab-panel { min-width: 0; }
.agent-tab-panel p { font-size: 0.8rem; line-height: 1.45; }
.agent-tab-panel pre {
  background: #111827; border-radius: 9px; color: #e5e7eb; font-size: 0.69rem;
  line-height: 1.5; margin: 9px 0; max-height: 190px; overflow: auto; padding: 11px;
  white-space: pre-wrap; word-break: break-word;
}
.copy-config { margin-bottom: 5px; }

.workspace-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 20px clamp(16px, 2vw, 32px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-tab {
  min-width: 132px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 720;
}

.workspace-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 24%, transparent);
}

.workspace-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}

.workspace-tab-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.conversations-panel {
  width: calc(100% - 2 * clamp(16px, 2vw, 32px));
  margin-right: auto;
  margin-left: auto;
  margin-top: 0;
  padding: 0;
  overflow: hidden;
}

.conversations-heading {
  min-height: 76px;
  margin: 0;
  padding: 18px 20px;
}

.conversations-heading > div {
  display: grid;
  gap: 3px;
}

.conversations-heading .kicker { margin-bottom: 1px; }
.conversations-heading .muted {
  font-size: 0.78rem;
  font-weight: 450;
}

.conversation-locked {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 34px 20px;
  text-align: center;
}

.conversation-layout {
  height: clamp(560px, 68dvh, 720px);
  min-height: 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.dialogs-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.dialog-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.dialog-search input {
  min-width: 0;
}

.dialog-filters {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.dialog-tabs {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1.45fr;
}

.dialog-tab {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  padding: 10px 5px 9px;
}

.dialog-tab:last-child {
  border-right: 0;
}

.dialog-tab:hover,
.dialog-tab.active {
  color: var(--text);
  background: var(--surface-soft);
}

.dialog-tab.active {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.online-refresh-control {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 650;
}

.online-refresh-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.online-refresh-slider {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 999px;
  background: var(--surface-soft);
  transition: background 160ms ease, border-color 160ms ease;
}

.online-refresh-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.online-refresh-control input:checked + .online-refresh-slider {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.online-refresh-control input:checked + .online-refresh-slider::after {
  transform: translateX(14px);
  background: var(--accent);
}

.online-refresh-control input:focus-visible + .online-refresh-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dialogs-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: color-mix(in srgb, var(--muted) 38%, transparent) transparent;
  scrollbar-width: thin;
}

.dialogs-list::-webkit-scrollbar {
  width: 7px;
}

.dialogs-list::-webkit-scrollbar-track {
  background: transparent;
}

.dialogs-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  background-clip: padding-box;
}

.dialogs-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 58%, transparent);
  background-clip: padding-box;
}

.dialog-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.dialog-item:hover,
.dialog-item.active {
  background: var(--surface);
}

.dialog-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.dialog-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
}

.dialog-content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.dialog-item-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-item-heading strong,
.dialog-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-item-heading strong {
  flex: 1;
  font-size: 0.88rem;
}

.dialog-preview {
  color: var(--muted);
  font-size: 0.76rem;
}

.unread-badge {
  min-width: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 750;
  padding: 3px 6px;
  text-align: center;
}

.chat-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  background:
    radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 18rem),
    var(--surface);
}

.chat-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header > div {
  display: grid;
  gap: 4px;
}

.chat-header .muted {
  font-size: 0.75rem;
}

.messages-list {
  min-width: 0;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  padding: 18px;
}

.message-item {
  max-width: min(75%, 620px);
  display: grid;
  gap: 5px;
  align-self: flex-start;
  padding: 10px 12px 7px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px;
  background: var(--surface-soft);
}

.message-item.outgoing {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 12px 12px 3px 12px;
  background: var(--accent-soft);
}

.message-body {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.45;
}

.message-meta {
  color: var(--muted);
  font-size: 0.65rem;
  text-align: right;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.message-form textarea {
  width: 100%;
  min-height: 46px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
}

.message-form textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}

@media (max-width: 767px) {
  .workspace-tabs {
    width: calc(100% - 28px);
    margin-inline: 14px;
  }

  .workspace-tab {
    flex: 1;
    min-width: 0;
  }

  .conversations-panel {
    width: calc(100% - 28px);
    margin-inline: auto;
  }

  .conversation-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .dialogs-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dialogs-list {
    max-height: 280px;
  }

  .message-item {
    max-width: 88%;
  }

  .agent-heading {
    flex-direction: row;
  }
}
