:root {
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-dark: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --color-primary: #667eea;
    --color-secondary: #764ba2;
}

@media (min-width: 1200px) {
    .container { max-width: 90%; }
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

main {
    flex: 1;
}

main.container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-top: 2rem;
    margin-bottom: 2rem;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    animation: slideUp 0.5s ease-out;
}

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

/* Навбар */
.navbar {
    background: var(--gradient-dark) !important;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: var(--transition);
}

.navbar-brand:hover {
    filter: brightness(1.2);
}

.navbar-brand .badge {
    background: rgba(255,255,255,0.2) !important;
    border: 1px solid rgba(255,255,255,0.3);
    font-size: 0.7rem;
    vertical-align: middle;
    transition: none;
}

.nav-link {
    position: relative;
    transition: var(--transition);
    margin: 0 2px;
    border-radius: 8px;
    padding: 8px 16px !important;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-1px);
}

/* Заголовок страницы */
h2 {
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
}

h2 i {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Фильтр */
#status-filter {
    border-radius: 12px;
    border: 2px solid #e0e7ff;
    padding: 8px 16px;
    font-weight: 500;
    transition: var(--transition);
    background: white;
    cursor: pointer;
}

#status-filter:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#status-filter:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Таблица */
.table {
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table thead th {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    color: #4a5568;
    padding: 12px 16px;
}

.table tbody tr {
    background: white;
    box-shadow: var(--shadow-sm);
    border-radius: 12px;
    transition: var(--transition);
    animation: fadeIn 0.5s ease-out backwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: #f8faff;
}

.table td {
    padding: 12px 10px;
    vertical-align: middle;
    border: none;
    font-size: 0.85rem;
}

.table td:first-child {
    font-weight: 700;
    color: var(--color-primary);
}

.table a.text-decoration-none {
    color: #2d3748;
    font-weight: 600;
    transition: var(--transition);
}

.table a.text-decoration-none:hover {
    color: var(--color-primary);
}

/* Бейджи статусов */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    transition: var(--transition);
}

.badge:hover {
    filter: brightness(1.15);
}

.badge.bg-primary {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
}

.badge.bg-info {
    background: linear-gradient(135deg, #4facfe, #00f2fe) !important;
}

.badge.bg-warning {
    background: linear-gradient(135deg, #fa709a, #fee140) !important;
    color: #333 !important;
}

.badge.bg-success {
    background: linear-gradient(135deg, #43e97b, #38f9d7) !important;
}

.badge.bg-secondary {
    background: linear-gradient(135deg, #a8a8b8, #8e8ea0) !important;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #f093fb, #f5576c) !important;
}

.badge.bg-purple {
    background: linear-gradient(135deg, #a855f7, #7c3aed) !important;
}

.badge.bg-yellow {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    color: #333 !important;
}

.badge.bg-orange {
    background: linear-gradient(135deg, #fb923c, #ea580c) !important;
    color: #fff !important;
}

.badge.bg-brown {
    background: linear-gradient(135deg, #a16207, #854d0e) !important;
}

/* Приоритеты */
.priority-critical { color: #dc3545; font-weight: 700; }
.priority-high { color: #fd7e14; font-weight: 600; }
.priority-medium { color: #0d6efd; }
.priority-low { color: #198754; }

/* Кнопки */
.btn-outline-primary {
    border-radius: 12px;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 500;
    transition: var(--transition);
    padding: 6px 12px;
}

.btn-outline-primary:hover {
    background: var(--gradient-primary);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: white;
}

/* Аватарки — универсальные размеры */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    flex-shrink: 0;
}

.avatar-xs { width: 20px; height: 20px; }
.avatar-sm { width: 28px; height: 28px; }
.avatar-md { width: 32px; height: 32px; }
.avatar-lg { width: 48px; height: 48px; }
.avatar-xl { width: 100px; height: 100px; }

.avatar-icon {
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-icon-xs { width: 20px; height: 20px; font-size: 10px; }
.avatar-icon-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-icon-md { width: 32px; height: 32px; font-size: 14px; }
.avatar-icon-lg { width: 48px; height: 48px; font-size: 20px; }
.avatar-icon-xl { width: 100px; height: 100px; font-size: 40px; }

/* Обратная совместимость */
.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 4px;
}

.user-avatar-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-right: 4px;
}

/* Dropzone (для комментариев) */
.drop-zone {
    border: 2px dashed #adb5bd;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s;
    background: #f8f9fa;
}

.drop-zone.dragover {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.file-preview {
    max-width: 100px;
    max-height: 100px;
    object-fit: cover;
}

/* Toast — анимации */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast.show {
    animation: toastIn 0.4s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

.toast.hiding {
    animation: toastOut 0.3s cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
}

/* Дропдаун */
.dropdown-menu {
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    border-radius: 10px;
    padding: 10px 16px;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: #f0f4ff;
    transform: translateX(4px);
}

/* Футер */
footer {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
    color: rgba(255,255,255,0.8) !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}

footer small {
    color: rgba(255,255,255,0.9) !important;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* Breadcrumbs */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 4rem;
    opacity: 0.4;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Login page */
.login-wrapper {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    border: none;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--gradient-dark);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: none;
    -webkit-text-fill-color: white;
    color: white;
    margin-bottom: 0.25rem;
}

.login-header p {
    opacity: 0.8;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.login-body {
    padding: 2rem;
}

/* Комментарии — сохраняем переносы строк */
.comment-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    main.container {
        margin: 1rem;
        padding: 1rem;
        border-radius: 16px;
    }

    .table {
        font-size: 0.85rem;
    }

    .table td, .table th {
        padding: 8px;
    }

    .login-card {
        margin: 0.5rem;
    }

    .dropdown-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* executor badges в таблице */
.executor-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Стиль для priority в inline-стилях (обратная совместимость) */
[style*="color: #ffc107"] {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[style*="color: #dc3545"] {
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Widget cards */
.widget-card {
    border-radius: 16px;
    transition: var(--transition);
}

.widget-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.widget-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.widget-value {
    font-size: 2rem;
    line-height: 1.2;
}

.widget-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Idle time indicators */
.idle-time {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.idle-green { background: #d1e7dd; color: #0f5132; }
.idle-yellow { background: #fff3cd; color: #664d03; }
.idle-orange { background: #ffe0b2; color: #e65100; }
.idle-red { background: #f8d7da; color: #842029; }

/* Search input */
.input-group .input-group-text {
    border-color: #dee2e6;
    border-radius: 12px 0 0 12px;
}

.input-group .form-control {
    border-color: #dee2e6;
    border-radius: 0 12px 12px 0;
}

.input-group .form-control:focus,
.input-group .input-group-text:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Small widget cards (1-line) */
.widget-card-sm {
    border-radius: 12px;
    transition: var(--transition);
    white-space: nowrap;
}

.widget-card-sm:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Left strips for row highlighting */
tr.row-needs-attention td:first-child {
    border-left: 4px solid var(--color-primary);
    padding-left: 6px;
    border-radius: 12px 0 0 12px;
}

tr.row-overdue td:first-child {
    border-left: 4px solid #dc3545;
    padding-left: 6px;
    border-radius: 12px 0 0 12px;
}

tr.row-attention td:first-child {
    border-left: 4px solid #ffc107;
    padding-left: 6px;
    border-radius: 12px 0 0 12px;
}

/* Modal styling */
.modal-content {
    border: none;
    border-radius: 16px;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 16px 16px 0 0;
}

.modal-footer .btn {
    border-radius: 10px;
    padding: 8px 20px;
}
