/* WAY Modal System - Dark Theme */

/* ВАЖНО: Не используем класс .way-modal для position/display,
   так как Bootstrap модалки используют свою структуру */

/* ВАЖНО: Не используем класс .way-modal для position/display,
   так как Bootstrap модалки используют свою структуру */

/* Backdrop для кастомных модалок (не Bootstrap) */
.way-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

/* Container для кастомных модалок (не Bootstrap) */

.way-modal-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: #1a1a1a;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.way-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.way-modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.way-modal-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.way-modal-title-group {
    flex: 1;
    min-width: 0;
}

.way-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.way-modal-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.way-modal-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.way-modal-status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Quick Actions */
.way-modal-quick-actions {
    display: flex;
    gap: 8px;
}

.way-modal-quick-action {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.way-modal-quick-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.way-modal-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.way-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Tabs */
.way-modal-tabs {
    background: #2d2d2d;
    border-bottom: 1px solid #3d3d3d;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.way-modal-tab {
    padding: 14px 20px;
    background: none;
    border: none;
    color: #888;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.way-modal-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.way-modal-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Body */
.way-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #1a1a1a;
    color: #fff;
}

.way-modal-body::-webkit-scrollbar {
    width: 8px;
}

.way-modal-body::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.way-modal-body::-webkit-scrollbar-thumb {
    background: #3d3d3d;
    border-radius: 4px;
}

.way-modal-body::-webkit-scrollbar-thumb:hover {
    background: #4d4d4d;
}

/* Tab Content Styles */
.way-modal-body h3 {
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.way-modal-body p {
    color: #ccc;
    line-height: 1.6;
}

.way-modal-body .info-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #2d2d2d;
}

.way-modal-body .info-label {
    color: #888;
    min-width: 120px;
    font-size: 0.9rem;
}

.way-modal-body .info-value {
    color: #fff;
    font-size: 0.9rem;
}

.way-modal-body .info-value a {
    color: #667eea;
    text-decoration: none;
}

.way-modal-body .info-value a:hover {
    text-decoration: underline;
}

/* Loading */
.way-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #888;
}

.way-modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #3d3d3d;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile */
@media (max-width: 768px) {
    .way-modal-container {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .way-modal-header {
        padding: 16px;
    }
    
    .way-modal-title {
        font-size: 1.1rem;
    }
    
    .way-modal-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .way-modal-quick-actions {
        gap: 4px;
    }
    
    .way-modal-quick-action {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .way-modal-tabs {
        overflow-x: auto;
    }
    
    .way-modal-tab {
        padding: 12px 16px;
        font-size: 0.85rem;
    }
    
    .way-modal-body {
        padding: 16px;
    }
    
    .way-modal-body .info-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .way-modal-body .info-label {
        min-width: auto;
        font-weight: 600;
    }
}

/* Bootstrap Modal Dark Theme Override */
.modal-content {
    background: linear-gradient(135deg, #2d2d2d 0%, #252525 100%);
    border: 1px solid #3d3d3d;
    color: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    border-bottom: 1px solid #3d3d3d;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 24px;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
}

.modal-title {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    row-gap: 4px;
    line-height: 1.25;
}

.modal-title .entity-icon {
    font-size: 1.5rem;
}

.modal-title .entity-id {
    font-size: 0.9rem;
    opacity: 0.8;
    font-weight: 500;
}

.modal-title-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.modal-title-container .modal-title {
    flex: 1 1 200px;
    min-width: 0;
}

.entity-status {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 100%;
}

.entity-status .badge {
    padding: 6px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.modal-body {
    background: #1a1a1a;
    color: #fff;
    padding: 0;
}

.modal-footer {
    border-top: 1px solid #3d3d3d;
    background: #2d2d2d;
    padding: 16px 24px;
}

.btn-close {
    filter: invert(1) brightness(100);
    opacity: 0.8;
    transition: all 0.2s;
}

.btn-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Quick Actions in Header */
.quick-actions-header {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.quick-action-btn {
    padding: 7px 12px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.quick-action-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    opacity: 0;
    transition: opacity 0.3s;
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.quick-action-btn:hover::before {
    opacity: 1;
}

.quick-action-btn:active {
    transform: translateY(-1px);
}

.quick-action-btn span:first-child {
    font-size: 1rem;
    position: relative;
    z-index: 1;
}
.quick-action-btn span:first-child i {
    font-size: 1rem;
}

.quick-action-btn span:last-child {
    position: relative;
    z-index: 1;
}

/* Цветные варианты кнопок */
.quick-action-btn.btn-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(5, 150, 105, 0.3));
    border-color: rgba(16, 185, 129, 0.5);
}

.quick-action-btn.btn-success:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.5), rgba(5, 150, 105, 0.5));
    border-color: rgba(16, 185, 129, 0.7);
}

.quick-action-btn.btn-primary {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(37, 99, 235, 0.3));
    border-color: rgba(59, 130, 246, 0.5);
}

.quick-action-btn.btn-primary:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.5), rgba(37, 99, 235, 0.5));
    border-color: rgba(59, 130, 246, 0.7);
}

.quick-action-btn.btn-info {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(8, 145, 178, 0.3));
    border-color: rgba(6, 182, 212, 0.5);
}

.quick-action-btn.btn-info:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.5), rgba(8, 145, 178, 0.5));
    border-color: rgba(6, 182, 212, 0.7);
}

.quick-action-btn.btn-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(217, 119, 6, 0.3));
    border-color: rgba(245, 158, 11, 0.5);
}

.quick-action-btn.btn-warning:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.5), rgba(217, 119, 6, 0.5));
    border-color: rgba(245, 158, 11, 0.7);
}

/* Modal Tabs Navigation - Segmented Control Style */
.modal-tabs-nav {
    background: #1a1a1a;
    border-bottom: none;
    padding: 10px 16px;
    display: flex;
    justify-content: center;
}

.modal-tabs-nav .nav-tabs {
    border-bottom: none;
    background: #2d2d2d;
    border-radius: 12px;
    padding: 3px;
    display: inline-flex;
    gap: 0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #3d3d3d;
    position: relative;
}

.modal-tabs-nav .nav-link {
    color: #888;
    border: none;
    padding: 8px 14px;
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border-radius: 9px;
    position: relative;
    z-index: 1;
    min-width: auto;
    justify-content: center;
}

.modal-tabs-nav .nav-link:hover {
    color: #fff;
}

.modal-tabs-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.modal-tabs-nav .nav-link i {
    font-size: 0.95rem;
    transition: transform 0.3s;
}

.modal-tabs-nav .nav-link.active i {
    transform: scale(1.02);
}

/* Tab Content */
.tab-content {
    padding: 24px;
    min-height: 300px;
    background: #1a1a1a;
}

.tab-pane {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Optimization — табы в ряд со скроллом, без наложения */
@media (max-width: 768px) {
    .modal-tabs-nav {
        padding: 8px 10px;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .modal-tabs-nav .nav-tabs {
        width: max-content;
        min-width: 100%;
        display: flex;
        flex-wrap: nowrap;
        padding: 3px;
        justify-content: flex-start;
    }
    
    .modal-tabs-nav .nav-link {
        flex: 0 0 auto;
        min-width: auto;
        padding: 8px 12px;
        font-size: 0.82rem !important;
        min-height: 40px;
    }
    
    .modal-tabs-nav .nav-link span {
        display: inline;
    }
    
    .modal-tabs-nav .nav-link i {
        font-size: 0.95rem;
        margin: 0 5px 0 0;
        flex-shrink: 0;
    }
}

@media (max-width: 520px) {
    .modal-tabs-nav .nav-link .way-modal-tab-text {
        display: none;
    }
    .modal-tabs-nav .nav-link {
        padding: 8px 11px;
        min-width: 40px;
        justify-content: center;
    }
    .modal-tabs-nav .nav-link i {
        margin: 0;
    }
}

.modal .form-control,
.modal .form-select {
    background: #1a1a1a;
    border-color: #3d3d3d;
    color: #fff;
}

.modal .form-control:focus,
.modal .form-select:focus {
    background: #1a1a1a;
    border-color: #667eea;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.modal .form-control::placeholder {
    color: #666;
}

.modal .form-label {
    color: #aaa;
    font-weight: 500;
}

.modal .form-select option {
    background: #1a1a1a;
    color: #fff;
}

/* Tabs in modals */
.modal .nav-tabs {
    border-bottom: 1px solid #3d3d3d;
    background: #1a1a1a;
}

.modal .nav-tabs .nav-link {
    color: #888;
    border: none;
    border-bottom: 2px solid transparent;
}

.modal .nav-tabs .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.modal .nav-tabs .nav-link.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    border-bottom-color: #667eea;
}

/* Tables in modals */
.modal .table {
    color: #ddd;
}

.modal .table thead th {
    background: #1a1a1a;
    border-bottom: 2px solid #3d3d3d;
    color: #aaa;
}

.modal .table tbody tr {
    background: #2d2d2d;
}

.modal .table tbody tr:hover {
    background: #3d3d3d;
}

.modal .table tbody td {
    border-bottom: 1px solid #3d3d3d;
    color: #ddd;
}

/* Cards in modals */
.modal .card {
    background: #1a1a1a;
    border-color: #3d3d3d;
    color: #fff;
}

.modal .card-body {
    background: #1a1a1a;
}

/* Badges in modals */
.modal .badge {
    font-weight: 600;
}

/* Alerts in modals */
.modal .alert {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    color: #fff;
}

.modal .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.modal .alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.modal .alert-warning {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
}

/* Text colors */
.modal .text-muted {
    color: #aaa !important;
}

/* Links */
.modal a {
    color: #667eea;
}

.modal a:hover {
    color: #7c8ef5;
}

/* Buttons */
.modal .btn-primary {
    background: #667eea;
    border-color: #667eea;
}

.modal .btn-primary:hover {
    background: #5568d3;
    border-color: #4c5fc7;
}

.modal .btn-secondary {
    background: #3d3d3d;
    border-color: #3d3d3d;
    color: #fff;
}

.modal .btn-secondary:hover {
    background: #4d4d4d;
    border-color: #4d4d4d;
}

.modal .btn-success {
    background: #22c55e;
    border-color: #22c55e;
}

.modal .btn-success:hover {
    background: #16a34a;
    border-color: #15803d;
}

.modal .btn-danger {
    background: #ef4444;
    border-color: #ef4444;
}

.modal .btn-danger:hover {
    background: #dc2626;
    border-color: #b91c1c;
}

.modal .btn-warning {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #000;
}

.modal .btn-warning:hover {
    background: #d97706;
    border-color: #b45309;
}

.modal .btn-info {
    background: #3b82f6;
    border-color: #3b82f6;
}

.modal .btn-info:hover {
    background: #667eea;
    border-color: #5a6fd6;
}

.modal .btn-outline-primary {
    color: #667eea;
    border-color: #667eea;
}

.modal .btn-outline-primary:hover {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
}

.modal .btn-outline-secondary {
    color: #aaa;
    border-color: #3d3d3d;
}

.modal .btn-outline-secondary:hover {
    background: #3d3d3d;
    border-color: #3d3d3d;
    color: #fff;
}

/* Spinner */
.modal .spinner-border {
    color: #667eea;
}

/* Scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #3d3d3d;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #667eea;
}

/* Lead Info Container */
.lead-info-container h6 {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-info-container .table {
    background: transparent;
    margin-bottom: 0;
}

.lead-info-container .table td {
    padding: 12px 8px;
    border-bottom: 1px solid #3d3d3d;
    vertical-align: middle;
}

.lead-info-container .table td:first-child {
    color: #888;
    font-weight: 600;
}

.lead-info-container .table td:last-child {
    color: #fff;
}

.lead-info-container .card {
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    border-radius: 12px;
}

.lead-info-container .card-body {
    padding: 16px;
    color: #ccc;
}

.lead-info-container .badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
}

.lead-info-container .btn {
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
}

/* Tasks List */
.tasks-list .card {
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    border-radius: 12px;
    transition: all 0.2s;
}

.tasks-list .card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.tasks-list .card-body {
    padding: 16px;
}

.tasks-list h6 {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.tasks-list small {
    color: #888;
    font-size: 0.8rem;
}

.tasks-list .badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
}

/* Comments Section */
#lead-comments-container {
    min-height: 200px;
}

.comment-item {
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.comment-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.comment-author {
    font-weight: 700;
    color: #fff;
    font-size: 0.95rem;
}

.comment-date {
    color: #888;
    font-size: 0.8rem;
}

.comment-text {
    color: #ccc;
    line-height: 1.6;
    font-size: 0.9rem;
}

.comment-form {
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.comment-form textarea {
    background: #1a1a1a;
    border: 2px solid #3d3d3d;
    border-radius: 10px;
    color: #fff;
    padding: 12px;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 100px;
    transition: all 0.2s;
}

.comment-form textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.comment-form textarea::placeholder {
    color: #666;
}

.comment-form .btn {
    margin-top: 12px;
}

/* History Timeline */
.history-timeline {
    position: relative;
    padding-left: 40px;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
}

.history-item {
    position: relative;
    padding-bottom: 24px;
}

.history-item:last-child {
    padding-bottom: 0;
}

.history-icon {
    position: absolute;
    left: -32px;
    top: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.history-item strong {
    color: #fff;
    font-weight: 600;
}

.history-item p {
    color: #ccc;
    margin-top: 4px;
    font-size: 0.9rem;
}

.history-item small {
    color: #888;
    font-size: 0.8rem;
}

/* Empty States */
.text-center.py-5 {
    padding: 60px 20px !important;
}

.text-center.py-5 i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 16px;
}

.text-center.py-5 p {
    color: #888;
    font-size: 1rem;
    margin-bottom: 16px;
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

/* Mobile Optimization for Modal */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 16px;
        flex-wrap: wrap;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
    
    .modal-title .entity-icon {
        font-size: 1.2rem;
    }
    
    .modal-title .entity-id {
        font-size: 0.8rem;
    }
    
    .modal-title-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .entity-status {
        margin-left: 0 !important;
        margin-top: 2px;
    }
    
    .quick-actions-header {
        width: 100%;
        margin-top: 8px;
        gap: 6px;
    }
    
    .quick-action-btn {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
        font-size: 0.75rem;
        justify-content: center;
    }
    
    .quick-action-btn span:last-child {
        display: none;
    }
    
    .quick-action-btn span:first-child {
        font-size: 1.05rem;
    }
    
    .modal-tabs-nav .nav-link {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .tab-content {
        padding: 16px;
    }
    
    .lead-info-container .row {
        margin: 0;
    }
    
    .lead-info-container .col-md-6 {
        padding: 0;
        margin-bottom: 24px;
    }
    
    .lead-info-container .table td {
        padding: 10px 4px;
        font-size: 0.85rem;
    }
    
    .lead-info-container .table td:first-child {
        width: 100px;
    }
    
    .lead-info-container .btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .history-timeline {
        padding-left: 32px;
    }
    
    .history-icon {
        left: -28px;
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .modal-footer .btn {
        flex: 1;
    }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }
    
    .comment-form textarea,
    .modal input,
    .modal select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Landscape Mode on Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-header {
        padding: 12px 16px;
    }
    
    .quick-actions-header {
        margin-top: 8px;
    }
    
    .modal-tabs-nav .nav-link {
        padding: 10px 14px;
    }
    
    .tab-content {
        padding: 12px;
    }
}

/* Quick Action Buttons in Lead Info */
.lead-info-container .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    filter: brightness(1.2);
}

.lead-info-container .btn:active {
    transform: translateY(0);
}

/* Edit Button Hover Effect */
.lead-info-container .btn-lg:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.lead-info-container .btn-lg:active {
    transform: translateY(-1px);
}

/* Edit Modal Footer Buttons */
#editLeadModal .modal-footer .btn:hover {
    transform: translateY(-2px);
}

#editLeadModal .modal-footer .btn:active {
    transform: translateY(0);
}

#editLeadModal .modal-footer .btn-secondary:hover {
    background: #4d4d4d !important;
    border-color: #5d5d5d !important;
}

#editLeadModal .modal-footer .btn-primary:hover {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5) !important;
    filter: brightness(1.1);
}

/* Edit Modal Tabs Hover */
#editLeadModal .nav-link:hover {
    filter: brightness(1.2);
}

/* Lead modal — вкладка «Задачи» (компакт, мобильный) */
.lmt-wrap { max-width: 900px; margin: 0 auto; padding: 0 2px 8px; }
.lmt-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.lmt-toolbar-title {
    margin: 0; color: #fff; font-weight: 700; font-size: 0.95rem;
    display: flex; align-items: center; gap: 8px;
}
.lmt-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 800; background: rgba(102,126,234,0.25); color: #c4b5fd;
}
.lmt-btn-add {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px; border: none; cursor: pointer; font-weight: 700; font-size: 0.82rem;
    background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.lmt-btn-add:hover { filter: brightness(1.06); transform: translateY(-1px); }

.lmt-form-panel {
    display: none;
    gap: 12px;
    margin-bottom: 16px; padding: 14px 14px 12px;
    border-radius: 14px;
    background: linear-gradient(165deg, rgba(30,30,48,0.98), rgba(18,18,28,0.95));
    border: 1px solid rgba(99,102,241,0.22);
    box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
.lmt-form-head {
    font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
    color: #a5b4fc; display: flex; align-items: center; gap: 8px;
}
.lmt-form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px;
}
.lmt-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lmt-field-full { grid-column: 1 / -1; }
.lmt-label { font-size: 0.72rem; font-weight: 600; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.03em; }
.lmt-input, .lmt-select, .lmt-textarea {
    width: 100%; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.35); color: #f4f4f5; padding: 10px 12px; font-size: 0.88rem;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.lmt-input:focus, .lmt-select:focus, .lmt-textarea:focus {
    border-color: rgba(99,102,241,0.55);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.lmt-textarea { resize: vertical; min-height: 64px; }
.lmt-form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.lmt-btn-ghost {
    padding: 8px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12);
    background: transparent; color: rgba(255,255,255,0.55); font-weight: 600; font-size: 0.82rem; cursor: pointer;
}
.lmt-btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.22); }
.lmt-btn-primary {
    padding: 8px 16px; border-radius: 10px; border: none; cursor: pointer; font-weight: 700; font-size: 0.82rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
    display: inline-flex; align-items: center; gap: 6px;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.lmt-btn-primary:hover { filter: brightness(1.05); }

.lmt-list { display: flex; flex-direction: column; gap: 10px; }
.lmt-task-card {
    border-radius: 14px; padding: 12px 14px;
    background: rgba(26,26,40,0.95);
    border: 1px solid rgba(255,255,255,0.07);
}
.lmt-task-card--overdue { border-color: rgba(239,68,68,0.45); box-shadow: 0 0 0 1px rgba(239,68,68,0.12); }
.lmt-task-head { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.lmt-task-title { margin: 0; color: #fff; font-weight: 700; font-size: 0.92rem; line-height: 1.35; word-break: break-word; }
.lmt-task-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.lmt-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 8px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    border: 1px solid;
}
.lmt-task-desc {
    margin: 8px 0 0; color: rgba(255,255,255,0.55); font-size: 0.8rem; line-height: 1.45;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; word-break: break-word;
}
.lmt-task-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.06);
}
.lmt-task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 0.78rem; color: rgba(255,255,255,0.45); min-width: 0; }
.lmt-task-meta--late { color: #fca5a5; }
.lmt-task-type { color: rgba(165,180,252,0.85); font-weight: 600; }
.lmt-btn-done {
    padding: 6px 12px; border-radius: 9px; border: none; cursor: pointer; font-weight: 700; font-size: 0.75rem;
    background: rgba(16,185,129,0.18); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.35);
    display: inline-flex; align-items: center; gap: 4px;
}
.lmt-btn-done:hover { background: rgba(16,185,129,0.28); color: #fff; }

@media (max-width: 576px) {
    .lmt-form-grid { grid-template-columns: 1fr; }
    .lmt-toolbar-title { font-size: 0.9rem; }
    .lmt-btn-add span { display: none; }
    .lmt-btn-add { padding: 8px 12px; }
    .lmt-task-foot { flex-direction: column; align-items: stretch; }
    .lmt-btn-done { justify-content: center; width: 100%; min-height: 44px; font-size: 0.85rem; }
}

/* Unified finance/notification modal polish across role dashboards */
.wd-modal,
.modal.show,
.modal.fade.show {
    backdrop-filter: blur(14px);
}

.wd-modal-content,
.modal-content {
    background: linear-gradient(165deg, rgba(18,18,28,0.98), rgba(10,10,18,0.96));
    border: 1px solid rgba(139,92,246,0.18);
    box-shadow: 0 28px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.wd-modal-hdr,
.modal-header {
    background: linear-gradient(180deg, rgba(139,92,246,0.08), rgba(139,92,246,0));
}

/* Только кастомная кнопка wd-modal — НЕ трогаем Bootstrap .btn-close: шортханд background сбрасывает mask/SVG крестика */
.wd-modal-close,
.modal .close {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.72);
    opacity: 1;
}

.wd-modal-close:hover,
.modal .close:hover {
    background: rgba(139,92,246,0.16);
    color: #fff;
}

.inv-upload-area,
.wd-file-input,
.modal .form-control,
.modal .form-select {
    box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}

html.theme-light .wd-modal,
html.theme-light .modal.show,
html.theme-light .modal.fade.show {
    backdrop-filter: blur(12px);
}

html.theme-light .wd-modal-content,
html.theme-light .modal-content {
    background: #ffffff;
    border-color: #dbe2ef;
    box-shadow: 0 28px 70px rgba(15,23,42,0.18), 0 0 0 1px rgba(255,255,255,0.8) inset;
}

html.theme-light .wd-modal-hdr,
html.theme-light .modal-header {
    background: linear-gradient(180deg, rgba(102,126,234,0.08), rgba(102,126,234,0));
}

html.theme-light .wd-modal-hdr h3,
html.theme-light .modal-title {
    color: #0f172a;
}

html.theme-light .wd-modal-close,
html.theme-light .modal .close {
    filter: none !important;
    opacity: 0.82 !important;
}

html.theme-light .wd-modal-close:hover,
html.theme-light .modal .close:hover {
    opacity: 1 !important;
}

@media (max-width: 576px) {
    .wd-modal-content,
    .modal-dialog {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        margin: 8px auto;
    }

    .wd-modal-content,
    .modal-content {
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
        overflow: hidden;
    }

    .wd-modal-body,
    .modal-body {
        max-height: calc(100dvh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
