/* CRM Kanban View */
.crm-card-ids {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    margin-bottom: 3px;
    flex-wrap: wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 9px;
}

.crm-card-ids .crm-chat-id,
.crm-card-ids .crm-card-cabinet {
    background: #f0f2f5;
    color: #555;
    padding: 1px 5px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.crm-card-ids .crm-card-cabinet {
    background: #e3f2fd;
    color: #1565c0;
}

.crm-card-ids .crm-chat-id:hover,
.crm-card-ids .crm-card-cabinet:hover {
    background: #1565c0;
    color: #fff;
}

.crm-kanban {
    display: flex;
    gap: 8px;
    padding: 8px;
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    align-items: stretch;
    background: #e2e6ea;
}

/* Kanban Column */
.kanban-column {
    flex: 1;
    min-width: 240px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    background: #e2e6ea;
    border-radius: 6px;
    overflow: hidden;
}

.kanban-column-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px 8px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
    border-top: 3px solid transparent;
}

.kanban-column-header-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.kanban-column-header[data-col="unchecked"] { border-top-color: #9e9e9e; background: #fafafa; }
.kanban-column-header[data-col="errors"]    { border-top-color: #e53935; background: #fdecea; }
.kanban-column-header[data-col="clean"]     { border-top-color: #1565c0; background: #e8f1fb; }
.kanban-column-header[data-col="awaiting"]  { border-top-color: #fb8c00; background: #fff3e0; }
.kanban-column-header[data-col="sent"]      { border-top-color: #43a047; background: #e8f5e9; }
.kanban-column-header[data-col="skipped"]   { border-top-color: #bdbdbd; background: #f5f5f5; }

.kanban-column-icon {
    font-size: 14px;
    font-weight: 700;
}

.kanban-column-title {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-column-count {
    font-size: 11px;
    color: #999;
    background: #eee;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.kanban-column-sum {
    font-size: 11px;
    font-weight: 600;
    color: #2e7d32;
    align-self: flex-end;
    white-space: nowrap;
    margin-top: 1px;
    line-height: 1.2;
    min-height: 13px; /* зарезервировано — высота шапок одинакова даже без суммы */
}

/* В колонках, где оплата = тревожный сигнал (есть оплата, но отчёт не дошёл) */
.kanban-column-header[data-col="errors"] .kanban-column-sum,
.kanban-column-header[data-col="skipped"] .kanban-column-sum,
.kanban-column-header[data-col="unchecked"] .kanban-column-sum {
    color: #c62828;
}

.kanban-column-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Cards */
.crm-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-left: 3px solid #cfd2d6;
    border-radius: 5px;
    padding: 8px 10px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.crm-card[data-col="unchecked"] { border-left-color: #9e9e9e; }
.crm-card[data-col="errors"]    { border-left-color: #e53935; }
.crm-card[data-col="clean"]     { border-left-color: #1565c0; }
.crm-card[data-col="awaiting"]  { border-left-color: #fb8c00; }
.crm-card[data-col="sent"]      { border-left-color: #43a047; }
.crm-card[data-col="skipped"]   { border-left-color: #bdbdbd; }

.crm-card:hover {
    border-top-color: #1565c0;
    border-right-color: #1565c0;
    border-bottom-color: #1565c0;
    box-shadow: 0 2px 6px rgba(21, 101, 192, 0.12);
    transform: translateY(-1px);
}

.crm-card.crm-card-visited {
    border-top-color: #7b1fa2;
    border-right-color: #7b1fa2;
    border-bottom-color: #7b1fa2;
    border-top-width: 2px;
    border-right-width: 2px;
    border-bottom-width: 2px;
    padding: 7px 9px; /* компенсация лишнего border */
}

.crm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 3px;
}

.crm-card-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.crm-card-tariff {
    font-size: 8px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.crm-card-header .crm-card-settings,
.crm-card-header .crm-card-skip,
.crm-card-header .crm-card-unskip {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    padding: 2px 6px;
    color: #888;
    flex-shrink: 0;
    border-radius: 3px;
}

.crm-card-header .crm-card-unskip {
    color: #1565c0;
    font-size: 10px;
    font-weight: 500;
}

.crm-card-header .crm-card-settings:hover,
.crm-card-header .crm-card-skip:hover,
.crm-card-header .crm-card-unskip:hover {
    background: #eee;
    color: #333;
    border-color: #ddd;
}

.crm-card-header .crm-card-unskip:hover {
    background: #e3f2fd;
    color: #0d47a1;
    border-color: #1565c0;
}

/* Видимы только при hover на карточке — снижают визуальный шум */
.crm-card .crm-card-overflow {
    opacity: 0;
    transition: opacity 0.15s;
}

.crm-card:hover .crm-card-overflow,
.crm-card-overflow:focus-visible {
    opacity: 1;
}

.crm-card-sub {
    font-size: 10px;
    color: #888;
    margin-bottom: 2px;
}

.crm-card-meta {
    font-size: 10px;
    color: #666;
}

.crm-card-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 3px 0;
}

.crm-contact {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.crm-contact.tg { background: #e3f2fd; color: #1565c0; }
.crm-contact.email { background: #f3e5f5; color: #7b1fa2; }
.crm-contact.phone { background: #e8f5e9; color: #2e7d32; }
.crm-contact:hover { opacity: 0.8; }

/* Status badges row — все статусы в одном ряду, единая форма pill */
.crm-card-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.crm-card-statuses:empty {
    display: none;
}

.crm-card-status {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    display: inline-block;
    line-height: 1.3;
    margin: 0;
}

.crm-card-status.error {
    background: #ffebee;
    color: #c62828;
}

.crm-card-status.awaiting {
    background: #fff3e0;
    color: #e65100;
}

.crm-card-status.sent {
    background: #e8f5e9;
    color: #2e7d32;
}

.crm-card-status.clean {
    background: #e8f5e9;
    color: #2e7d32;
}

.crm-card-status.placements {
    background: #e3f2fd;
    color: #1565c0;
}

/* Flags — toggle-бейджи */
.crm-card-flags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.crm-flag {
    font-size: 9px;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    color: #999;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    opacity: 0.5;
}

.crm-flag:hover {
    opacity: 0.8;
}

.crm-flag.active {
    opacity: 1;
    border-color: currentColor;
    font-weight: 600;
}

/* Skip button */
.crm-card-skip {
    width: 18px;
    height: 18px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    color: #bbb;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
}

.crm-card-skip:hover {
    border-color: #e53935;
    color: #e53935;
}

.crm-card-skip.confirm {
    background: #ffebee;
    border-color: #e53935;
    color: #e53935;
    font-weight: 700;
}

/* Bottom row — кнопки */
.crm-card-bottom {
    display: flex;
    align-items: stretch;
    gap: 4px;
    margin-top: 6px;
}

.crm-card-report {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.crm-card-report:hover {
    background: #f0f4ff;
    border-color: #1565c0;
    color: #1565c0;
}

.crm-card-report svg {
    flex-shrink: 0;
}


/* Free tariff cards — визуально маркированы фоном, левая полоса колонки сохраняется */
.crm-card.tariff-free {
    background: #fafafa;
    border-top-color: #e0e0e0;
    border-right-color: #e0e0e0;
    border-bottom-color: #e0e0e0;
}

.crm-card.tariff-free .crm-card-name {
    color: #555;
}

.crm-card.tariff-free:hover {
    background: #fff;
    border-top-color: #bdbdbd;
    border-right-color: #bdbdbd;
    border-bottom-color: #bdbdbd;
}

/* Progress bar */
.crm-progress-bar {
    height: 20px;
    background: #f0f0f0;
    border-radius: 4px;
    margin: 0 8px 6px 8px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.crm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1565c0, #42a5f5);
    border-radius: 4px;
    transition: width 0.3s;
}

.crm-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    line-height: 20px;
    color: #555;
    font-weight: 500;
}

/* Action buttons */
.crm-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    font-size: 10px;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.crm-card-action:hover {
    background: #e3f2fd;
    border-color: #1565c0;
    color: #1565c0;
}

.crm-card-action.confirm {
    background: #fff3e0;
    border-color: #fb8c00;
    color: #e65100;
    font-weight: 600;
    animation: pulse-confirm 0.3s ease;
}

@keyframes pulse-confirm {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* Status clean */
.crm-card-status.clean {
    background: #e3f2fd;
    color: #1565c0;
}

/* Sentinel */
.lazy-sentinel {
    height: 1px;
    width: 100%;
}
