/* Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f3f4f6;
    --white: #ffffff;
    --shadow: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
}

/* Login Container */
#loginContainer {
    display: block !important;
}

#loginContainer[style*="display: none"] {
    display: none !important;
}

#loginContainer[style*="display: block"] {
    display: block !important;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, var(--secondary) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 20s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.login-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 50px 40px;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-card h2 {
    color: var(--dark);
    margin-bottom: 35px;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.login-logo i {
    font-size: 40px;
    color: white;
}

.login-card h2 {
    margin-bottom: 8px;
    -webkit-text-fill-color: initial;
    background: none;
    color: var(--dark);
}

.login-subtitle {
    color: var(--gray);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#loginForm {
    margin-top: 10px;
}

#loginForm .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
}

#loginForm .form-group label i {
    color: var(--primary);
    font-size: 14px;
    width: 16px;
}

#loginForm .form-group input {
    position: relative;
}

#loginForm .form-group {
    position: relative;
}

#loginForm .btn {
    width: 100%;
    margin-top: 10px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#loginError {
    margin-top: 20px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    display: none;
}

#loginError:not(:empty) {
    display: block;
}

/* Form Elements - Улучшенный стиль */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label::before {
    content: '•';
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
}

/* Form-group и label в форме создания чек-листа на всю ширину */
/* Убираем ограничения ширины для формы создания чек-листа и всех родительских элементов */
#checklists {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#checklists > div {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Блок «Існуючі чек-листи»: заголовок окремо, чекбокс під ним зліва */
.existing-checklists-block {
    display: block !important;
    margin-bottom: 30px;
}

.existing-checklists-title {
    margin: 0 0 10px 0 !important;
    color: var(--dark);
    display: block !important;
}

.checklist-show-inactive-row {
    display: block !important;
    margin-bottom: 15px;
    text-align: left !important;
}

.checklist-show-inactive-label {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
}

.checklist-show-inactive-cb {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Родительский div для формы создания чек-листа */
.checklist-form-wrapper,
#checklists > div:has(#checklistForm),
#checklists > div:last-child,
#checklists .checklist-form-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
}

#checklistForm {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

#checklistForm .form-group {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

#checklistForm .form-group label:not(.repeat-day-label),
#checklistForm .form-group label:first-of-type:not(.repeat-day-label),
#checklistForm label[for="title"],
#checklistForm .form-group:first-child label:not(.repeat-day-label) {
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex-basis: 100% !important;
    flex-grow: 1 !important;
    flex-shrink: 0 !important;
}

/* Сохраняем стиль для псевдоэлемента в форме чек-листа */
#checklistForm .form-group label:not(.repeat-day-label)::before {
    display: inline-block;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Прибираємо псевдо-елемент ::before для чекбоксів днів */
.repeat-day-label::before,
#checklistForm .repeat-day-label::before {
    content: none !important;
    display: none !important;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: #f8fafc;
    color: var(--dark);
    font-family: inherit;
    box-sizing: border-box;
    display: block;
}

.form-group input:hover {
    border-color: #cbd5e1;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.form-group select {
    width: 100%;
    padding: 12px 36px 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: #f8fafc;
    color: var(--dark);
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    box-sizing: border-box;
    display: block;
}

.form-group select:hover {
    border-color: #cbd5e1;
    background: white;
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    resize: vertical;
    font-family: inherit;
    background: #f8fafc;
    color: var(--dark);
    min-height: 100px;
    box-sizing: border-box;
    display: block;
}

.form-group textarea:hover {
    border-color: #cbd5e1;
    background: white;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* Полноширинные кнопки */
.btn-full {
    width: 100%;
}

/* Маленькие кнопки */
.btn-sm {
    height: 32px;
    width: 32px;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15);
}

/* Кнопки пагінації */
.btn-pagination {
    height: auto;
    min-width: auto;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15);
}

/* Кнопки-иконки */
.btn-icon {
    padding: 8px 12px;
    font-size: 14px;
}

.remove-attachment {
    width: auto;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn:active {
    transform: translateY(0);
}

/* Цветные кнопки */
.btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-primary,
.btn:not(.btn-secondary):not(.btn-danger):not(.btn-success):not(.btn-warning) {
    width: auto;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.error {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

/* Main Content */
#mainContent {
    display: none;
    min-height: 100vh;
    background: var(--light);
}

/* Header */
header {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 2px solid #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    margin: 0 auto;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Кнопка повідомлень в хедері */
.messages-btn, .settings-btn {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.messages-btn:hover, .settings-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.messages-btn.has-unread {
    color: var(--primary);
}

/* Стиль для іконки повідомлень */
.messages-btn .fa-comments:before {
    content: "\f086";
    color: #fff;
}

/* Badge для непрочитаних повідомлень в хедері */
.unread-messages-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid white;
    box-sizing: border-box;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#userAvatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-details {
    display: flex;
    flex-direction: column;
    height: 40px;
}

#userName {
    font-weight: 700;
    color: white;
    font-size: 14px;
}

/* Стили для роли пользователя в header (не для select в форме) */
header #userRole,
.user-details #userRole,
#userRoleDisplay {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    padding: 5px 0;
    border-radius: 12px;
    font-weight: 500;
    display: inline-block;
}

/* Убеждаемся, что select в форме не переопределяется */
#userFormContainer #userRole,
form #userRole {
    width: 100%;
    padding: 12px 36px 12px 16px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: var(--radius-sm) !important;
    font-size: 14px !important;
    transition: var(--transition) !important;
    background: #f8fafc !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
    color: var(--dark) !important;
    font-family: inherit !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    box-sizing: border-box !important;
    display: block !important;
    font-weight: 400 !important;
}

header button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.logo i {
    color: white;
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-size: 14px;
    color: var(--gray);
}

#userAvatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-info button {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.user-info button:hover {
    background: #dc2626;
}

/* Main Layout */
main {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: 2px solid #e2e8f0;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-btn:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-btn:hover::before {
    transform: scaleY(1);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
}

.nav-btn.active::before {
    transform: scaleY(1);
    background: white;
    width: 4px;
}

.nav-btn i {
    width: 20px;
    text-align: center;
}

/* Dynamic Content */
#dynamicContent {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.section {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.section h2 {
    color: var(--dark);
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
    margin: -30px -30px 25px -30px;
}

.section h2 i {
    color: white;
    font-size: 22px;
}

.section h2::after {
    content: '';
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    margin-left: 10px;
}

/* Общие стили для секций форм */
.form-section {
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.form-section:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.form-section-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    border-top: 2px solid #e2e8f0;
}

/* Общие стили для заголовков h3 в секциях */
.section h3 {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 18px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.section h3::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.section h3.no-subscription-title {
    font-weight: inherit;
    color: inherit;
    margin-bottom: inherit;
    font-size: inherit;
    padding: 0;
    background: none;
    border-left: none;
    border-radius: 0;
    display: block !important;
    align-items: inherit;
    gap: inherit;
}

.section h3.no-subscription-title::before {
    content: none;
}

.section h3 i {
    color: var(--primary);
    font-size: 16px;
}

/* Универсальные стили для карточек */
.card,
.checklist-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before,
.checklist-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.card:hover,
.checklist-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

/* Сітка картки чек-листа: назва зліва, кнопки справа, далі опис і контент */
.checklist-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
}

.checklist-card-header-row {
    grid-column: 1;
    grid-row: 1;
}

.checklist-card-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: end;
}

.checklist-card-description {
    grid-column: 1 / -1;
    grid-row: 2;
}

.checklist-card-body-grid {
    grid-column: 1 / -1;
    grid-row: 3;
}

.checklist-card-three-blocks {
    grid-column: 1 / -1;
    grid-row: 2;
}

.card-header,
.checklist-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.card-title,
.checklist-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title::before,
.checklist-card-title::before {
    content: '';
    width: 6px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 3px;
}

.card-content,
.checklist-card-content {
    color: var(--dark);
    line-height: 1.6;
}

/* Кнопки дій чек-листа */
.checklist-card-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    min-width: auto;
}

.checklist-card-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 12px;
}

/* В десктопі - тільки іконки (як в розкладі) */
.checklist-card-actions .btn-text {
    display: none;
}

/* Двоколоночний блок: метадані зліва, виконавці та бейджі справа */
.checklist-card-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}

.checklist-card-meta,
.checklist-card-right-col {
    min-height: 100%;
    box-sizing: border-box;
}

.checklist-card-right-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Виконавці на десктопі - в рядок з переносом */
.checklist-executors-block {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
}

.checklist-executors-block strong {
    display: inline;
    margin-bottom: 0;
    white-space: nowrap;
}

.checklist-executors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.executor-badge {
    margin-right: 0;
    margin-bottom: 0;
}

/* Статистика в один рядок на десктопі */
.checklist-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checklist-card-meta-inner {
    padding: 14px 18px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    height: 100%;
    box-sizing: border-box;
}

/* Десктоп: 2 ряди по 2 комірки — рядок 1: ID, Створено; рядок 2: Призначено, Час; далі Повторювати на всю ширину */
.checklist-card-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    font-size: 13px;
    height: 100%;
    align-content: start;
}

.checklist-meta-item-placeholder {
    visibility: hidden;
    min-height: 1px;
}

.checklist-meta-item-full {
    grid-column: 1 / -1;
}

.checklist-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Лінійне відображення мета-інформації чек-листа в один рядок з перенесенням за потреби */
.checklist-meta-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 13px;
}

.checklist-meta-inline span {
    white-space: nowrap;
}

.checklist-meta-label {
    color: #64748b;
    font-weight: 500;
    flex-shrink: 0;
}

.checklist-meta-value {
    color: var(--dark);
    font-weight: 600;
    min-width: 0;
}
 
/* Лінійне відображення виконавців і статистики */
.checklist-executors-inline {
    font-size: 13px;
    color: var(--dark);
    margin-bottom: 8px;
}

.checklist-stats-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 13px;
    color: var(--dark);
}

.checklist-stats-inline span {
    white-space: nowrap;
}

/* Статусы и бейджи */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.status.pending,
.status.⏳ {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fbbf24;
}

.status.in_progress,
.status.🔄 {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.status.completed,
.status.✅ {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #10b981;
}

.status.overdue,
.status.🔴 {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Бейджи */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--gray);
    font-weight: 500;
}

.success-message {
    color: #065f46;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--success);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.warning-message {
    color: #92400e;
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--warning);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message {
    color: #991b1b;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--danger);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tables - Улучшенный стиль */
/* Приховати картки на десктопі */
.schedule-cards-mobile,
.history-cards-mobile,
.users-cards-mobile {
    display: none;
}

.table-container {
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: var(--transition);
}

.table-container:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 700;
    color: var(--dark);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.8px;
    border-bottom: 3px solid var(--primary);
    position: relative;
}

.table th::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 50%, transparent 100%);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: var(--transition);
}

.table th.sortable:hover {
    background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
    color: var(--primary);
}

.table th.sortable i {
    margin-left: 8px;
    font-size: 10px;
    opacity: 0.5;
    transition: var(--transition);
    color: var(--primary);
}

.table th.sortable:hover i {
    opacity: 1;
    color: var(--primary-dark);
}

.table tr {
    transition: var(--transition);
}

.table tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table tr:last-child td {
    border-bottom: none;
}


/* Кнопки пагінації */
.btn-pagination {
    height: auto;
    min-width: auto;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
    transform: translateY(-2px);
}

/* Кнопки фильтров */
.schedule-filter-btn,
.filter-btn {
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    background: white;
    color: var(--dark);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    flex-grow: 0;
    width: auto;
    min-width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.schedule-filter-btn::before,
.filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.schedule-filter-btn:hover::before,
.filter-btn:hover::before {
    left: 100%;
}

.schedule-filter-btn:hover,
.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.btn-secondary.active,
.schedule-filter-btn.active,
.btn.btn-secondary.schedule-filter-btn.active,
.filter-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: white !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
    transform: translateY(-1px);
}

.btn-secondary.active:hover,
.schedule-filter-btn.active:hover,
.btn.btn-secondary.schedule-filter-btn.active:hover,
.filter-btn.active:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4338ca 100%) !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4) !important;
    transform: translateY(-2px);
}

/* Поля поиска */
input[type="search"],
input[type="tel"]:not(.form-group input):not(#userPhone),
input[type="email"]:not(.form-group input),
.search-input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: #f8fafc;
    color: var(--dark);
    font-family: inherit;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}

/* Виняток для полів форми користувача */
.form-group input[type="tel"],
.form-group input[type="email"],
#userPhone {
    max-width: 100% !important;
}

/* Исключаем поля форм из ограничения ширины поиска */
input[type="text"]:not(.search-input):not(#scheduleSearchInput) {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: #f8fafc;
    color: var(--dark);
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Специфично для поля поиска в расписании */
.search-input,
#scheduleSearchInput {
    max-width: 400px;
}

/* Кнопка "Оберіть файл" для чек-листів - max-width: 220px для десктопу і планшетів */
@media (min-width: 769px) {
    div[style*="max-width: 220px"]:has(input.item-attachment) {
        max-width: 220px !important;
    }
}

/* Поле title в форме создания чек-листа должно быть на всю ширину */
#checklistForm input#title,
form#checklistForm input[name="title"],
#checklistForm input[type="text"][id="title"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
}

input[type="search"]:hover,
input[type="tel"]:hover,
input[type="email"]:hover,
.search-input:hover,
#scheduleSearchInput:hover {
    border-color: #cbd5e1;
    background: white;
}

input[type="text"]:not(.search-input):not(#scheduleSearchInput):hover {
    border-color: #cbd5e1;
    background: white;
}

input[type="search"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
.search-input:focus,
#scheduleSearchInput:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

input[type="text"]:not(.search-input):not(#scheduleSearchInput):focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

/* Поле поиска с иконкой */
.form-group.search-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 400px;
}

.form-group.search-wrapper::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 14px;
    z-index: 2;
    pointer-events: none;
}

.form-group.search-wrapper .search-input {
    padding-left: 40px;
    position: relative;
}

/* Forms */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Для чата используем display: block (как в истории), центрирование через margin: auto на содержимом */
#chatModal.show {
    display: block !important;
    overflow-y: auto !important;
}

/* Для paymentModal також використовуємо flex для центрування */
#paymentModal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    padding: 0;
    border-radius: var(--radius);
    max-width: 650px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalSlideIn 0.3s ease;
    position: relative;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    /* Центрування модального вікна - тільки коли модальне вікно відкрите */
    margin: auto;
}

.modal-content h2 {
    margin: 0;
    color: white;
    font-size: 24px;
    font-weight: 700;
    padding: 20px 30px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-content h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: white;
    border-radius: 2px;
}

.modal-content:not(.chat-modal-content) > form,
.modal-content:not(.chat-modal-content) > div:not(.close) {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-content .close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
    z-index: 10;
}

.modal-content .close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Группировка полей в модальном окне */
.modal-section {
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.modal-section:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.modal-section-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-section .form-group {
    margin-bottom: 15px;
}

.modal-section .form-group:last-child {
    margin-bottom: 0;
}

/* Стили для кнопки сохранения */
.modal-content .btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
    background: var(--primary);
    border: none;
    transition: var(--transition);
}

.modal-content .btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Стилі для повідомлень - базові правила, які завжди застосовуються */
.notification {
    position: fixed !important;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
    max-width: 500px !important;
    min-width: 250px !important;
    word-wrap: break-word !important;
    box-sizing: border-box !important;
    /* Гарантуємо, що елемент не обрізається */
    margin: 0 !important;
    border: none !important;
    outline: none !important;
    /* Гарантуємо видимість тексту та фону */
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    text-align: left !important;
    padding: 15px 20px !important;
    border-radius: 8px !important;
}

/* Портал для повідомлень - окремий контейнер поза layout-елементами */
#notification-root {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: 2147483646 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    contain: none !important;
    will-change: auto !important;
    overflow: visible !important;
}

/* Анімації для повідомлень, що з'являються справа вгорі */
@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Анімації для повідомлень, що з'являються знизу (для сумісності) */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-right {
        gap: 10px;
    }
    
    .status {
        font-size: 10px;
    }
    
    main {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--light);
        padding: 10px 0;
    }
    
    .nav-btn {
        margin: 2px 5px;
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .nav-btn.active {
        background: var(--primary) !important;
        color: white !important;
    }
    
    #dynamicContent {
        padding: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    /* Мета-информация чек-листов на новой строке в мобильной версии */
    .checklist-meta-info {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }
    
    .checklist-meta-info .meta-separator {
        display: none !important;
    }
    
    .checklist-meta-info span:not(.meta-separator) {
        display: block;
        width: 100%;
    }
    
    /* Кнопки фильтров в расписании на всю ширину */
    #scheduleFilterButtons {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #scheduleFilterButtons .schedule-filter-btn,
    #scheduleFilterButtons .filter-btn,
    #historyFilterButtons .schedule-filter-btn,
    #historyFilterButtons .btn {
        width: 100% !important;
        min-width: 100% !important;
        flex: 1 1 100% !important;
        height: 32px;
    }
    
    #historyFilterButtons {
        flex-direction: column !important;
    }
    
    /* Картки розкладу для мобільних пристроїв */
    .schedule-table-desktop,
    .history-table-desktop,
    .users-table-desktop {
        display: none !important;
    }
    
    .schedule-cards-mobile,
    .history-cards-mobile,
    .users-cards-mobile {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .schedule-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .schedule-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .schedule-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
    }
    
    .schedule-card-id {
        font-size: 12px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .schedule-card-body {
        padding: 15px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .schedule-card-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .schedule-card-label {
        font-size: 12px;
        color: var(--gray);
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .schedule-card-label i {
        width: 16px;
        color: var(--primary);
    }
    
    .schedule-card-value {
        font-size: 14px;
        color: var(--dark);
        font-weight: 500;
        word-break: break-word;
    }
    
    .schedule-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .schedule-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }
    
    /* Картка чек-листа: flex-колонка, кнопки внизу */
    .checklist-card {
        display: flex;
        flex-direction: column;
    }
    
    .checklist-card-actions { order: 1; }
    .checklist-card-three-blocks { order: 2; }
    
    /* Кнопки дій чек-листа для мобільних — внизу картки */
    .checklist-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
        margin: 15px -25px -25px -25px;
        border-radius: 0 0 var(--radius) var(--radius);
        width: calc(100% + 50px);
    }
    
    .checklist-card-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        height: 32px;
    }
    
    .checklist-card-actions .btn-text {
        display: inline;
    }
    
    /* Блоки мета-інформації та виконавців один під одним на мобільних */
    .checklist-card-body-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .checklist-card-meta-inner {
        padding: 10px 12px;
    }
    
    .checklist-card-meta-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        font-size: 12px;
    }
    
    .checklist-card-meta-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    /* Три блоки в колонку на мобільних */
    .checklist-card-three-blocks {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .checklist-meta-vertical {
        font-size: 12px;
        gap: 8px;
    }
    
    .checklist-stats-inline {
        flex-direction: column;
        gap: 6px;
    }
    
    .checklist-stat-item {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .checklist-stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .checklist-stats-grid > div {
        padding: 4px 8px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    /* Виконавці в мобільній версії */
    .checklist-executors-block {
        display: flex;
        flex-direction: column;
    }
    
    .checklist-executors-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .executor-badge {
        margin-right: 0 !important;
        margin-bottom: 6px !important;
    }
    
    /* Картки користувачів для мобільних */
    .user-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .user-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .user-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .user-card-id {
        font-size: 12px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .user-card-body {
        padding: 15px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .user-card-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .user-card-label {
        font-size: 12px;
        color: var(--gray);
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .user-card-label i {
        width: 16px;
        color: var(--primary);
    }
    
    .user-card-value {
        font-size: 14px;
        color: var(--dark);
        font-weight: 500;
        word-break: break-word;
    }
    
    .user-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .user-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }
    }
    

/* Адаптація для планшетів (768px - 1024px) - використовуємо картки як на мобільних */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Картки розкладу для планшетів */
    .schedule-table-desktop,
    .history-table-desktop,
    .users-table-desktop {
        display: none !important;
    }
    
    .schedule-cards-mobile,
    .history-cards-mobile,
    .users-cards-mobile {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .schedule-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .schedule-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .schedule-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
    }
    
    .schedule-card-id {
        font-size: 12px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .schedule-card-body {
        padding: 15px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .schedule-card-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .schedule-card-label {
        font-size: 12px;
        color: var(--gray);
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .schedule-card-label i {
        width: 16px;
        color: var(--primary);
    }
    
    .schedule-card-value {
        font-size: 14px;
        color: var(--dark);
        font-weight: 500;
        word-break: break-word;
    }
    
    .schedule-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .schedule-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }
    
    /* Картка чек-листа: кнопки внизу */
    .checklist-card {
        display: flex;
        flex-direction: column;
    }
    
    .checklist-card-actions { order: 1; }
    .checklist-card-three-blocks { order: 2; }
    
    .checklist-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
        margin: 15px -25px -25px -25px;
        border-radius: 0 0 var(--radius) var(--radius);
        width: calc(100% + 50px);
    }
    
    .checklist-card-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        height: 32px;
    }
    
    .checklist-card-actions .btn-text {
        display: inline;
    }
    
    .checklist-card-body-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .checklist-card-meta-inner {
        padding: 10px 12px;
    }
    
    .checklist-card-meta-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        font-size: 12px;
    }
    
    .checklist-card-meta-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .checklist-meta-item-full {
        flex: none;
        width: 100%;
    }
    
    .checklist-meta-item-placeholder {
        display: none;
    }
    
    .checklist-card-right-col {
        font-size: 12px;
        gap: 8px;
    }
    
    .checklist-stats-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .checklist-stats-grid > div {
        padding: 4px 8px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    /* Картки користувачів для планшетів */
    .user-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .user-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .user-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .user-card-id {
        font-size: 12px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .user-card-body {
        padding: 15px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .user-card-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .user-card-label {
        font-size: 12px;
        color: var(--gray);
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .user-card-label i {
        width: 16px;
        color: var(--primary);
    }
    
    .user-card-value {
        font-size: 14px;
        color: var(--dark);
        font-weight: 500;
        word-break: break-word;
    }
    
    .user-card-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .user-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }

    
    /* Кнопки фільтрів на всю ширину */
    #scheduleFilterButtons,
    #historyFilterButtons {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #scheduleFilterButtons .schedule-filter-btn,
    #scheduleFilterButtons .filter-btn,
    #historyFilterButtons .schedule-filter-btn,
    #historyFilterButtons .btn {
        width: 100% !important;
        min-width: 100% !important;
        flex: 1 1 100% !important;
        height: 32px;
    }
    
    /* Активна кнопка навігації має пріоритет над hover */
    .nav-btn.active,
    .nav-btn.active:hover {
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
        color: white !important;
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
    }
    
    /* Кнопка "Оберіть файл" для чек-листів - на всю ширину на мобільних */
    div[style*="max-width: 220px"]:has(input.item-attachment),
    div[style*="max-width: 220px"]:has(.item-attachment) {
        max-width: 100% !important;
        min-width: 100% !important;
        width: 100% !important;
        flex: 1 1 100% !important;
    }
    
    /* Перевизначення inline стилів для кнопки "Оберіть файл" на мобільних */
    div[style*="position: relative"][style*="flex: 1"][style*="min-width: 200px"][style*="max-width: 220px"]:has(input.item-attachment) {
        max-width: 100% !important;
        min-width: 100% !important;
        width: 100% !important;
    }
}



/* КРИТИЧЕСКОЕ ПРАВИЛО: Форсируем ширину label в форме создания чек-листа */
body #checklists.section .checklist-form-wrapper form#checklistForm .form-group:first-child > label,
body #checklists.section .checklist-form-wrapper form#checklistForm .form-group:first-of-type > label[for="title"] {
    width: calc(100% - 0px) !important;
    max-width: none !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
}

body #checklists.section .checklist-form-wrapper form#checklistForm .form-group:first-child {
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
}

/* ФИНАЛЬНОЕ РЕШЕНИЕ: Принудительно убираем все ограничения ширины */
html body div#checklists.section div.checklist-form-wrapper form#checklistForm div.form-group:first-of-type label[for="title"],
html body #checklists.section .checklist-form-wrapper #checklistForm .form-group:first-child > label {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    float: none !important;
    clear: both !important;
    position: relative !important;
}

html body #checklists.section .checklist-form-wrapper #checklistForm .form-group:first-child {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
}

/* ============================================
   БАЗА ЗНАНЬ - АДАПТИВНІ СТИЛІ
   ============================================ */

/* Картки бази знань - приховані на десктопі */
.knowledge-cards-mobile {
    display: none;
}

/* Мобільні стилі для бази знань */
@media (max-width: 768px) {
    /* Приховуємо таблицю, показуємо картки */
    .knowledge-table-desktop {
        display: none !important;
    }
    
    .knowledge-cards-mobile {
        display: flex !important;
        flex-direction: column;
        gap: 15px;
    }
    
    /* Стилі карток */
    .knowledge-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .knowledge-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .knowledge-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .knowledge-card-id {
        font-size: 11px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .knowledge-card-category {
        font-size: 11px;
        padding: 4px 10px;
        background: var(--primary);
        color: white;
        border-radius: 12px;
        font-weight: 500;
    }
    
    .knowledge-card-body {
        padding: 15px;
    }
    
    .knowledge-card-title {
        font-size: 15px;
        font-weight: 600;
        color: var(--dark);
        margin-bottom: 10px;
        line-height: 1.4;
    }
    
    .knowledge-card-date {
        font-size: 12px;
        color: var(--gray);
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .knowledge-card-date i {
        color: var(--primary);
    }
    
    .knowledge-card-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .knowledge-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }
    
    /* Форма додавання статті */
    #knowledge .form-group > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #knowledge .form-group > div[style*="display: flex"] select,
    #knowledge .form-group > div[style*="display: flex"] input,
    #knowledge .form-group > div[style*="display: flex"] button {
        flex: none !important;
        width: 100% !important;
    }
    
    /* Таблиця категорій */
    #categoriesList .table-container {
        overflow-x: auto;
    }
    
    #categoriesList .table th,
    #categoriesList .table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    #categoriesList .table td:last-child {
        white-space: nowrap;
    }
    
    #categoriesList .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Планшетні стилі для бази знань */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Приховуємо таблицю, показуємо картки */
    .knowledge-table-desktop {
        display: none !important;
    }
    
    .knowledge-cards-mobile {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Стилі карток для планшетів */
    .knowledge-card {
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: box-shadow 0.3s ease;
    }
    
    .knowledge-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .knowledge-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 2px solid var(--light);
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .knowledge-card-id {
        font-size: 11px;
        color: var(--gray);
        font-weight: 600;
    }
    
    .knowledge-card-category {
        font-size: 11px;
        padding: 4px 10px;
        background: var(--primary);
        color: white;
        border-radius: 12px;
        font-weight: 500;
    }
    
    .knowledge-card-body {
        padding: 15px;
    }
    
    .knowledge-card-title {
        font-size: 15px;
        font-weight: 600;
        color: var(--dark);
        margin-bottom: 10px;
        line-height: 1.4;
    }
    
    .knowledge-card-date {
        font-size: 12px;
        color: var(--gray);
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    .knowledge-card-date i {
        color: var(--primary);
    }
    
    .knowledge-card-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 15px;
        background: #f9fafb;
        border-top: 1px solid var(--light);
    }
    
    .knowledge-card-actions .btn {
        width: 100%;
        justify-content: center;
        height: 32px;
    }
    
    /* Таблиця категорій для планшетів */
    #categoriesList .table th,
    #categoriesList .table td {
        padding: 12px 10px;
        font-size: 14px;
    }
}

/* Стилі для чекбоксів днів повторення */
.repeat-day-label,
#checklistForm .repeat-day-label,
.form-group .repeat-day-label {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
    padding: 5px 8px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
    flex: 0 0 auto !important;
    justify-content: center;
    width: auto !important;
    max-width: none !important;
    min-width: auto !important;
    margin-bottom: 0 !important;
    flex-basis: auto !important;
}

.repeat-day-label:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.repeat-day-label .repeat-day-checkbox {
    cursor: pointer;
    margin: 0;
}

.repeat-day-label .repeat-day-checkbox:checked + span {
    color: var(--primary);
    font-weight: 600;
}

.repeat-day-label:has(.repeat-day-checkbox:checked) {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: var(--primary);
    color: #1e40af;
}
