/* Final lead workbench overrides: keep the leads page as a clean card feed. */
.leads-workbench .lead-main-row {
  display: grid !important;
  grid-template-columns:
    92px
    minmax(190px, 1.05fr)
    minmax(280px, 2.15fr)
    minmax(190px, 1.05fr)
    minmax(170px, 0.95fr)
    minmax(170px, 0.95fr)
    128px !important;
  grid-template-areas:
    "id contact question region status money actions"
    "id route question buyer status money actions" !important;
  border: 1px solid rgba(216, 225, 236, 0.95) !important;
  border-left: 3px solid rgba(15, 143, 126, 0.58) !important;
  border-radius: 8px !important;
  overflow: hidden;
}

.leads-workbench .lead-main-row td {
  display: grid !important;
  align-content: start;
  gap: 5px;
  min-width: 0 !important;
  padding: 13px 12px !important;
  border-left: 0 !important;
  border-bottom: 0 !important;
  background: #fff !important;
}

.leads-workbench .lead-main-row td + td {
  border-left: 1px solid rgba(226, 234, 243, 0.8) !important;
}

.leads-workbench .lead-main-row td::before {
  color: #718198;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leads-workbench .lead-id-cell {
  grid-area: id;
}

.leads-workbench .lead-id-cell::before {
  content: "ID";
}

.leads-workbench .lead-contact-cell {
  grid-area: contact;
}

.leads-workbench .lead-contact-cell::before {
  content: "Контакт";
}

.leads-workbench .lead-region-cell {
  grid-area: region;
}

.leads-workbench .lead-region-cell::before {
  content: "Регион";
}

.leads-workbench .lead-question-cell {
  grid-area: question;
  max-width: none !important;
  color: #142135;
  font-size: 15px;
  line-height: 1.45;
}

.leads-workbench .lead-question-cell::before {
  content: "Вопрос";
}

.leads-workbench .lead-route-cell:nth-child(5) {
  grid-area: route;
}

.leads-workbench .lead-route-cell:nth-child(5)::before {
  content: "Вебмастер";
}

.leads-workbench .lead-route-cell:nth-child(6) {
  grid-area: buyer;
}

.leads-workbench .lead-route-cell:nth-child(6)::before {
  content: "Покупатель";
}

.leads-workbench .lead-money-cell {
  grid-area: money;
}

.leads-workbench .lead-money-cell::before {
  content: "Деньги";
}

.leads-workbench .lead-status-cell {
  grid-area: status;
  min-width: 0 !important;
}

.leads-workbench .lead-status-cell::before {
  content: "Статус";
}

.leads-workbench .row-actions {
  grid-area: actions;
  min-width: 0 !important;
  align-content: center !important;
}

.leads-workbench .row-actions::before {
  content: "Действия";
}

.leads-workbench .lead-contact-cell strong {
  color: #6d5dfc !important;
  font-size: 16px !important;
}

.leads-workbench .lead-money-cell strong {
  color: #00875f !important;
}

@media (max-width: 1400px) {
  .leads-workbench .lead-main-row {
    grid-template-columns: 86px minmax(180px, 1fr) minmax(260px, 1.6fr) minmax(170px, 1fr) 120px !important;
    grid-template-areas:
      "id contact question status actions"
      "id region question money actions"
      "id route buyer money actions" !important;
  }

  .user-account-card .partner-stats {
    grid-template-columns: repeat(3, minmax(96px, 1fr));
  }

  .account-settings-strip {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 480px) {
  .leads-workbench .lead-main-row {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "id"
      "contact"
      "question"
      "region"
      "route"
      "buyer"
      "money"
      "status"
      "actions" !important;
  }

  .leads-workbench .lead-main-row td + td {
    border-left: 0 !important;
    border-top: 1px solid rgba(226, 234, 243, 0.8) !important;
  }

  .user-account-card .partner-stats {
    grid-template-columns: 1fr 1fr;
  }

  .partner-card-head,
  .account-card-actions {
    display: grid;
    justify-content: stretch;
  }

  .account-card-badges {
    justify-content: flex-start;
  }

  .account-settings-strip {
    grid-template-columns: 1fr;
  }
}

/* Compact lead feed: keep the operational list dense, with full text available in details. */
.leads-workbench tbody {
  gap: 8px !important;
}

.leads-workbench .lead-main-row {
  grid-template-columns:
    74px
    minmax(160px, 0.95fr)
    minmax(260px, 1.7fr)
    minmax(132px, 0.72fr)
    minmax(132px, 0.72fr)
    102px !important;
  grid-template-areas:
    "id contact question status money actions"
    "id region route status buyer actions" !important;
  border-radius: 8px !important;
}

.leads-workbench .lead-main-row td {
  padding: 9px 11px !important;
  gap: 3px !important;
  min-height: 0 !important;
  align-self: start !important;
}

.leads-workbench .lead-main-row td::before {
  font-size: 9px !important;
  margin-bottom: 2px !important;
}

.leads-workbench .lead-question-cell {
  align-content: start !important;
  align-self: start !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 76px !important;
  font-size: 13px !important;
  line-height: 1.35 !important;
}

.leads-workbench .lead-id-cell strong,
.leads-workbench .lead-contact-cell strong {
  font-size: 14px !important;
}

.leads-workbench .lead-region-cell strong,
.leads-workbench .lead-route-cell strong,
.leads-workbench .lead-money-cell strong {
  font-size: 13px !important;
}

.leads-workbench .lead-contact-cell span,
.leads-workbench .lead-region-cell span,
.leads-workbench .lead-route-cell span,
.leads-workbench .lead-money-cell span,
.leads-workbench .lead-status-cell small,
.leads-workbench .lead-id-cell small {
  font-size: 11px !important;
  line-height: 1.2 !important;
  margin-top: 2px !important;
}

.leads-workbench .lead-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px !important;
}

.leads-workbench .lead-status-actions button,
.leads-workbench .row-actions .small-button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
}

.leads-workbench .status {
  min-height: 24px;
  padding: 4px 10px;
}

.leads-workbench .pill {
  min-height: 22px;
  padding: 3px 8px;
}

.leads-workbench .lead-detail-row {
  margin-top: -8px !important;
}

@media (max-width: 1400px) {
  .leads-workbench .lead-main-row {
    grid-template-columns: 72px minmax(160px, 1fr) minmax(240px, 1.55fr) minmax(132px, 0.8fr) 102px !important;
    grid-template-areas:
      "id contact question status actions"
      "id region question money actions"
      "id route buyer money actions" !important;
  }
}

@media (max-width: 720px) {
  .leads-workbench .lead-main-row {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "id"
      "contact"
      "question"
      "region"
      "route"
      "buyer"
      "money"
      "status"
      "actions" !important;
  }

  .leads-workbench .lead-question-cell {
    -webkit-line-clamp: 6;
  }
}

@media (min-width: 481px) and (max-width: 1400px) {
  .leads-workbench .lead-main-row {
    grid-template-columns: 72px minmax(150px, 0.9fr) minmax(250px, 1.6fr) minmax(128px, 0.75fr) minmax(128px, 0.75fr) 102px !important;
    grid-template-areas:
      "id contact question status money actions"
      "id region route status buyer actions" !important;
  }
}

/* Dense desktop lead register: one operational row, full lead opens in details. */
@media (min-width: 481px) {
  .leads-workbench tbody {
    gap: 6px !important;
  }

  .leads-workbench .lead-main-row {
    grid-template-columns:
      68px
      minmax(150px, 0.95fr)
      minmax(128px, 0.72fr)
      minmax(280px, 1.7fr)
      minmax(128px, 0.75fr)
      minmax(126px, 0.72fr)
      minmax(142px, 0.8fr)
      86px
      84px !important;
    grid-template-areas: "id contact region question route buyer status money actions" !important;
  }

  .leads-workbench .lead-main-row td {
    padding: 7px 9px !important;
    gap: 2px !important;
  }

  .leads-workbench .lead-main-row td::before {
    font-size: 8px !important;
    margin-bottom: 1px !important;
  }

  .leads-workbench .lead-question-cell {
    -webkit-line-clamp: 2;
    max-height: 40px !important;
    font-size: 12px !important;
    line-height: 1.28 !important;
  }

  .leads-workbench .lead-id-cell strong,
  .leads-workbench .lead-contact-cell strong,
  .leads-workbench .lead-money-cell strong {
    font-size: 13px !important;
  }

  .leads-workbench .lead-region-cell strong,
  .leads-workbench .lead-route-cell strong {
    font-size: 12px !important;
  }

  .leads-workbench .lead-contact-cell span,
  .leads-workbench .lead-region-cell span,
  .leads-workbench .lead-route-cell span,
  .leads-workbench .lead-money-cell span,
  .leads-workbench .lead-status-cell small,
  .leads-workbench .lead-id-cell small {
    font-size: 10px !important;
    line-height: 1.15 !important;
  }

  .leads-workbench .lead-status-cell {
    gap: 3px !important;
  }

  .leads-workbench .lead-status-actions {
    gap: 3px !important;
    margin-top: 3px !important;
  }

  .leads-workbench .lead-status-actions button {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 11px;
  }

  .leads-workbench .row-actions .small-button {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 11px;
  }

  .leads-workbench .status {
    min-height: 22px;
    padding: 3px 8px;
  }

  .leads-workbench .pill {
    min-height: 20px;
    padding: 2px 7px;
  }
}

/* Ultra dense lead list for daily work: rows stay compact, full data is in details. */
@media (min-width: 481px) {
  .leads-workbench .lead-main-row {
    align-items: stretch !important;
  }

  .leads-workbench .lead-main-row td {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    overflow: hidden;
  }

  .leads-workbench .lead-main-row td::before {
    display: none !important;
  }

  .leads-workbench .lead-main-row strong {
    line-height: 1.15 !important;
  }

  .leads-workbench .lead-question-cell {
    max-height: 34px !important;
    -webkit-line-clamp: 2 !important;
  }

  .leads-workbench .lead-contact-cell span,
  .leads-workbench .lead-region-cell span,
  .leads-workbench .lead-route-cell span,
  .leads-workbench .lead-money-cell span,
  .leads-workbench .lead-status-cell small,
  .leads-workbench .lead-id-cell small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leads-workbench .lead-id-cell small:nth-of-type(n + 2),
  .leads-workbench .lead-contact-cell span:not(.pill),
  .leads-workbench .lead-region-cell span:not(.pill),
  .leads-workbench .lead-route-cell span,
  .leads-workbench .lead-money-cell span,
  .leads-workbench .lead-status-cell small {
    display: none !important;
  }

  .leads-workbench .lead-status-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px !important;
  }

  .leads-workbench .lead-status-actions button {
    min-width: 0;
    min-height: 22px;
    padding: 2px 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leads-workbench .row-actions .small-button {
    min-height: 24px;
    padding: 3px 7px;
  }

  .leads-workbench .status {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leads-workbench .lead-main-row:hover .lead-contact-cell span:not(.pill),
  .leads-workbench .lead-main-row:hover .lead-region-cell span:not(.pill),
  .leads-workbench .lead-main-row:hover .lead-route-cell span,
  .leads-workbench .lead-main-row:hover .lead-money-cell span,
  .leads-workbench .lead-main-row:hover .lead-status-cell small {
    display: block !important;
  }
}
