/* =========================================================
 * Lead Modal — чистый редизайн карточки лида.
 * Используем семантические CSS-классы (.lm-* и .crml-*),
 * полностью адаптировано под обе темы и мобилки.
 *
 * Подключается из base.html после lead-modal-polish.css.
 * Полностью совместимо со старой разметкой (lead-info-*),
 * новые блоки с .lm- работают параллельно.
 * ========================================================= */

/* === 1. Корневой контейнер карточки === */
.lm-card {
    --lm-bg: #0f172a;
    --lm-surface: rgba(255, 255, 255, 0.03);
    --lm-surface-2: rgba(255, 255, 255, 0.06);
    --lm-border: rgba(255, 255, 255, 0.08);
    --lm-border-strong: rgba(167, 139, 250, 0.35);
    --lm-text: #f8fafc;
    --lm-text-muted: #94a3b8;
    --lm-accent: #a78bfa;
    --lm-accent-2: #818cf8;
    --lm-success: #10b981;
    --lm-warn: #f59e0b;
    --lm-danger: #ef4444;
    --lm-info: #3b82f6;

    max-width: 920px;
    margin: 0 auto;
    color: var(--lm-text);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 4px;
}

html.theme-light .lm-card {
    --lm-bg: #ffffff;
    --lm-surface: #ffffff;
    --lm-surface-2: #f8fafc;
    --lm-border: #e2e8f0;
    --lm-border-strong: #c4b5fd;
    --lm-text: #0f172a;
    --lm-text-muted: #64748b;
    --lm-accent: #7c3aed;
    --lm-accent-2: #6366f1;
}

/* === 2. Шапка карточки: имя, статус, бюджет === */
.lm-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    padding: 20px 22px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.16), rgba(118, 75, 162, 0.16));
    border: 1px solid var(--lm-border-strong);
    border-radius: 18px;
}
html.theme-light .lm-hero {
    background: linear-gradient(135deg, #ede9fe, #f5f3ff);
    border-color: #c4b5fd;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.10);
}

.lm-hero__title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--lm-text);
    line-height: 1.25;
    word-break: break-word;
}
.lm-hero__sub {
    color: var(--lm-text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.lm-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(167, 139, 250, 0.18);
    color: var(--lm-accent);
    border: 1px solid var(--lm-border-strong);
}
html.theme-light .lm-hero__badge {
    background: #ede9fe;
    color: #6d28d9;
}
.lm-hero__budget {
    text-align: right;
    align-self: center;
}
.lm-hero__budget-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--lm-success);
    line-height: 1;
}
html.theme-light .lm-hero__budget-value { color: #047857; }
.lm-hero__budget-label {
    font-size: 0.7rem;
    color: var(--lm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
}

/* === 3. Секция (общий стиль для всех блоков) === */
.lm-section {
    background: var(--lm-surface);
    border: 1px solid var(--lm-border);
    border-radius: 16px;
    padding: 18px 20px;
}
html.theme-light .lm-section {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.lm-section__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.lm-section__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--lm-accent), var(--lm-accent-2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.lm-section__title {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--lm-text-muted);
}
html.theme-light .lm-section__title { color: #475569; }
.lm-section__hint {
    margin-left: auto;
    font-size: 0.74rem;
    color: var(--lm-text-muted);
}

/* === 4. Список свойств: иконка + лейбл + значение === */
.lm-prop-list { display: flex; flex-direction: column; }
.lm-prop {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--lm-border);
}
.lm-prop:last-child { border-bottom: none; }
.lm-prop__icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    font-size: 1rem;
    flex-shrink: 0;
}
.lm-prop__icon--success { background: linear-gradient(135deg, #10b981, #059669); }
.lm-prop__icon--warn { background: linear-gradient(135deg, #f59e0b, #d97706); }
.lm-prop__icon--info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.lm-prop__icon--pink { background: linear-gradient(135deg, #ec4899, #db2777); }
.lm-prop__icon--cyan { background: linear-gradient(135deg, #06b6d4, #0891b2); }

.lm-prop__body { min-width: 0; }
.lm-prop__label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--lm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 3px;
}
html.theme-light .lm-prop__label { color: #64748b; }
.lm-prop__value {
    color: var(--lm-text);
    font-weight: 700;
    font-size: 0.95rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.lm-prop__value a {
    color: inherit;
    text-decoration: none;
}
.lm-prop__value a:hover { text-decoration: underline; }
.lm-prop__value--accent { color: var(--lm-success); font-weight: 800; }

.lm-prop__action {
    background: var(--lm-surface-2);
    border: 1px solid var(--lm-border);
    color: var(--lm-text-muted);
    padding: 6px 10px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}
.lm-prop__action:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--lm-success);
}
html.theme-light .lm-prop__action {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}
html.theme-light .lm-prop__action:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #047857;
}

/* === 5. Описание/заметки === */
.lm-note {
    padding: 14px 16px;
    background: var(--lm-surface-2);
    border-radius: 12px;
    border-left: 3px solid var(--lm-accent);
    color: var(--lm-text);
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
}
html.theme-light .lm-note {
    background: #f8fafc;
    color: #1e293b;
}

/* === 6. Кнопки действий === */
.lm-actions {
    display: grid;
    gap: 10px;
}
.lm-actions--grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.lm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
    background: transparent;
    color: var(--lm-text);
    text-align: center;
    user-select: none;
}
.lm-btn:hover { transform: translateY(-1px); }
.lm-btn:active { transform: translateY(0); }
.lm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.lm-btn--ghost {
    background: var(--lm-surface-2);
    border-color: var(--lm-border);
    color: var(--lm-text);
}
.lm-btn--ghost:hover {
    border-color: var(--lm-border-strong);
    background: rgba(167, 139, 250, 0.10);
}
html.theme-light .lm-btn--ghost {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #1e293b;
}
html.theme-light .lm-btn--ghost:hover {
    background: #f1f5f9;
    border-color: #a78bfa;
    color: #6d28d9;
}

.lm-btn--primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}
.lm-btn--primary:hover {
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.5);
}

.lm-btn--success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}
.lm-btn--success:hover {
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.45);
}

.lm-btn--danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.45);
    color: #ef4444;
}
.lm-btn--danger:hover {
    background: rgba(239, 68, 68, 0.25);
}
html.theme-light .lm-btn--danger {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.lm-btn--lg {
    padding: 16px 22px;
    font-size: 0.95rem;
    border-radius: 14px;
}

.lm-btn__icon { font-size: 1rem; }

/* === 7. Инвайт-блок (приглашение заказчика) === */
.lm-invite {
    border-radius: 16px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.16), rgba(139, 92, 246, 0.08));
    border: 1px solid var(--lm-border-strong);
}
html.theme-light .lm-invite {
    background: linear-gradient(135deg, #ede9fe, #f5f3ff);
    border-color: #c4b5fd;
}

.lm-invite__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--lm-accent);
    margin-bottom: 6px;
}
.lm-invite__hint {
    font-size: 0.82rem;
    color: var(--lm-text-muted);
    line-height: 1.45;
    margin-bottom: 12px;
}
.lm-invite__btn {
    width: 100%;
}
.lm-invite__status {
    margin-top: 10px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #10b981;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
}
html.theme-light .lm-invite__status {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #047857;
}
.lm-invite__result {
    margin-top: 12px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 12px;
    padding: 12px;
}
html.theme-light .lm-invite__result {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.lm-invite__result-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--lm-success);
    margin-bottom: 8px;
}
.lm-invite__row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
}
.lm-invite__input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--lm-border);
    border-radius: 10px;
    color: var(--lm-text);
    font-size: 0.82rem;
    font-family: 'SF Mono', Consolas, monospace;
}
html.theme-light .lm-invite__input {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}
.lm-invite__copy {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.82rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
html.theme-light .lm-invite__copy {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #047857;
}
.lm-invite__copy:hover {
    background: rgba(16, 185, 129, 0.30);
}
html.theme-light .lm-invite__copy:hover {
    background: #a7f3d0;
}

/* === 8. Быстрые статусные кнопки === */
.lm-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.lm-quick-btn {
    padding: 12px 14px;
    border-radius: 11px;
    border: 1px solid var(--lm-border);
    background: var(--lm-surface-2);
    color: var(--lm-text);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.lm-quick-btn:hover {
    border-color: var(--lm-accent);
    transform: translateY(-1px);
}
html.theme-light .lm-quick-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #1e293b;
}
html.theme-light .lm-quick-btn:hover {
    background: #f8fafc;
    border-color: #a78bfa;
    color: #6d28d9;
}

.lm-quick-empty {
    padding: 12px 14px;
    border-radius: 11px;
    background: var(--lm-surface-2);
    border: 1px dashed var(--lm-border);
    color: var(--lm-text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* === 9. Сетка фактов проекта (тип / площадь / бюджет / сроки) === */
.lm-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.lm-fact {
    background: var(--lm-surface-2);
    border: 1px solid var(--lm-border);
    border-radius: 12px;
    padding: 12px 14px;
}
html.theme-light .lm-fact {
    background: #f8fafc;
    border-color: #e2e8f0;
}
.lm-fact__label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--lm-text-muted);
    margin-bottom: 4px;
}
.lm-fact__value {
    font-weight: 800;
    color: var(--lm-text);
    font-size: 0.98rem;
}
.lm-fact__value--money { color: var(--lm-success); }
html.theme-light .lm-fact__value--money { color: #047857; }

/* === 10. Конструктор мечты === */
.lm-dream {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.14), rgba(219, 39, 119, 0.10));
    border: 1px solid rgba(236, 72, 153, 0.32);
    border-radius: 16px;
    padding: 18px 20px;
}
html.theme-light .lm-dream {
    background: linear-gradient(135deg, #fdf2f8, #fce7f3);
    border-color: #f9a8d4;
}
.lm-dream__title {
    color: #ec4899;
    display: flex;
    align-items: center;
    gap: 10px;
}
.lm-dream__title .lm-section__icon {
    background: linear-gradient(135deg, #ec4899, #db2777);
}
.lm-dream__hot {
    margin-left: auto;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.6rem;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 800;
    letter-spacing: 0.6px;
}
.lm-dream__panel {
    background: var(--lm-surface-2);
    border-radius: 11px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
html.theme-light .lm-dream__panel {
    background: #ffffff;
    border: 1px solid #fce7f3;
}
.lm-dream__panel-label {
    font-size: 0.68rem;
    color: #ec4899;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 700;
    margin-bottom: 6px;
}
.lm-dream__row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.86rem;
    color: var(--lm-text);
    border-bottom: 1px dashed var(--lm-border);
}
.lm-dream__row:last-child { border-bottom: none; }
.lm-dream__row-label { color: var(--lm-text-muted); }
.lm-dream__row-value { font-weight: 700; }
.lm-dream__total {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.4);
}
html.theme-light .lm-dream__total {
    background: #ecfdf5;
    border-color: #6ee7b7;
}
.lm-dream__total-row {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 8px;
    color: var(--lm-success);
    font-size: 1.1rem;
    font-weight: 900;
}
html.theme-light .lm-dream__total-row {
    border-top-color: #6ee7b7;
}

/* === 11. Финальный CTA-блок (создать объект, редактировать) === */
.lm-cta {
    display: grid;
    gap: 10px;
    padding-top: 6px;
}

/* === 12. Mobile === */
@media (max-width: 640px) {
    .lm-card { padding: 0 2px; gap: 14px; }
    .lm-section { padding: 14px 14px; }
    .lm-hero { grid-template-columns: 1fr; }
    .lm-hero__budget { text-align: left; }
    .lm-prop {
        grid-template-columns: 32px 1fr;
        grid-template-rows: auto auto;
    }
    .lm-prop__action { grid-column: 2; justify-self: end; }
    .lm-quick-actions { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}


/* === 13. Funnel timeline (воронка лида в карточке) === */
.lm-funnel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}
.lm-funnel-step {
    position: relative;
    padding: 10px 12px;
    border-radius: 11px;
    background: var(--lm-surface-2);
    border: 1px solid var(--lm-border);
    color: var(--lm-text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 60px;
    transition: all 0.15s ease;
}
html.theme-light .lm-funnel-step {
    background: #f8fafc;
    border-color: #e2e8f0;
}
.lm-funnel-step__num {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--lm-text-muted);
}
.lm-funnel-step__label {
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.2;
    color: var(--lm-text);
}
.lm-funnel-step--done {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.32);
    color: #6ee7b7;
}
html.theme-light .lm-funnel-step--done {
    background: #ecfdf5;
    border-color: #6ee7b7;
}
.lm-funnel-step--done .lm-funnel-step__label,
.lm-funnel-step--done .lm-funnel-step__num {
    color: #047857;
}
html.theme-light .lm-funnel-step--done .lm-funnel-step__label,
html.theme-light .lm-funnel-step--done .lm-funnel-step__num {
    color: #047857;
}
.lm-funnel-step--current {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.22), rgba(139, 92, 246, 0.18));
    border-color: var(--lm-border-strong);
    color: #fff;
    box-shadow: 0 6px 18px rgba(167, 139, 250, 0.25);
}
html.theme-light .lm-funnel-step--current {
    background: linear-gradient(135deg, #ede9fe, #f5f3ff);
    border-color: #a78bfa;
    color: #4c1d95;
}
.lm-funnel-step--current .lm-funnel-step__label,
.lm-funnel-step--current .lm-funnel-step__num {
    color: inherit;
}
.lm-funnel-step--lost {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}
html.theme-light .lm-funnel-step--lost {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.lm-funnel__divider {
    margin: 14px 0 8px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--lm-text-muted);
}

/* Контекстный блок «что сделать сейчас» */
.lm-context {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(251, 191, 36, 0.04));
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 14px;
    padding: 14px 16px;
}
html.theme-light .lm-context {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: #fcd34d;
}
.lm-context__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.86rem;
    color: #fbbf24;
    margin-bottom: 6px;
}
html.theme-light .lm-context__title { color: #b45309; }
.lm-context__hint {
    font-size: 0.83rem;
    line-height: 1.45;
    color: var(--lm-text);
    margin-bottom: 10px;
}
html.theme-light .lm-context__hint { color: #1e293b; }
.lm-context__actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}
