@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

body { font-family: 'Inter', sans-serif; }

/* Стили для упоминаний пользователей */
.mention-highlight {
    color: #3b82f6;
    font-weight: 600;
    background-color: rgba(59, 130, 246, 0.1);
    padding: 1px 3px;
    border-radius: 3px;
}

.dark .mention-highlight {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.15);
}

.mention-autocomplete-item {
    transition: background-color 0.15s ease;
}

.mention-autocomplete-item:hover {
    background-color: #eff6ff;
}

.dark .mention-autocomplete-item:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--color-slate-300); border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: var(--color-slate-600); }

/* Tabs */
.tab-btn.active { background-color: transparent; color: var(--color-blue-600); border-bottom: 2px solid var(--color-blue-600); }
.dark .tab-btn.active { background-color: transparent; color: var(--color-blue-400); border-bottom: 2px solid var(--color-blue-400); }
.tab-btn { color: var(--color-slate-500); border-bottom: 2px solid transparent; }
.dark .tab-btn { color: var(--color-slate-400); }

/* Modal Tabs */
.modal-tab.active { border-bottom: 2px solid var(--color-blue-600); color: var(--color-blue-600); font-weight: bold; }
.dark .modal-tab.active { border-bottom: 2px solid var(--color-blue-400); color: var(--color-blue-400); }
.modal-tab { color: var(--color-slate-500); cursor: pointer; border-bottom: 2px solid transparent; }
.dark .modal-tab { color: var(--color-slate-400); }

/* Toast Notification */
.toast { 
    position: fixed; bottom: 90px; right: 20px; 
    background: var(--color-slate-800); color: var(--color-white); 
    padding: 12px 24px; border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
    transform: translateY(100px); opacity: 0; 
    transition: all 0.3s ease-out; z-index: 100; 
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Global Loader */
#globalLoader { 
    position: fixed; inset: 0; 
    background: rgba(255,255,255,0.8); 
    z-index: 9999; 
    display: none; 
    justify-content: center; align-items: center; flex-direction: column; 
    backdrop-filter: blur(2px); 
}
.dark #globalLoader { background: rgba(15, 23, 42, 0.9); }

.spinner { 
    width: 40px; height: 40px; 
    border: 4px solid var(--color-slate-200); 
    border-top: 4px solid var(--color-blue-600); 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
}
@keyframes spin {0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }}

/* Sync Button (FAB) */
.sync-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 100;
    display: flex; align-items: center; gap: 8px;
}
.sync-fab {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: 99px; 
    color: var(--color-white); font-weight: bold; font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease; border: none; cursor: pointer;
}
.sync-details-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background-color: var(--color-white); color: var(--color-slate-600);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: none; cursor: pointer; transition: all 0.3s ease;
}
.dark .sync-details-btn { background-color: var(--color-slate-700); color: var(--color-white); }
.sync-details-btn:hover { transform: scale(1.05); background-color: var(--color-slate-100); }
.dark .sync-details-btn:hover { background-color: var(--color-slate-600); }

.sync-dropdown {
    position: absolute; bottom: 60px; right: 0;
    width: 300px; max-height: 400px; overflow-y: auto;
    background-color: var(--color-white); border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    padding: 12px; z-index: 101;
    animation: slideUp 0.3s ease-out;
}
.dark .sync-dropdown { background-color: var(--color-slate-800); border: 1px solid var(--color-slate-700); }

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

.sync-dropdown-header {
    font-weight: bold; font-size: 0.85rem; color: var(--color-slate-500);
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--color-slate-100);
}
.dark .sync-dropdown-header { color: var(--color-slate-400); border-bottom-color: var(--color-slate-700); }

.sync-group { margin-bottom: 8px; }
.sync-group-header {
    display: flex; align-items: center; gap: 8px; padding: 8px;
    border-radius: 6px; cursor: pointer; transition: background 0.2s;
    font-size: 0.9rem; font-weight: 500;
}
.sync-group-header:hover { background-color: var(--color-slate-50); }
.dark .sync-group-header:hover { background-color: var(--color-slate-700); }

.sync-group-icon { font-size: 0.75rem; transition: transform 0.2s; color: var(--color-slate-400); }
.sync-group-icon.expanded { transform: rotate(90deg); }

.sync-group-content { padding: 4px 0 4px 24px; }
.sync-item {
    display: flex; align-items: center; gap: 8px; padding: 4px 0;
    font-size: 0.8rem; color: var(--color-slate-700);
}
.dark .sync-item { color: var(--color-slate-300); }
.sync-op-dot { width: 6px; height: 6px; border-radius: 50%; }
.op-update { background-color: #10b981; }
.op-delete { background-color: #ef4444; }

@media (max-width: 768px) {
    .sync-container { 
        bottom: 0; right: 0; left: 0; border-radius: 0;
        padding: 10px 20px; background-color: rgba(255,255,255,0.9);
        backdrop-filter: blur(10px); border-top: 1px solid var(--color-slate-200);
        justify-content: center;
    }
    .dark .sync-container { background-color: rgba(30, 41, 59, 0.9); border-top-color: var(--color-slate-700); }
    .sync-dropdown {
        position: fixed; bottom: 64px; left: 10px; right: 10px; width: auto;
        max-height: 50vh; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
    }
}
.sync-clean { background-color: var(--color-blue-600); opacity: 0.8; }
.sync-dirty { background-color: #dc2626; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }

/* Print Styles */
@media print {
    @page { margin: 0.5cm; size: auto; }
    body > *:not(#printArea) { display: none !important; }
    body { background-color: white !important; color: black !important; height: auto !important; overflow: visible !important; }
    #printArea { display: block !important; position: relative !important; width: 100% !important; height: auto !important; left: 0 !important; top: 0 !important; background: white !important; color: black !important; padding: 0 !important; margin: 0 !important; visibility: visible !important; font-size: 12pt; }
    #printArea * { visibility: visible !important; color: black !important; background: transparent !important; border-color: #000 !important; }
    #printArea .project-description { word-wrap: break-word !important; overflow-wrap: break-word !important; white-space: pre-wrap !important; word-break: break-word !important; max-width: 100% !important; }
    .no-print { display: none !important; }
}

/* Статус подключения */
#connectionStatus {
    background-color: rgba(0, 0, 0, 0);
    background-image: none;
}

/* Sorting Headers */
.sortable-header { cursor: pointer; user-select: none; transition: color 0.2s; }
.sortable-header:hover { color: var(--color-blue-600); }
.dark .sortable-header:hover { color: var(--color-blue-400); }
.sort-icon { display: inline-block; width: 10px; margin-left: 4px; opacity: 0.3; }
.sortable-header.active .sort-icon { opacity: 1; color: var(--color-blue-600); }
.dark .sortable-header.active .sort-icon { color: var(--color-blue-400); }

/* Notifications */
#notificationsBadge {
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#notificationsDropdown {
    animation: slideDown 0.2s ease-out;
}

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

/* Feedback (Messages) */
#feedbackBadge {
    animation: pulse-badge 2s infinite;
}

/* Feedback Modal Checkbox (Round) */
#feedbackAdminMessagesList input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-slate-400);
    border-radius: 50%;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

#feedbackAdminMessagesList input[type="checkbox"]:checked {
    background-color: var(--color-blue-600);
    border-color: var(--color-blue-600);
}

#feedbackAdminMessagesList input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Image Previews in Feedback */
#feedbackImagePreviews > div {
    position: relative;
}

#feedbackImagePreviews > div > div[data-preview-index] {
    transition: transform 0.2s;
}

#feedbackImagePreviews > div:hover > div[data-preview-index] {
    transform: scale(1.05);
}

/* Image Lightbox */
#imageLightbox {
    backdrop-filter: blur(5px);
    animation: fadeInLightbox 0.2s ease-out;
}

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

#imageLightbox img {
    animation: zoomInImage 0.3s ease-out;
}

@keyframes zoomInImage {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Attachment Indicator */
.feedback-attachment-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Attachment Grid Hover Effects */
#feedbackMessageViewAttachmentsGrid > div img {
    transition: transform 0.2s, box-shadow 0.2s;
}

#feedbackMessageViewAttachmentsGrid > div:hover img {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.dark #feedbackAdminMessagesList input[type="checkbox"] {
    border-color: var(--color-slate-500);
}

.dark #feedbackAdminMessagesList input[type="checkbox"]:checked {
    background-color: var(--color-blue-500);
    border-color: var(--color-blue-500);
}

.notification-item {
    transition: background-color 0.2s;
}

.notification-item:hover {
    background-color: var(--color-slate-50);
}

.dark .notification-item:hover {
    background-color: var(--color-slate-700);
}

.notification-unread {
    background-color: var(--color-blue-50);
    border-left: 3px solid var(--color-blue-600);
}

.dark .notification-unread {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Form Helpers */
.lbl { display: block; font-size: 0.75rem; font-weight: 700; color: var(--color-slate-500); margin-bottom: 0.25rem; text-transform: uppercase; } 
.dark .lbl { color: var(--color-slate-400); } 
.inp { width: 100%; border: 1px solid var(--color-slate-300); padding: 0.5rem; border-radius: 0.375rem; font-size: 0.875rem; } 
.inp:focus { outline: none; border-color: var(--color-blue-500); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

/* Растягиваемые textarea для комментариев и описаний */
textarea.inp,
textarea.resizable-textarea {
    resize: vertical;
    min-height: 60px;
}

/* Spec Tree Styles */
#specTreeContainer .fa-chevron-right,
#specTreeContainer .fa-chevron-down {
    transition: transform 0.2s ease;
}

#specTreeContainer > div {
    transition: background-color 0.2s ease;
}

/* Modal Animations */
.modal-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease-out, backdrop-filter 0.3s ease-out;
    backdrop-filter: blur(0px);
}

.modal-backdrop.show {
    opacity: 1;
    backdrop-filter: blur(8px);
}

/* Модальные окна без размытия */
.modal-backdrop.no-blur.show {
    backdrop-filter: blur(0px);
}

.modal-content {
    position: relative;
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease-out;
}

.modal-backdrop.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-content.is-dragging {
    cursor: grabbing;
}

.modal-drag-handle {
    cursor: grab;
}

body.modal-dragging {
    user-select: none;
}

.settings-nav-btn.active {
    border-color: var(--color-blue-500);
    background: var(--color-blue-50);
    color: var(--color-blue-700);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

.dark .settings-nav-btn.active {
    background: var(--color-slate-700);
    color: var(--color-blue-200);
    border-color: var(--color-blue-500);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

/* Admin dual-panel (profile + settings) */
.admin-dual-panel #settingsModal {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 32px;
}

.admin-dual-panel #settingsModal .modal-content {
    position: fixed;
    left: 32px;
    top: 32px;
    height: calc(100vh - 64px);
    max-width: 62vw;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.admin-dual-panel #userProfileModal {
    background: transparent;
    justify-content: flex-end;
    align-items: flex-start;
    pointer-events: none;
    z-index: 60;
    padding: 32px;
}

.admin-dual-panel #userProfileModal .modal-content {
    position: fixed;
    right: 32px;
    top: 32px;
    height: calc(100vh - 64px);
    max-width: 32vw;
    border-radius: 20px;
    border-left: 1px solid var(--color-slate-200);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.admin-dual-panel #userProfileModal.modal-backdrop {
    backdrop-filter: none;
}

.dark.admin-dual-panel #settingsModal .modal-content,
.dark.admin-dual-panel #userProfileModal .modal-content {
    background: var(--color-slate-800);
    border-color: var(--color-slate-700);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
}

/* Help Navigation Styles */
.help-nav-btn {
    transition: all 0.2s ease;
}

.help-nav-btn.active {
    background-color: var(--color-blue-100);
    color: var(--color-blue-800);
    font-weight: 700;
}

.dark .help-nav-btn.active {
    background-color: var(--color-slate-700);
    color: var(--color-blue-400);
}

.help-nav-btn:hover {
    transform: translateX(4px);
}

/* Dropdown Menu */
#dropdownMenu {
    animation: fadeIn 0.2s ease-out;
}

#dropdownMenu button {
    border-bottom: 1px solid var(--color-slate-200);
}

.dark #dropdownMenu button {
    border-bottom-color: var(--color-slate-600);
}

#dropdownMenu button:last-child {
    border-bottom: none;
}

#dropdownMenu button.bg-blue-50,
#dropdownMenu button.dark\:bg-blue-900\/20 {
    font-weight: 600;
}

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

/* Контейнеры таблиц на панели дашборда для прокрутки */
#dashDeadlineTable,
#dashLowStockTable,
#dashLastMovTable {
    /* Таблицы будут иметь естественную высоту внутри контейнера с прокруткой */
}

/* Чеклист документации проекта - иконка файла */
.documentation-checkbox {
    flex-shrink: 0;
    outline: none;
    user-select: none;
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.documentation-checkbox:focus {
    outline: 2px solid rgba(251, 146, 60, 0.5);
    outline-offset: 2px;
}

.documentation-checkbox.checked {
    animation: filePulse 0.3s ease-out;
}

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

/* Круглый чекбокс для важной информации в КП */
.proposal-important-checkbox {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.proposal-important-checkbox:hover {
    border-color: #2563eb;
}

.proposal-important-checkbox:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.proposal-important-checkbox:checked::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 14px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.dark .proposal-important-checkbox {
    border-color: #60a5fa;
}

.dark .proposal-important-checkbox:hover {
    border-color: #93c5fd;
}

.dark .proposal-important-checkbox:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Стили для диаграммы Ганта (кастомная реализация) */
#ganttContainer {
    width: 100%;
    max-height: 350px;
    overflow: auto;
}

.gantt-wrapper {
    min-width: 100%;
}

.gantt-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.gantt-label-cell {
    width: 720px;
    min-width: 720px;
    max-width: 720px;
    padding: 8px 12px;
    font-size: 13px;
    color: #334155;
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    left: 0;
    z-index: 9;
}

.dark .gantt-label-cell {
    color: #e2e8f0;
    border-right-color: #334155;
}

.gantt-label-num {
    font-weight: 700;
    font-size: 12px;
    color: #3b82f6;
    min-width: 60px;
    padding: 2px 6px;
    background-color: #dbeafe;
    border-radius: 4px;
    text-align: center;
}

.dark .gantt-label-num {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.gantt-label-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .gantt-label-name {
    color: #e2e8f0;
}

.gantt-bars-cell {
    position: relative;
    padding: 0;
}

.gantt-header-row {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #ffffff;
}

.dark .gantt-header-row {
    background-color: #1e293b;
}

.gantt-header-row .gantt-label-cell {
    height: 32px;
    vertical-align: bottom;
    position: sticky;
    left: 0;
    z-index: 11;
    background-color: #ffffff;
}

.dark .gantt-header-row .gantt-label-cell {
    background-color: #1e293b;
}

.gantt-header-row .gantt-bars-cell {
    height: 32px;
    border-bottom: 1px solid #e2e8f0;
}

.dark .gantt-header-row .gantt-bars-cell {
    border-bottom-color: #334155;
}

.gantt-timeline {
    position: relative;
    width: 100%;
    height: 100%;
}

.gantt-month {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: 0 8px 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    border-left: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.gantt-month:first-child {
    border-left: none;
}

.dark .gantt-month {
    color: #94a3b8;
    border-left-color: #334155;
}

.gantt-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.gantt-row:hover {
    background-color: #f8fafc;
}

.dark .gantt-row:hover {
    background-color: #1e293b;
}

.gantt-row .gantt-bars-cell {
    height: 32px;
    border-bottom: 1px solid #f1f5f9;
}

.dark .gantt-row .gantt-bars-cell {
    border-bottom-color: #1e293b;
}

.gantt-bars-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.gantt-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #e2e8f0;
}

.dark .gantt-grid-line {
    background-color: #334155;
}

.gantt-bar {
    position: absolute;
    height: 18px;
    top: 7px;
    border-radius: 3px;
    min-width: 4px;
}

.gantt-bar-project {
    background-color: #3b82f6;
    z-index: 1;
}

.gantt-bar-design {
    background-color: #f97316;
    z-index: 2;
}

.gantt-legend {
    display: flex;
    gap: 16px;
    padding: 10px 0 4px 0;
    font-size: 11px;
    color: #64748b;
}

.dark .gantt-legend {
    color: #94a3b8;
}

.gantt-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gantt-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.gantt-legend-project {
    background-color: #3b82f6;
}

.gantt-legend-design {
    background-color: #f97316;
}

/* Единые стили кнопок */
.btn-blue,
.btn-green,
.btn-red,
.btn-yellow,
.btn-purple {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 500;
    border-radius: 9999px;
    transition: all 0.3s ease;
    background-color: transparent;
}

.btn-blue {
    border: 2px solid var(--color-btn-blue);
    color: var(--color-btn-blue);
}

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

.btn-green {
    border: 2px solid var(--color-btn-green);
    color: var(--color-btn-green);
}

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

.btn-red {
    border: 2px solid var(--color-btn-red);
    color: var(--color-btn-red);
}

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

.btn-yellow {
    border: 2px solid #eab308;
    color: #eab308;
}

.btn-yellow:hover {
    background-color: #eab308;
    color: white;
}

.btn-purple {
    border: 2px solid #a855f7;
    color: #a855f7;
}

.btn-purple:hover {
    background-color: #a855f7;
    color: white;
}

/* Стили для маленьких кнопок с иконками */
.btn-blue.w-6,
.btn-green.w-6,
.btn-red.w-6 {
    padding: 0;
    min-width: 24px;
    min-height: 24px;
}

.btn-blue.w-6 i,
.btn-green.w-6 i,
.btn-red.w-6 i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 1;
}

/* Всплывающее увеличенное изображение */
.img-zoom-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 8px;
    max-width: 350px;
    max-height: 350px;
}

.dark .img-zoom-tooltip {
    background: var(--color-slate-800);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.img-zoom-tooltip.show {
    opacity: 1;
}

.img-zoom-tooltip img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Эффект при наведении на изображение в таблице */
table img.cursor-pointer {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

table img.cursor-pointer:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --- Menu Customization Seasonal Effects --- */

/* Winter: Falling Snowflakes */
.snowflake {
    position: absolute;
    top: -10px;
    width: 12px;
    height: 12px;
    animation: snowfall linear infinite;
    pointer-events: none;
    z-index: 0;
}

/* Центр снежинки */
.snowflake::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 
        /* Основные 6 лучей */
        0 -6px 0 -0.5px white,
        0 6px 0 -0.5px white,
        -5.2px -3px 0 -0.5px white,
        5.2px 3px 0 -0.5px white,
        -5.2px 3px 0 -0.5px white,
        5.2px -3px 0 -0.5px white,
        /* Дополнительные короткие лучи */
        0 -4px 0 -1px white,
        0 4px 0 -1px white,
        -3.5px -2px 0 -1px white,
        3.5px 2px 0 -1px white,
        -3.5px 2px 0 -1px white,
        3.5px -2px 0 -1px white,
        /* Кончики лучей */
        0 -8px 0 -1.5px rgba(255, 255, 255, 0.8),
        0 8px 0 -1.5px rgba(255, 255, 255, 0.8),
        -7px -4px 0 -1.5px rgba(255, 255, 255, 0.8),
        7px 4px 0 -1.5px rgba(255, 255, 255, 0.8),
        -7px 4px 0 -1.5px rgba(255, 255, 255, 0.8),
        7px -4px 0 -1.5px rgba(255, 255, 255, 0.8);
}

/* Дополнительный слой для объёма */
.snowflake::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(30deg);
    width: 2px;
    height: 2px;
    background: transparent;
    box-shadow: 
        /* Промежуточные лучи для создания звёздочки */
        0 -5px 0 -0.5px rgba(255, 255, 255, 0.7),
        0 5px 0 -0.5px rgba(255, 255, 255, 0.7),
        -4.3px -2.5px 0 -0.5px rgba(255, 255, 255, 0.7),
        4.3px 2.5px 0 -0.5px rgba(255, 255, 255, 0.7),
        -4.3px 2.5px 0 -0.5px rgba(255, 255, 255, 0.7),
        4.3px -2.5px 0 -0.5px rgba(255, 255, 255, 0.7);
}

@keyframes snowfall {
    0% { 
        transform: translateY(0) rotate(0deg); 
        opacity: 0.9; 
        filter: blur(0px);
    }
    50% {
        opacity: 0.8;
        filter: blur(0.3px);
    }
    100% { 
        transform: translateY(100px) rotate(360deg); 
        opacity: 0;
        filter: blur(0.5px);
    }
}

/* Winter: Ёлочки с игрушками */
.winter-tree {
    position: absolute;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.winter-tree-shape {
    position: relative;
    width: 0;
    height: 0;
}

/* Треугольная форма ёлки - первый ярус */
.winter-tree-shape::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 30px solid #166534;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

/* Второй ярус ёлки */
.winter-tree-shape::after {
    content: '';
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 22px solid #15803d;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

/* Ствол ёлки */
.winter-tree-trunk {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: #78350f;
    border-radius: 2px;
}

/* Игрушки на ёлке */
.tree-ornament {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    box-shadow: 0 0 4px currentColor, 0 0 8px currentColor;
    animation: ornament-glow 2s ease-in-out infinite alternate;
}

.tree-ornament.red { background: #ef4444; color: #ef4444; }
.tree-ornament.gold { background: #fbbf24; color: #fbbf24; }
.tree-ornament.blue { background: #3b82f6; color: #3b82f6; }
.tree-ornament.silver { background: #e2e8f0; color: #e2e8f0; }

@keyframes ornament-glow {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.15); }
}

/* Звезда на верхушке */
.tree-star {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #fbbf24;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: star-twinkle 1.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 4px #fbbf24);
}

@keyframes star-twinkle {
    0% { opacity: 0.8; transform: translateX(-50%) scale(1) rotate(0deg); }
    100% { opacity: 1; transform: translateX(-50%) scale(1.2) rotate(10deg); }
}

/* Winter: Гирлянда с мигающими лампочками */
.winter-garland {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.garland-wire {
    display: none; /* Провод скрыт */
}

.garland-bulb {
    position: absolute;
    top: 6px;
    width: 8px;
    height: 12px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    filter: blur(0.5px);
    animation: bulb-blink ease-in-out infinite;
    box-shadow: 0 0 6px currentColor, 0 0 12px currentColor, 0 2px 4px rgba(0,0,0,0.3);
}

/* Провод от гирлянды к лампочке */
.garland-bulb::before {
    display: none; /* Маленькие проводки скрыты */
}

/* Цвета лампочек */
.garland-bulb.red { 
    background: radial-gradient(ellipse at 30% 30%, #fca5a5, #ef4444, #b91c1c); 
    color: #ef4444;
    animation-delay: 0s;
}
.garland-bulb.yellow { 
    background: radial-gradient(ellipse at 30% 30%, #fef08a, #facc15, #ca8a04); 
    color: #facc15;
    animation-delay: 0.3s;
}
.garland-bulb.green { 
    background: radial-gradient(ellipse at 30% 30%, #86efac, #22c55e, #15803d); 
    color: #22c55e;
    animation-delay: 0.6s;
}
.garland-bulb.blue { 
    background: radial-gradient(ellipse at 30% 30%, #93c5fd, #3b82f6, #1d4ed8); 
    color: #3b82f6;
    animation-delay: 0.9s;
}
.garland-bulb.purple { 
    background: radial-gradient(ellipse at 30% 30%, #d8b4fe, #a855f7, #7c3aed); 
    color: #a855f7;
    animation-delay: 1.2s;
}
.garland-bulb.white { 
    background: radial-gradient(ellipse at 30% 30%, #ffffff, #f1f5f9, #cbd5e1); 
    color: #f8fafc;
    animation-delay: 1.5s;
}

@keyframes bulb-blink {
    0%, 100% { 
        opacity: 0.4; 
        transform: scale(0.9);
        filter: blur(0.5px);
    }
    50% { 
        opacity: 1; 
        transform: scale(1.1);
        filter: blur(0px);
        box-shadow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 30px currentColor, 0 2px 4px rgba(0,0,0,0.3);
    }
}

/* Второй ряд гирлянды (волна) */
.garland-wire.wave {
    display: none; /* Второй провод скрыт */
}

.garland-bulb.wave-bulb {
    top: auto;
    bottom: 6px;
    width: 6px;
    height: 10px;
}

/* Spring: Floating Petals */
.petal {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 8px;
    background: #fecdd3; /* Rose-200 */
    border-radius: 50% 0 50% 0;
    animation: petalfall linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes petalfall {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0.9; }
    50% { transform: translateY(50px) translateX(20px) rotate(180deg); opacity: 0.8; }
    100% { transform: translateY(100px) translateX(-20px) rotate(360deg); opacity: 0; }
}

/* Autumn: Falling Leaves */
.leaf {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    background: #f97316; /* Orange-500 */
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: leaffall linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes leaffall {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0.9; }
    25% { transform: translateY(25px) translateX(15px) rotate(45deg); }
    50% { transform: translateY(50px) translateX(-15px) rotate(90deg); }
    75% { transform: translateY(75px) translateX(15px) rotate(135deg); }
    100% { transform: translateY(100px) translateX(0) rotate(180deg); opacity: 0; }
}

/* Summer: Sun Shine Effect */
.sun-shine {
    position: absolute;
    top: -50px;
    left: 20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0.3;
    animation: sunshine 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes sunshine {
    0% { transform: scale(1) translateX(0); opacity: 0.3; }
    50% { transform: scale(1.2) translateX(20px); opacity: 0.5; }
    100% { transform: scale(1) translateX(0); opacity: 0.3; }
}

/* Background Override Class */
.menu-custom-bg {
    background-color: transparent !important; /* Will be set via inline style */
}

/* ============================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ============================================ */

/* Мобильное меню (гамбургер) */
.mobile-menu-btn {
    display: none;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.mobile-menu-overlay.show {
    opacity: 1;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    right: 0;
    width: 280px;
    max-width: 85vw;
    background: white;
    border-left: 1px solid var(--color-slate-200);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

.dark .mobile-menu {
    background: var(--color-slate-800);
    border-left-color: var(--color-slate-700);
}

.mobile-menu.show {
    transform: translateX(0);
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-slate-200);
    color: var(--color-slate-700);
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.dark .mobile-menu-item {
    border-bottom-color: var(--color-slate-700);
    color: var(--color-slate-300);
}

.mobile-menu-item:hover {
    background-color: var(--color-slate-50);
}

.dark .mobile-menu-item:hover {
    background-color: var(--color-slate-700);
}

.mobile-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--color-blue-600);
}

.dark .mobile-menu-item i {
    color: var(--color-blue-400);
}

/* Нижняя навигация для мобильных (вкладки) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--color-slate-200);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.dark .mobile-bottom-nav {
    background: var(--color-slate-800);
    border-top-color: var(--color-slate-700);
}

.mobile-bottom-nav-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
}

.mobile-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    color: var(--color-slate-500);
    transition: all 0.2s;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 10px;
}

.mobile-tab-btn i {
    font-size: 20px;
}

.mobile-tab-btn.active {
    color: var(--color-blue-600);
}

.dark .mobile-tab-btn {
    color: var(--color-slate-400);
}

.dark .mobile-tab-btn.active {
    color: var(--color-blue-400);
}

/* Карточное представление таблиц на мобильных */
.mobile-card-view {
    display: none;
}

.mobile-card {
    position: relative;
    background: white;
    border: 1px solid var(--color-slate-200);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    /* Оптимизация для плавного скролла на мобильных */
    transform: translateZ(0);
    backface-visibility: hidden;
    content-visibility: auto;
    contain-intrinsic-size: 0 200px;
}

.dark .mobile-card {
    background: var(--color-slate-800);
    border-color: var(--color-slate-700);
}

.mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.mobile-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--color-slate-800);
    flex: 1;
    line-height: 1.4;
}

.dark .mobile-card-title {
    color: var(--color-slate-100);
}

.mobile-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-slate-100);
}

.dark .mobile-card-row {
    border-bottom-color: var(--color-slate-700);
}

.mobile-card-row:last-child {
    border-bottom: none;
}

.mobile-card-label {
    font-size: 12px;
    color: var(--color-slate-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dark .mobile-card-label {
    color: var(--color-slate-400);
}

.mobile-card-value {
    font-size: 14px;
    color: var(--color-slate-700);
    font-weight: 600;
    text-align: right;
}

.dark .mobile-card-value {
    color: var(--color-slate-200);
}

.mobile-card-value.highlight {
    color: var(--color-blue-600);
    font-size: 16px;
}

.dark .mobile-card-value.highlight {
    color: var(--color-blue-400);
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-slate-200);
}

.dark .mobile-card-actions {
    border-top-color: var(--color-slate-700);
}

.mobile-card-action-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Отступ для нижней навигации */
.mobile-content-padding {
    padding-bottom: 0;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    /* Показываем мобильное меню */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        color: var(--color-slate-600);
        cursor: pointer;
        font-size: 20px;
    }
    
    .dark .mobile-menu-btn {
        color: var(--color-slate-300);
    }
    
    .mobile-menu-btn:hover {
        background: var(--color-slate-100);
        border-radius: 8px;
    }
    
    .dark .mobile-menu-btn:hover {
        background: var(--color-slate-700);
    }
    
    .mobile-menu {
        display: block;
    }
    
    .mobile-menu-overlay {
        display: block;
    }
    
    /* Показываем нижнюю навигацию */
    .mobile-bottom-nav {
        display: block;
    }
    
    /* Добавляем отступ снизу для контента */
    .mobile-content-padding {
        padding-bottom: 80px;
    }
    
    /* Скрываем десктопные вкладки в шапке */
    header nav.hidden.md\:flex {
        display: none !important;
    }
    
    /* Скрываем элементы шапки на мобильных */
    #notificationsContainer,
    #userProfileBtn,
    #settingsBtn,
    button[onclick="toggleTheme()"],
    button[onclick="init()"],
    button[onclick="logout()"] {
        display: none !important;
    }
    
    /* Скрываем кнопку синхронизации (FAB) на мобильных */
    #syncBtn {
        display: none !important;
    }
    
    /* Скрываем функциональные кнопки на мобильных */
    .mobile-hide {
        display: none !important;
    }
    
    /* Преобразуем таблицы в карточки */
    .table-container {
        position: relative;
    }
    
    .table-container table {
        display: none;
    }
    
    .mobile-card-view {
        display: block;
        /* Убираем overflow, так как скролл происходит на родительском контейнере */
        overflow: visible;
    }
    
    /* Контейнер с overflow-auto для товаров */
    #warehouseTableContainer .overflow-auto {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        /* Увеличиваем минимальную высоту для лучшей работы с меню браузера */
        min-height: calc(100vh + 100px);
        /* Улучшаем обработку touch событий */
        touch-action: pan-y;
    }
    
    /* Основной контейнер приложения для мобильных */
    @media (max-width: 768px) {
        html {
            /* Разрешаем небольшой скролл для работы меню браузера */
            height: 100%;
            overflow-x: hidden;
        }
        
        body {
            position: relative;
            min-height: 100vh;
            overflow-x: hidden;
        }
        
        #appContainer {
            position: relative;
            min-height: 100vh;
        }
        
        /* Невидимый триггер для скрытия меню браузера */
        #mobileBrowserMenuTrigger {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 1px;
            background: transparent;
            pointer-events: none;
            z-index: -1;
        }
    }
    
    /* Стили для карточек дашборда */
    #dashDeadlineTable,
    #dashLowStockTable,
    #dashLastMovTable {
        display: none;
    }
    
    /* Toast уведомления на мобильных */
    .toast {
        bottom: 100px;
        right: 16px;
        left: 16px;
        max-width: calc(100vw - 32px);
    }
    
    /* Модальные окна на мобильных */
    .modal-content {
        width: 95vw;
        max-width: 95vw;
        margin: 20px auto;
        max-height: 90vh;
    }
    
    /* Модальное окно карточки товара на весь экран на мобильных */
    #itemCardModal.modal-backdrop {
        padding: 0 !important;
        align-items: stretch !important;
    }
    
    #itemCardModal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Поля в карточке товара в один столбец на мобильных */
    #itemCardModal .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Внутренние grid тоже в один столбец (Всего и Ед. изм) */
    #itemCardModal .space-y-4 .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Все элементы с col-span-2 занимают всю ширину */
    #itemCardModal .col-span-2 {
        grid-column: span 1 !important;
    }
    
    /* Кнопки внизу карточки товара в один столбец на мобильных */
    #itemCardModal .flex.justify-between.items-center {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }
    
    #itemCardModal .flex.justify-between.items-center > div {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    #itemCardModal .flex.justify-between.items-center > div > button,
    #itemCardModal .flex.justify-between.items-center > button {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Уменьшаем отступы на мобильных */
    #itemCardModal .p-6 {
        padding: 16px !important;
    }
    
    /* Вкладки в карточке товара */
    #itemCardModal .flex.gap-6 {
        gap: 12px !important;
    }
    
    /* --- Mobile Project Card Modal --- */
    #projectCardModal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    #projectCardModal .p-6 {
        padding: 16px !important;
    }

    /* Stack grid columns for project fields */
    #projectCardModal .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* Adjust buttons in project modal */
    #projectCardModal .flex.justify-between.pt-4 {
        flex-direction: column !important;
        gap: 16px !important;
    }

    #projectCardModal .flex.justify-between.pt-4 .flex.gap-2 {
        width: 100% !important;
        flex-direction: column !important;
    }

    #projectCardModal .flex.justify-between.pt-4 button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* --- Mobile Settings Modal --- */
    #settingsModal.modal-backdrop {
        padding: 0 !important;
        align-items: stretch !important;
    }

    #settingsModal .modal-content {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
    }

    /* Stack sidebar and content in settings */
    #settingsModal .flex-col.lg\:flex-row {
        flex-direction: column !important;
    }

    #settingsModal .lg\:w-64 {
        width: 100% !important;
        max-height: 200px;
        overflow-y: auto;
        border-bottom: 1px solid var(--color-slate-200);
        margin-bottom: 16px;
    }

    .dark #settingsModal .lg\:w-64 {
        border-bottom-color: var(--color-slate-700);
    }

    /* --- Mobile User Profile Modal --- */
    #userProfileModal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        top: 0 !important;
        right: 0 !important;
    }

    /* --- Mobile Notifications Dropdown --- */
    #notificationsDropdown {
        position: fixed !important;
        top: 64px !important; /* Header height */
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 64px) !important;
        max-height: calc(100vh - 64px) !important;
        border-radius: 0 !important;
        margin: 0 !important;
        z-index: 1002 !important;
    }

    /* --- Mobile Feedback Modals --- */
    #feedbackUserModal .modal-content,
    #feedbackAdminModal .modal-content,
    #feedbackMessageViewModal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* --- Mobile AI Chat Widget --- */
    #aiChatWidget {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        z-index: 2000 !important;
    }

    #aiChatDragHandle {
        cursor: default !important;
    }

    #aiChatResizeHandle {
        display: none !important;
    }

    /* Улучшаем читаемость карточек */
    .mobile-card {
        font-size: 14px;
    }
    
    /* Адаптация заголовков */
    h2 {
        font-size: 20px;
    }
    
    /* Адаптация панелей */
    .grid {
        gap: 12px;
    }
}

/* Расширяющийся поиск на мобильных */
@media (max-width: 768px) {
    .mobile-search-container {
        position: relative;
        transition: all 0.3s ease;
    }
    
    .mobile-search-input {
        transition: all 0.3s ease;
    }
    
    .mobile-search-input:focus {
        position: fixed !important;
        top: 64px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        z-index: 1001 !important;
        border-radius: 0 !important;
        padding: 16px 48px 16px 48px !important;
        font-size: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        margin: 0 !important;
    }
    
    .mobile-search-container:has(.mobile-search-input:focus) .fa-search {
        left: 16px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        font-size: 18px !important;
    }
    
    /* Затемнение при фокусе на поиске */
    .mobile-search-input:focus ~ #mobileSearchOverlay {
        display: block !important;
    }
}

/* Мобильное меню категорий */
#mobileCategoryDropdown {
    animation: slideDown 0.2s ease-out;
}

.mobile-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-slate-200);
    color: var(--color-slate-700);
    cursor: pointer;
    transition: background-color 0.2s;
}

.dark .mobile-category-item {
    border-bottom-color: var(--color-slate-700);
    color: var(--color-slate-300);
}

.mobile-category-item:hover,
.mobile-category-item.active {
    background-color: var(--color-blue-50);
    color: var(--color-blue-700);
}

.dark .mobile-category-item:hover,
.dark .mobile-category-item.active {
    background-color: var(--color-slate-700);
    color: var(--color-blue-400);
}

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

.mobile-category-name {
    font-weight: 500;
    font-size: 14px;
}

.mobile-category-count {
    font-size: 12px;
    color: var(--color-slate-500);
    background: var(--color-slate-100);
    padding: 2px 8px;
    border-radius: 12px;
}

.dark .mobile-category-count {
    color: var(--color-slate-400);
    background: var(--color-slate-700);
}

.mobile-category-item.active .mobile-category-count {
    background: var(--color-blue-100);
    color: var(--color-blue-700);
}

.dark .mobile-category-item.active .mobile-category-count {
    background: var(--color-slate-600);
    color: var(--color-blue-400);
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
    .mobile-menu {
        width: 100vw;
        max-width: 100vw;
    }
    
    .mobile-card {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .mobile-card-title {
        font-size: 14px;
    }
    
    .mobile-card-value {
        font-size: 13px;
    }
    
    .mobile-bottom-nav-content {
        height: 56px;
    }
    
    .mobile-tab-btn {
        font-size: 9px;
        padding: 6px 2px;
    }
    
    .mobile-tab-btn i {
        font-size: 18px;
    }
}

/* Кастомный tooltip без задержки */
.custom-tooltip {
    position: relative;
    cursor: pointer;
}

/* Отключаем стандартные CSS tooltip, используем динамический JS tooltip */
.custom-tooltip::before {
    content: none;
    display: none;
}

/* Резервный стандартный tooltip (не используется в проектах) */
.custom-tooltip-static::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0s;
    z-index: 99999;
    max-width: 300px;
    min-width: 120px;
    white-space: pre-line;
    word-wrap: break-word;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    visibility: hidden;
}

.dark .custom-tooltip::before {
    background-color: rgba(30, 41, 59, 0.95);
    color: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.custom-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Fixed tooltip для обхода overflow */
.custom-tooltip-fixed {
    position: fixed;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 99999;
    max-width: 300px;
    min-width: 120px;
    white-space: pre-line;
    word-wrap: break-word;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0s;
}

.dark .custom-tooltip-fixed {
    background-color: rgba(30, 41, 59, 0.95);
    color: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Стили для описания проекта при печати */
.project-description {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Documentation Dropdown Styles */
.documentation-dropdown-container {
    position: relative;
}

/* Ensure the dropdown is above other table elements */
.documentation-dropdown-container .absolute {
    z-index: 100;
}

.documentation-dropdown {
    pointer-events: auto;
    display: none;
}

.documentation-dropdown-container.is-active .documentation-dropdown {
    display: block;
}

/* Mobile adjustments for documentation status in cards */
.mobile-card-row .documentation-dropdown-container {
    margin-left: -8px; /* Offset padding of the button */
}

.mobile-card-row .documentation-dropdown-container .absolute {
    bottom: auto;
    top: 100%;
    margin-top: 8px;
    margin-bottom: 0;
}

/* ============================================
   MARKDOWN СТИЛИ ДЛЯ AI ЧАТА
   ============================================ */

#aiChatMessages .markdown-content {
    line-height: 1.6;
}

#aiChatMessages h1,
#aiChatMessages h2,
#aiChatMessages h3,
#aiChatMessages h4,
#aiChatMessages h5,
#aiChatMessages h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: inherit;
}

#aiChatMessages h1 { font-size: 1.25rem; }
#aiChatMessages h2 { font-size: 1.1rem; }
#aiChatMessages h3 { font-size: 1rem; }
#aiChatMessages h4 { font-size: 0.95rem; }
#aiChatMessages h5 { font-size: 0.9rem; }
#aiChatMessages h6 { font-size: 0.85rem; }

#aiChatMessages p {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#aiChatMessages ul,
#aiChatMessages ol {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#aiChatMessages li {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

#aiChatMessages code {
    background: rgba(100, 116, 139, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: inherit;
}

#aiChatMessages pre {
    background: #1e293b;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid #334155;
}

#aiChatMessages pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.85rem;
}

#aiChatMessages blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 1rem;
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    color: #64748b;
    font-style: italic;
}

#aiChatMessages table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

#aiChatMessages th,
#aiChatMessages td {
    border: 1px solid #e2e8f0;
    padding: 0.5rem;
    text-align: left;
}

#aiChatMessages th {
    background: #f1f5f9;
    font-weight: 600;
}

#aiChatMessages a {
    color: #3b82f6;
    text-decoration: underline;
    cursor: pointer;
}

#aiChatMessages a:hover {
    color: #2563eb;
}

#aiChatMessages strong,
#aiChatMessages b {
    font-weight: 600;
}

#aiChatMessages em,
#aiChatMessages i {
    font-style: italic;
}

#aiChatMessages hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 1rem 0;
}

/* Темная тема для Markdown */
.dark #aiChatMessages code {
    background: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

.dark #aiChatMessages pre {
    background: #0f172a;
    border-color: #1e293b;
}

.dark #aiChatMessages pre code {
    color: #e2e8f0;
}

.dark #aiChatMessages blockquote {
    border-left-color: #60a5fa;
    color: #94a3b8;
}

.dark #aiChatMessages th {
    background: #334155;
    color: #f1f5f9;
}

.dark #aiChatMessages th,
.dark #aiChatMessages td {
    border-color: #475569;
    color: #e2e8f0;
}

.dark #aiChatMessages a {
    color: #60a5fa;
}

.dark #aiChatMessages a:hover {
    color: #93c5fd;
}

.dark #aiChatMessages hr {
    border-top-color: #334155;
}

/* Скрытие поля Файл / Документ (URL) и кнопки загрузки в карточке проекта */
/* Скрываем label и input для pcFile, а также кнопку загрузки */
label[for="pcFile"],
#pcFile,
#pcFileUploadProgress,
button[onclick*="openFileUploadForProjectCard"] {
    display: none !important;
}

/* Скрываем родительский div для pcFile */
#pview-info > div:has(label[for="pcFile"]),
#pview-info > div:has(#pcFile) {
    display: none !important;
}

/* Оптимизация производительности таблиц */
#warehouseTableBody tr {
    content-visibility: auto;
    contain-intrinsic-size: 0 56px; /* Примерная высота строки h-14 */
}

#projectsTableBody tr {
    content-visibility: auto;
    contain-intrinsic-size: 0 64px; /* Высота строки h-16 */
}

.table-container .overflow-auto {
    will-change: transform;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Улучшение плавности скролла */
/* ============================================
   КАТАЛОГ ИЗДЕЛИЙ
   ============================================ */

/* Сетка каталога */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .catalog-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Карточка изделия */
.catalog-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-slate-200);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 680px; /* Фиксированная высота карточки */
}

.dark .catalog-card {
    background: var(--color-slate-800);
    border-color: var(--color-slate-700);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.catalog-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--color-blue-400);
}

.dark .catalog-card:hover {
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.4);
    border-color: var(--color-blue-500);
}

/* Изображение в карточке */
.catalog-card-image {
    width: 100%;
    height: 220px;
    position: relative;
    background: var(--color-slate-100);
    overflow: hidden;
    border-bottom: 1px solid var(--color-slate-100);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Изображение не сжимается */
}

.dark .catalog-card-image {
    background: var(--color-slate-900);
    border-bottom-color: var(--color-slate-700);
}

.catalog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.catalog-card:hover .catalog-card-image img {
    transform: scale(1.05);
}

.catalog-card-image .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-slate-400);
}

/* Контент карточки */
.catalog-card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Прокрутка контента при расширении блоков */
    overflow-x: hidden;
}

.catalog-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-slate-800);
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dark .catalog-card-title {
    color: var(--color-white);
}

/* Характеристики (бейджи) */
.catalog-card-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.catalog-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    background: var(--color-blue-50);
    color: var(--color-blue-600);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.dark .catalog-badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-blue-400);
}

/* Метаданные (мелкий текст) */
.catalog-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.catalog-meta-item {
    font-size: 0.75rem;
    color: var(--color-slate-500);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dark .catalog-meta-item {
    color: var(--color-slate-400);
}

.catalog-meta-item i {
    width: 14px;
    text-align: center;
    color: var(--color-slate-400);
}

.catalog-meta-label {
    font-weight: 500;
    color: var(--color-slate-400);
}

.catalog-meta-value {
    font-weight: 600;
    color: var(--color-slate-700);
}

.dark .catalog-meta-value {
    color: var(--color-slate-200);
}

/* Количество */
.catalog-card-qty {
    margin-top: auto;
    background: var(--color-slate-50);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-blue-700);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark .catalog-card-qty {
    background: var(--color-slate-700);
    color: var(--color-blue-300);
}

/* Кнопки действий */
.catalog-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.catalog-card-actions button {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* Кнопки сортировки */
.btn-sort {
    transition: all 0.2s;
    border: 1px solid var(--color-slate-200);
}

.btn-sort.active {
    background-color: var(--color-blue-600);
    color: white;
    border-color: var(--color-blue-600);
}

.dark .btn-sort {
    border-color: var(--color-slate-700);
}

.dark .btn-sort.active {
    background-color: var(--color-blue-500);
}

/* Раскрывающаяся секция в карточке каталога */
.catalog-details-toggle {
    width: 100%;
    text-align: center;
    padding: 0.5rem 0;
    margin: 0.5rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-blue-600);
    cursor: pointer;
    transition: all 0.2s;
    border-top: 1px dashed var(--color-slate-200);
    border-bottom: 1px dashed var(--color-slate-200);
}

.dark .catalog-details-toggle {
    color: var(--color-blue-400);
    border-top-color: var(--color-slate-700);
    border-bottom-color: var(--color-slate-700);
}

.catalog-details-toggle:hover {
    color: var(--color-blue-700);
    background-color: var(--color-slate-50);
}

.dark .catalog-details-toggle:hover {
    color: var(--color-blue-300);
    background-color: var(--color-slate-700);
}

.catalog-details-extended {
    background: var(--color-slate-50);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    animation: slideDownFade 0.3s ease-out;
}

.dark .catalog-details-extended {
    background: var(--color-slate-900);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    animation: slideDownFade 0.3s ease-out;
}

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

/* Индикатор комментария */
.catalog-comment-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-blue-600);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10;
    cursor: help;
    border: 1px solid var(--color-slate-100);
}

.catalog-comment-indicator i {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark .catalog-comment-indicator {
    background: var(--color-slate-800);
    border-color: var(--color-slate-700);
    color: var(--color-blue-400);
}

