.lead-drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
}

.lead-drawer.is-open {
  display: block;
}

.lead-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 42, 0.45);
  backdrop-filter: blur(6px);
}

.lead-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: -18px 0 48px rgba(12, 18, 42, 0.16);
  display: grid;
  grid-template-rows: auto 1fr;
}

.lead-drawer__header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  padding: 24px 24px 22px;
  border-bottom: 1px solid var(--border);
}

.lead-drawer__intro {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.lead-drawer__actions {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.lead-drawer__actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  text-decoration: none;
}

.lead-drawer__amo-link {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 999px;
  color: var(--text);
}

.lead-drawer__amo-link:visited,
.lead-drawer__amo-link:hover,
.lead-drawer__amo-link:focus-visible {
  color: var(--text);
  text-decoration: none;
}

.lead-drawer__amo-link--hidden {
  display: none;
}

.lead-drawer__header h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: pretty;
  max-width: none;
}

.lead-drawer__header .panel__hint {
  margin: 0;
  max-width: 360px;
  line-height: 1.5;
}

.lead-drawer__amo-link,
.lead-drawer__ai-button,
.lead-drawer__close-button {
  min-width: 128px;
}

.lead-drawer__close-button {
  padding-inline: 14px;
}

@media (max-width: 960px) {
  .lead-drawer__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .lead-drawer__header .panel__hint {
    max-width: none;
  }

  .lead-drawer__amo-link,
  .lead-drawer__ai-button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .lead-drawer__close-button {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .drawer-meta__row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .drawer-meta__row > :last-child {
    text-align: left;
  }
}

.lead-drawer__content {
  padding: 22px 24px 30px;
  overflow: auto;
  display: grid;
  gap: 18px;
}

.drawer-grid {
  display: grid;
  gap: 14px;
}

.drawer-section {
  padding: 18px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.drawer-section h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.drawer-meta {
  display: grid;
  gap: 10px;
}

.drawer-meta__row {
  display: grid;
  grid-template-columns: minmax(108px, 136px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.drawer-meta__row span:first-child {
  color: var(--muted);
  line-height: 1.45;
}

.drawer-meta__row > :last-child {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.drawer-history {
  display: grid;
  gap: 10px;
}

.drawer-history__item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

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

.drawer-section__head h3 {
  margin: 0;
}

.drawer-section__action {
  white-space: nowrap;
}

.drawer-timeline {
  display: grid;
  gap: 10px;
}

.drawer-timeline__item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.drawer-timeline__item--manager {
  border-left: 4px solid var(--blue-600);
}

.drawer-timeline__item--system {
  border-left: 4px solid var(--border-strong);
}

.drawer-timeline__item--status {
  border-left: 4px solid var(--green-600);
}

.drawer-timeline__item--note {
  border-left: 4px solid var(--warning);
}

.drawer-timeline__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: baseline;
}

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

.drawer-timeline__body {
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.drawer-signal {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 8px;
}

.drawer-signal--positive {
  border-left: 4px solid var(--green-600);
}

.drawer-signal--neutral {
  border-left: 4px solid var(--blue-600);
}

.drawer-signal--warning {
  border-left: 4px solid var(--warning);
}

.drawer-signal--system {
  border-left: 4px solid var(--border-strong);
}

.drawer-signal__body {
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}

.drawer-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.drawer-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}

.drawer-chat-status--success {
  border-color: color-mix(in srgb, var(--green-600) 34%, var(--border));
  color: color-mix(in srgb, var(--green-600) 74%, var(--text));
}

.drawer-chat-status--warning {
  border-color: color-mix(in srgb, var(--warning) 36%, var(--border));
  color: color-mix(in srgb, var(--warning) 78%, var(--text));
}

.drawer-chat-status--danger {
  border-color: color-mix(in srgb, var(--red-600) 30%, var(--border));
  color: color-mix(in srgb, var(--red-600) 74%, var(--text));
}

.drawer-chat-stream {
  display: grid;
  gap: 10px;
}

.drawer-chat-attachments {
  display: grid;
  gap: 10px;
}

.drawer-chat-attachment {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.drawer-chat-attachment span {
  color: var(--muted);
  font-size: 13px;
}

.drawer-chat-attachment p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.drawer-chat-message {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 8px;
}

.drawer-chat-message--incoming {
  border-left: 4px solid var(--green-600);
}

.drawer-chat-message--outgoing {
  border-left: 4px solid var(--blue-600);
}

.drawer-chat-message--neutral {
  border-left: 4px solid var(--border-strong);
}

.drawer-chat-message__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.drawer-chat-message__head span {
  color: var(--muted);
  font-size: 13px;
}

.drawer-chat-message__body {
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.drawer-analysis {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.drawer-analysis__block {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.drawer-analysis__block h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.drawer-analysis__block ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.drawer-analysis__block li {
  overflow-wrap: anywhere;
}

.lead-trigger {
  cursor: pointer;
}

@media (max-width: 720px) {
  .lead-drawer__actions {
    grid-template-columns: 1fr;
  }

  .lead-drawer__amo-link {
    width: 100%;
    min-height: 40px;
    padding-inline: 14px;
  }

  .lead-drawer__ai-button,
  .lead-drawer__close-button {
    min-width: 0;
    width: 100%;
  }

  .lead-drawer__header h2 {
    font-size: 20px;
  }

  .lead-drawer__header {
    padding: 20px 18px 18px;
  }

  .lead-drawer__content {
    padding: 18px 18px 24px;
  }

  .drawer-section {
    padding: 14px;
    border-radius: 16px;
  }

  .drawer-meta__row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .drawer-meta__row > :last-child {
    text-align: left;
  }
}
