/* ========================================
   Task-Chat Full — Полный адаптивный дизайн
   DESKTOP FIRST подход
   ======================================== */

:root {
    /* Цветовая палитра */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray: #64748b;
    --gray-light: #e2e8f0;
    --bg: #f1f5f9;
    --white: #ffffff;
    
    /* Градиенты */
    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-secondary: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    
    /* Тени */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Радиусы */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: var(--bg);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.05) 0%, transparent 40%);
    min-height: 100vh;
}

/* ========================================
   Навигация - DESKTOP
   ======================================== */
nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-brand i {
    font-size: 2rem;
    color: var(--primary);
}

.nav-brand h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius);
    transition: all 0.2s;
    text-decoration: none;
    color: var(--gray);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}

.nav-link:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--dark);
}

.nav-link.active {
    background: var(--gradient-primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.logout-btn:hover {
    background: var(--danger);
    color: var(--white);
}

/* Роли пользователей */
.user-info-mobile {
    margin-right: 12px;
    padding-right: 16px;
    border-right: 1px solid var(--gray-light);
    display: inline-block;
}

.user-role {
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: visible;
}

.role-admin { 
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
    color: white; 
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.role-doctor { 
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); 
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.role-physicist { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* role-badge - отдельный класс для бейджей в welcome message */
.role-badge {
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: visible;
}

/* Бейдж непрочитанных */
.chat-indicator {
    position: relative;
    display: inline-flex;
}

.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 2px 0;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    animation: pulse 2s infinite;
    border: 2px solid var(--white);
    z-index: 10;
    line-height: 1;
    text-align: center;
}

.chat-badge[style*="display: none"] {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5); }
    50% { transform: scale(1.15); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.7); }
}

/* ========================================
   Контейнер
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px;
}

/* ========================================
   Flash сообщения
   ======================================== */
.flash-messages {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash {
    padding: 16px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease-out;
    font-weight: 500;
    border-left: 4px solid;
}

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

.flash-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left-color: var(--success);
    color: #065f46;
}

.flash-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left-color: var(--danger);
    color: #991b1b;
}

.flash-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left-color: var(--secondary);
    color: #1e40af;
}

/* ========================================
   Страница входа
   ======================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px;
    width: 100%;
    max-width: 440px;
    border: 1px solid var(--gray-light);
}

.login-card h2 {
    margin-bottom: 12px;
    color: var(--dark);
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
}

.login-card p {
    text-align: center;
    color: var(--gray);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

.form-input,
.form-control {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--dark);
    background: var(--white);
    transition: all 0.2s;
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
    color: var(--gray);
}

.form-actions {
    margin-top: 32px;
}

.login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-light);
    text-align: center;
    color: var(--gray);
    font-size: 13px;
}

/* ========================================
   Dashboard - DESKTOP
   ======================================== */
.dashboard {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px;
    border: 1px solid var(--gray-light);
}

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

.welcome-message h2 {
    margin-bottom: 8px;
    color: var(--dark);
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.welcome-message h2 i {
    color: var(--danger);
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.user-role-badge {
    margin: 0;
}

/* Кнопка создания задачи */
.btn-create-task {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

.btn-create-task:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.5);
}

/* ========================================
   Форма создания задачи - DESKTOP
   ======================================== */
.task-form {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    border: 1px solid var(--gray-light);
    box-shadow: var(--shadow-lg);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--gray-light);
}

.form-header h3 {
    margin: 0 0 8px 0;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
}

.form-header p {
    margin: 0;
    color: var(--gray);
    font-size: 14px;
}

.btn-close {
    background: var(--white);
    border: 2px solid var(--gray-light);
    color: var(--gray);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    transform: rotate(90deg);
}

.form-section {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 28px;
    border-radius: var(--radius);
    margin: 24px 0;
    border: 1px solid var(--gray-light);
}

.form-section h4 {
    margin: 0 0 24px 0;
    color: var(--dark);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h4 i {
    color: var(--primary);
    font-size: 1.2rem;
}

.form-hint {
    font-size: 12px;
    color: var(--gray);
    margin-top: 8px;
    font-style: italic;
}

.user-status {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
}

.user-status.online {
    color: var(--success);
}

.user-status.offline {
    color: var(--gray);
}

/* Required mark */
.required {
    color: var(--danger);
    font-weight: 700;
    margin-left: 4px;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Form Group */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

.form-group label i {
    color: var(--primary);
    font-size: 1rem;
    width: 18px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--dark);
    background: var(--white);
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-group input[type="text"]::placeholder,
.form-group textarea::placeholder {
    color: var(--gray);
}

/* Select with custom arrow */
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%234f46e5' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 50px;
    cursor: pointer;
}

.form-group select:disabled {
    background-color: #f8fafc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Textarea */
.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.description-group textarea {
    min-height: 140px;
    resize: vertical;
}

/* File upload */
.file-upload-wrapper {
    position: relative;
    margin: 12px 0;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--white);
    border: 2px dashed var(--gray-light);
    border-radius: var(--radius);
    transition: all 0.3s;
    cursor: pointer;
}

.file-upload-label:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.file-upload-label i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.file-upload-label span {
    color: var(--gray);
    font-size: 14px;
    font-weight: 500;
}

/* Список выбранных файлов */
.selected-files-list {
    margin-top: 16px;
}

.selected-files {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
}

.selected-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-light);
    transition: all 0.2s;
}

.selected-file-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.selected-file-item i {
    font-size: 1.5rem;
    color: var(--primary);
    width: 30px;
    text-align: center;
}

.selected-file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.selected-file-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-file-size {
    font-size: 12px;
    color: var(--gray);
}

.selected-file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.view-file-btn {
    background: var(--white);
    border: 2px solid var(--gray-light);
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.view-file-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.remove-file-btn {
    background: var(--white);
    border: 2px solid var(--gray-light);
    color: var(--gray);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.remove-file-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--white);
    transform: rotate(90deg);
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-light);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 15px;
    font-weight: 600;
}

/* ========================================
   Статистика - DESKTOP
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 28px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--gray-light);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card:nth-child(2)::before {
    background: var(--gradient-warning);
}

.stat-card:nth-child(3)::before {
    background: var(--gradient-secondary);
}

.stat-card:nth-child(4)::before {
    background: var(--gradient-success);
}

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

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: var(--gradient-primary);
    color: white;
    flex-shrink: 0;
}

.stat-card:nth-child(2) .stat-icon {
    background: var(--gradient-warning);
}

.stat-card:nth-child(3) .stat-icon {
    background: var(--gradient-secondary);
}

.stat-card:nth-child(4) .stat-icon {
    background: var(--gradient-success);
}

.stat-info h3 {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.stat-number {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

/* ========================================
   Фильтры - DESKTOP
   ======================================== */
.filters {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.filter-group {
    margin-bottom: 0;
}

.filter-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid var(--gray-light);
    background: var(--white);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* ========================================
   Список задач - DESKTOP
   ======================================== */
.tasks-container {
    margin-top: 24px;
}

.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--gray-light);
}

.tasks-header h3 {
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
}

.btn-refresh {
    background: var(--white);
    border: 2px solid var(--gray-light);
    color: var(--gray);
    cursor: pointer;
    font-size: 16px;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: rotate(90deg);
}

.tasks-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* ========================================
   Карточка задачи - DESKTOP
   ======================================== */
.task-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.task-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
}

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

.task-card.status-pending::before {
    background: var(--warning);
}

.task-card.status-in_progress::before {
    background: var(--secondary);
}

.task-card.status-completed::before {
    background: var(--success);
}

.task-card.status-cancelled::before {
    background: var(--danger);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}

.task-title-section h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 10px;
    line-height: 1.4;
}

.task-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--gray);
}

.task-id {
    background: var(--gray-light);
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
}

.task-date {
    display: flex;
    align-items: center;
    gap: 5px;
}

.task-status-badge .task-status {
    padding: 8px 18px;
    border-radius: var(--radius-xl);
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-status.status-pending {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.task-status.status-in_progress {
    background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
    color: #075985;
}

.task-status.status-completed {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.task-status.status-cancelled {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.task-body {
    margin-bottom: 20px;
}

.task-description {
    color: var(--gray);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Превью изображений */
.task-images-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin: 16px 0;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.image-preview-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.image-preview-item:hover img {
    transform: scale(1.1);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(79, 70, 229, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.image-preview-item:hover .image-overlay {
    opacity: 1;
}

.image-overlay i {
    color: white;
    font-size: 2rem;
}

/* Модальное окно для изображений */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 10001;
    line-height: 1;
}

.image-modal-close:hover {
    color: var(--primary);
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}

.image-modal-caption {
    color: white;
    font-size: 16px;
    margin-top: 16px;
    text-align: center;
    max-width: 800px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius);
}

.task-meta-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 16px 0;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 11px;
    color: var(--gray);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    color: var(--dark);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-participants {
    display: flex;
    gap: 24px;
    padding: 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: var(--radius);
    margin: 16px 0;
    border: 1px solid #bfdbfe;
}

.participant {
    display: flex;
    gap: 8px;
    align-items: center;
}

.participant-role {
    color: var(--gray);
    font-size: 13px;
    font-weight: 500;
}

.participant-name {
    font-weight: 600;
    color: var(--dark);
}

.user-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

.task-timeline {
    padding: 16px 0 0 0;
    border-top: 1px solid var(--gray-light);
    margin-top: 16px;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray);
    font-size: 13px;
    margin-bottom: 8px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-item i {
    color: var(--primary);
    font-size: 14px;
}

/* ========================================
   Кнопки - DESKTOP
   ======================================== */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray);
    border: 2px solid var(--gray-light);
}

.btn-secondary:hover {
    border-color: var(--gray);
    color: var(--dark);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-warning {
    background: var(--gradient-warning);
    color: white;
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-chat {
    background: var(--gradient-secondary);
    color: white;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}

.btn-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

.btn-files {
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
    color: white;
}

.btn-add-files {
    background: var(--gradient-success);
    color: white;
}

.btn-small {
    padding: 10px 16px;
    font-size: 13px;
}

.task-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
    flex-wrap: wrap;
}

.status-update {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-select {
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    color: var(--dark);
    background: var(--white);
}

.status-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========================================
   Чат - DESKTOP
   ======================================== */
.chat-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-light);
}

.chat-header {
    padding: 24px 32px;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-task-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-back {
    color: white;
    text-decoration: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: background 0.3s;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.btn-back:hover {
    background: rgba(255,255,255,0.3);
}

.task-title-section h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.chat-partner-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.partner-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.3);
}

.partner-details h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.partner-role {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.task-details-panel {
    width: 340px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-right: 1px solid var(--gray-light);
    display: flex;
    flex-direction: column;
}

.task-details-header {
    padding: 20px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-details-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--dark);
    font-weight: 600;
}

.btn-toggle-details {
    background: var(--white);
    border: 1px solid var(--gray-light);
    color: var(--gray);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.task-details-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.detail-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-light);
}

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

.detail-label {
    display: block;
    font-size: 11px;
    color: var(--gray);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-value {
    display: block;
    font-size: 14px;
    color: var(--dark);
    font-weight: 500;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    position: relative;
}

.messages-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 8px;
}

.message {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message-outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 16px 20px;
    border-radius: 20px;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.message-outgoing .message-content {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.message-incoming .message-content {
    background: var(--white);
    color: var(--dark);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-light);
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-sender {
    font-size: 12px;
    color: var(--gray);
    margin-top: 8px;
    padding: 0 4px;
    font-weight: 500;
}

.chat-footer {
    border-top: 1px solid var(--gray-light);
    background: var(--white);
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chat-typing-indicator {
    padding: 12px 32px;
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--gray);
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
}

.chat-typing-indicator.show {
    display: flex;
}

.message-input-wrapper {
    padding: 0;
}

.message-form {
    padding: 24px 32px;
}

.message-input-container {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

#messageInput {
    flex: 1;
    padding: 16px 22px;
    border: 2px solid var(--gray-light);
    border-radius: 28px;
    font-size: 15px;
    resize: none;
    min-height: 52px;
    max-height: 160px;
    line-height: 1.5;
    transition: all 0.2s;
    font-family: inherit;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

#messageInput::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn-send {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.btn-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(79, 70, 229, 0.4);
}

.chat-typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ========================================
   Модальные окна - DESKTOP
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--white);
    margin: 8% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 650px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    background: var(--gradient-primary);
    color: white;
    padding: 24px 28px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.close-modal {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    opacity: 0.8;
    transition: opacity 0.3s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 28px;
    max-height: 450px;
    overflow-y: auto;
}

.unread-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unread-task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    transition: all 0.2s;
}

.unread-task-item:hover {
    transform: translateX(6px);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: var(--shadow-sm);
}

.unread-task-info h4 {
    margin: 0 0 8px 0;
    color: var(--dark);
    font-size: 15px;
    font-weight: 600;
}

.unread-task-info p {
    margin: 0;
    font-size: 13px;
    color: var(--gray);
    display: flex;
    gap: 16px;
}

.unread-count {
    color: var(--danger);
    font-weight: 600;
}

.last-sender {
    color: var(--primary);
}

.files-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 40px;
    backdrop-filter: blur(4px);
}

.files-modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.files-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--gray-light);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.files-modal-header h3 {
    margin: 0;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
}

.files-modal-close {
    background: var(--white);
    border: 2px solid var(--gray-light);
    font-size: 18px;
    color: var(--gray);
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.files-modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.files-modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

.files-modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--gray-light);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.file-card {
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s;
    background: var(--white);
}

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

.file-preview {
    height: 180px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s;
}

.file-preview img:hover {
    transform: scale(1.08);
}

.file-icon {
    font-size: 4rem;
    color: var(--primary);
}

.file-info {
    padding: 18px;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.no-files {
    text-align: center;
    padding: 80px 20px;
    color: var(--gray);
}

.no-files i {
    font-size: 6rem;
    margin-bottom: 24px;
    opacity: 0.3;
}

.no-files h4 {
    margin: 0 0 8px 0;
    color: var(--dark);
}

.no-files p {
    margin: 0;
    font-size: 14px;
}

/* ========================================
   Админ-панель - DESKTOP
   ======================================== */
.admin-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px;
    border: 1px solid var(--gray-light);
}

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

.admin-menu {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th,
.admin-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
}

.admin-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    color: var(--dark);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.admin-table td {
    color: var(--gray);
    font-size: 14px;
}

.admin-table tr:hover {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

/* ========================================
   Страницы ошибок
   ======================================== */
.error-page {
    text-align: center;
    padding: 100px 20px;
}

.error-page h1 {
    font-size: 10rem;
    background: var(--gradient-danger);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1;
}

.error-page h2 {
    color: var(--dark);
    margin-bottom: 16px;
    font-size: 1.75rem;
}

.error-page p {
    color: var(--gray);
    margin-bottom: 32px;
    font-size: 1rem;
}

/* ========================================
   Уведомления
   ======================================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 18px 24px;
    border-radius: var(--radius);
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 500;
}

/* ========================================
   Админ-панель - новые стили
   ======================================== */
.admin-dashboard {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px;
    border: 1px solid var(--gray-light);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 20px;
    flex-wrap: wrap;
}

.admin-header h1 {
    font-size: 1.75rem;
    color: var(--dark);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-subtitle {
    color: var(--gray);
    font-size: 14px;
    margin: 0;
}

/* Карточки статистики */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.admin-stat-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    gap: 20px;
    transition: all 0.3s;
}

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

.admin-stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.admin-stat-card .stat-info h3 {
    font-size: 13px;
    color: var(--gray);
    margin: 0 0 8px 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    display: block;
    margin-bottom: 12px;
}

.stat-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--gray-light);
    color: var(--gray);
    font-weight: 500;
}

.stat-badge.status-pending { background: #fef3c7; color: #92400e; }
.stat-badge.status-in_progress { background: #bae6fd; color: #075985; }
.stat-badge.status-completed { background: #d1fae5; color: #065f46; }
.stat-badge.status-cancelled { background: #fee2e2; color: #991b1b; }

/* Быстрые действия */
.admin-actions {
    margin-bottom: 32px;
}

.admin-actions h2 {
    font-size: 1.3rem;
    color: var(--dark);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.admin-action-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
}

.admin-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.admin-action-card i {
    font-size: 2.5rem;
    color: var(--primary);
}

.admin-action-card h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--dark);
}

.admin-action-card p {
    font-size: 13px;
    color: var(--gray);
    margin: 0;
}

/* Секции */
.admin-section {
    margin-bottom: 32px;
}

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-section-header h2 {
    font-size: 1.3rem;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Таблицы */
.admin-table-container {
    overflow-x: auto;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
}

.admin-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    color: var(--dark);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.admin-table td {
    color: var(--gray);
    font-size: 14px;
}

.admin-table tr:hover {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

.admin-table .admin-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

/* Фильтры */
.admin-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.filter-group select {
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    background: var(--white);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Статусы */
.status-online {
    color: var(--success);
    font-weight: 500;
    font-size: 13px;
}

.status-offline {
    color: var(--gray);
    font-weight: 500;
    font-size: 13px;
}

.status-online i,
.status-offline i {
    font-size: 8px;
    margin-right: 6px;
}

/* Кнопки */
.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-info {
    background: var(--secondary);
    color: white;
}

.btn-info:hover {
    background: #0284c7;
}

/* Массовые действия - админка */
.admin-mass-actions {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.mass-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mass-actions-header h3 {
    font-size: 1.1rem;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.selected-count {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    background: var(--white);
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid var(--primary);
}

.mass-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.mass-action-card {
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mass-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.mass-action-card.danger:hover {
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.mass-action-card i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.mass-action-card.danger i {
    color: var(--danger);
}

.mass-action-card h4 {
    font-size: 1rem;
    color: var(--dark);
    margin: 0 0 8px 0;
}

.mass-action-card p {
    font-size: 12px;
    color: var(--gray);
    margin: 0;
    line-height: 1.5;
}

/* Текст */
.text-muted {
    color: var(--gray);
    font-size: 12px;
}

.research-type {
    font-size: 13px;
    color: var(--gray);
    font-weight: 500;
}

/* Отделение */
.department-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--gray-light);
    color: var(--dark);
    font-weight: 600;
    white-space: nowrap;
}

/* Tooltip для полного ФИО - Desktop */
@media (min-width: 769px) {
    td strong[title],
    .participant-name[title],
    .doctor-name[title],
    .chat-partner-info h3[title],
    .user-role[title] {
        cursor: help;
        position: relative;
    }

    td strong[title]:hover::after,
    .participant-name[title]:hover::after,
    .doctor-name[title]:hover::after,
    .chat-partner-info h3[title]:hover::after,
    .user-role[title]:hover::after {
        content: attr(title);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: var(--dark);
        color: white;
        padding: 8px 12px;
        border-radius: var(--radius);
        font-size: 13px;
        font-weight: 500;
        white-space: nowrap;
        z-index: 1000;
        box-shadow: var(--shadow-md);
        margin-bottom: 8px;
        opacity: 0;
        animation: tooltipFadeIn 0.2s ease-out forwards;
        pointer-events: none;
    }

    td strong[title]:hover::before,
    .participant-name[title]:hover::before,
    .doctor-name[title]:hover::before,
    .chat-partner-info h3[title]:hover::before,
    .user-role[title]:hover::before {
        content: '';
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: var(--dark);
        z-index: 1001;
        margin-bottom: -4px;
        opacity: 0;
        animation: tooltipFadeIn 0.2s ease-out forwards;
        animation-delay: 0.1s;
        pointer-events: none;
    }
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Мобильные - показываем tooltip по клику */
@media (max-width: 768px) {
    td strong[title],
    .participant-name[title],
    .doctor-name[title],
    .chat-partner-info h3[title],
    .user-role[title] {
        cursor: pointer;
        position: relative;
    }

    td strong[title].show-tooltip::after,
    .participant-name[title].show-tooltip::after,
    .doctor-name[title].show-tooltip::after,
    .chat-partner-info h3[title].show-tooltip::after,
    .user-role[title].show-tooltip::after {
        content: attr(title);
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: var(--dark);
        color: white;
        padding: 16px 24px;
        border-radius: var(--radius-lg);
        font-size: 16px;
        font-weight: 500;
        white-space: normal;
        max-width: 90%;
        z-index: 10000;
        box-shadow: var(--shadow-lg);
        text-align: center;
    }

    td strong[title].show-tooltip::before,
    .participant-name[title].show-tooltip::before,
    .doctor-name[title].show-tooltip::before,
    .chat-partner-info h3[title].show-tooltip::before,
    .user-role[title].show-tooltip::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
    }
}

/* Убираем старые стили приоритетов */
.priority-badge,
.priority-urgent,
.priority-high,
.priority-medium,
.priority-low {
    display: none;
}

/* Адаптивность для админки */
@media (max-width: 768px) {
    .admin-dashboard {
        padding: 16px;
    }

    .admin-header {
        flex-direction: column;
        gap: 16px;
    }

    .admin-header h1 {
        font-size: 1.3rem;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-actions-grid {
        grid-template-columns: 1fr;
    }

    .admin-filters {
        flex-direction: column;
    }

    .search-box {
        min-width: 100%;
    }

    .admin-table {
        font-size: 12px;
    }

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

    .admin-table .admin-actions {
        flex-direction: column;
        gap: 4px;
    }
    
    /* Фикс для полей ввода */
    .admin-table input,
    .admin-table select {
        max-width: 100%;
        font-size: 13px;
    }
}

/* Фикс для всех полей ввода на мобильных */
@media (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    select,
    textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .form-control {
        max-width: 100%;
    }
    
    .form-group {
        max-width: 100%;
    }
    
    /* Фикс для кнопок */
    .btn {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* Фикс для карточек и блоков */
    .admin-stat-card,
    .admin-action-card,
    .task-card,
    .form-section {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Фикс для модальных окон */
    .modal-content {
        width: 95%;
        max-width: 95%;
    }
    
    /* Фикс для таблиц */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

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

.notification-success {
    background: var(--gradient-success);
}

.notification-error {
    background: var(--gradient-danger);
}

.notification-info {
    background: var(--gradient-secondary);
}

/* ========================================
   Утилиты
   ======================================== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-card {
    box-shadow: var(--shadow);
}

.shadow-card-hover:hover {
    box-shadow: var(--shadow-md);
}

/* ========================================
   МОБИЛЬНАЯ ВЕРСИЯ - Media Queries
   ======================================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    /* Навигация - мобильная */
    .nav-container {
        padding: 12px 16px;
    }

    .nav-brand h1 {
        font-size: 1.3rem;
    }

    .nav-brand i {
        font-size: 1.5rem;
    }

    .nav-links {
        gap: 4px;
    }

    .nav-link {
        padding: 10px 12px;
        font-size: 13px;
    }

    .nav-link .link-text {
        display: none;
    }

    .user-info-mobile {
        margin-right: 8px;
        padding-right: 10px;
        display: inline-block;
    }

    .user-role {
        padding: 6px 12px;
        font-size: 11px;
        white-space: nowrap;
        overflow: visible;
    }

    .user-role span:not(:first-child) {
        display: none;
    }

    /* Превью изображений - мобильная версия */
    .task-images-preview {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        padding: 12px;
    }

    .image-modal-close {
        font-size: 30px;
        top: 15px;
        right: 20px;
    }

    .image-modal-caption {
        font-size: 14px;
        padding: 8px 16px;
    }

    /* Контейнер */
    .container {
        padding: 16px;
    }

    /* Dashboard */
    .dashboard {
        padding: 20px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        margin-bottom: 24px;
    }

    .welcome-message h2 {
        font-size: 1.3rem;
    }

    .btn-create-task {
        width: 100%;
        justify-content: center;
        padding: 14px 24px;
    }

    /* Статистика - мобильная */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    /* Форма задачи - мобильная */
    .task-form {
        padding: 20px;
    }

    .form-section {
        padding: 16px;
    }
    
    /* Фикс для select на мобильных - предотвращаем выезд за границы */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group select,
    .form-group input[type="text"],
    .form-group input[type="password"],
    .form-group input[type="email"],
    .form-group input[type="number"] {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Фикс для textarea на мобильных - центрирование и размеры */
    .form-group textarea {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        resize: vertical;
    }
    
    /* File upload - фикс для мобильных */
    .file-upload-wrapper {
        max-width: 100%;
        overflow: hidden;
    }
    
    .file-upload-label {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Карточки задач - мобильные */
    .tasks-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .task-card {
        padding: 20px;
    }

    .task-header {
        flex-direction: column;
        gap: 12px;
    }

    .task-meta-info {
        grid-template-columns: 1fr;
    }

    .task-participants {
        flex-direction: column;
        gap: 12px;
    }

    .task-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .status-update {
        margin-left: 0;
        width: 100%;
    }

    .status-select {
        width: 100%;
    }

    /* Чат - мобильный - ПОЛНОСТЬЮ ПЕРЕРАБОТАНО */
    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height для мобильных */
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--white);
        z-index: 100;
    }

    .chat-header {
        flex-shrink: 0;
        padding: 12px 16px;
        min-height: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .chat-task-info {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
        min-width: 0;
    }

    .btn-back {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .chat-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* Информация о задаче - сворачиваемая панель сверху */
    .task-details-panel {
        width: 100%;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--gray-light);
        background: var(--white);
        max-height: 40vh;
        overflow-y: auto;
    }

    .task-details-header {
        padding: 12px 16px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 1px solid var(--gray-light);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .task-details-header h4 {
        font-size: 13px;
        margin: 0;
    }

    .task-details-content {
        display: none;  /* Скрыто по умолчанию на мобильных */
        padding: 12px 16px;
    }

    .task-details-content.show {
        display: block !important;
    }

    .btn-toggle-details {
        display: block !important;
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
    }

    /* Контейнер сообщений - ГИБКИЙ */
    .messages-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        padding-bottom: 20px;
        background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
        scroll-behavior: smooth;
    }

    .messages-list {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding-bottom: 10px;
        min-height: min-content;
    }

    /* Подвал с полем ввода - ФИКСИРОВАННЫЙ */
    .chat-footer {
        flex-shrink: 0;
        background: var(--white);
        border-top: 1px solid var(--gray-light);
        padding: 0;
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        position: relative;
        z-index: 20;
        display: flex;
        flex-direction: column;
    }

    .message-input-wrapper {
        background: var(--white);
    }

    .message-form {
        padding: 0;
        margin: 0;
    }

    .message-input-container {
        gap: 10px;
        align-items: flex-end;
    }

    #messageInput {
        padding: 12px 16px;
        min-height: 44px;
        max-height: 120px;
        font-size: 16px; /* Предотвращает zoom на iOS */
        border: 2px solid var(--gray-light);
        line-height: 1.4;
        resize: none;
    }

    #messageInput:focus {
        border-color: var(--primary);
    }

    .btn-send {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        align-self: flex-end;
    }

    /* Индикатор "печатает" */
    .chat-typing-indicator {
        padding: 8px 16px;
        font-size: 12px;
        background: var(--white);
        border-bottom: 1px solid var(--gray-light);
        display: none;
    }

    .chat-typing-indicator.show {
        display: flex;
    }

    /* Сообщения */
    .message {
        max-width: 85%;
    }

    .message-outgoing {
        align-self: flex-end !important;
        align-items: flex-end !important;
    }

    .message-incoming {
        align-self: flex-start !important;
        align-items: flex-start !important;
    }

    /* Модальные окна - мобильные */
    .modal-content {
        margin: 15% auto;
        width: 95%;
    }

    .files-modal-overlay {
        padding: 10px;
    }

    .files-modal {
        max-width: 100%;
        max-height: 95vh;
    }

    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .file-preview {
        height: 140px;
    }

    /* Админка - мобильная */
    .admin-panel {
        padding: 20px;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .nav-brand h1 {
        display: none;
    }

    .filter-buttons {
        justify-content: center;
    }

    .filter-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .files-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .task-meta {
        flex-direction: column;
        gap: 6px;
    }
}
