/* ===================== Сторінка "Ліди" ===================== */

/* Вкладки етапів */
.lead-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.lead-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #ffffff;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.lead-tab:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
}

.lead-tab.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.lead-tab-count {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
    text-align: center;
}

.lead-tab.active .lead-tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Пошук + фільтри в один ряд */
.lead-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.lead-filters .search-input {
    flex: 1;
}

.lead-select {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
}

.lead-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #9a6b1a;
    cursor: pointer;
    white-space: nowrap;
}

.lead-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #f59e0b;
}

/* Таблиця */
.leads-table .lead-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.leads-table .lead-req-count {
    color: #2563eb;
    font-weight: 600;
}

.leads-table .lead-wrap {
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
}

.leads-table tbody tr.lead-attention td:first-child {
    box-shadow: inset 4px 0 0 #f59e0b;
}

.next-today {
    color: #9a6b1a;
    font-weight: 700;
}

.next-overdue {
    color: #dc2626;
    font-weight: 700;
}

.next-hint {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
}

.lead-call-reminder {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #9a6b1a;
    font-weight: 600;
}

#leadsCountBar {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Форма */
.lead-two {
    display: flex;
    gap: 6px;
}

.lead-two select {
    width: 45%;
}

.lead-two input {
    flex: 1;
    min-width: 0;
}

.form-group .lead-status-option {
    min-width: 110px;
}

.form-group .lead-status-option.status-quote:has(input:checked) {
    background: #fef3c7;
    color: #9a6b1a;
}
.form-group .lead-status-option.status-offer:has(input:checked) {
    background: #eff6ff;
    color: #1d4ed8;
}
.form-group .lead-status-option.status-progress:has(input:checked) {
    background: #ede9fe;
    color: #6d28d9;
}
.form-group .lead-status-option.status-confirmed:has(input:checked) {
    background: #dcfce7;
    color: #15803d;
}
.form-group .lead-status-option.status-rejected:has(input:checked) {
    background: #fee2e2;
    color: #b91c1c;
}

/* Без кольору плашки, поки етап не обраний */
.form-group .lead-status-option {
    background: #ffffff;
    border-color: #e2e8f0;
}

/* Картка */
.lead-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.lead-section-title > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.lead-section-title .btn-answer {
    text-decoration: none;
}

.history-add {
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8f0;
}

.history-add textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.history-add-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    font-size: 13px;
    color: #475569;
}

.history-add-row input {
    margin-left: 6px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
}

.history-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 6px 18px 12px;
}

.history-item {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.history-item:last-child {
    border-bottom: none;
}

.history-meta {
    font-size: 11px;
    color: #94a3b8;
}

.history-text {
    font-size: 14px;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-word;
}

.history-auto .history-text {
    color: #64748b;
    font-style: italic;
    font-size: 13px;
}

.lead-request {
    display: grid;
    grid-template-columns: 90px 110px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #1e293b;
    text-decoration: none;
}

.lead-request:hover {
    background: #f8fafc;
}

.lead-request-date {
    color: #64748b;
}

.lead-request-route {
    font-weight: 600;
}

/* ===================== Шкала прогресу клієнта ===================== */

.pg {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.pg-seg {
    position: relative;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.pg-label {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 6px;
}

.pg-todo {
    background: #e2e8f0;
    color: #94a3b8;
}

.pg-done {
    background: var(--pg);
    color: #ffffff;
}

.pg-green {
    background: #10b981;
    color: #ffffff;
}

/* Поточний етап: смугастий у кольорі етапу + пульсація */
.pg-current {
    background: repeating-linear-gradient(
        -45deg,
        color-mix(in srgb, var(--pg) 22%, #ffffff),
        color-mix(in srgb, var(--pg) 22%, #ffffff) 8px,
        color-mix(in srgb, var(--pg) 10%, #ffffff) 8px,
        color-mix(in srgb, var(--pg) 10%, #ffffff) 16px
    );
    color: var(--pg);
    box-shadow: inset 0 0 0 2px var(--pg);
    animation: pg-pulse 1.8s ease-in-out infinite;
}

@keyframes pg-pulse {
    50% {
        box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pg) 40%, #ffffff);
    }
}

.pg-refused {
    background: #fecaca;
    color: #b91c1c;
}

.pg-box {
    padding: 14px 18px;
}

.pg-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
}

.pg-head-text {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 14px;
}

.pg-head-done {
    color: #059669;
}

.pg-head-refused {
    color: #b91c1c;
}

.pg-head-hint {
    font-size: 13px;
    color: #64748b;
}

.pg-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
}

.pg-card {
    margin-bottom: 16px;
}

.pg-form {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.pg-form .pg-box {
    padding: 10px 12px;
}

/* Маленька смужка в таблиці */
.pg-mini {
    margin-top: 6px;
    gap: 2px;
    width: 110px;
}

.pg-mini .pg-seg {
    height: 6px;
    border-radius: 3px;
}

.pg-mini .pg-current {
    background: color-mix(in srgb, var(--pg) 35%, #ffffff);
    box-shadow: none;
    animation: none;
}

@media (max-width: 700px) {
    .pg-label {
        font-size: 10px;
        padding: 0 2px;
    }
}

/* ---------- Експорт / Імпорт / По Україні ---------- */
.trade-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.form-group .trade-chip {
    flex: 1;
    min-width: 130px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.trade-chip input {
    display: none;
}
.form-group .trade-chip.trade-export:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}
.form-group .trade-chip.trade-import:has(input:checked) {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #15803d;
}
.form-group .trade-chip.trade-ua:has(input:checked) {
    border-color: #b8862e;
    background: #fffbeb;
    color: #9a6b1a;
}

.trade-badge {
    display: inline-block;
    margin: 1px 3px 1px 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    background: #f1f5f9;
    color: #334155;
}
.trade-badge.trade-export {
    background: #dbeafe;
    color: #1d4ed8;
}
.trade-badge.trade-import {
    background: #dcfce7;
    color: #15803d;
}
.trade-badge.trade-ua {
    background: #fef3c7;
    color: #9a6b1a;
}
.lead-trade-cell {
    min-width: 90px;
}
